48188a5877abc5113f86aca9eefab1a9da531e4b
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-2.6.25 / 140-sidewinder_support.patch
1 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
2 ===================================================================
3 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Kconfig
4 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
5 @@ -65,6 +65,14 @@ config MACH_PRONGHORNMETRO
6 Engineering Pronghorn Metro Platform. For more
7 information on this platform, see <file:Documentation/arm/IXP4xx>.
8
9 +config MACH_SIDEWINDER
10 + bool "Sidewinder"
11 + select PCI
12 + help
13 + Say 'Y' here if you want your kernel to support the ADI
14 + Engineering Sidewinder Platform. For more
15 + information on this platform, see <file:Documentation/arm/IXP4xx>.
16 +
17 config MACH_COMPEX
18 bool "Compex WP18 / NP18A"
19 select PCI
20 @@ -163,7 +171,7 @@ config MACH_FSG
21 #
22 config CPU_IXP46X
23 bool
24 - depends on MACH_IXDP465
25 + depends on MACH_IXDP465 || MACH_SIDEWINDER
26 default y
27
28 config CPU_IXP43X
29 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
30 ===================================================================
31 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Makefile
32 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
33 @@ -19,6 +19,7 @@ obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
34 obj-pci-$(CONFIG_MACH_PRONGHORNMETRO) += pronghornmetro-pci.o
35 obj-pci-$(CONFIG_MACH_COMPEX) += ixdp425-pci.o
36 obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
37 +obj-pci-$(CONFIG_MACH_SIDEWINDER) += sidewinder-pci.o
38
39 obj-y += common.o
40
41 @@ -36,6 +37,7 @@ obj-$(CONFIG_MACH_FSG) += fsg-setup.o
42 obj-$(CONFIG_MACH_PRONGHORNMETRO) += pronghornmetro-setup.o
43 obj-$(CONFIG_MACH_COMPEX) += compex-setup.o
44 obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
45 +obj-$(CONFIG_MACH_SIDEWINDER) += sidewinder-setup.o
46
47 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
48 obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
49 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/sidewinder-pci.c
50 ===================================================================
51 --- /dev/null
52 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/sidewinder-pci.c
53 @@ -0,0 +1,71 @@
54 +/*
55 + * arch/arch/mach-ixp4xx/pronghornmetro-pci.c
56 + *
57 + * PCI setup routines for ADI Engineering Sidewinder
58 + *
59 + * Copyright (C) 2007 Imre Kaloz <kaloz@openwrt.org>
60 + *
61 + * based on coyote-pci.c:
62 + * Copyright (C) 2002 Jungo Software Technologies.
63 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
64 + *
65 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
66 + *
67 + * This program is free software; you can redistribute it and/or modify
68 + * it under the terms of the GNU General Public License version 2 as
69 + * published by the Free Software Foundation.
70 + *
71 + */
72 +
73 +#include <linux/kernel.h>
74 +#include <linux/pci.h>
75 +#include <linux/init.h>
76 +#include <linux/irq.h>
77 +
78 +#include <asm/mach-types.h>
79 +#include <asm/hardware.h>
80 +#include <asm/irq.h>
81 +
82 +#include <asm/mach/pci.h>
83 +
84 +extern void ixp4xx_pci_preinit(void);
85 +extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
86 +extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
87 +
88 +void __init sidewinder_pci_preinit(void)
89 +{
90 + set_irq_type(IRQ_IXP4XX_GPIO11, IRQT_LOW);
91 + set_irq_type(IRQ_IXP4XX_GPIO10, IRQT_LOW);
92 + set_irq_type(IRQ_IXP4XX_GPIO9, IRQT_LOW);
93 +
94 + ixp4xx_pci_preinit();
95 +}
96 +
97 +static int __init sidewinder_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
98 +{
99 + if (slot == 1)
100 + return IRQ_IXP4XX_GPIO11;
101 + else if (slot == 2)
102 + return IRQ_IXP4XX_GPIO10;
103 + else if (slot == 3)
104 + return IRQ_IXP4XX_GPIO9;
105 + else return -1;
106 +}
107 +
108 +struct hw_pci sidewinder_pci __initdata = {
109 + .nr_controllers = 1,
110 + .preinit = sidewinder_pci_preinit,
111 + .swizzle = pci_std_swizzle,
112 + .setup = ixp4xx_setup,
113 + .scan = ixp4xx_scan_bus,
114 + .map_irq = sidewinder_map_irq,
115 +};
116 +
117 +int __init sidewinder_pci_init(void)
118 +{
119 + if (machine_is_sidewinder())
120 + pci_common_init(&sidewinder_pci);
121 + return 0;
122 +}
123 +
124 +subsys_initcall(sidewinder_pci_init);
125 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/sidewinder-setup.c
126 ===================================================================
127 --- /dev/null
128 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/sidewinder-setup.c
129 @@ -0,0 +1,115 @@
130 +/*
131 + * arch/arm/mach-ixp4xx/sidewinder-setup.c
132 + *
133 + * Board setup for the ADI Engineering Sidewinder
134 + *
135 + * Copyright (C) 2007 Imre Kaloz <Kaloz@openwrt.org>
136 + *
137 + * based on coyote-setup.c:
138 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
139 + *
140 + * Author: Imre Kaloz <Kaloz@openwrt.org>
141 + */
142 +
143 +#include <linux/kernel.h>
144 +#include <linux/serial.h>
145 +#include <linux/serial_8250.h>
146 +
147 +#include <asm/mach-types.h>
148 +#include <asm/mach/arch.h>
149 +#include <asm/mach/flash.h>
150 +
151 +static struct flash_platform_data sidewinder_flash_data = {
152 + .map_name = "cfi_probe",
153 + .width = 2,
154 +};
155 +
156 +static struct resource sidewinder_flash_resource = {
157 + .flags = IORESOURCE_MEM,
158 +};
159 +
160 +static struct platform_device sidewinder_flash = {
161 + .name = "IXP4XX-Flash",
162 + .id = 0,
163 + .dev = {
164 + .platform_data = &sidewinder_flash_data,
165 + },
166 + .num_resources = 1,
167 + .resource = &sidewinder_flash_resource,
168 +};
169 +
170 +static struct resource sidewinder_uart_resources[] = {
171 + {
172 + .start = IXP4XX_UART1_BASE_PHYS,
173 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
174 + .flags = IORESOURCE_MEM,
175 + },
176 + {
177 + .start = IXP4XX_UART2_BASE_PHYS,
178 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
179 + .flags = IORESOURCE_MEM,
180 + }
181 +};
182 +
183 +static struct plat_serial8250_port sidewinder_uart_data[] = {
184 + {
185 + .mapbase = IXP4XX_UART1_BASE_PHYS,
186 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
187 + .irq = IRQ_IXP4XX_UART1,
188 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
189 + .iotype = UPIO_MEM,
190 + .regshift = 2,
191 + .uartclk = IXP4XX_UART_XTAL,
192 + },
193 + {
194 + .mapbase = IXP4XX_UART2_BASE_PHYS,
195 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
196 + .irq = IRQ_IXP4XX_UART2,
197 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
198 + .iotype = UPIO_MEM,
199 + .regshift = 2,
200 + .uartclk = IXP4XX_UART_XTAL,
201 + },
202 + { },
203 +};
204 +
205 +static struct platform_device sidewinder_uart = {
206 + .name = "serial8250",
207 + .id = PLAT8250_DEV_PLATFORM,
208 + .dev = {
209 + .platform_data = sidewinder_uart_data,
210 + },
211 + .num_resources = ARRAY_SIZE(sidewinder_uart_resources),
212 + .resource = sidewinder_uart_resources,
213 +};
214 +
215 +static struct platform_device *sidewinder_devices[] __initdata = {
216 + &sidewinder_flash,
217 + &sidewinder_uart,
218 +};
219 +
220 +static void __init sidewinder_init(void)
221 +{
222 + ixp4xx_sys_init();
223 +
224 + sidewinder_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
225 + sidewinder_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_64M - 1;
226 +
227 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
228 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
229 +
230 + platform_add_devices(sidewinder_devices, ARRAY_SIZE(sidewinder_devices));
231 +}
232 +
233 +#ifdef CONFIG_MACH_SIDEWINDER
234 +MACHINE_START(SIDEWINDER, "ADI Engineering Sidewinder")
235 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
236 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
237 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
238 + .map_io = ixp4xx_map_io,
239 + .init_irq = ixp4xx_init_irq,
240 + .timer = &ixp4xx_timer,
241 + .boot_params = 0x0100,
242 + .init_machine = sidewinder_init,
243 +MACHINE_END
244 +#endif