80c4ba08de8b3d8babbacc9f67a5c531b9a1202c
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-3.10 / 180-tw5334_support.patch
1 --- a/arch/arm/mach-ixp4xx/Kconfig
2 +++ b/arch/arm/mach-ixp4xx/Kconfig
3 @@ -164,6 +164,14 @@ config ARCH_PRPMC1100
4 PrPCM1100 Processor Mezanine Module. For more information on
5 this platform, see <file:Documentation/arm/IXP4xx>.
6
7 +config MACH_TW5334
8 + bool "Titan Wireless TW-533-4"
9 + select PCI
10 + help
11 + Say 'Y' here if you want your kernel to support the Titan
12 + Wireless TW533-4. For more information on this platform,
13 + see http://openwrt.org
14 +
15 config MACH_NAS100D
16 bool
17 prompt "NAS100D"
18 --- a/arch/arm/mach-ixp4xx/Makefile
19 +++ b/arch/arm/mach-ixp4xx/Makefile
20 @@ -24,6 +24,7 @@ obj-pci-$(CONFIG_MACH_SIDEWINDER) += sid
21 obj-pci-$(CONFIG_MACH_COMPEXWP18) += ixdp425-pci.o
22 obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
23 obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
24 +obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
25
26 obj-y += common.o
27
28 @@ -49,6 +50,7 @@ obj-$(CONFIG_MACH_SIDEWINDER) += sidewin
29 obj-$(CONFIG_MACH_COMPEXWP18) += compex42x-setup.o
30 obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
31 obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
32 +obj-$(CONFIG_MACH_TW5334) += tw5334-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 @@ -44,7 +44,7 @@ static __inline__ void __arch_decomp_set
39 machine_is_gateway7001() || machine_is_wg302v2() ||
40 machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
41 machine_is_pronghorn() || machine_is_pronghorn_metro() ||
42 - machine_is_wrt300nv2())
43 + machine_is_wrt300nv2() || machine_is_tw5334())
44 uart_base = (volatile u32*) IXP4XX_UART2_BASE_PHYS;
45 else
46 uart_base = (volatile u32*) IXP4XX_UART1_BASE_PHYS;
47 --- /dev/null
48 +++ b/arch/arm/mach-ixp4xx/tw5334-pci.c
49 @@ -0,0 +1,68 @@
50 +/*
51 + * arch/arch/mach-ixp4xx/tw5334-pci.c
52 + *
53 + * PCI setup routines for the Titan Wireless TW-533-4
54 + *
55 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
56 + *
57 + * based on coyote-pci.c:
58 + * Copyright (C) 2002 Jungo Software Technologies.
59 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
60 + *
61 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
62 + *
63 + * This program is free software; you can redistribute it and/or modify
64 + * it under the terms of the GNU General Public License version 2 as
65 + * published by the Free Software Foundation.
66 + *
67 + */
68 +
69 +#include <linux/kernel.h>
70 +#include <linux/pci.h>
71 +#include <linux/init.h>
72 +#include <linux/irq.h>
73 +
74 +#include <asm/mach-types.h>
75 +#include <mach/hardware.h>
76 +
77 +#include <asm/mach/pci.h>
78 +
79 +void __init tw5334_pci_preinit(void)
80 +{
81 + irq_set_irq_type(IRQ_IXP4XX_GPIO6, IRQ_TYPE_LEVEL_LOW);
82 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_LEVEL_LOW);
83 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_LEVEL_LOW);
84 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_LEVEL_LOW);
85 +
86 + ixp4xx_pci_preinit();
87 +}
88 +
89 +static int __init tw5334_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
90 +{
91 + if (slot == 12)
92 + return IRQ_IXP4XX_GPIO6;
93 + else if (slot == 13)
94 + return IRQ_IXP4XX_GPIO2;
95 + else if (slot == 14)
96 + return IRQ_IXP4XX_GPIO1;
97 + else if (slot == 15)
98 + return IRQ_IXP4XX_GPIO0;
99 + else return -1;
100 +}
101 +
102 +struct hw_pci tw5334_pci __initdata = {
103 + .nr_controllers = 1,
104 + .preinit = tw5334_pci_preinit,
105 + .ops = &ixp4xx_ops,
106 + .setup = ixp4xx_setup,
107 + .map_irq = tw5334_map_irq,
108 +};
109 +
110 +int __init tw5334_pci_init(void)
111 +{
112 + if (machine_is_tw5334())
113 + pci_common_init(&tw5334_pci);
114 + return 0;
115 +}
116 +
117 +subsys_initcall(tw5334_pci_init);
118 --- /dev/null
119 +++ b/arch/arm/mach-ixp4xx/tw5334-setup.c
120 @@ -0,0 +1,167 @@
121 +/*
122 + * arch/arm/mach-ixp4xx/tw5334-setup.c
123 + *
124 + * Board setup for the Titan Wireless TW-533-4
125 + *
126 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
127 + *
128 + * based on coyote-setup.c:
129 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
130 + *
131 + * Author: Imre Kaloz <Kaloz@openwrt.org>
132 + */
133 +
134 +#include <linux/if_ether.h>
135 +#include <linux/kernel.h>
136 +#include <linux/init.h>
137 +#include <linux/device.h>
138 +#include <linux/serial.h>
139 +#include <linux/tty.h>
140 +#include <linux/serial_8250.h>
141 +#include <linux/slab.h>
142 +
143 +#include <asm/types.h>
144 +#include <asm/setup.h>
145 +#include <asm/memory.h>
146 +#include <mach/hardware.h>
147 +#include <asm/irq.h>
148 +#include <asm/mach-types.h>
149 +#include <asm/mach/arch.h>
150 +#include <asm/mach/flash.h>
151 +
152 +static struct flash_platform_data tw5334_flash_data = {
153 + .map_name = "cfi_probe",
154 + .width = 2,
155 +};
156 +
157 +static struct resource tw5334_flash_resource = {
158 + .flags = IORESOURCE_MEM,
159 +};
160 +
161 +static struct platform_device tw5334_flash = {
162 + .name = "IXP4XX-Flash",
163 + .id = 0,
164 + .dev = {
165 + .platform_data = &tw5334_flash_data,
166 + },
167 + .num_resources = 1,
168 + .resource = &tw5334_flash_resource,
169 +};
170 +
171 +static struct resource tw5334_uart_resource = {
172 + .start = IXP4XX_UART2_BASE_PHYS,
173 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
174 + .flags = IORESOURCE_MEM,
175 +};
176 +
177 +static struct plat_serial8250_port tw5334_uart_data[] = {
178 + {
179 + .mapbase = IXP4XX_UART2_BASE_PHYS,
180 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
181 + .irq = IRQ_IXP4XX_UART2,
182 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
183 + .iotype = UPIO_MEM,
184 + .regshift = 2,
185 + .uartclk = IXP4XX_UART_XTAL,
186 + },
187 + { },
188 +};
189 +
190 +static struct platform_device tw5334_uart = {
191 + .name = "serial8250",
192 + .id = PLAT8250_DEV_PLATFORM,
193 + .dev = {
194 + .platform_data = tw5334_uart_data,
195 + },
196 + .num_resources = 1,
197 + .resource = &tw5334_uart_resource,
198 +};
199 +
200 +/* Built-in 10/100 Ethernet MAC interfaces */
201 +static struct eth_plat_info tw5334_plat_eth[] = {
202 + {
203 + .phy = 0,
204 + .rxq = 3,
205 + .txreadyq = 20,
206 + }, {
207 + .phy = 1,
208 + .rxq = 4,
209 + .txreadyq = 21,
210 + }
211 +};
212 +
213 +static struct platform_device tw5334_eth[] = {
214 + {
215 + .name = "ixp4xx_eth",
216 + .id = IXP4XX_ETH_NPEB,
217 + .dev.platform_data = tw5334_plat_eth,
218 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
219 + }, {
220 + .name = "ixp4xx_eth",
221 + .id = IXP4XX_ETH_NPEC,
222 + .dev.platform_data = tw5334_plat_eth + 1,
223 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
224 + }
225 +};
226 +
227 +static struct platform_device *tw5334_devices[] __initdata = {
228 + &tw5334_flash,
229 + &tw5334_uart,
230 + &tw5334_eth[0],
231 + &tw5334_eth[1],
232 +};
233 +
234 +static void __init tw5334_init(void)
235 +{
236 + uint8_t __iomem *f;
237 + int i;
238 +
239 + ixp4xx_sys_init();
240 +
241 + tw5334_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
242 + tw5334_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
243 +
244 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
245 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
246 +
247 + platform_add_devices(tw5334_devices, ARRAY_SIZE(tw5334_devices));
248 +
249 + /*
250 + * Map in a portion of the flash and read the MAC addresses.
251 + * Since it is stored in BE in the flash itself, we need to
252 + * byteswap it if we're in LE mode.
253 + */
254 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
255 + if (f) {
256 + for (i = 0; i < 6; i++) {
257 +#ifdef __ARMEB__
258 + tw5334_plat_eth[0].hwaddr[i] = readb(f + 0xFC0422 + i);
259 + tw5334_plat_eth[1].hwaddr[i] = readb(f + 0xFC043B + i);
260 +#else
261 + tw5334_plat_eth[0].hwaddr[i] = readb(f + 0xFC0422 + (i^3));
262 + tw5334_plat_eth[1].hwaddr[i] = readb(f + 0xFC043B + (i^3));
263 +#endif
264 + }
265 + iounmap(f);
266 + }
267 +
268 + printk(KERN_INFO "TW-533-4: Using MAC address %pM for port 0\n",
269 + tw5334_plat_eth[0].hwaddr);
270 + printk(KERN_INFO "TW-533-4: Using MAC address %pM for port 1\n",
271 + tw5334_plat_eth[1].hwaddr);
272 +}
273 +
274 +#ifdef CONFIG_MACH_TW5334
275 +MACHINE_START(TW5334, "Titan Wireless TW-533-4")
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 = tw5334_init,
282 +#if defined(CONFIG_PCI)
283 + .dma_zone_size = SZ_64M,
284 +#endif
285 + .restart = ixp4xx_restart,
286 +MACHINE_END
287 +#endif