| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * arch/arm/mach-ep93xx/ts72xx.c |
|---|
| 3 | 4 | * Technologic Systems TS72xx SBC support. |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * 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. |
|---|
| 11 | 7 | */ |
|---|
| 12 | 8 | |
|---|
| 13 | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 16 | 12 | #include <linux/init.h> |
|---|
| 17 | 13 | #include <linux/platform_device.h> |
|---|
| 18 | 14 | #include <linux/io.h> |
|---|
| 19 | | -#include <linux/mtd/rawnand.h> |
|---|
| 20 | | -#include <linux/mtd/partitions.h> |
|---|
| 15 | +#include <linux/mtd/platnand.h> |
|---|
| 21 | 16 | #include <linux/spi/spi.h> |
|---|
| 22 | 17 | #include <linux/spi/flash.h> |
|---|
| 23 | 18 | #include <linux/spi/mmc_spi.h> |
|---|
| 24 | 19 | #include <linux/mmc/host.h> |
|---|
| 25 | 20 | #include <linux/platform_data/spi-ep93xx.h> |
|---|
| 21 | +#include <linux/gpio/machine.h> |
|---|
| 26 | 22 | |
|---|
| 27 | | -#include <mach/gpio-ep93xx.h> |
|---|
| 28 | | -#include <mach/hardware.h> |
|---|
| 23 | +#include "gpio-ep93xx.h" |
|---|
| 24 | +#include "hardware.h" |
|---|
| 29 | 25 | #include <mach/irqs.h> |
|---|
| 30 | | -#include <mach/gpio-ep93xx.h> |
|---|
| 31 | 26 | |
|---|
| 32 | 27 | #include <asm/mach-types.h> |
|---|
| 33 | 28 | #include <asm/mach/map.h> |
|---|
| .. | .. |
|---|
| 76 | 71 | #define TS72XX_NAND_CONTROL_ADDR_LINE 22 /* 0xN0400000 */ |
|---|
| 77 | 72 | #define TS72XX_NAND_BUSY_ADDR_LINE 23 /* 0xN0800000 */ |
|---|
| 78 | 73 | |
|---|
| 79 | | -static void ts72xx_nand_hwcontrol(struct mtd_info *mtd, |
|---|
| 74 | +static void ts72xx_nand_hwcontrol(struct nand_chip *chip, |
|---|
| 80 | 75 | int cmd, unsigned int ctrl) |
|---|
| 81 | 76 | { |
|---|
| 82 | | - struct nand_chip *chip = mtd_to_nand(mtd); |
|---|
| 83 | | - |
|---|
| 84 | 77 | if (ctrl & NAND_CTRL_CHANGE) { |
|---|
| 85 | | - void __iomem *addr = chip->IO_ADDR_R; |
|---|
| 78 | + void __iomem *addr = chip->legacy.IO_ADDR_R; |
|---|
| 86 | 79 | unsigned char bits; |
|---|
| 87 | 80 | |
|---|
| 88 | 81 | addr += (1 << TS72XX_NAND_CONTROL_ADDR_LINE); |
|---|
| .. | .. |
|---|
| 96 | 89 | } |
|---|
| 97 | 90 | |
|---|
| 98 | 91 | if (cmd != NAND_CMD_NONE) |
|---|
| 99 | | - __raw_writeb(cmd, chip->IO_ADDR_W); |
|---|
| 92 | + __raw_writeb(cmd, chip->legacy.IO_ADDR_W); |
|---|
| 100 | 93 | } |
|---|
| 101 | 94 | |
|---|
| 102 | | -static int ts72xx_nand_device_ready(struct mtd_info *mtd) |
|---|
| 95 | +static int ts72xx_nand_device_ready(struct nand_chip *chip) |
|---|
| 103 | 96 | { |
|---|
| 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; |
|---|
| 106 | 98 | |
|---|
| 107 | 99 | addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE); |
|---|
| 108 | 100 | |
|---|
| .. | .. |
|---|
| 274 | 266 | * The all work is performed automatically by !SPI_FRAME (SFRM1) and |
|---|
| 275 | 267 | * goes through CPLD |
|---|
| 276 | 268 | */ |
|---|
| 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 | + }, |
|---|
| 279 | 275 | }; |
|---|
| 280 | 276 | |
|---|
| 281 | 277 | static struct ep93xx_spi_info bk3_spi_master __initdata = { |
|---|
| 282 | | - .chipselect = bk3_spi_chipselects, |
|---|
| 283 | | - .num_chipselect = ARRAY_SIZE(bk3_spi_chipselects), |
|---|
| 284 | 278 | .use_dma = 1, |
|---|
| 285 | 279 | }; |
|---|
| 286 | 280 | |
|---|
| .. | .. |
|---|
| 321 | 315 | }, |
|---|
| 322 | 316 | }; |
|---|
| 323 | 317 | |
|---|
| 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 | + }, |
|---|
| 326 | 325 | }; |
|---|
| 327 | 326 | |
|---|
| 328 | 327 | 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 */ |
|---|
| 331 | 329 | }; |
|---|
| 332 | 330 | |
|---|
| 333 | 331 | static void __init ts72xx_init_machine(void) |
|---|
| .. | .. |
|---|
| 344 | 342 | if (board_is_ts7300()) |
|---|
| 345 | 343 | platform_device_register(&ts73xx_fpga_device); |
|---|
| 346 | 344 | #endif |
|---|
| 345 | + gpiod_add_lookup_table(&ts72xx_spi_cs_gpio_table); |
|---|
| 347 | 346 | ep93xx_register_spi(&ts72xx_spi_info, ts72xx_spi_devices, |
|---|
| 348 | 347 | ARRAY_SIZE(ts72xx_spi_devices)); |
|---|
| 349 | 348 | } |
|---|
| .. | .. |
|---|
| 403 | 402 | |
|---|
| 404 | 403 | ep93xx_register_eth(&ts72xx_eth_data, 1); |
|---|
| 405 | 404 | |
|---|
| 405 | + gpiod_add_lookup_table(&bk3_spi_cs_gpio_table); |
|---|
| 406 | 406 | ep93xx_register_spi(&bk3_spi_master, bk3_spi_board_info, |
|---|
| 407 | 407 | ARRAY_SIZE(bk3_spi_board_info)); |
|---|
| 408 | 408 | |
|---|