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