ff2d7c64e23a6105eea2e78a086f1c59a678c6c3
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-3.3 / 520-tw2662_support.patch
1 --- a/arch/arm/mach-ixp4xx/Kconfig
2 +++ b/arch/arm/mach-ixp4xx/Kconfig
3 @@ -180,6 +180,15 @@ config ARCH_PRPMC1100
4 PrPCM1100 Processor Mezanine Module. For more information on
5 this platform, see <file:Documentation/arm/IXP4xx>.
6
7 +config MACH_TW2662
8 + bool "Titan Wireless TW-266-2"
9 + select PCI
10 + help
11 + Say 'Y' here if you want your kernel to support the Titan
12 + Wireless TW266-2. For more information on this platform,
13 + see http://openwrt.org
14 +
15 +
16 config MACH_TW5334
17 bool "Titan Wireless TW-533-4"
18 select PCI
19 --- a/arch/arm/mach-ixp4xx/Makefile
20 +++ b/arch/arm/mach-ixp4xx/Makefile
21 @@ -25,6 +25,7 @@ obj-pci-$(CONFIG_MACH_SIDEWINDER) += sid
22 obj-pci-$(CONFIG_MACH_COMPEXWP18) += ixdp425-pci.o
23 obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
24 obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
25 +obj-pci-$(CONFIG_MACH_TW2662) += tw2662-pci.o
26 obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
27 obj-pci-$(CONFIG_MACH_MI424WR) += mi424wr-pci.o
28 obj-pci-$(CONFIG_MACH_USR8200) += usr8200-pci.o
29 @@ -54,6 +55,7 @@ obj-$(CONFIG_MACH_SIDEWINDER) += sidewin
30 obj-$(CONFIG_MACH_COMPEXWP18) += compex42x-setup.o
31 obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
32 obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
33 +obj-$(CONFIG_MACH_TW2662) += tw2662-setup.o
34 obj-$(CONFIG_MACH_TW5334) += tw5334-setup.o
35 obj-$(CONFIG_MACH_MI424WR) += mi424wr-setup.o
36 obj-$(CONFIG_MACH_USR8200) += usr8200-setup.o
37 --- a/arch/arm/mach-ixp4xx/include/mach/uncompress.h
38 +++ b/arch/arm/mach-ixp4xx/include/mach/uncompress.h
39 @@ -45,7 +45,7 @@ static __inline__ void __arch_decomp_set
40 machine_is_devixp() || machine_is_miccpt() || machine_is_mic256() ||
41 machine_is_pronghorn() || machine_is_pronghorn_metro() ||
42 machine_is_wrt300nv2() || machine_is_tw5334() ||
43 - machine_is_usr8200())
44 + machine_is_usr8200() || machine_is_tw2662())
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/tw2662-pci.c
50 @@ -0,0 +1,68 @@
51 +/*
52 + * arch/arm/mach-ixp4xx/tw2662-pci.c
53 + *
54 + * PCI setup routines for Tiran Wireless TW-266-2 platform
55 + *
56 + * Copyright (C) 2002 Jungo Software Technologies.
57 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
58 + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
59 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
60 + *
61 + * Maintainer: Deepak Saxena <dsaxena@mvista.com>
62 + * Maintainer: Alexandros C. Couloumbis <alex@ozo.com>
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 +#include <asm/mach-types.h>
75 +#include <mach/hardware.h>
76 +#include <asm/irq.h>
77 +#include <asm/mach/pci.h>
78 +
79 +#define SLOT0_DEVID 1
80 +#define SLOT1_DEVID 3
81 +
82 +/* PCI controller GPIO to IRQ pin mappings */
83 +#define SLOT0_INTA 11
84 +#define SLOT1_INTA 9
85 +
86 +void __init tw2662_pci_preinit(void)
87 +{
88 + irq_set_irq_type(IXP4XX_GPIO_IRQ(SLOT0_INTA), IRQ_TYPE_LEVEL_LOW);
89 + irq_set_irq_type(IXP4XX_GPIO_IRQ(SLOT1_INTA), IRQ_TYPE_LEVEL_LOW);
90 + ixp4xx_pci_preinit();
91 +}
92 +
93 +static int __init tw2662_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
94 +{
95 + if (slot == SLOT0_DEVID)
96 + return IXP4XX_GPIO_IRQ(SLOT0_INTA);
97 + else if (slot == SLOT1_DEVID)
98 + return IXP4XX_GPIO_IRQ(SLOT1_INTA);
99 + else return -1;
100 +}
101 +
102 +struct hw_pci tw2662_pci __initdata = {
103 + .nr_controllers = 1,
104 + .preinit = tw2662_pci_preinit,
105 + .swizzle = pci_std_swizzle,
106 + .setup = ixp4xx_setup,
107 + .scan = ixp4xx_scan_bus,
108 + .map_irq = tw2662_map_irq,
109 +};
110 +
111 +int __init tw2662_pci_init(void)
112 +{
113 + if (machine_is_tw2662())
114 + pci_common_init(&tw2662_pci);
115 + return 0;
116 +}
117 +
118 +subsys_initcall(tw2662_pci_init);
119 --- /dev/null
120 +++ b/arch/arm/mach-ixp4xx/tw2662-setup.c
121 @@ -0,0 +1,205 @@
122 +/*
123 + * arch/arm/mach-ixp4xx/tw2662-setup.c
124 + *
125 + * Titan Wireless TW-266-2
126 + *
127 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
128 + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
129 + *
130 + * based on ap1000-setup.c:
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 +#include <linux/netdevice.h>
143 +#include <linux/etherdevice.h>
144 +#include <linux/platform_device.h>
145 +
146 +#include <asm/io.h>
147 +#include <asm/types.h>
148 +#include <asm/setup.h>
149 +#include <asm/memory.h>
150 +#include <mach/hardware.h>
151 +#include <asm/mach-types.h>
152 +#include <asm/irq.h>
153 +#include <asm/mach/arch.h>
154 +#include <asm/mach/flash.h>
155 +
156 +/* gpio mask used by platform device */
157 +#define TW2662_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7)
158 +
159 +static struct flash_platform_data tw2662_flash_data = {
160 + .map_name = "cfi_probe",
161 + .width = 2,
162 +};
163 +
164 +static struct resource tw2662_flash_resource = {
165 + .flags = IORESOURCE_MEM,
166 +};
167 +
168 +static struct platform_device tw2662_flash = {
169 + .name = "IXP4XX-Flash",
170 + .id = 0,
171 + .dev = {
172 + .platform_data = &tw2662_flash_data,
173 + },
174 + .num_resources = 1,
175 + .resource = &tw2662_flash_resource,
176 +};
177 +
178 +static struct resource tw2662_gpio_resources[] = {
179 + {
180 + .name = "gpio",
181 + /* FIXME: gpio mask should be model specific */
182 + .start = TW2662_GPIO_MASK,
183 + .end = TW2662_GPIO_MASK,
184 + .flags = 0,
185 + },
186 +};
187 +
188 +static struct resource tw2662_uart_resources[] = {
189 + {
190 + .start = IXP4XX_UART1_BASE_PHYS,
191 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
192 + .flags = IORESOURCE_MEM
193 + },
194 + {
195 + .start = IXP4XX_UART2_BASE_PHYS,
196 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
197 + .flags = IORESOURCE_MEM
198 + }
199 +};
200 +
201 +static struct plat_serial8250_port tw2662_uart_data[] = {
202 + {
203 + .mapbase = IXP4XX_UART1_BASE_PHYS,
204 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
205 + .irq = IRQ_IXP4XX_UART1,
206 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
207 + .iotype = UPIO_MEM,
208 + .regshift = 2,
209 + .uartclk = IXP4XX_UART_XTAL,
210 + },
211 + {
212 + .mapbase = IXP4XX_UART2_BASE_PHYS,
213 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
214 + .irq = IRQ_IXP4XX_UART2,
215 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
216 + .iotype = UPIO_MEM,
217 + .regshift = 2,
218 + .uartclk = IXP4XX_UART_XTAL,
219 + },
220 + { },
221 +};
222 +
223 +static struct platform_device tw2662_uart = {
224 + .name = "serial8250",
225 + .id = PLAT8250_DEV_PLATFORM,
226 + .dev.platform_data = tw2662_uart_data,
227 + .num_resources = 2,
228 + .resource = tw2662_uart_resources
229 +};
230 +
231 +/* Built-in 10/100 Ethernet MAC interfaces */
232 +static struct eth_plat_info tw2662_plat_eth[] = {
233 + {
234 + .phy = 3,
235 + .rxq = 3,
236 + .txreadyq = 20,
237 + }, {
238 + .phy = 1,
239 + .rxq = 4,
240 + .txreadyq = 21,
241 + }
242 +};
243 +
244 +static struct platform_device tw2662_eth[] = {
245 + {
246 + .name = "ixp4xx_eth",
247 + .id = IXP4XX_ETH_NPEB,
248 + .dev.platform_data = tw2662_plat_eth,
249 + }, {
250 + .name = "ixp4xx_eth",
251 + .id = IXP4XX_ETH_NPEC,
252 + .dev.platform_data = tw2662_plat_eth + 1,
253 + }
254 +};
255 +
256 +
257 +static struct platform_device *tw2662_devices[] __initdata = {
258 + &tw2662_flash,
259 + &tw2662_uart,
260 + &tw2662_eth[0],
261 + &tw2662_eth[1],
262 +};
263 +
264 +static char tw2662_mem_fixup[] __initdata = "mem=64M ";
265 +
266 +static void __init tw2662_fixup(struct tag *tags, char **cmdline,
267 + struct meminfo *mi)
268 +{
269 + struct tag *t = tags;
270 + char *p = *cmdline;
271 +
272 + /* Find the end of the tags table, taking note of any cmdline tag. */
273 + for (; t->hdr.size; t = tag_next(t)) {
274 + if (t->hdr.tag == ATAG_CMDLINE) {
275 + p = t->u.cmdline.cmdline;
276 + }
277 + }
278 +
279 + /* Overwrite the end of the table with a new cmdline tag. */
280 + t->hdr.tag = ATAG_CMDLINE;
281 + t->hdr.size = (sizeof (struct tag_header) +
282 + strlen(tw2662_mem_fixup) + strlen(p) + 1 + 4) >> 2;
283 + strlcpy(t->u.cmdline.cmdline, tw2662_mem_fixup, COMMAND_LINE_SIZE);
284 + strlcpy(t->u.cmdline.cmdline + strlen(tw2662_mem_fixup), p,
285 + COMMAND_LINE_SIZE - strlen(tw2662_mem_fixup));
286 +
287 + /* Terminate the table. */
288 + t = tag_next(t);
289 + t->hdr.tag = ATAG_NONE;
290 + t->hdr.size = 0;
291 +}
292 +
293 +static void __init tw2662_init(void)
294 +{
295 + ixp4xx_sys_init();
296 +
297 + tw2662_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
298 + tw2662_flash_resource.end =
299 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
300 +
301 + platform_add_devices(tw2662_devices, ARRAY_SIZE(tw2662_devices));
302 +
303 + if (!(is_valid_ether_addr(tw2662_plat_eth[0].hwaddr)))
304 + random_ether_addr(tw2662_plat_eth[0].hwaddr);
305 + if (!(is_valid_ether_addr(tw2662_plat_eth[1].hwaddr))) {
306 + memcpy(tw2662_plat_eth[1].hwaddr, tw2662_plat_eth[0].hwaddr, ETH_ALEN);
307 + tw2662_plat_eth[1].hwaddr[5] = (tw2662_plat_eth[0].hwaddr[5] + 1);
308 + }
309 +
310 +}
311 +
312 +#ifdef CONFIG_MACH_TW2662
313 +MACHINE_START(TW2662, "Titan Wireless TW-266-2")
314 + /* Maintainer: Alexandros C. Couloumbis <alex@ozo.com> */
315 + .fixup = tw2662_fixup,
316 + .map_io = ixp4xx_map_io,
317 + .init_irq = ixp4xx_init_irq,
318 + .timer = &ixp4xx_timer,
319 + .atag_offset = 0x0100,
320 + .init_machine = tw2662_init,
321 +#if defined(CONFIG_PCI)
322 + .dma_zone_size = SZ_64M,
323 +#endif
324 + .restart = ixp4xx_restart,
325 +MACHINE_END
326 +#endif