blob: 57d7df79d8389b8373d1e0c24a3133f26ba70643 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * arch/arm/mach-ixp4xx/ixdp425-setup.c
4 *
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +01005 * IXDP425/IXCDP1100 board-setup
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * Copyright (C) 2003-2005 MontaVista Software, Inc.
8 *
9 * Author: Deepak Saxena <dsaxena@plexity.net>
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/device.h>
15#include <linux/serial.h>
16#include <linux/tty.h>
17#include <linux/serial_8250.h>
Linus Walleijb2e63552017-09-10 01:30:46 +020018#include <linux/gpio/machine.h>
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010019#include <linux/io.h>
20#include <linux/mtd/mtd.h>
Boris Brezillond4092d72017-08-04 17:29:10 +020021#include <linux/mtd/rawnand.h>
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010022#include <linux/mtd/partitions.h>
Boris Brezillonc7921bb2018-09-07 00:38:46 +020023#include <linux/mtd/platnand.h>
Russell King8029db12008-09-06 12:11:37 +010024#include <linux/delay.h>
Linus Walleij8040dd02013-09-10 11:19:55 +020025#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/types.h>
27#include <asm/setup.h>
28#include <asm/memory.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/mach-types.h>
31#include <asm/irq.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/flash.h>
34
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +010035#define IXDP425_SDA_PIN 7
36#define IXDP425_SCL_PIN 6
37
38/* NAND Flash pins */
39#define IXDP425_NAND_NCE_PIN 12
40
41#define IXDP425_NAND_CMD_BYTE 0x01
42#define IXDP425_NAND_ADDR_BYTE 0x02
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044static struct flash_platform_data ixdp425_flash_data = {
45 .map_name = "cfi_probe",
46 .width = 2,
47};
48
49static struct resource ixdp425_flash_resource = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 .flags = IORESOURCE_MEM,
51};
52
53static struct platform_device ixdp425_flash = {
54 .name = "IXP4XX-Flash",
55 .id = 0,
56 .dev = {
57 .platform_data = &ixdp425_flash_data,
58 },
59 .num_resources = 1,
60 .resource = &ixdp425_flash_resource,
61};
62
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010063#if defined(CONFIG_MTD_NAND_PLATFORM) || \
64 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
65
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010066static struct mtd_partition ixdp425_partitions[] = {
67 {
68 .name = "ixp400 NAND FS 0",
69 .offset = 0,
70 .size = SZ_8M
71 }, {
72 .name = "ixp400 NAND FS 1",
73 .offset = MTDPART_OFS_APPEND,
74 .size = MTDPART_SIZ_FULL
75 },
76};
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010077
78static void
Boris Brezillon47bd59e2018-09-06 14:05:13 +020079ixdp425_flash_nand_cmd_ctrl(struct nand_chip *this, int cmd, unsigned int ctrl)
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010080{
Boris BREZILLONd9dccc62015-12-10 09:00:40 +010081 int offset = (int)nand_get_controller_data(this);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010082
83 if (ctrl & NAND_CTRL_CHANGE) {
84 if (ctrl & NAND_NCE) {
Linus Walleij8040dd02013-09-10 11:19:55 +020085 gpio_set_value(IXDP425_NAND_NCE_PIN, 0);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010086 udelay(5);
87 } else
Linus Walleij8040dd02013-09-10 11:19:55 +020088 gpio_set_value(IXDP425_NAND_NCE_PIN, 1);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010089
90 offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
91 offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
Boris BREZILLONd9dccc62015-12-10 09:00:40 +010092 nand_set_controller_data(this, (void *)offset);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010093 }
94
95 if (cmd != NAND_CMD_NONE)
Boris Brezillon82fc5092018-09-07 00:38:34 +020096 writeb(cmd, this->legacy.IO_ADDR_W + offset);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010097}
98
99static struct platform_nand_data ixdp425_flash_nand_data = {
100 .chip = {
Marek Vasutef077172010-08-12 02:14:54 +0100101 .nr_chips = 1,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100102 .chip_delay = 30,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100103 .partitions = ixdp425_partitions,
104 .nr_partitions = ARRAY_SIZE(ixdp425_partitions),
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100105 },
106 .ctrl = {
107 .cmd_ctrl = ixdp425_flash_nand_cmd_ctrl
108 }
109};
110
111static struct resource ixdp425_flash_nand_resource = {
112 .flags = IORESOURCE_MEM,
113};
114
115static struct platform_device ixdp425_flash_nand = {
116 .name = "gen_nand",
117 .id = -1,
118 .dev = {
119 .platform_data = &ixdp425_flash_nand_data,
120 },
121 .num_resources = 1,
122 .resource = &ixdp425_flash_nand_resource,
123};
124#endif /* CONFIG_MTD_NAND_PLATFORM */
125
Linus Walleijb2e63552017-09-10 01:30:46 +0200126static struct gpiod_lookup_table ixdp425_i2c_gpiod_table = {
Linus Walleijf59c3032018-05-26 18:37:34 +0200127 .dev_id = "i2c-gpio.0",
Linus Walleijb2e63552017-09-10 01:30:46 +0200128 .table = {
129 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SDA_PIN,
Linus Walleij4d0ce622017-09-10 23:03:32 +0200130 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +0200131 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SCL_PIN,
Linus Walleij4d0ce622017-09-10 23:03:32 +0200132 NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +0200133 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134};
135
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100136static struct platform_device ixdp425_i2c_gpio = {
137 .name = "i2c-gpio",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100139 .dev = {
Linus Walleijb2e63552017-09-10 01:30:46 +0200140 .platform_data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142};
143
144static struct resource ixdp425_uart_resources[] = {
145 {
146 .start = IXP4XX_UART1_BASE_PHYS,
147 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
148 .flags = IORESOURCE_MEM
149 },
150 {
151 .start = IXP4XX_UART2_BASE_PHYS,
152 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
153 .flags = IORESOURCE_MEM
154 }
155};
156
157static struct plat_serial8250_port ixdp425_uart_data[] = {
158 {
159 .mapbase = IXP4XX_UART1_BASE_PHYS,
160 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
161 .irq = IRQ_IXP4XX_UART1,
Deepak Saxena8c741ed2005-08-03 19:58:21 +0100162 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 .iotype = UPIO_MEM,
164 .regshift = 2,
165 .uartclk = IXP4XX_UART_XTAL,
166 },
167 {
168 .mapbase = IXP4XX_UART2_BASE_PHYS,
169 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
Jeff Hansena35d6c92005-12-01 15:50:35 +0000170 .irq = IRQ_IXP4XX_UART2,
Deepak Saxena8c741ed2005-08-03 19:58:21 +0100171 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 .iotype = UPIO_MEM,
173 .regshift = 2,
174 .uartclk = IXP4XX_UART_XTAL,
Stefan Sorensenbcaafbe2005-07-06 23:06:04 +0100175 },
176 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177};
178
179static struct platform_device ixdp425_uart = {
180 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100181 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 .dev.platform_data = ixdp425_uart_data,
183 .num_resources = 2,
184 .resource = ixdp425_uart_resources
185};
186
Rod Whitby78225912008-01-31 12:44:03 +0100187/* Built-in 10/100 Ethernet MAC interfaces */
188static struct eth_plat_info ixdp425_plat_eth[] = {
189 {
190 .phy = 0,
191 .rxq = 3,
192 .txreadyq = 20,
193 }, {
194 .phy = 1,
195 .rxq = 4,
196 .txreadyq = 21,
197 }
198};
199
200static struct platform_device ixdp425_eth[] = {
201 {
202 .name = "ixp4xx_eth",
203 .id = IXP4XX_ETH_NPEB,
204 .dev.platform_data = ixdp425_plat_eth,
205 }, {
206 .name = "ixp4xx_eth",
207 .id = IXP4XX_ETH_NPEC,
208 .dev.platform_data = ixdp425_plat_eth + 1,
209 }
210};
211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212static struct platform_device *ixdp425_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100213 &ixdp425_i2c_gpio,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 &ixdp425_flash,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100215#if defined(CONFIG_MTD_NAND_PLATFORM) || \
216 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
217 &ixdp425_flash_nand,
218#endif
Rod Whitby78225912008-01-31 12:44:03 +0100219 &ixdp425_uart,
220 &ixdp425_eth[0],
221 &ixdp425_eth[1],
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222};
223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224static void __init ixdp425_init(void)
225{
226 ixp4xx_sys_init();
227
Deepak Saxena54e269e2006-01-05 20:59:29 +0000228 ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
229 ixdp425_flash_resource.end =
230 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100232#if defined(CONFIG_MTD_NAND_PLATFORM) || \
233 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
234 ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3),
235 ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1;
236
Linus Walleij8040dd02013-09-10 11:19:55 +0200237 gpio_request(IXDP425_NAND_NCE_PIN, "NAND NCE pin");
238 gpio_direction_output(IXDP425_NAND_NCE_PIN, 0);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100239
240 /* Configure expansion bus for NAND Flash */
241 *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
242 IXP4XX_EXP_BUS_STROBE_T(1) | /* extend by 1 clock */
243 IXP4XX_EXP_BUS_CYCLES(0) | /* Intel cycles */
244 IXP4XX_EXP_BUS_SIZE(0) | /* 512bytes addr space*/
245 IXP4XX_EXP_BUS_WR_EN |
246 IXP4XX_EXP_BUS_BYTE_EN; /* 8 bit data bus */
247#endif
248
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100249 if (cpu_is_ixp43x()) {
250 ixdp425_uart.num_resources = 1;
251 ixdp425_uart_data[1].flags = 0;
252 }
253
Linus Walleijb2e63552017-09-10 01:30:46 +0200254 gpiod_add_lookup_table(&ixdp425_i2c_gpiod_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
256}
257
Deepak Saxenab38708f2005-09-28 18:07:01 -0700258#ifdef CONFIG_ARCH_IXDP425
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100260 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100261 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600262 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100263 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700264 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400265 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100266 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400267#if defined(CONFIG_PCI)
268 .dma_zone_size = SZ_64M,
269#endif
Russell Kingd1b860f2011-11-05 12:10:55 +0000270 .restart = ixp4xx_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100272#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Deepak Saxenae0a20082005-09-18 21:11:56 +0100274#ifdef CONFIG_MACH_IXDP465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100276 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100277 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600278 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100279 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700280 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400281 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100282 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400283#if defined(CONFIG_PCI)
284 .dma_zone_size = SZ_64M,
285#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100287#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
Deepak Saxenae0a20082005-09-18 21:11:56 +0100289#ifdef CONFIG_ARCH_PRPMC1100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100291 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100292 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600293 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100294 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700295 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400296 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100297 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400298#if defined(CONFIG_PCI)
299 .dma_zone_size = SZ_64M,
300#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100302#endif
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100303
304#ifdef CONFIG_MACH_KIXRP435
305MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
306 /* Maintainer: MontaVista Software, Inc. */
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100307 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600308 .init_early = ixp4xx_init_early,
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100309 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700310 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400311 .atag_offset = 0x100,
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100312 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400313#if defined(CONFIG_PCI)
314 .dma_zone_size = SZ_64M,
315#endif
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100316MACHINE_END
317#endif