ixp4xx: add support for linux 3.10
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-3.10 / 115-sidewinder_support.patch
1 From 95dac4a842a3c66f69f949b48f9075e16275f77b Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sun, 30 Jun 2013 15:48:47 +0200
4 Subject: [PATCH 07/36] 115-sidewinder_support.patch
5
6 ---
7 arch/arm/mach-ixp4xx/Kconfig | 10 +-
8 arch/arm/mach-ixp4xx/Makefile | 2 +
9 arch/arm/mach-ixp4xx/sidewinder-pci.c | 68 ++++++++++++++
10 arch/arm/mach-ixp4xx/sidewinder-setup.c | 151 +++++++++++++++++++++++++++++++
11 4 files changed, 230 insertions(+), 1 deletion(-)
12 create mode 100644 arch/arm/mach-ixp4xx/sidewinder-pci.c
13 create mode 100644 arch/arm/mach-ixp4xx/sidewinder-setup.c
14
15 --- a/arch/arm/mach-ixp4xx/Kconfig
16 +++ b/arch/arm/mach-ixp4xx/Kconfig
17 @@ -81,6 +81,14 @@ config MACH_PRONGHORN
18 config MACH_PRONGHORNMETRO
19 def_bool MACH_PRONGHORN
20
21 +config MACH_SIDEWINDER
22 + bool "ADI Sidewinder"
23 + select PCI
24 + help
25 + Say 'Y' here if you want your kernel to support the ADI
26 + Engineering Sidewinder board. For more information on this
27 + platform, see http://www.adiengineering.com
28 +
29 config ARCH_IXDP425
30 bool "IXDP425"
31 help
32 @@ -177,7 +185,7 @@ config MACH_ARCOM_VULCAN
33 #
34 config CPU_IXP46X
35 bool
36 - depends on MACH_IXDP465
37 + depends on MACH_IXDP465 || MACH_SIDEWINDER
38 default y
39
40 config CPU_IXP43X
41 --- a/arch/arm/mach-ixp4xx/Makefile
42 +++ b/arch/arm/mach-ixp4xx/Makefile
43 @@ -20,6 +20,7 @@ obj-pci-$(CONFIG_MACH_WG302V2) += wg302
44 obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
45 obj-pci-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-pci.o
46 obj-pci-$(CONFIG_MACH_PRONGHORN) += pronghorn-pci.o
47 +obj-pci-$(CONFIG_MACH_SIDEWINDER) += sidewinder-pci.o
48
49 obj-y += common.o
50
51 @@ -41,6 +42,7 @@ obj-$(CONFIG_MACH_FSG) += fsg-setup.o
52 obj-$(CONFIG_MACH_GORAMO_MLR) += goramo_mlr.o
53 obj-$(CONFIG_MACH_ARCOM_VULCAN) += vulcan-setup.o
54 obj-$(CONFIG_MACH_PRONGHORN) += pronghorn-setup.o
55 +obj-$(CONFIG_MACH_SIDEWINDER) += sidewinder-setup.o
56
57 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
58 obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
59 --- /dev/null
60 +++ b/arch/arm/mach-ixp4xx/sidewinder-pci.c
61 @@ -0,0 +1,67 @@
62 +/*
63 + * arch/arch/mach-ixp4xx/pronghornmetro-pci.c
64 + *
65 + * PCI setup routines for ADI Engineering Sidewinder
66 + *
67 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
68 + *
69 + * based on coyote-pci.c:
70 + * Copyright (C) 2002 Jungo Software Technologies.
71 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
72 + *
73 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
74 + *
75 + * This program is free software; you can redistribute it and/or modify
76 + * it under the terms of the GNU General Public License version 2 as
77 + * published by the Free Software Foundation.
78 + *
79 + */
80 +
81 +#include <linux/kernel.h>
82 +#include <linux/pci.h>
83 +#include <linux/init.h>
84 +#include <linux/irq.h>
85 +
86 +#include <asm/mach-types.h>
87 +#include <mach/hardware.h>
88 +#include <asm/irq.h>
89 +
90 +#include <asm/mach/pci.h>
91 +
92 +void __init sidewinder_pci_preinit(void)
93 +{
94 + irq_set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
95 + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
96 + irq_set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW);
97 +
98 + ixp4xx_pci_preinit();
99 +}
100 +
101 +static int __init sidewinder_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
102 +{
103 + if (slot == 1)
104 + return IRQ_IXP4XX_GPIO11;
105 + else if (slot == 2)
106 + return IRQ_IXP4XX_GPIO10;
107 + else if (slot == 3)
108 + return IRQ_IXP4XX_GPIO9;
109 + else
110 + return -1;
111 +}
112 +
113 +struct hw_pci sidewinder_pci __initdata = {
114 + .nr_controllers = 1,
115 + .preinit = sidewinder_pci_preinit,
116 + .ops = &ixp4xx_ops,
117 + .setup = ixp4xx_setup,
118 + .map_irq = sidewinder_map_irq,
119 +};
120 +
121 +int __init sidewinder_pci_init(void)
122 +{
123 + if (machine_is_sidewinder())
124 + pci_common_init(&sidewinder_pci);
125 + return 0;
126 +}
127 +
128 +subsys_initcall(sidewinder_pci_init);
129 --- /dev/null
130 +++ b/arch/arm/mach-ixp4xx/sidewinder-setup.c
131 @@ -0,0 +1,155 @@
132 +/*
133 + * arch/arm/mach-ixp4xx/sidewinder-setup.c
134 + *
135 + * Board setup for the ADI Engineering Sidewinder
136 + *
137 + * Copyright (C) 2008 Imre Kaloz <Kaloz@openwrt.org>
138 + *
139 + * based on coyote-setup.c:
140 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
141 + *
142 + * Author: Imre Kaloz <Kaloz@openwrt.org>
143 + */
144 +
145 +#include <linux/kernel.h>
146 +#include <linux/serial.h>
147 +#include <linux/serial_8250.h>
148 +#include <linux/dma-mapping.h>
149 +
150 +#include <asm/mach-types.h>
151 +#include <asm/mach/arch.h>
152 +#include <asm/mach/flash.h>
153 +
154 +static struct flash_platform_data sidewinder_flash_data = {
155 + .map_name = "cfi_probe",
156 + .width = 2,
157 +};
158 +
159 +static struct resource sidewinder_flash_resource = {
160 + .flags = IORESOURCE_MEM,
161 +};
162 +
163 +static struct platform_device sidewinder_flash = {
164 + .name = "IXP4XX-Flash",
165 + .id = 0,
166 + .dev = {
167 + .platform_data = &sidewinder_flash_data,
168 + },
169 + .num_resources = 1,
170 + .resource = &sidewinder_flash_resource,
171 +};
172 +
173 +static struct resource sidewinder_uart_resources[] = {
174 + {
175 + .start = IXP4XX_UART1_BASE_PHYS,
176 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
177 + .flags = IORESOURCE_MEM,
178 + },
179 + {
180 + .start = IXP4XX_UART2_BASE_PHYS,
181 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
182 + .flags = IORESOURCE_MEM,
183 + }
184 +};
185 +
186 +static struct plat_serial8250_port sidewinder_uart_data[] = {
187 + {
188 + .mapbase = IXP4XX_UART1_BASE_PHYS,
189 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
190 + .irq = IRQ_IXP4XX_UART1,
191 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
192 + .iotype = UPIO_MEM,
193 + .regshift = 2,
194 + .uartclk = IXP4XX_UART_XTAL,
195 + },
196 + {
197 + .mapbase = IXP4XX_UART2_BASE_PHYS,
198 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
199 + .irq = IRQ_IXP4XX_UART2,
200 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
201 + .iotype = UPIO_MEM,
202 + .regshift = 2,
203 + .uartclk = IXP4XX_UART_XTAL,
204 + },
205 + { },
206 +};
207 +
208 +static struct platform_device sidewinder_uart = {
209 + .name = "serial8250",
210 + .id = PLAT8250_DEV_PLATFORM,
211 + .dev = {
212 + .platform_data = sidewinder_uart_data,
213 + },
214 + .num_resources = ARRAY_SIZE(sidewinder_uart_resources),
215 + .resource = sidewinder_uart_resources,
216 +};
217 +
218 +static struct eth_plat_info sidewinder_plat_eth[] = {
219 + {
220 + .phy = 5,
221 + .rxq = 3,
222 + .txreadyq = 20,
223 + }, {
224 + .phy = IXP4XX_ETH_PHY_MAX_ADDR,
225 + .phy_mask = 0x1e,
226 + .rxq = 4,
227 + .txreadyq = 21,
228 + }, {
229 + .phy = 31,
230 + .rxq = 2,
231 + .txreadyq = 19,
232 + }
233 +};
234 +
235 +static struct platform_device sidewinder_eth[] = {
236 + {
237 + .name = "ixp4xx_eth",
238 + .id = IXP4XX_ETH_NPEB,
239 + .dev.platform_data = sidewinder_plat_eth,
240 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
241 + }, {
242 + .name = "ixp4xx_eth",
243 + .id = IXP4XX_ETH_NPEC,
244 + .dev.platform_data = sidewinder_plat_eth + 1,
245 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
246 + }, {
247 + .name = "ixp4xx_eth",
248 + .id = IXP4XX_ETH_NPEA,
249 + .dev.platform_data = sidewinder_plat_eth + 2,
250 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
251 + }
252 +};
253 +
254 +static struct platform_device *sidewinder_devices[] __initdata = {
255 + &sidewinder_flash,
256 + &sidewinder_uart,
257 + &sidewinder_eth[0],
258 + &sidewinder_eth[1],
259 + &sidewinder_eth[2],
260 +};
261 +
262 +static void __init sidewinder_init(void)
263 +{
264 + ixp4xx_sys_init();
265 +
266 + sidewinder_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
267 + sidewinder_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_64M - 1;
268 +
269 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
270 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
271 +
272 + platform_add_devices(sidewinder_devices, ARRAY_SIZE(sidewinder_devices));
273 +}
274 +
275 +MACHINE_START(SIDEWINDER, "ADI Engineering Sidewinder")
276 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
277 + .map_io = ixp4xx_map_io,
278 + .init_irq = ixp4xx_init_irq,
279 + .init_time = ixp4xx_timer_init,
280 + .atag_offset = 0x0100,
281 + .init_machine = sidewinder_init,
282 +#if defined(CONFIG_PCI)
283 + .dma_zone_size = SZ_64M,
284 +#endif
285 + .restart = ixp4xx_restart,
286 +MACHINE_END