| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * RouterBoard 500 Platform devices |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> |
|---|
| 5 | 6 | * 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. |
|---|
| 16 | 7 | */ |
|---|
| 17 | 8 | #include <linux/kernel.h> |
|---|
| 18 | 9 | #include <linux/export.h> |
|---|
| .. | .. |
|---|
| 20 | 11 | #include <linux/ctype.h> |
|---|
| 21 | 12 | #include <linux/string.h> |
|---|
| 22 | 13 | #include <linux/platform_device.h> |
|---|
| 23 | | -#include <linux/mtd/rawnand.h> |
|---|
| 14 | +#include <linux/mtd/platnand.h> |
|---|
| 24 | 15 | #include <linux/mtd/mtd.h> |
|---|
| 25 | | -#include <linux/mtd/partitions.h> |
|---|
| 26 | 16 | #include <linux/gpio.h> |
|---|
| 17 | +#include <linux/gpio/machine.h> |
|---|
| 27 | 18 | #include <linux/gpio_keys.h> |
|---|
| 28 | 19 | #include <linux/input.h> |
|---|
| 29 | 20 | #include <linux/serial_8250.h> |
|---|
| .. | .. |
|---|
| 128 | 119 | } |
|---|
| 129 | 120 | }; |
|---|
| 130 | 121 | |
|---|
| 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 | + }, |
|---|
| 133 | 129 | }; |
|---|
| 134 | 130 | |
|---|
| 135 | 131 | static struct platform_device cf_slot0 = { |
|---|
| 136 | 132 | .id = -1, |
|---|
| 137 | 133 | .name = "pata-rb532-cf", |
|---|
| 138 | | - .dev.platform_data = &cf_slot0_data, |
|---|
| 139 | 134 | .resource = cf_slot0_res, |
|---|
| 140 | 135 | .num_resources = ARRAY_SIZE(cf_slot0_res), |
|---|
| 141 | 136 | }; |
|---|
| 142 | 137 | |
|---|
| 143 | 138 | /* 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) |
|---|
| 145 | 140 | { |
|---|
| 146 | 141 | return gpio_get_value(GPIO_RDY); |
|---|
| 147 | 142 | } |
|---|
| 148 | 143 | |
|---|
| 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) |
|---|
| 150 | 145 | { |
|---|
| 151 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
|---|
| 152 | 146 | unsigned char orbits, nandbits; |
|---|
| 153 | 147 | |
|---|
| 154 | 148 | if (ctrl & NAND_CTRL_CHANGE) { |
|---|
| .. | .. |
|---|
| 161 | 155 | set_latch_u5(orbits, nandbits); |
|---|
| 162 | 156 | } |
|---|
| 163 | 157 | if (cmd != NAND_CMD_NONE) |
|---|
| 164 | | - writeb(cmd, chip->IO_ADDR_W); |
|---|
| 158 | + writeb(cmd, chip->legacy.IO_ADDR_W); |
|---|
| 165 | 159 | } |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | static struct resource nand_slot0_res[] = { |
|---|
| .. | .. |
|---|
| 292 | 286 | nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000; |
|---|
| 293 | 287 | |
|---|
| 294 | 288 | /* 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); |
|---|
| 296 | 290 | |
|---|
| 297 | 291 | if (!dev3.base) { |
|---|
| 298 | 292 | printk(KERN_ERR "rb532: cannot remap device controller 3\n"); |
|---|
| .. | .. |
|---|
| 307 | 301 | |
|---|
| 308 | 302 | dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data); |
|---|
| 309 | 303 | |
|---|
| 304 | + gpiod_add_lookup_table(&cf_slot0_gpio_table); |
|---|
| 310 | 305 | return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs)); |
|---|
| 311 | 306 | } |
|---|
| 312 | 307 | |
|---|
| .. | .. |
|---|
| 315 | 310 | static int __init setup_kmac(char *s) |
|---|
| 316 | 311 | { |
|---|
| 317 | 312 | 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)) |
|---|
| 319 | 314 | printk(KERN_ERR "Invalid mac\n"); |
|---|
| 320 | | - return -EINVAL; |
|---|
| 321 | | - } |
|---|
| 322 | | - return 0; |
|---|
| 315 | + return 1; |
|---|
| 323 | 316 | } |
|---|
| 324 | 317 | |
|---|
| 325 | 318 | __setup("kmac=", setup_kmac); |
|---|