blob: 8937263cec4a799a0bc5e607abcc4a97bfbd5a66 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/arm/mach-ixp4xx/ixdp425-setup.c
3 *
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +01004 * IXDP425/IXCDP1100 board-setup
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * Copyright (C) 2003-2005 MontaVista Software, Inc.
7 *
8 * Author: Deepak Saxena <dsaxena@plexity.net>
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/device.h>
14#include <linux/serial.h>
15#include <linux/tty.h>
16#include <linux/serial_8250.h>
Linus Walleijb2e63552017-09-10 01:30:46 +020017#include <linux/gpio/machine.h>
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010018#include <linux/io.h>
19#include <linux/mtd/mtd.h>
Boris Brezillond4092d72017-08-04 17:29:10 +020020#include <linux/mtd/rawnand.h>
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010021#include <linux/mtd/partitions.h>
Russell King8029db12008-09-06 12:11:37 +010022#include <linux/delay.h>
Linus Walleij8040dd02013-09-10 11:19:55 +020023#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/types.h>
25#include <asm/setup.h>
26#include <asm/memory.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/mach-types.h>
29#include <asm/irq.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/flash.h>
32
Krzysztof Hałasa9bf4d672009-11-16 15:24:41 +010033#define IXDP425_SDA_PIN 7
34#define IXDP425_SCL_PIN 6
35
36/* NAND Flash pins */
37#define IXDP425_NAND_NCE_PIN 12
38
39#define IXDP425_NAND_CMD_BYTE 0x01
40#define IXDP425_NAND_ADDR_BYTE 0x02
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042static struct flash_platform_data ixdp425_flash_data = {
43 .map_name = "cfi_probe",
44 .width = 2,
45};
46
47static struct resource ixdp425_flash_resource = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 .flags = IORESOURCE_MEM,
49};
50
51static struct platform_device ixdp425_flash = {
52 .name = "IXP4XX-Flash",
53 .id = 0,
54 .dev = {
55 .platform_data = &ixdp425_flash_data,
56 },
57 .num_resources = 1,
58 .resource = &ixdp425_flash_resource,
59};
60
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010061#if defined(CONFIG_MTD_NAND_PLATFORM) || \
62 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
63
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010064static struct mtd_partition ixdp425_partitions[] = {
65 {
66 .name = "ixp400 NAND FS 0",
67 .offset = 0,
68 .size = SZ_8M
69 }, {
70 .name = "ixp400 NAND FS 1",
71 .offset = MTDPART_OFS_APPEND,
72 .size = MTDPART_SIZ_FULL
73 },
74};
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010075
76static void
77ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
78{
Boris BREZILLONc993e092015-12-01 12:02:58 +010079 struct nand_chip *this = mtd_to_nand(mtd);
Boris BREZILLONd9dccc62015-12-10 09:00:40 +010080 int offset = (int)nand_get_controller_data(this);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010081
82 if (ctrl & NAND_CTRL_CHANGE) {
83 if (ctrl & NAND_NCE) {
Linus Walleij8040dd02013-09-10 11:19:55 +020084 gpio_set_value(IXDP425_NAND_NCE_PIN, 0);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010085 udelay(5);
86 } else
Linus Walleij8040dd02013-09-10 11:19:55 +020087 gpio_set_value(IXDP425_NAND_NCE_PIN, 1);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010088
89 offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
90 offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
Boris BREZILLONd9dccc62015-12-10 09:00:40 +010091 nand_set_controller_data(this, (void *)offset);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +010092 }
93
94 if (cmd != NAND_CMD_NONE)
95 writeb(cmd, this->IO_ADDR_W + offset);
96}
97
98static struct platform_nand_data ixdp425_flash_nand_data = {
99 .chip = {
Marek Vasutef077172010-08-12 02:14:54 +0100100 .nr_chips = 1,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100101 .chip_delay = 30,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100102 .partitions = ixdp425_partitions,
103 .nr_partitions = ARRAY_SIZE(ixdp425_partitions),
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100104 },
105 .ctrl = {
106 .cmd_ctrl = ixdp425_flash_nand_cmd_ctrl
107 }
108};
109
110static struct resource ixdp425_flash_nand_resource = {
111 .flags = IORESOURCE_MEM,
112};
113
114static struct platform_device ixdp425_flash_nand = {
115 .name = "gen_nand",
116 .id = -1,
117 .dev = {
118 .platform_data = &ixdp425_flash_nand_data,
119 },
120 .num_resources = 1,
121 .resource = &ixdp425_flash_nand_resource,
122};
123#endif /* CONFIG_MTD_NAND_PLATFORM */
124
Linus Walleijb2e63552017-09-10 01:30:46 +0200125static struct gpiod_lookup_table ixdp425_i2c_gpiod_table = {
126 .dev_id = "i2c-gpio",
127 .table = {
128 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SDA_PIN,
129 NULL, 0, GPIO_ACTIVE_HIGH),
130 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", IXDP425_SCL_PIN,
131 NULL, 1, GPIO_ACTIVE_HIGH),
132 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133};
134
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100135static struct platform_device ixdp425_i2c_gpio = {
136 .name = "i2c-gpio",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 .id = 0,
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100138 .dev = {
Linus Walleijb2e63552017-09-10 01:30:46 +0200139 .platform_data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141};
142
143static struct resource ixdp425_uart_resources[] = {
144 {
145 .start = IXP4XX_UART1_BASE_PHYS,
146 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
147 .flags = IORESOURCE_MEM
148 },
149 {
150 .start = IXP4XX_UART2_BASE_PHYS,
151 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
152 .flags = IORESOURCE_MEM
153 }
154};
155
156static struct plat_serial8250_port ixdp425_uart_data[] = {
157 {
158 .mapbase = IXP4XX_UART1_BASE_PHYS,
159 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
160 .irq = IRQ_IXP4XX_UART1,
Deepak Saxena8c741ed2005-08-03 19:58:21 +0100161 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 .iotype = UPIO_MEM,
163 .regshift = 2,
164 .uartclk = IXP4XX_UART_XTAL,
165 },
166 {
167 .mapbase = IXP4XX_UART2_BASE_PHYS,
168 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
Jeff Hansena35d6c92005-12-01 15:50:35 +0000169 .irq = IRQ_IXP4XX_UART2,
Deepak Saxena8c741ed2005-08-03 19:58:21 +0100170 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 .iotype = UPIO_MEM,
172 .regshift = 2,
173 .uartclk = IXP4XX_UART_XTAL,
Stefan Sorensenbcaafbe2005-07-06 23:06:04 +0100174 },
175 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176};
177
178static struct platform_device ixdp425_uart = {
179 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100180 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 .dev.platform_data = ixdp425_uart_data,
182 .num_resources = 2,
183 .resource = ixdp425_uart_resources
184};
185
Rod Whitby78225912008-01-31 12:44:03 +0100186/* Built-in 10/100 Ethernet MAC interfaces */
187static struct eth_plat_info ixdp425_plat_eth[] = {
188 {
189 .phy = 0,
190 .rxq = 3,
191 .txreadyq = 20,
192 }, {
193 .phy = 1,
194 .rxq = 4,
195 .txreadyq = 21,
196 }
197};
198
199static struct platform_device ixdp425_eth[] = {
200 {
201 .name = "ixp4xx_eth",
202 .id = IXP4XX_ETH_NPEB,
203 .dev.platform_data = ixdp425_plat_eth,
204 }, {
205 .name = "ixp4xx_eth",
206 .id = IXP4XX_ETH_NPEC,
207 .dev.platform_data = ixdp425_plat_eth + 1,
208 }
209};
210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211static struct platform_device *ixdp425_devices[] __initdata = {
Michael-Luke Jones5a4a2382008-01-27 18:14:46 +0100212 &ixdp425_i2c_gpio,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 &ixdp425_flash,
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100214#if defined(CONFIG_MTD_NAND_PLATFORM) || \
215 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
216 &ixdp425_flash_nand,
217#endif
Rod Whitby78225912008-01-31 12:44:03 +0100218 &ixdp425_uart,
219 &ixdp425_eth[0],
220 &ixdp425_eth[1],
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221};
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223static void __init ixdp425_init(void)
224{
225 ixp4xx_sys_init();
226
Deepak Saxena54e269e2006-01-05 20:59:29 +0000227 ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
228 ixdp425_flash_resource.end =
229 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100231#if defined(CONFIG_MTD_NAND_PLATFORM) || \
232 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
233 ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3),
234 ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1;
235
Linus Walleij8040dd02013-09-10 11:19:55 +0200236 gpio_request(IXDP425_NAND_NCE_PIN, "NAND NCE pin");
237 gpio_direction_output(IXDP425_NAND_NCE_PIN, 0);
Vladimir Barinov4ad48b42007-05-16 20:39:02 +0100238
239 /* Configure expansion bus for NAND Flash */
240 *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
241 IXP4XX_EXP_BUS_STROBE_T(1) | /* extend by 1 clock */
242 IXP4XX_EXP_BUS_CYCLES(0) | /* Intel cycles */
243 IXP4XX_EXP_BUS_SIZE(0) | /* 512bytes addr space*/
244 IXP4XX_EXP_BUS_WR_EN |
245 IXP4XX_EXP_BUS_BYTE_EN; /* 8 bit data bus */
246#endif
247
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100248 if (cpu_is_ixp43x()) {
249 ixdp425_uart.num_resources = 1;
250 ixdp425_uart_data[1].flags = 0;
251 }
252
Linus Walleijb2e63552017-09-10 01:30:46 +0200253 gpiod_add_lookup_table(&ixdp425_i2c_gpiod_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
255}
256
Deepak Saxenab38708f2005-09-28 18:07:01 -0700257#ifdef CONFIG_ARCH_IXDP425
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100259 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100260 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600261 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100262 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700263 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400264 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100265 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400266#if defined(CONFIG_PCI)
267 .dma_zone_size = SZ_64M,
268#endif
Russell Kingd1b860f2011-11-05 12:10:55 +0000269 .restart = ixp4xx_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100271#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Deepak Saxenae0a20082005-09-18 21:11:56 +0100273#ifdef CONFIG_MACH_IXDP465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100275 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100276 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600277 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100278 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700279 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400280 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100281 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400282#if defined(CONFIG_PCI)
283 .dma_zone_size = SZ_64M,
284#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100286#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Deepak Saxenae0a20082005-09-18 21:11:56 +0100288#ifdef CONFIG_ARCH_PRPMC1100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100290 /* Maintainer: MontaVista Software, Inc. */
Deepak Saxenae605ecd2005-08-29 22:46:29 +0100291 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600292 .init_early = ixp4xx_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100293 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700294 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400295 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100296 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400297#if defined(CONFIG_PCI)
298 .dma_zone_size = SZ_64M,
299#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300MACHINE_END
Deepak Saxenae0a20082005-09-18 21:11:56 +0100301#endif
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100302
303#ifdef CONFIG_MACH_KIXRP435
304MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
305 /* Maintainer: MontaVista Software, Inc. */
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100306 .map_io = ixp4xx_map_io,
Rob Herringf4495882012-03-06 15:01:53 -0600307 .init_early = ixp4xx_init_early,
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100308 .init_irq = ixp4xx_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700309 .init_time = ixp4xx_timer_init,
Nicolas Pitree022c722011-07-05 22:38:13 -0400310 .atag_offset = 0x100,
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100311 .init_machine = ixdp425_init,
Nicolas Pitre7553ee72011-07-05 22:28:09 -0400312#if defined(CONFIG_PCI)
313 .dma_zone_size = SZ_64M,
314#endif
Ruslan V. Sushko45fba082007-04-06 15:00:31 +0100315MACHINE_END
316#endif