ixp4xx: add v3.18 support
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-3.18 / 500-usr8200_support.patch
1 --- a/arch/arm/mach-ixp4xx/Kconfig
2 +++ b/arch/arm/mach-ixp4xx/Kconfig
3 @@ -93,6 +93,14 @@ config MACH_SIDEWINDER
4 Engineering Sidewinder board. For more information on this
5 platform, see http://www.adiengineering.com
6
7 +config MACH_USR8200
8 + bool "USRobotics USR8200"
9 + select PCI
10 + help
11 + Say 'Y' here if you want your kernel to support the USRobotics
12 + USR8200 router board. For more information on this platform, see
13 + http://openwrt.org
14 +
15 config MACH_COMPEXWP18
16 bool "Compex WP18 / NP18A"
17 select PCI
18 --- a/arch/arm/mach-ixp4xx/Makefile
19 +++ b/arch/arm/mach-ixp4xx/Makefile
20 @@ -27,6 +27,7 @@ obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt
21 obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
22 obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
23 obj-pci-$(CONFIG_MACH_MI424WR) += mi424wr-pci.o
24 +obj-pci-$(CONFIG_MACH_USR8200) += usr8200-pci.o
25
26 obj-y += common.o
27
28 @@ -55,6 +56,7 @@ obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv
29 obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
30 obj-$(CONFIG_MACH_TW5334) += tw5334-setup.o
31 obj-$(CONFIG_MACH_MI424WR) += mi424wr-setup.o
32 +obj-$(CONFIG_MACH_USR8200) += usr8200-setup.o
33
34 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
35 obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
36 --- a/arch/arm/mach-ixp4xx/include/mach/uncompress.h
37 +++ b/arch/arm/mach-ixp4xx/include/mach/uncompress.h
38 @@ -44,7 +44,8 @@ static __inline__ void __arch_decomp_set
39 machine_is_gateway7001() || machine_is_wg302v2() ||
40 machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
41 machine_is_pronghorn() || machine_is_pronghorn_metro() ||
42 - machine_is_wrt300nv2() || machine_is_tw5334())
43 + machine_is_wrt300nv2() || machine_is_tw5334() ||
44 + machine_is_usr8200())
45 uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
46 else
47 uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;
48 --- /dev/null
49 +++ b/arch/arm/mach-ixp4xx/usr8200-pci.c
50 @@ -0,0 +1,77 @@
51 +/*
52 + * arch/arch/mach-ixp4xx/usr8200-pci.c
53 + *
54 + * PCI setup routines for USRobotics USR8200
55 + *
56 + * Copyright (C) 2008 Peter Denison <openwrt@marshadder.org>
57 + *
58 + * based on pronghorn-pci.c
59 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
60 + * based on coyote-pci.c:
61 + * Copyright (C) 2002 Jungo Software Technologies.
62 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
63 + *
64 + * Maintainer: Peter Denison <openwrt@marshadder.org>
65 + *
66 + * This program is free software; you can redistribute it and/or modify
67 + * it under the terms of the GNU General Public License version 2 as
68 + * published by the Free Software Foundation.
69 + *
70 + */
71 +
72 +#include <linux/kernel.h>
73 +#include <linux/pci.h>
74 +#include <linux/init.h>
75 +#include <linux/irq.h>
76 +
77 +#include <asm/mach-types.h>
78 +#include <mach/hardware.h>
79 +
80 +#include <asm/mach/pci.h>
81 +
82 +void __init usr8200_pci_preinit(void)
83 +{
84 + irq_set_irq_type(IRQ_IXP4XX_GPIO7, IRQ_TYPE_LEVEL_LOW);
85 + irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
86 + irq_set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW);
87 + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
88 + irq_set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
89 +
90 + ixp4xx_pci_preinit();
91 +}
92 +
93 +static int __init usr8200_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
94 +{
95 + if (slot == 14)
96 + return IRQ_IXP4XX_GPIO7;
97 + else if (slot == 15)
98 + return IRQ_IXP4XX_GPIO8;
99 + else if (slot == 16) {
100 + if (pin == 1)
101 + return IRQ_IXP4XX_GPIO11;
102 + else if (pin == 2)
103 + return IRQ_IXP4XX_GPIO10;
104 + else if (pin == 3)
105 + return IRQ_IXP4XX_GPIO9;
106 + else
107 + return -1;
108 + } else
109 + return -1;
110 +}
111 +
112 +struct hw_pci usr8200_pci __initdata = {
113 + .nr_controllers = 1,
114 + .preinit = usr8200_pci_preinit,
115 + .ops = &ixp4xx_ops,
116 + .setup = ixp4xx_setup,
117 + .map_irq = usr8200_map_irq,
118 +};
119 +
120 +int __init usr8200_pci_init(void)
121 +{
122 + if (machine_is_usr8200())
123 + pci_common_init(&usr8200_pci);
124 + return 0;
125 +}
126 +
127 +subsys_initcall(usr8200_pci_init);
128 --- /dev/null
129 +++ b/arch/arm/mach-ixp4xx/usr8200-setup.c
130 @@ -0,0 +1,217 @@
131 +/*
132 + * arch/arm/mach-ixp4xx/usr8200-setup.c
133 + *
134 + * Board setup for the USRobotics USR8200
135 + *
136 + * Copyright (C) 2008 Peter Denison <openwrt@marshadder.org>
137 + *
138 + * based on pronghorn-setup.c:
139 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
140 + * based on coyote-setup.c:
141 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
142 + *
143 + * Author: Peter Denison <openwrt@marshadder.org>
144 + */
145 +
146 +#include <linux/kernel.h>
147 +#include <linux/init.h>
148 +#include <linux/device.h>
149 +#include <linux/serial.h>
150 +#include <linux/tty.h>
151 +#include <linux/serial_8250.h>
152 +#include <linux/slab.h>
153 +#include <linux/types.h>
154 +#include <linux/memory.h>
155 +#include <linux/i2c-gpio.h>
156 +#include <linux/leds.h>
157 +#include <linux/dma-mapping.h>
158 +
159 +#include <asm/setup.h>
160 +#include <mach/hardware.h>
161 +#include <asm/irq.h>
162 +#include <asm/mach-types.h>
163 +#include <asm/mach/arch.h>
164 +#include <asm/mach/flash.h>
165 +
166 +static struct flash_platform_data usr8200_flash_data = {
167 + .map_name = "cfi_probe",
168 + .width = 2,
169 +};
170 +
171 +static struct resource usr8200_flash_resource = {
172 + .flags = IORESOURCE_MEM,
173 +};
174 +
175 +static struct platform_device usr8200_flash = {
176 + .name = "IXP4XX-Flash",
177 + .id = 0,
178 + .dev = {
179 + .platform_data = &usr8200_flash_data,
180 + },
181 + .num_resources = 1,
182 + .resource = &usr8200_flash_resource,
183 +};
184 +
185 +static struct resource usr8200_uart_resources [] = {
186 + {
187 + .start = IXP4XX_UART2_BASE_PHYS,
188 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
189 + .flags = IORESOURCE_MEM
190 + },
191 + {
192 + .start = IXP4XX_UART1_BASE_PHYS,
193 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
194 + .flags = IORESOURCE_MEM
195 + }
196 +};
197 +
198 +static struct plat_serial8250_port usr8200_uart_data[] = {
199 + {
200 + .mapbase = IXP4XX_UART2_BASE_PHYS,
201 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
202 + .irq = IRQ_IXP4XX_UART2,
203 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
204 + .iotype = UPIO_MEM,
205 + .regshift = 2,
206 + .uartclk = IXP4XX_UART_XTAL,
207 + },
208 + {
209 + .mapbase = IXP4XX_UART1_BASE_PHYS,
210 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
211 + .irq = IRQ_IXP4XX_UART1,
212 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
213 + .iotype = UPIO_MEM,
214 + .regshift = 2,
215 + .uartclk = IXP4XX_UART_XTAL,
216 + },
217 + { },
218 +};
219 +
220 +static struct platform_device usr8200_uart = {
221 + .name = "serial8250",
222 + .id = PLAT8250_DEV_PLATFORM,
223 + .dev = {
224 + .platform_data = usr8200_uart_data,
225 + },
226 + .num_resources = 2,
227 + .resource = usr8200_uart_resources,
228 +};
229 +
230 +static struct gpio_led usr8200_led_pin[] = {
231 + {
232 + .name = "usr8200:usb1",
233 + .gpio = 0,
234 + .active_low = 1,
235 + },
236 + {
237 + .name = "usr8200:usb2",
238 + .gpio = 1,
239 + .active_low = 1,
240 + },
241 + {
242 + .name = "usr8200:ieee1394",
243 + .gpio = 2,
244 + .active_low = 1,
245 + },
246 + {
247 + .name = "usr8200:internal",
248 + .gpio = 3,
249 + .active_low = 1,
250 + },
251 + {
252 + .name = "usr8200:power",
253 + .gpio = 14,
254 + }
255 +};
256 +
257 +static struct gpio_led_platform_data usr8200_led_data = {
258 + .num_leds = ARRAY_SIZE(usr8200_led_pin),
259 + .leds = usr8200_led_pin,
260 +};
261 +
262 +static struct platform_device usr8200_led = {
263 + .name = "leds-gpio",
264 + .id = -1,
265 + .dev.platform_data = &usr8200_led_data,
266 +};
267 +
268 +static struct eth_plat_info usr8200_plat_eth[] = {
269 + { /* NPEC - LAN with Marvell 88E6060 switch */
270 + .phy = IXP4XX_ETH_PHY_MAX_ADDR,
271 + .phy_mask = 0x0F0000,
272 + .rxq = 4,
273 + .txreadyq = 21,
274 + }, { /* NPEB - WAN */
275 + .phy = 9,
276 + .rxq = 3,
277 + .txreadyq = 20,
278 + }
279 +};
280 +
281 +static struct platform_device usr8200_eth[] = {
282 + {
283 + .name = "ixp4xx_eth",
284 + .id = IXP4XX_ETH_NPEC,
285 + .dev.platform_data = usr8200_plat_eth,
286 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
287 + }, {
288 + .name = "ixp4xx_eth",
289 + .id = IXP4XX_ETH_NPEB,
290 + .dev.platform_data = usr8200_plat_eth + 1,
291 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
292 + }
293 +};
294 +
295 +static struct resource usr8200_rtc_resources = {
296 + .flags = IORESOURCE_MEM
297 +};
298 +
299 +static struct platform_device usr8200_rtc = {
300 + .name = "rtc7301",
301 + .id = 0,
302 + .num_resources = 1,
303 + .resource = &usr8200_rtc_resources,
304 +};
305 +
306 +static struct platform_device *usr8200_devices[] __initdata = {
307 + &usr8200_flash,
308 + &usr8200_uart,
309 + &usr8200_led,
310 + &usr8200_eth[0],
311 + &usr8200_eth[1],
312 + &usr8200_rtc,
313 +};
314 +
315 +static void __init usr8200_init(void)
316 +{
317 + ixp4xx_sys_init();
318 +
319 + usr8200_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
320 + usr8200_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
321 +
322 + usr8200_rtc_resources.start = IXP4XX_EXP_BUS_BASE(2);
323 + usr8200_rtc_resources.end = IXP4XX_EXP_BUS_BASE(2) + 0x01ff;
324 +
325 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
326 + *IXP4XX_EXP_CS2 = 0x3fff000 | IXP4XX_EXP_BUS_SIZE(0) | IXP4XX_EXP_BUS_WR_EN |
327 + IXP4XX_EXP_BUS_CS_EN | IXP4XX_EXP_BUS_BYTE_EN;
328 + *IXP4XX_GPIO_GPCLKR = 0x01100000;
329 +
330 + /* configure button as input */
331 + gpio_line_config(12, IXP4XX_GPIO_IN);
332 +
333 + platform_add_devices(usr8200_devices, ARRAY_SIZE(usr8200_devices));
334 +}
335 +
336 +MACHINE_START(USR8200, "USRobotics USR8200")
337 + /* Maintainer: Peter Denison <openwrt@marshadder.org> */
338 + .map_io = ixp4xx_map_io,
339 + .init_irq = ixp4xx_init_irq,
340 + .init_time = ixp4xx_timer_init,
341 + .atag_offset = 0x0100,
342 + .init_machine = usr8200_init,
343 +#if defined(CONFIG_PCI)
344 + .dma_zone_size = SZ_64M,
345 +#endif
346 + .restart = ixp4xx_restart,
347 +MACHINE_END