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