Root/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_COMPEX) += 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_COMPEX) += compex-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,213 @@
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 platform_device tw2662_gpio = {
189+ .name = "GPIODEV",
190+ .id = -1,
191+ .num_resources = ARRAY_SIZE(tw2662_gpio_resources),
192+ .resource = tw2662_gpio_resources,
193+};
194+
195+static struct resource tw2662_uart_resources[] = {
196+ {
197+ .start = IXP4XX_UART1_BASE_PHYS,
198+ .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
199+ .flags = IORESOURCE_MEM
200+ },
201+ {
202+ .start = IXP4XX_UART2_BASE_PHYS,
203+ .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
204+ .flags = IORESOURCE_MEM
205+ }
206+};
207+
208+static struct plat_serial8250_port tw2662_uart_data[] = {
209+ {
210+ .mapbase = IXP4XX_UART1_BASE_PHYS,
211+ .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
212+ .irq = IRQ_IXP4XX_UART1,
213+ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
214+ .iotype = UPIO_MEM,
215+ .regshift = 2,
216+ .uartclk = IXP4XX_UART_XTAL,
217+ },
218+ {
219+ .mapbase = IXP4XX_UART2_BASE_PHYS,
220+ .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
221+ .irq = IRQ_IXP4XX_UART2,
222+ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
223+ .iotype = UPIO_MEM,
224+ .regshift = 2,
225+ .uartclk = IXP4XX_UART_XTAL,
226+ },
227+ { },
228+};
229+
230+static struct platform_device tw2662_uart = {
231+ .name = "serial8250",
232+ .id = PLAT8250_DEV_PLATFORM,
233+ .dev.platform_data = tw2662_uart_data,
234+ .num_resources = 2,
235+ .resource = tw2662_uart_resources
236+};
237+
238+/* Built-in 10/100 Ethernet MAC interfaces */
239+static struct eth_plat_info tw2662_plat_eth[] = {
240+ {
241+ .phy = 3,
242+ .rxq = 3,
243+ .txreadyq = 20,
244+ }, {
245+ .phy = 1,
246+ .rxq = 4,
247+ .txreadyq = 21,
248+ }
249+};
250+
251+static struct platform_device tw2662_eth[] = {
252+ {
253+ .name = "ixp4xx_eth",
254+ .id = IXP4XX_ETH_NPEB,
255+ .dev.platform_data = tw2662_plat_eth,
256+ }, {
257+ .name = "ixp4xx_eth",
258+ .id = IXP4XX_ETH_NPEC,
259+ .dev.platform_data = tw2662_plat_eth + 1,
260+ }
261+};
262+
263+
264+static struct platform_device *tw2662_devices[] __initdata = {
265+ &tw2662_flash,
266+ &tw2662_uart,
267+ &tw2662_gpio,
268+ &tw2662_eth[0],
269+ &tw2662_eth[1],
270+};
271+
272+static char tw2662_mem_fixup[] __initdata = "mem=64M ";
273+
274+static void __init tw2662_fixup(struct tag *tags, char **cmdline,
275+ struct meminfo *mi)
276+{
277+ struct tag *t = tags;
278+ char *p = *cmdline;
279+
280+ /* Find the end of the tags table, taking note of any cmdline tag. */
281+ for (; t->hdr.size; t = tag_next(t)) {
282+ if (t->hdr.tag == ATAG_CMDLINE) {
283+ p = t->u.cmdline.cmdline;
284+ }
285+ }
286+
287+ /* Overwrite the end of the table with a new cmdline tag. */
288+ t->hdr.tag = ATAG_CMDLINE;
289+ t->hdr.size = (sizeof (struct tag_header) +
290+ strlen(tw2662_mem_fixup) + strlen(p) + 1 + 4) >> 2;
291+ strlcpy(t->u.cmdline.cmdline, tw2662_mem_fixup, COMMAND_LINE_SIZE);
292+ strlcpy(t->u.cmdline.cmdline + strlen(tw2662_mem_fixup), p,
293+ COMMAND_LINE_SIZE - strlen(tw2662_mem_fixup));
294+
295+ /* Terminate the table. */
296+ t = tag_next(t);
297+ t->hdr.tag = ATAG_NONE;
298+ t->hdr.size = 0;
299+}
300+
301+static void __init tw2662_init(void)
302+{
303+ ixp4xx_sys_init();
304+
305+ tw2662_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
306+ tw2662_flash_resource.end =
307+ IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
308+
309+ platform_add_devices(tw2662_devices, ARRAY_SIZE(tw2662_devices));
310+
311+ if (!(is_valid_ether_addr(tw2662_plat_eth[0].hwaddr)))
312+ random_ether_addr(tw2662_plat_eth[0].hwaddr);
313+ if (!(is_valid_ether_addr(tw2662_plat_eth[1].hwaddr))) {
314+ memcpy(tw2662_plat_eth[1].hwaddr, tw2662_plat_eth[0].hwaddr, ETH_ALEN);
315+ tw2662_plat_eth[1].hwaddr[5] = (tw2662_plat_eth[0].hwaddr[5] + 1);
316+ }
317+
318+}
319+
320+#ifdef CONFIG_MACH_TW2662
321+MACHINE_START(TW2662, "Titan Wireless TW-266-2")
322+ /* Maintainer: Alexandros C. Couloumbis <alex@ozo.com> */
323+ .fixup = tw2662_fixup,
324+ .map_io = ixp4xx_map_io,
325+ .init_irq = ixp4xx_init_irq,
326+ .timer = &ixp4xx_timer,
327+ .atag_offset = 0x0100,
328+ .init_machine = tw2662_init,
329+#if defined(CONFIG_PCI)
330+ .dma_zone_size = SZ_64M,
331+#endif
332+ .restart = ixp4xx_restart,
333+MACHINE_END
334+#endif
335

Archive Download this file



interactive