octeon: drop 3.14 support
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-3.14 / 520-tw2662_support.patch
1 --- a/arch/arm/mach-ixp4xx/Kconfig
2 +++ b/arch/arm/mach-ixp4xx/Kconfig
3 @@ -176,6 +176,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,67 @@
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 + .ops = &ixp4xx_ops,
106 + .setup = ixp4xx_setup,
107 + .map_irq = tw2662_map_irq,
108 +};
109 +
110 +int __init tw2662_pci_init(void)
111 +{
112 + if (machine_is_tw2662())
113 + pci_common_init(&tw2662_pci);
114 + return 0;
115 +}
116 +
117 +subsys_initcall(tw2662_pci_init);
118 --- /dev/null
119 +++ b/arch/arm/mach-ixp4xx/tw2662-setup.c
120 @@ -0,0 +1,197 @@
121 +/*
122 + * arch/arm/mach-ixp4xx/tw2662-setup.c
123 + *
124 + * Titan Wireless TW-266-2
125 + *
126 + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
127 + * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
128 + *
129 + * based on ap1000-setup.c:
130 + * Author: Imre Kaloz <Kaloz@openwrt.org>
131 + */
132 +
133 +#include <linux/if_ether.h>
134 +#include <linux/kernel.h>
135 +#include <linux/init.h>
136 +#include <linux/device.h>
137 +#include <linux/serial.h>
138 +#include <linux/tty.h>
139 +#include <linux/serial_8250.h>
140 +#include <linux/slab.h>
141 +#include <linux/netdevice.h>
142 +#include <linux/etherdevice.h>
143 +#include <linux/platform_device.h>
144 +
145 +#include <asm/io.h>
146 +#include <asm/types.h>
147 +#include <asm/setup.h>
148 +#include <asm/memory.h>
149 +#include <mach/hardware.h>
150 +#include <asm/mach-types.h>
151 +#include <asm/irq.h>
152 +#include <asm/mach/arch.h>
153 +#include <asm/mach/flash.h>
154 +
155 +/* gpio mask used by platform device */
156 +#define TW2662_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7)
157 +
158 +static struct flash_platform_data tw2662_flash_data = {
159 + .map_name = "cfi_probe",
160 + .width = 2,
161 +};
162 +
163 +static struct resource tw2662_flash_resource = {
164 + .flags = IORESOURCE_MEM,
165 +};
166 +
167 +static struct platform_device tw2662_flash = {
168 + .name = "IXP4XX-Flash",
169 + .id = 0,
170 + .dev = {
171 + .platform_data = &tw2662_flash_data,
172 + },
173 + .num_resources = 1,
174 + .resource = &tw2662_flash_resource,
175 +};
176 +
177 +static struct resource tw2662_uart_resources[] = {
178 + {
179 + .start = IXP4XX_UART1_BASE_PHYS,
180 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
181 + .flags = IORESOURCE_MEM
182 + },
183 + {
184 + .start = IXP4XX_UART2_BASE_PHYS,
185 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
186 + .flags = IORESOURCE_MEM
187 + }
188 +};
189 +
190 +static struct plat_serial8250_port tw2662_uart_data[] = {
191 + {
192 + .mapbase = IXP4XX_UART1_BASE_PHYS,
193 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
194 + .irq = IRQ_IXP4XX_UART1,
195 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
196 + .iotype = UPIO_MEM,
197 + .regshift = 2,
198 + .uartclk = IXP4XX_UART_XTAL,
199 + },
200 + {
201 + .mapbase = IXP4XX_UART2_BASE_PHYS,
202 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
203 + .irq = IRQ_IXP4XX_UART2,
204 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
205 + .iotype = UPIO_MEM,
206 + .regshift = 2,
207 + .uartclk = IXP4XX_UART_XTAL,
208 + },
209 + { },
210 +};
211 +
212 +static struct platform_device tw2662_uart = {
213 + .name = "serial8250",
214 + .id = PLAT8250_DEV_PLATFORM,
215 + .dev.platform_data = tw2662_uart_data,
216 + .num_resources = 2,
217 + .resource = tw2662_uart_resources
218 +};
219 +
220 +/* Built-in 10/100 Ethernet MAC interfaces */
221 +static struct eth_plat_info tw2662_plat_eth[] = {
222 + {
223 + .phy = 3,
224 + .rxq = 3,
225 + .txreadyq = 20,
226 + }, {
227 + .phy = 1,
228 + .rxq = 4,
229 + .txreadyq = 21,
230 + }
231 +};
232 +
233 +static struct platform_device tw2662_eth[] = {
234 + {
235 + .name = "ixp4xx_eth",
236 + .id = IXP4XX_ETH_NPEB,
237 + .dev.platform_data = tw2662_plat_eth,
238 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
239 + }, {
240 + .name = "ixp4xx_eth",
241 + .id = IXP4XX_ETH_NPEC,
242 + .dev.platform_data = tw2662_plat_eth + 1,
243 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
244 + }
245 +};
246 +
247 +
248 +static struct platform_device *tw2662_devices[] __initdata = {
249 + &tw2662_flash,
250 + &tw2662_uart,
251 + &tw2662_eth[0],
252 + &tw2662_eth[1],
253 +};
254 +
255 +static char tw2662_mem_fixup[] __initdata = "mem=64M ";
256 +
257 +static void __init tw2662_fixup(struct tag *tags, char **cmdline,
258 + struct meminfo *mi)
259 +{
260 + struct tag *t = tags;
261 + char *p = *cmdline;
262 +
263 + /* Find the end of the tags table, taking note of any cmdline tag. */
264 + for (; t->hdr.size; t = tag_next(t)) {
265 + if (t->hdr.tag == ATAG_CMDLINE) {
266 + p = t->u.cmdline.cmdline;
267 + }
268 + }
269 +
270 + /* Overwrite the end of the table with a new cmdline tag. */
271 + t->hdr.tag = ATAG_CMDLINE;
272 + t->hdr.size = (sizeof (struct tag_header) +
273 + strlen(tw2662_mem_fixup) + strlen(p) + 1 + 4) >> 2;
274 + strlcpy(t->u.cmdline.cmdline, tw2662_mem_fixup, COMMAND_LINE_SIZE);
275 + strlcpy(t->u.cmdline.cmdline + strlen(tw2662_mem_fixup), p,
276 + COMMAND_LINE_SIZE - strlen(tw2662_mem_fixup));
277 +
278 + /* Terminate the table. */
279 + t = tag_next(t);
280 + t->hdr.tag = ATAG_NONE;
281 + t->hdr.size = 0;
282 +}
283 +
284 +static void __init tw2662_init(void)
285 +{
286 + ixp4xx_sys_init();
287 +
288 + tw2662_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
289 + tw2662_flash_resource.end =
290 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
291 +
292 + platform_add_devices(tw2662_devices, ARRAY_SIZE(tw2662_devices));
293 +
294 + if (!(is_valid_ether_addr(tw2662_plat_eth[0].hwaddr)))
295 + random_ether_addr(tw2662_plat_eth[0].hwaddr);
296 + if (!(is_valid_ether_addr(tw2662_plat_eth[1].hwaddr))) {
297 + memcpy(tw2662_plat_eth[1].hwaddr, tw2662_plat_eth[0].hwaddr, ETH_ALEN);
298 + tw2662_plat_eth[1].hwaddr[5] = (tw2662_plat_eth[0].hwaddr[5] + 1);
299 + }
300 +
301 +}
302 +
303 +#ifdef CONFIG_MACH_TW2662
304 +MACHINE_START(TW2662, "Titan Wireless TW-266-2")
305 + /* Maintainer: Alexandros C. Couloumbis <alex@ozo.com> */
306 + .fixup = tw2662_fixup,
307 + .map_io = ixp4xx_map_io,
308 + .init_irq = ixp4xx_init_irq,
309 + .init_time = ixp4xx_timer_init,
310 + .atag_offset = 0x0100,
311 + .init_machine = tw2662_init,
312 +#if defined(CONFIG_PCI)
313 + .dma_zone_size = SZ_64M,
314 +#endif
315 + .restart = ixp4xx_restart,
316 +MACHINE_END
317 +#endif