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