ixp4xx: add v3.18 support
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-3.18 / 105-wg302v1_support.patch
1 --- a/arch/arm/configs/ixp4xx_defconfig
2 +++ b/arch/arm/configs/ixp4xx_defconfig
3 @@ -13,6 +13,7 @@ CONFIG_MACH_AVILA=y
4 CONFIG_MACH_LOFT=y
5 CONFIG_ARCH_ADI_COYOTE=y
6 CONFIG_MACH_GATEWAY7001=y
7 +CONFIG_MACH_WG302V1=y
8 CONFIG_MACH_WG302V2=y
9 CONFIG_ARCH_IXDP425=y
10 CONFIG_MACH_IXDPG425=y
11 --- a/arch/arm/mach-ixp4xx/Kconfig
12 +++ b/arch/arm/mach-ixp4xx/Kconfig
13 @@ -45,6 +45,14 @@ config MACH_GATEWAY7001
14 7001 Access Point. For more information on this platform,
15 see http://openwrt.org
16
17 +config MACH_WG302V1
18 + bool "Netgear WG302 v1 / WAG302 v1"
19 + select PCI
20 + help
21 + Say 'Y' here if you want your kernel to support Netgear's
22 + WG302 v1 or WAG302 v1 Access Points. For more information
23 + on this platform, see http://openwrt.org
24 +
25 config MACH_WG302V2
26 bool "Netgear WG302 v2 / WAG302 v2"
27 select PCI
28 --- a/arch/arm/mach-ixp4xx/Makefile
29 +++ b/arch/arm/mach-ixp4xx/Makefile
30 @@ -15,6 +15,7 @@ obj-pci-$(CONFIG_MACH_NSLU2) += nslu2-p
31 obj-pci-$(CONFIG_MACH_NAS100D) += nas100d-pci.o
32 obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
33 obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
34 +obj-pci-$(CONFIG_MACH_WG302V1) += wg302v1-pci.o
35 obj-pci-$(CONFIG_MACH_WG302V2) += wg302v2-pci.o
36 obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
37 obj-pci-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-pci.o
38 @@ -33,6 +34,7 @@ obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.
39 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
40 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
41 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
42 +obj-$(CONFIG_MACH_WG302V1) += wg302v1-setup.o
43 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
44 obj-$(CONFIG_MACH_FSG) += fsg-setup.o
45 obj-$(CONFIG_MACH_GORAMO_MLR) += goramo_mlr.o
46 --- /dev/null
47 +++ b/arch/arm/mach-ixp4xx/wg302v1-pci.c
48 @@ -0,0 +1,63 @@
49 +/*
50 + * arch/arch/mach-ixp4xx/wg302v1-pci.c
51 + *
52 + * PCI setup routines for the Netgear WG302 v1 and WAG302 v1
53 + *
54 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
55 + *
56 + * based on coyote-pci.c:
57 + * Copyright (C) 2002 Jungo Software Technologies.
58 + * Copyright (C) 2003 MontaVista Software, Inc.
59 + *
60 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
61 + *
62 + * This program is free software; you can redistribute it and/or modify
63 + * it under the terms of the GNU General Public License version 2 as
64 + * published by the Free Software Foundation.
65 + *
66 + */
67 +
68 +#include <linux/kernel.h>
69 +#include <linux/pci.h>
70 +#include <linux/init.h>
71 +#include <linux/irq.h>
72 +
73 +#include <asm/mach-types.h>
74 +#include <mach/hardware.h>
75 +
76 +#include <asm/mach/pci.h>
77 +
78 +void __init wg302v1_pci_preinit(void)
79 +{
80 + irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
81 + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
82 +
83 + ixp4xx_pci_preinit();
84 +}
85 +
86 +static int __init wg302v1_map_irq(const 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_GPIO10;
92 + else
93 + return -1;
94 +}
95 +
96 +struct hw_pci wg302v1_pci __initdata = {
97 + .nr_controllers = 1,
98 + .preinit = wg302v1_pci_preinit,
99 + .ops = &ixp4xx_ops,
100 + .setup = ixp4xx_setup,
101 + .map_irq = wg302v1_map_irq,
102 +};
103 +
104 +int __init wg302v1_pci_init(void)
105 +{
106 + if (machine_is_wg302v1())
107 + pci_common_init(&wg302v1_pci);
108 + return 0;
109 +}
110 +
111 +subsys_initcall(wg302v1_pci_init);
112 --- /dev/null
113 +++ b/arch/arm/mach-ixp4xx/wg302v1-setup.c
114 @@ -0,0 +1,147 @@
115 +/*
116 + * arch/arm/mach-ixp4xx/wg302v1-setup.c
117 + *
118 + * Board setup for the Netgear WG302 v1 and WAG302 v1
119 + *
120 + * Copyright (C) 2008 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 +
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 +#include <linux/types.h>
137 +#include <linux/memory.h>
138 +#include <linux/dma-mapping.h>
139 +
140 +#include <asm/setup.h>
141 +#include <mach/hardware.h>
142 +#include <asm/irq.h>
143 +#include <asm/mach-types.h>
144 +#include <asm/mach/arch.h>
145 +#include <asm/mach/flash.h>
146 +
147 +static struct flash_platform_data wg302v1_flash_data = {
148 + .map_name = "cfi_probe",
149 + .width = 2,
150 +};
151 +
152 +static struct resource wg302v1_flash_resource = {
153 + .flags = IORESOURCE_MEM,
154 +};
155 +
156 +static struct platform_device wg302v1_flash = {
157 + .name = "IXP4XX-Flash",
158 + .id = 0,
159 + .dev = {
160 + .platform_data = &wg302v1_flash_data,
161 + },
162 + .num_resources = 1,
163 + .resource = &wg302v1_flash_resource,
164 +};
165 +
166 +static struct resource wg302v1_uart_resources[] = {
167 + {
168 + .start = IXP4XX_UART1_BASE_PHYS,
169 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
170 + .flags = IORESOURCE_MEM,
171 + },
172 + {
173 + .start = IXP4XX_UART2_BASE_PHYS,
174 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
175 + .flags = IORESOURCE_MEM,
176 + }
177 +};
178 +
179 +static struct plat_serial8250_port wg302v1_uart_data[] = {
180 + {
181 + .mapbase = IXP4XX_UART1_BASE_PHYS,
182 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
183 + .irq = IRQ_IXP4XX_UART1,
184 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
185 + .iotype = UPIO_MEM,
186 + .regshift = 2,
187 + .uartclk = IXP4XX_UART_XTAL,
188 + },
189 + {
190 + .mapbase = IXP4XX_UART2_BASE_PHYS,
191 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
192 + .irq = IRQ_IXP4XX_UART2,
193 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
194 + .iotype = UPIO_MEM,
195 + .regshift = 2,
196 + .uartclk = IXP4XX_UART_XTAL,
197 + },
198 + { },
199 +};
200 +
201 +static struct platform_device wg302v1_uart = {
202 + .name = "serial8250",
203 + .id = PLAT8250_DEV_PLATFORM,
204 + .dev = {
205 + .platform_data = wg302v1_uart_data,
206 + },
207 + .num_resources = 2,
208 + .resource = wg302v1_uart_resources,
209 +};
210 +
211 +static struct eth_plat_info wg302v1_plat_eth[] = {
212 + {
213 + .phy = 30,
214 + .rxq = 3,
215 + .txreadyq = 20,
216 + }
217 +};
218 +
219 +static struct platform_device wg302v1_eth[] = {
220 + {
221 + .name = "ixp4xx_eth",
222 + .id = IXP4XX_ETH_NPEB,
223 + .dev.platform_data = wg302v1_plat_eth,
224 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
225 + }
226 +};
227 +
228 +static struct platform_device *wg302v1_devices[] __initdata = {
229 + &wg302v1_flash,
230 + &wg302v1_uart,
231 + &wg302v1_eth[0],
232 +};
233 +
234 +static void __init wg302v1_init(void)
235 +{
236 + ixp4xx_sys_init();
237 +
238 + wg302v1_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
239 + wg302v1_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
240 +
241 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
242 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
243 +
244 + platform_add_devices(wg302v1_devices, ARRAY_SIZE(wg302v1_devices));
245 +}
246 +
247 +#ifdef CONFIG_MACH_WG302V1
248 +MACHINE_START(WG302V1, "Netgear WG302 v1 / WAG302 v1")
249 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
250 + .fixup = wg302v1_fixup,
251 + .map_io = ixp4xx_map_io,
252 + .init_irq = ixp4xx_init_irq,
253 + .init_time = ixp4xx_timer_init,
254 + .atag_offset = 0x0100,
255 + .init_machine = wg302v1_init,
256 +#if defined(CONFIG_PCI)
257 + .dma_zone_size = SZ_64M,
258 +#endif
259 + .restart = ixp4xx_restart,
260 +MACHINE_END
261 +#endif