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