hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/mips/rb532/devices.c
....@@ -1,18 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * RouterBoard 500 Platform devices
34 *
45 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
56 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.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
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
167 */
178 #include <linux/kernel.h>
189 #include <linux/export.h>
....@@ -20,10 +11,10 @@
2011 #include <linux/ctype.h>
2112 #include <linux/string.h>
2213 #include <linux/platform_device.h>
23
-#include <linux/mtd/rawnand.h>
14
+#include <linux/mtd/platnand.h>
2415 #include <linux/mtd/mtd.h>
25
-#include <linux/mtd/partitions.h>
2616 #include <linux/gpio.h>
17
+#include <linux/gpio/machine.h>
2718 #include <linux/gpio_keys.h>
2819 #include <linux/input.h>
2920 #include <linux/serial_8250.h>
....@@ -128,27 +119,30 @@
128119 }
129120 };
130121
131
-static struct cf_device cf_slot0_data = {
132
- .gpio_pin = CF_GPIO_NUM
122
+static struct gpiod_lookup_table cf_slot0_gpio_table = {
123
+ .dev_id = "pata-rb532-cf",
124
+ .table = {
125
+ GPIO_LOOKUP("gpio0", CF_GPIO_NUM,
126
+ NULL, GPIO_ACTIVE_HIGH),
127
+ { },
128
+ },
133129 };
134130
135131 static struct platform_device cf_slot0 = {
136132 .id = -1,
137133 .name = "pata-rb532-cf",
138
- .dev.platform_data = &cf_slot0_data,
139134 .resource = cf_slot0_res,
140135 .num_resources = ARRAY_SIZE(cf_slot0_res),
141136 };
142137
143138 /* Resources and device for NAND */
144
-static int rb532_dev_ready(struct mtd_info *mtd)
139
+static int rb532_dev_ready(struct nand_chip *chip)
145140 {
146141 return gpio_get_value(GPIO_RDY);
147142 }
148143
149
-static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
144
+static void rb532_cmd_ctrl(struct nand_chip *chip, int cmd, unsigned int ctrl)
150145 {
151
- struct nand_chip *chip = mtd_to_nand(mtd);
152146 unsigned char orbits, nandbits;
153147
154148 if (ctrl & NAND_CTRL_CHANGE) {
....@@ -161,7 +155,7 @@
161155 set_latch_u5(orbits, nandbits);
162156 }
163157 if (cmd != NAND_CMD_NONE)
164
- writeb(cmd, chip->IO_ADDR_W);
158
+ writeb(cmd, chip->legacy.IO_ADDR_W);
165159 }
166160
167161 static struct resource nand_slot0_res[] = {
....@@ -292,7 +286,7 @@
292286 nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000;
293287
294288 /* Read and map device controller 3 */
295
- dev3.base = ioremap_nocache(readl(IDT434_REG_BASE + DEV3BASE), 1);
289
+ dev3.base = ioremap(readl(IDT434_REG_BASE + DEV3BASE), 1);
296290
297291 if (!dev3.base) {
298292 printk(KERN_ERR "rb532: cannot remap device controller 3\n");
....@@ -307,6 +301,7 @@
307301
308302 dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data);
309303
304
+ gpiod_add_lookup_table(&cf_slot0_gpio_table);
310305 return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs));
311306 }
312307
....@@ -315,11 +310,9 @@
315310 static int __init setup_kmac(char *s)
316311 {
317312 printk(KERN_INFO "korina mac = %s\n", s);
318
- if (!mac_pton(s, korina_dev0_data.mac)) {
313
+ if (!mac_pton(s, korina_dev0_data.mac))
319314 printk(KERN_ERR "Invalid mac\n");
320
- return -EINVAL;
321
- }
322
- return 0;
315
+ return 1;
323316 }
324317
325318 __setup("kmac=", setup_kmac);