ixp4xx patches cleanup, round one
[openwrt/staging/mkresin.git] / target / linux / ixp4xx / patches-2.6.26 / 105-wg302v1_support.patch
1 --- a/arch/arm/configs/ixp4xx_defconfig
2 +++ b/arch/arm/configs/ixp4xx_defconfig
3 @@ -155,6 +155,7 @@
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 @@ -49,6 +49,14 @@
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 @@ -14,6 +14,7 @@
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
38 @@ -28,6 +29,7 @@
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
46 --- /dev/null
47 +++ b/arch/arm/mach-ixp4xx/wg302v1-pci.c
48 @@ -0,0 +1,64 @@
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 <asm/hardware.h>
75 +
76 +#include <asm/mach/pci.h>
77 +
78 +void __init wg302v1_pci_preinit(void)
79 +{
80 + set_irq_type(IRQ_IXP4XX_GPIO8, IRQT_LOW);
81 + set_irq_type(IRQ_IXP4XX_GPIO10, IRQT_LOW);
82 +
83 + ixp4xx_pci_preinit();
84 +}
85 +
86 +static int __init wg302v1_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_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 + .swizzle = pci_std_swizzle,
100 + .setup = ixp4xx_setup,
101 + .scan = ixp4xx_scan_bus,
102 + .map_irq = wg302v1_map_irq,
103 +};
104 +
105 +int __init wg302v1_pci_init(void)
106 +{
107 + if (machine_is_wg302v1())
108 + pci_common_init(&wg302v1_pci);
109 + return 0;
110 +}
111 +
112 +subsys_initcall(wg302v1_pci_init);
113 --- /dev/null
114 +++ b/arch/arm/mach-ixp4xx/wg302v1-setup.c
115 @@ -0,0 +1,126 @@
116 +/*
117 + * arch/arm/mach-ixp4xx/wg302v1-setup.c
118 + *
119 + * Board setup for the Netgear WG302 v1 and WAG302 v1
120 + *
121 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
122 + *
123 + * based on coyote-setup.c:
124 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
125 + *
126 + * Author: Imre Kaloz <kaloz@openwrt.org>
127 + *
128 + */
129 +
130 +#include <linux/kernel.h>
131 +#include <linux/init.h>
132 +#include <linux/device.h>
133 +#include <linux/serial.h>
134 +#include <linux/tty.h>
135 +#include <linux/serial_8250.h>
136 +#include <linux/slab.h>
137 +#include <linux/types.h>
138 +#include <linux/memory.h>
139 +
140 +#include <asm/setup.h>
141 +#include <asm/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_resource = {
167 + .start = IXP4XX_UART1_BASE_PHYS,
168 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
169 + .flags = IORESOURCE_MEM,
170 +};
171 +
172 +static struct plat_serial8250_port wg302v1_uart_data[] = {
173 + {
174 + .mapbase = IXP4XX_UART1_BASE_PHYS,
175 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
176 + .irq = IRQ_IXP4XX_UART1,
177 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
178 + .iotype = UPIO_MEM,
179 + .regshift = 2,
180 + .uartclk = IXP4XX_UART_XTAL,
181 + },
182 + { },
183 +};
184 +
185 +static struct platform_device wg302v1_uart = {
186 + .name = "serial8250",
187 + .id = PLAT8250_DEV_PLATFORM,
188 + .dev = {
189 + .platform_data = wg302v1_uart_data,
190 + },
191 + .num_resources = 1,
192 + .resource = &wg302v1_uart_resource,
193 +};
194 +
195 +static struct eth_plat_info wg302v1_plat_eth[] = {
196 + {
197 + .phy = 30,
198 + .rxq = 3,
199 + .txreadyq = 20,
200 + }
201 +};
202 +
203 +static struct platform_device wg302v1_eth[] = {
204 + {
205 + .name = "ixp4xx_eth",
206 + .id = IXP4XX_ETH_NPEB,
207 + .dev.platform_data = wg302v1_plat_eth,
208 + }
209 +};
210 +
211 +static struct platform_device *wg302v1_devices[] __initdata = {
212 + &wg302v1_flash,
213 + &wg302v1_uart,
214 + &wg302v1_eth[0],
215 +};
216 +
217 +static void __init wg302v1_init(void)
218 +{
219 + ixp4xx_sys_init();
220 +
221 + wg302v1_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
222 + wg302v1_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
223 +
224 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
225 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
226 +
227 + platform_add_devices(wg302v1_devices, ARRAY_SIZE(wg302v1_devices));
228 +}
229 +
230 +#ifdef CONFIG_MACH_WG302V1
231 +MACHINE_START(WG302V1, "Netgear WG302 v1 / WAG302 v1")
232 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
233 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
234 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
235 + .map_io = ixp4xx_map_io,
236 + .init_irq = ixp4xx_init_irq,
237 + .timer = &ixp4xx_timer,
238 + .boot_params = 0x0100,
239 + .init_machine = wg302v1_init,
240 +MACHINE_END
241 +#endif