forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/arm/mach-ep93xx/ts72xx.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * arch/arm/mach-ep93xx/ts72xx.c
34 * Technologic Systems TS72xx SBC support.
45 *
56 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or (at
10
- * your option) any later version.
117 */
128
139 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -16,18 +12,17 @@
1612 #include <linux/init.h>
1713 #include <linux/platform_device.h>
1814 #include <linux/io.h>
19
-#include <linux/mtd/rawnand.h>
20
-#include <linux/mtd/partitions.h>
15
+#include <linux/mtd/platnand.h>
2116 #include <linux/spi/spi.h>
2217 #include <linux/spi/flash.h>
2318 #include <linux/spi/mmc_spi.h>
2419 #include <linux/mmc/host.h>
2520 #include <linux/platform_data/spi-ep93xx.h>
21
+#include <linux/gpio/machine.h>
2622
27
-#include <mach/gpio-ep93xx.h>
28
-#include <mach/hardware.h>
23
+#include "gpio-ep93xx.h"
24
+#include "hardware.h"
2925 #include <mach/irqs.h>
30
-#include <mach/gpio-ep93xx.h>
3126
3227 #include <asm/mach-types.h>
3328 #include <asm/mach/map.h>
....@@ -76,13 +71,11 @@
7671 #define TS72XX_NAND_CONTROL_ADDR_LINE 22 /* 0xN0400000 */
7772 #define TS72XX_NAND_BUSY_ADDR_LINE 23 /* 0xN0800000 */
7873
79
-static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,
74
+static void ts72xx_nand_hwcontrol(struct nand_chip *chip,
8075 int cmd, unsigned int ctrl)
8176 {
82
- struct nand_chip *chip = mtd_to_nand(mtd);
83
-
8477 if (ctrl & NAND_CTRL_CHANGE) {
85
- void __iomem *addr = chip->IO_ADDR_R;
78
+ void __iomem *addr = chip->legacy.IO_ADDR_R;
8679 unsigned char bits;
8780
8881 addr += (1 << TS72XX_NAND_CONTROL_ADDR_LINE);
....@@ -96,13 +89,12 @@
9689 }
9790
9891 if (cmd != NAND_CMD_NONE)
99
- __raw_writeb(cmd, chip->IO_ADDR_W);
92
+ __raw_writeb(cmd, chip->legacy.IO_ADDR_W);
10093 }
10194
102
-static int ts72xx_nand_device_ready(struct mtd_info *mtd)
95
+static int ts72xx_nand_device_ready(struct nand_chip *chip)
10396 {
104
- struct nand_chip *chip = mtd_to_nand(mtd);
105
- void __iomem *addr = chip->IO_ADDR_R;
97
+ void __iomem *addr = chip->legacy.IO_ADDR_R;
10698
10799 addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE);
108100
....@@ -274,13 +266,15 @@
274266 * The all work is performed automatically by !SPI_FRAME (SFRM1) and
275267 * goes through CPLD
276268 */
277
-static int bk3_spi_chipselects[] __initdata = {
278
- EP93XX_GPIO_LINE_F(3),
269
+static struct gpiod_lookup_table bk3_spi_cs_gpio_table = {
270
+ .dev_id = "spi0",
271
+ .table = {
272
+ GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW),
273
+ { },
274
+ },
279275 };
280276
281277 static struct ep93xx_spi_info bk3_spi_master __initdata = {
282
- .chipselect = bk3_spi_chipselects,
283
- .num_chipselect = ARRAY_SIZE(bk3_spi_chipselects),
284278 .use_dma = 1,
285279 };
286280
....@@ -321,13 +315,17 @@
321315 },
322316 };
323317
324
-static int ts72xx_spi_chipselects[] __initdata = {
325
- EP93XX_GPIO_LINE_F(2), /* DIO_17 */
318
+static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = {
319
+ .dev_id = "spi0",
320
+ .table = {
321
+ /* DIO_17 */
322
+ GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW),
323
+ { },
324
+ },
326325 };
327326
328327 static struct ep93xx_spi_info ts72xx_spi_info __initdata = {
329
- .chipselect = ts72xx_spi_chipselects,
330
- .num_chipselect = ARRAY_SIZE(ts72xx_spi_chipselects),
328
+ /* Intentionally left blank */
331329 };
332330
333331 static void __init ts72xx_init_machine(void)
....@@ -344,6 +342,7 @@
344342 if (board_is_ts7300())
345343 platform_device_register(&ts73xx_fpga_device);
346344 #endif
345
+ gpiod_add_lookup_table(&ts72xx_spi_cs_gpio_table);
347346 ep93xx_register_spi(&ts72xx_spi_info, ts72xx_spi_devices,
348347 ARRAY_SIZE(ts72xx_spi_devices));
349348 }
....@@ -403,6 +402,7 @@
403402
404403 ep93xx_register_eth(&ts72xx_eth_data, 1);
405404
405
+ gpiod_add_lookup_table(&bk3_spi_cs_gpio_table);
406406 ep93xx_register_spi(&bk3_spi_master, bk3_spi_board_info,
407407 ARRAY_SIZE(bk3_spi_board_info));
408408