1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * arch/arm/mach-ixp4xx/vulcan-setup.c
4 *
5 * Arcom/Eurotech Vulcan board-setup
6 *
7 * Copyright (C) 2010 Marc Zyngier <maz@misterjones.org>
8 *
9 * based on fsg-setup.c:
10 * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
11 */
12
13 #include <linux/if_ether.h>
14 #include <linux/irq.h>
15 #include <linux/serial.h>
16 #include <linux/serial_8250.h>
17 #include <linux/io.h>
18 #include <linux/w1-gpio.h>
19 #include <linux/gpio/machine.h>
20 #include <linux/mtd/plat-ram.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/flash.h>
24
25 #include "irqs.h"
26
27 static struct flash_platform_data vulcan_flash_data = {
28 .map_name = "cfi_probe",
29 .width = 2,
30 };
31
32 static struct resource vulcan_flash_resource = {
33 .flags = IORESOURCE_MEM,
34 };
35
36 static struct platform_device vulcan_flash = {
37 .name = "IXP4XX-Flash",
38 .id = 0,
39 .dev = {
40 .platform_data = &vulcan_flash_data,
41 },
42 .resource = &vulcan_flash_resource,
43 .num_resources = 1,
44 };
45
46 static struct platdata_mtd_ram vulcan_sram_data = {
47 .mapname = "Vulcan SRAM",
48 .bankwidth = 1,
49 };
50
51 static struct resource vulcan_sram_resource = {
52 .flags = IORESOURCE_MEM,
53 };
54
55 static struct platform_device vulcan_sram = {
56 .name = "mtd-ram",
57 .id = 0,
58 .dev = {
59 .platform_data = &vulcan_sram_data,
60 },
61 .resource = &vulcan_sram_resource,
62 .num_resources = 1,
63 };
64
65 static struct resource vulcan_uart_resources[] = {
66 [0] = {
67 .start = IXP4XX_UART1_BASE_PHYS,
68 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
69 .flags = IORESOURCE_MEM,
70 },
71 [1] = {
72 .start = IXP4XX_UART2_BASE_PHYS,
73 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
74 .flags = IORESOURCE_MEM,
75 },
76 [2] = {
77 .flags = IORESOURCE_MEM,
78 },
79 };
80
81 static struct plat_serial8250_port vulcan_uart_data[] = {
82 [0] = {
83 .mapbase = IXP4XX_UART1_BASE_PHYS,
84 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
85 .irq = IRQ_IXP4XX_UART1,
86 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
87 .iotype = UPIO_MEM,
88 .regshift = 2,
89 .uartclk = IXP4XX_UART_XTAL,
90 },
91 [1] = {
92 .mapbase = IXP4XX_UART2_BASE_PHYS,
93 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
94 .irq = IRQ_IXP4XX_UART2,
95 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
96 .iotype = UPIO_MEM,
97 .regshift = 2,
98 .uartclk = IXP4XX_UART_XTAL,
99 },
100 [2] = {
101 .irq = IXP4XX_GPIO_IRQ(4),
102 .irqflags = IRQF_TRIGGER_LOW,
103 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
104 .iotype = UPIO_MEM,
105 .uartclk = 1843200,
106 },
107 [3] = {
108 .irq = IXP4XX_GPIO_IRQ(4),
109 .irqflags = IRQF_TRIGGER_LOW,
110 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
111 .iotype = UPIO_MEM,
112 .uartclk = 1843200,
113 },
114 { }
115 };
116
117 static struct platform_device vulcan_uart = {
118 .name = "serial8250",
119 .id = PLAT8250_DEV_PLATFORM,
120 .dev = {
121 .platform_data = vulcan_uart_data,
122 },
123 .resource = vulcan_uart_resources,
124 .num_resources = ARRAY_SIZE(vulcan_uart_resources),
125 };
126
127 static struct eth_plat_info vulcan_plat_eth[] = {
128 [0] = {
129 .phy = 0,
130 .rxq = 3,
131 .txreadyq = 20,
132 },
133 [1] = {
134 .phy = 1,
135 .rxq = 4,
136 .txreadyq = 21,
137 },
138 };
139
140 static struct platform_device vulcan_eth[] = {
141 [0] = {
142 .name = "ixp4xx_eth",
143 .id = IXP4XX_ETH_NPEB,
144 .dev = {
145 .platform_data = &vulcan_plat_eth[0],
146 },
147 },
148 [1] = {
149 .name = "ixp4xx_eth",
150 .id = IXP4XX_ETH_NPEC,
151 .dev = {
152 .platform_data = &vulcan_plat_eth[1],
153 },
154 },
155 };
156
157 static struct resource vulcan_max6369_resource = {
158 .flags = IORESOURCE_MEM,
159 };
160
161 static struct platform_device vulcan_max6369 = {
162 .name = "max6369_wdt",
163 .id = -1,
164 .resource = &vulcan_max6369_resource,
165 .num_resources = 1,
166 };
167
168 static struct gpiod_lookup_table vulcan_w1_gpiod_table = {
169 .dev_id = "w1-gpio",
170 .table = {
171 GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", 14, NULL, 0,
172 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
173 },
174 };
175
176 static struct w1_gpio_platform_data vulcan_w1_gpio_pdata = {
177 /* Intentionally left blank */
178 };
179
180 static struct platform_device vulcan_w1_gpio = {
181 .name = "w1-gpio",
182 .id = 0,
183 .dev = {
184 .platform_data = &vulcan_w1_gpio_pdata,
185 },
186 };
187
188 static struct platform_device *vulcan_devices[] __initdata = {
189 &vulcan_uart,
190 &vulcan_flash,
191 &vulcan_sram,
192 &vulcan_max6369,
193 &vulcan_eth[0],
194 &vulcan_eth[1],
195 &vulcan_w1_gpio,
196 };
197
vulcan_init(void)198 static void __init vulcan_init(void)
199 {
200 ixp4xx_sys_init();
201
202 /* Flash is spread over both CS0 and CS1 */
203 vulcan_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
204 vulcan_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
205 *IXP4XX_EXP_CS0 = IXP4XX_EXP_BUS_CS_EN |
206 IXP4XX_EXP_BUS_STROBE_T(3) |
207 IXP4XX_EXP_BUS_SIZE(0xF) |
208 IXP4XX_EXP_BUS_BYTE_RD16 |
209 IXP4XX_EXP_BUS_WR_EN;
210 *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
211
212 /* SRAM on CS2, (256kB, 8bit, writable) */
213 vulcan_sram_resource.start = IXP4XX_EXP_BUS_BASE(2);
214 vulcan_sram_resource.end = IXP4XX_EXP_BUS_BASE(2) + SZ_256K - 1;
215 *IXP4XX_EXP_CS2 = IXP4XX_EXP_BUS_CS_EN |
216 IXP4XX_EXP_BUS_STROBE_T(1) |
217 IXP4XX_EXP_BUS_HOLD_T(2) |
218 IXP4XX_EXP_BUS_SIZE(9) |
219 IXP4XX_EXP_BUS_SPLT_EN |
220 IXP4XX_EXP_BUS_WR_EN |
221 IXP4XX_EXP_BUS_BYTE_EN;
222
223 /* XR16L2551 on CS3 (Moto style, 512 bytes, 8bits, writable) */
224 vulcan_uart_resources[2].start = IXP4XX_EXP_BUS_BASE(3);
225 vulcan_uart_resources[2].end = IXP4XX_EXP_BUS_BASE(3) + 16 - 1;
226 vulcan_uart_data[2].mapbase = vulcan_uart_resources[2].start;
227 vulcan_uart_data[3].mapbase = vulcan_uart_data[2].mapbase + 8;
228 *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
229 IXP4XX_EXP_BUS_STROBE_T(3) |
230 IXP4XX_EXP_BUS_CYCLES(IXP4XX_EXP_BUS_CYCLES_MOTOROLA)|
231 IXP4XX_EXP_BUS_WR_EN |
232 IXP4XX_EXP_BUS_BYTE_EN;
233
234 /* GPIOS on CS4 (512 bytes, 8bits, writable) */
235 *IXP4XX_EXP_CS4 = IXP4XX_EXP_BUS_CS_EN |
236 IXP4XX_EXP_BUS_WR_EN |
237 IXP4XX_EXP_BUS_BYTE_EN;
238
239 /* max6369 on CS5 (512 bytes, 8bits, writable) */
240 vulcan_max6369_resource.start = IXP4XX_EXP_BUS_BASE(5);
241 vulcan_max6369_resource.end = IXP4XX_EXP_BUS_BASE(5);
242 *IXP4XX_EXP_CS5 = IXP4XX_EXP_BUS_CS_EN |
243 IXP4XX_EXP_BUS_WR_EN |
244 IXP4XX_EXP_BUS_BYTE_EN;
245
246 gpiod_add_lookup_table(&vulcan_w1_gpiod_table);
247 platform_add_devices(vulcan_devices, ARRAY_SIZE(vulcan_devices));
248 }
249
250 MACHINE_START(ARCOM_VULCAN, "Arcom/Eurotech Vulcan")
251 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
252 .map_io = ixp4xx_map_io,
253 .init_early = ixp4xx_init_early,
254 .init_irq = ixp4xx_init_irq,
255 .init_time = ixp4xx_timer_init,
256 .atag_offset = 0x100,
257 .init_machine = vulcan_init,
258 #if defined(CONFIG_PCI)
259 .dma_zone_size = SZ_64M,
260 #endif
261 .restart = ixp4xx_restart,
262 MACHINE_END
263