[ixp4xx] clean up Avila/Cambria patches
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 130-wrt300nv2_support.patch
1 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
2 ===================================================================
3 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Kconfig
4 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
5 @@ -73,6 +73,14 @@ config MACH_COMPEX
6           WP18 or NP18A boards. For more information on this
7           platform, see http://openwrt.org
8  
9 +config MACH_WRT300NV2
10 +       bool "Linksys WRT300N v2"
11 +       select PCI
12 +       help
13 +         Say 'Y' here if you want your kernel to support Linksys' 
14 +         WRT300N v2 router. For more information on this
15 +         platform, see http://openwrt.org
16 +
17  config ARCH_IXDP425
18         bool "IXDP425"
19         help
20 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
21 ===================================================================
22 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Makefile
23 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
24 @@ -18,6 +18,7 @@ obj-pci-$(CONFIG_MACH_WG302V2)                += wg302
25  obj-pci-$(CONFIG_MACH_FSG)             += fsg-pci.o
26  obj-pci-$(CONFIG_MACH_PRONGHORNMETRO)  += pronghornmetro-pci.o
27  obj-pci-$(CONFIG_MACH_COMPEX)          += ixdp425-pci.o
28 +obj-pci-$(CONFIG_MACH_WRT300NV2)               += wrt300nv2-pci.o
29  
30  obj-y  += common.o
31  
32 @@ -34,6 +35,7 @@ obj-$(CONFIG_MACH_WG302V2)    += wg302v2-se
33  obj-$(CONFIG_MACH_FSG)         += fsg-setup.o
34  obj-$(CONFIG_MACH_PRONGHORNMETRO)      += pronghornmetro-setup.o
35  obj-$(CONFIG_MACH_COMPEX)      += compex-setup.o
36 +obj-$(CONFIG_MACH_WRT300NV2)   += wrt300nv2-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.25.4/arch/arm/mach-ixp4xx/wrt300nv2-pci.c
41 ===================================================================
42 --- /dev/null
43 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/wrt300nv2-pci.c
44 @@ -0,0 +1,65 @@
45 +/*
46 + * arch/arch/mach-ixp4xx/wrt300nv2-pci.c
47 + *
48 + * PCI setup routines for Linksys WRT300N v2
49 + *
50 + * Copyright (C) 2007 Imre Kaloz <kaloz@openwrt.org>
51 + *
52 + * based on coyote-pci.c:
53 + *     Copyright (C) 2002 Jungo Software Technologies.
54 + *     Copyright (C) 2003 MontaVista Softwrae, Inc.
55 + *
56 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
57 + *
58 + * This program is free software; you can redistribute it and/or modify
59 + * it under the terms of the GNU General Public License version 2 as
60 + * published by the Free Software Foundation.
61 + *
62 + */
63 +
64 +#include <linux/kernel.h>
65 +#include <linux/pci.h>
66 +#include <linux/init.h>
67 +#include <linux/irq.h>
68 +
69 +#include <asm/mach-types.h>
70 +#include <asm/hardware.h>
71 +#include <asm/irq.h>
72 +
73 +#include <asm/mach/pci.h>
74 +
75 +extern void ixp4xx_pci_preinit(void);
76 +extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
77 +extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
78 +
79 +void __init wrt300nv2_pci_preinit(void)
80 +{
81 +       set_irq_type(IRQ_IXP4XX_GPIO8, IRQT_LOW);
82 +
83 +       ixp4xx_pci_preinit();
84 +}
85 +
86 +static int __init wrt300nv2_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
87 +{
88 +       if (slot == 1)
89 +               return IRQ_IXP4XX_GPIO8;
90 +       else return -1;
91 +}
92 +
93 +struct hw_pci wrt300nv2_pci __initdata = {
94 +       .nr_controllers = 1,
95 +       .preinit =        wrt300nv2_pci_preinit,
96 +       .swizzle =        pci_std_swizzle,
97 +       .setup =          ixp4xx_setup,
98 +       .scan =           ixp4xx_scan_bus,
99 +       .map_irq =        wrt300nv2_map_irq,
100 +};
101 +
102 +int __init wrt300nv2_pci_init(void)
103 +{
104 +       if (machine_is_wrt300nv2())
105 +               pci_common_init(&wrt300nv2_pci);
106 +       return 0;
107 +}
108 +
109 +subsys_initcall(wrt300nv2_pci_init);
110 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/wrt300nv2-setup.c
111 ===================================================================
112 --- /dev/null
113 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/wrt300nv2-setup.c
114 @@ -0,0 +1,108 @@
115 +/*
116 + * arch/arm/mach-ixp4xx/wrt300nv2-setup.c
117 + *
118 + * Board setup for the Linksys WRT300N v2
119 + *
120 + * Copyright (C) 2007 Imre Kaloz <Kaloz@openwrt.org>
121 + *
122 + * based on coyote-setup.c:
123 + *      Copyright (C) 2003-2005 MontaVista Software, Inc.
124 + *
125 + * Author: Imre Kaloz <Kaloz@openwrt.org>
126 + */
127 +
128 +#include <linux/kernel.h>
129 +#include <linux/init.h>
130 +#include <linux/device.h>
131 +#include <linux/serial.h>
132 +#include <linux/tty.h>
133 +#include <linux/serial_8250.h>
134 +#include <linux/slab.h>
135 +
136 +#include <asm/types.h>
137 +#include <asm/setup.h>
138 +#include <asm/memory.h>
139 +#include <asm/hardware.h>
140 +#include <asm/irq.h>
141 +#include <asm/mach-types.h>
142 +#include <asm/mach/arch.h>
143 +#include <asm/mach/flash.h>
144 +
145 +static struct flash_platform_data wrt300nv2_flash_data = {
146 +       .map_name       = "cfi_probe",
147 +       .width          = 2,
148 +};
149 +
150 +static struct resource wrt300nv2_flash_resource = {
151 +       .flags          = IORESOURCE_MEM,
152 +};
153 +
154 +static struct platform_device wrt300nv2_flash = {
155 +       .name           = "IXP4XX-Flash",
156 +       .id             = 0,
157 +       .dev            = {
158 +               .platform_data = &wrt300nv2_flash_data,
159 +       },
160 +       .num_resources  = 1,
161 +       .resource       = &wrt300nv2_flash_resource,
162 +};
163 +
164 +static struct resource wrt300nv2_uart_resource = {
165 +       .start  = IXP4XX_UART2_BASE_PHYS,
166 +       .end    = IXP4XX_UART2_BASE_PHYS + 0x0fff,
167 +       .flags  = IORESOURCE_MEM,
168 +};
169 +
170 +static struct plat_serial8250_port wrt300nv2_uart_data[] = {
171 +       {
172 +               .mapbase        = IXP4XX_UART2_BASE_PHYS,
173 +               .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
174 +               .irq            = IRQ_IXP4XX_UART2,
175 +               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
176 +               .iotype         = UPIO_MEM,
177 +               .regshift       = 2,
178 +               .uartclk        = IXP4XX_UART_XTAL,
179 +       },
180 +       { },
181 +};
182 +
183 +static struct platform_device wrt300nv2_uart = {
184 +       .name           = "serial8250",
185 +       .id             = PLAT8250_DEV_PLATFORM,
186 +       .dev                    = {
187 +               .platform_data  = wrt300nv2_uart_data,
188 +       },
189 +       .num_resources  = 1,
190 +       .resource       = &wrt300nv2_uart_resource,
191 +};
192 +
193 +static struct platform_device *wrt300nv2_devices[] __initdata = {
194 +       &wrt300nv2_flash,
195 +       &wrt300nv2_uart
196 +};
197 +
198 +static void __init wrt300nv2_init(void)
199 +{
200 +       ixp4xx_sys_init();
201 +
202 +       wrt300nv2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
203 +       wrt300nv2_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
204 +
205 +       *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
206 +       *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
207 +
208 +       platform_add_devices(wrt300nv2_devices, ARRAY_SIZE(wrt300nv2_devices));
209 +}
210 +
211 +#ifdef CONFIG_MACH_WRT300NV2
212 +MACHINE_START(WRT300NV2, "Linksys WRT300N v2")
213 +       /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
214 +       .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
215 +       .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
216 +       .map_io         = ixp4xx_map_io,
217 +       .init_irq       = ixp4xx_init_irq,
218 +       .timer          = &ixp4xx_timer,
219 +       .boot_params    = 0x0100,
220 +       .init_machine   = wrt300nv2_init,
221 +MACHINE_END
222 +#endif
223 Index: linux-2.6.25.4/include/asm-arm/arch-ixp4xx/uncompress.h
224 ===================================================================
225 --- linux-2.6.25.4.orig/include/asm-arm/arch-ixp4xx/uncompress.h
226 +++ linux-2.6.25.4/include/asm-arm/arch-ixp4xx/uncompress.h
227 @@ -42,7 +42,7 @@ static __inline__ void __arch_decomp_set
228          */
229         if (machine_is_adi_coyote() || machine_is_gtwx5715() ||
230                          machine_is_gateway7001() || machine_is_wg302v2() ||
231 -                        machine_is_pronghorn_metro())
232 +                        machine_is_pronghorn_metro() || machine_is_wrt300nv2())
233                 uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
234         else
235                 uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;