add USB fixup & board detection for the Cambria, plus merge the LED latch driver...
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 190-cambria_support.patch
1 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
2 ===================================================================
3 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Kconfig
4 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Kconfig
5 @@ -25,6 +25,14 @@ config MACH_AVILA
6 Avila Network Platform. For more information on this platform,
7 see <file:Documentation/arm/IXP4xx>.
8
9 +config MACH_CAMBRIA
10 + bool "Cambria"
11 + select PCI
12 + help
13 + Say 'Y' here if you want your kernel to support the Gateworks
14 + Cambria series. For more information on this platform,
15 + see <file:Documentation/arm/IXP4xx>.
16 +
17 config MACH_LOFT
18 bool "Loft"
19 depends on MACH_AVILA
20 @@ -200,7 +208,7 @@ config CPU_IXP46X
21
22 config CPU_IXP43X
23 bool
24 - depends on MACH_KIXRP435
25 + depends on MACH_KIXRP435 || MACH_CAMBRIA
26 default y
27
28 config MACH_GTWX5715
29 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
30 ===================================================================
31 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/Makefile
32 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/Makefile
33 @@ -7,6 +7,7 @@ obj-pci-n :=
34
35 obj-pci-$(CONFIG_ARCH_IXDP4XX) += ixdp425-pci.o
36 obj-pci-$(CONFIG_MACH_AVILA) += avila-pci.o
37 +obj-pci-$(CONFIG_MACH_CAMBRIA) += cambria-pci.o
38 obj-pci-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o
39 obj-pci-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o
40 obj-pci-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o
41 @@ -28,6 +29,7 @@ obj-y += common.o
42
43 obj-$(CONFIG_ARCH_IXDP4XX) += ixdp425-setup.o
44 obj-$(CONFIG_MACH_AVILA) += avila-setup.o
45 +obj-$(CONFIG_MACH_CAMBRIA) += cambria-setup.o
46 obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
47 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
48 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
49 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-pci.c
50 ===================================================================
51 --- /dev/null
52 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-pci.c
53 @@ -0,0 +1,74 @@
54 +/*
55 + * arch/arch/mach-ixp4xx/cambria-pci.c
56 + *
57 + * PCI setup routines for Gateworks Cambria series
58 + *
59 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
60 + *
61 + * based on coyote-pci.c:
62 + * Copyright (C) 2002 Jungo Software Technologies.
63 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
64 + *
65 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
66 + *
67 + * This program is free software; you can redistribute it and/or modify
68 + * it under the terms of the GNU General Public License version 2 as
69 + * published by the Free Software Foundation.
70 + *
71 + */
72 +
73 +#include <linux/kernel.h>
74 +#include <linux/pci.h>
75 +#include <linux/init.h>
76 +#include <linux/irq.h>
77 +
78 +#include <asm/mach-types.h>
79 +#include <asm/hardware.h>
80 +#include <asm/irq.h>
81 +
82 +#include <asm/mach/pci.h>
83 +
84 +extern void ixp4xx_pci_preinit(void);
85 +extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
86 +extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
87 +
88 +void __init cambria_pci_preinit(void)
89 +{
90 + set_irq_type(IRQ_IXP4XX_GPIO11, IRQT_LOW);
91 + set_irq_type(IRQ_IXP4XX_GPIO10, IRQT_LOW);
92 + set_irq_type(IRQ_IXP4XX_GPIO9, IRQT_LOW);
93 + set_irq_type(IRQ_IXP4XX_GPIO8, IRQT_LOW);
94 +
95 + ixp4xx_pci_preinit();
96 +}
97 +
98 +static int __init cambria_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
99 +{
100 + if (slot == 1)
101 + return IRQ_IXP4XX_GPIO11;
102 + else if (slot == 2)
103 + return IRQ_IXP4XX_GPIO10;
104 + else if (slot == 3)
105 + return IRQ_IXP4XX_GPIO9;
106 + else if (slot == 4)
107 + return IRQ_IXP4XX_GPIO8;
108 + else return -1;
109 +}
110 +
111 +struct hw_pci cambria_pci __initdata = {
112 + .nr_controllers = 1,
113 + .preinit = cambria_pci_preinit,
114 + .swizzle = pci_std_swizzle,
115 + .setup = ixp4xx_setup,
116 + .scan = ixp4xx_scan_bus,
117 + .map_irq = cambria_map_irq,
118 +};
119 +
120 +int __init cambria_pci_init(void)
121 +{
122 + if (machine_is_cambria())
123 + pci_common_init(&cambria_pci);
124 + return 0;
125 +}
126 +
127 +subsys_initcall(cambria_pci_init);
128 diff -ruN /usr/src/openwrt/clean/linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-setup.c linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-setup.c
129 --- /usr/src/openwrt/clean/linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-setup.c 1969-12-31 16:00:00.000000000 -0800
130 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/cambria-setup.c 2008-05-20 16:02:43.000000000 -0700
131 @@ -0,0 +1,445 @@
132 +/*
133 + * arch/arm/mach-ixp4xx/cambria-setup.c
134 + *
135 + * Board setup for the Gateworks Cambria series
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/init.h>
147 +#include <linux/device.h>
148 +#include <linux/if_ether.h>
149 +#include <linux/socket.h>
150 +#include <linux/netdevice.h>
151 +#include <linux/serial.h>
152 +#include <linux/tty.h>
153 +#include <linux/serial_8250.h>
154 +#include <linux/slab.h>
155 +#ifdef CONFIG_SENSORS_EEPROM
156 +# include <linux/i2c.h>
157 +# include <linux/eeprom.h>
158 +#endif
159 +
160 +#include <linux/leds.h>
161 +#include <linux/i2c-gpio.h>
162 +#include <asm/types.h>
163 +#include <asm/setup.h>
164 +#include <asm/memory.h>
165 +#include <asm/hardware.h>
166 +#include <asm/irq.h>
167 +#include <asm/mach-types.h>
168 +#include <asm/mach/arch.h>
169 +#include <asm/mach/flash.h>
170 +
171 +struct cambria_board_info {
172 + unsigned char *model;
173 + void (* setup)(void);
174 +};
175 +
176 +static struct cambria_board_info *cambria_info __initdata;
177 +
178 +static struct flash_platform_data cambria_flash_data = {
179 + .map_name = "cfi_probe",
180 + .width = 2,
181 +};
182 +
183 +static struct resource cambria_flash_resource = {
184 + .flags = IORESOURCE_MEM,
185 +};
186 +
187 +static struct platform_device cambria_flash = {
188 + .name = "IXP4XX-Flash",
189 + .id = 0,
190 + .dev = {
191 + .platform_data = &cambria_flash_data,
192 + },
193 + .num_resources = 1,
194 + .resource = &cambria_flash_resource,
195 +};
196 +
197 +static struct i2c_gpio_platform_data cambria_i2c_gpio_data = {
198 + .sda_pin = 7,
199 + .scl_pin = 6,
200 +};
201 +
202 +static struct platform_device cambria_i2c_gpio = {
203 + .name = "i2c-gpio",
204 + .id = 0,
205 + .dev = {
206 + .platform_data = &cambria_i2c_gpio_data,
207 + },
208 +};
209 +
210 +static struct resource cambria_uart_resource = {
211 + .start = IXP4XX_UART1_BASE_PHYS,
212 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
213 + .flags = IORESOURCE_MEM,
214 +};
215 +
216 +static struct plat_serial8250_port cambria_uart_data[] = {
217 + {
218 + .mapbase = IXP4XX_UART1_BASE_PHYS,
219 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
220 + .irq = IRQ_IXP4XX_UART1,
221 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
222 + .iotype = UPIO_MEM,
223 + .regshift = 2,
224 + .uartclk = IXP4XX_UART_XTAL,
225 + },
226 + { },
227 +};
228 +
229 +static struct platform_device cambria_uart = {
230 + .name = "serial8250",
231 + .id = PLAT8250_DEV_PLATFORM,
232 + .dev = {
233 + .platform_data = cambria_uart_data,
234 + },
235 + .num_resources = 1,
236 + .resource = &cambria_uart_resource,
237 +};
238 +
239 +static struct resource cambria_pata_resources[] = {
240 + {
241 + .flags = IORESOURCE_MEM
242 + },
243 + {
244 + .flags = IORESOURCE_MEM,
245 + },
246 + {
247 + .name = "intrq",
248 + .start = IRQ_IXP4XX_GPIO12,
249 + .end = IRQ_IXP4XX_GPIO12,
250 + .flags = IORESOURCE_IRQ,
251 + },
252 +};
253 +
254 +static struct ixp4xx_pata_data cambria_pata_data = {
255 + .cs0_bits = 0xbfff3c03,
256 + .cs1_bits = 0xbfff3c03,
257 +};
258 +
259 +static struct platform_device cambria_pata = {
260 + .name = "pata_ixp4xx_cf",
261 + .id = 0,
262 + .dev.platform_data = &cambria_pata_data,
263 + .num_resources = ARRAY_SIZE(cambria_pata_resources),
264 + .resource = cambria_pata_resources,
265 +};
266 +
267 +static struct eth_plat_info cambria_npec_data = {
268 + .phy = 2,
269 + .rxq = 4,
270 + .txreadyq = 21,
271 +};
272 +
273 +static struct eth_plat_info cambria_npea_data = {
274 + .phy = 1,
275 + .rxq = 2,
276 + .txreadyq = 19,
277 +};
278 +
279 +static struct platform_device cambria_npec_device = {
280 + .name = "ixp4xx_eth",
281 + .id = IXP4XX_ETH_NPEC,
282 + .dev.platform_data = &cambria_npec_data,
283 +};
284 +
285 +static struct platform_device cambria_npea_device = {
286 + .name = "ixp4xx_eth",
287 + .id = IXP4XX_ETH_NPEA,
288 + .dev.platform_data = &cambria_npea_data,
289 +};
290 +
291 +static struct gpio_led cambria_gpio_leds[] = {
292 + {
293 + .name = "user", /* green led */
294 + .gpio = 5,
295 + .active_low = 1,
296 + }
297 +};
298 +
299 +static struct gpio_led_platform_data cambria_gpio_leds_data = {
300 + .num_leds = 1,
301 + .leds = cambria_gpio_leds,
302 +};
303 +
304 +static struct platform_device cambria_gpio_leds_device = {
305 + .name = "leds-gpio",
306 + .id = -1,
307 + .dev.platform_data = &cambria_gpio_leds_data,
308 +};
309 +
310 +
311 +static struct latch_led cambria_latch_leds[] = {
312 + {
313 + .name = "ledA", /* green led */
314 + .bit = 0,
315 + },
316 + {
317 + .name = "ledB", /* green led */
318 + .bit = 1,
319 + },
320 + {
321 + .name = "ledC", /* green led */
322 + .bit = 2,
323 + },
324 + {
325 + .name = "ledD", /* green led */
326 + .bit = 3,
327 + },
328 + {
329 + .name = "ledE", /* green led */
330 + .bit = 4,
331 + },
332 + {
333 + .name = "ledF", /* green led */
334 + .bit = 5,
335 + },
336 + {
337 + .name = "ledG", /* green led */
338 + .bit = 6,
339 + },
340 + {
341 + .name = "ledH", /* green led */
342 + .bit = 7,
343 + }
344 +};
345 +
346 +static struct latch_led_platform_data cambria_latch_leds_data = {
347 + .num_leds = 8,
348 + .leds = cambria_latch_leds,
349 + .mem = 0x53F40000,
350 +};
351 +
352 +static struct platform_device cambria_latch_leds_device = {
353 + .name = "leds-latch",
354 + .id = -1,
355 + .dev.platform_data = &cambria_latch_leds_data,
356 +};
357 +
358 +static struct resource cambria_usb0_resources[] = {
359 + {
360 + .start = 0xCD000000,
361 + .end = 0xCD000300,
362 + .flags = IORESOURCE_MEM,
363 + },
364 + {
365 + .start = 32,
366 + .flags = IORESOURCE_IRQ,
367 + },
368 +};
369 +
370 +static struct resource cambria_usb1_resources[] = {
371 + {
372 + .start = 0xCE000000,
373 + .end = 0xCE000300,
374 + .flags = IORESOURCE_MEM,
375 + },
376 + {
377 + .start = 33,
378 + .flags = IORESOURCE_IRQ,
379 + },
380 +};
381 +
382 +static u64 ehci_dma_mask = ~(u32)0;
383 +
384 +static struct platform_device cambria_usb0_device = {
385 + .name = "ixp4xx-ehci",
386 + .id = 0,
387 + .dev = {
388 + .dma_mask = &ehci_dma_mask,
389 + .coherent_dma_mask = 0xffffffff,
390 + },
391 + .resource = cambria_usb0_resources,
392 + .num_resources = 2,
393 +};
394 +
395 +static struct platform_device cambria_usb1_device = {
396 + .name = "ixp4xx-ehci",
397 + .id = 1,
398 + .dev = {
399 + .dma_mask = &ehci_dma_mask,
400 + .coherent_dma_mask = 0xffffffff,
401 + },
402 + .resource = cambria_usb1_resources,
403 + .num_resources = 2,
404 +};
405 +
406 +
407 +static struct platform_device *cambria_devices[] __initdata = {
408 + &cambria_i2c_gpio,
409 + &cambria_flash,
410 + &cambria_uart,
411 +};
412 +
413 +static void __init cambria_gw23xx_setup(void)
414 +{
415 + platform_device_register(&cambria_npec_device);
416 + platform_device_register(&cambria_npea_device);
417 +}
418 +
419 +#ifdef CONFIG_SENSORS_EEPROM
420 +static void __init cambria_gw2350_setup(void)
421 +{
422 + platform_device_register(&cambria_npec_device);
423 + platform_device_register(&cambria_npea_device);
424 +
425 + platform_device_register(&cambria_usb0_device);
426 + platform_device_register(&cambria_usb1_device);
427 +
428 + platform_device_register(&cambria_gpio_leds_device);
429 +}
430 +
431 +static void __init cambria_gw2358_setup(void)
432 +{
433 + platform_device_register(&cambria_npec_device);
434 + platform_device_register(&cambria_npea_device);
435 +
436 + platform_device_register(&cambria_usb0_device);
437 + platform_device_register(&cambria_usb1_device);
438 +
439 + platform_device_register(&cambria_pata);
440 +
441 + platform_device_register(&cambria_latch_leds_device);
442 +}
443 +
444 +static struct cambria_board_info cambria_boards[] __initdata = {
445 + {
446 + .model = "GW2350",
447 + .setup = cambria_gw2350_setup,
448 + }, {
449 + .model = "GW2358",
450 + .setup = cambria_gw2358_setup,
451 + }
452 +};
453 +
454 +static struct cambria_board_info * __init cambria_find_board_info(char *model)
455 +{
456 + int i;
457 +
458 + for (i = 0; i < ARRAY_SIZE(cambria_boards); i++) {
459 + struct cambria_board_info *info = &cambria_boards[i];
460 + if (strncmp(info->model, model, strlen(info->model)) == 0)
461 + return info;
462 + }
463 +
464 + return NULL;
465 +}
466 +
467 +struct cambria_eeprom_header {
468 + unsigned char mac0[ETH_ALEN];
469 + unsigned char mac1[ETH_ALEN];
470 + unsigned char res0[4];
471 + unsigned char magic[2];
472 + unsigned char config[14];
473 + unsigned char model[16];
474 +};
475 +
476 +static int __init cambria_eeprom_notify(struct notifier_block *self,
477 + unsigned long event, void *t)
478 +{
479 + struct eeprom_data *ee = t;
480 + struct cambria_eeprom_header hdr;
481 +
482 + if (cambria_info)
483 + return NOTIFY_DONE;
484 +
485 + /* The eeprom is at address 0x51 */
486 + if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
487 + return NOTIFY_DONE;
488 +
489 + ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
490 + 0, sizeof(hdr));
491 +
492 + if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
493 + return NOTIFY_DONE;
494 +
495 + memcpy(&cambria_npec_data.hwaddr, hdr.mac0, ETH_ALEN);
496 + memcpy(&cambria_npea_data.hwaddr, hdr.mac1, ETH_ALEN);
497 +
498 + cambria_info = cambria_find_board_info(hdr.model);
499 +
500 + return NOTIFY_OK;
501 +}
502 +
503 +static struct notifier_block cambria_eeprom_notifier __initdata = {
504 + .notifier_call = cambria_eeprom_notify
505 +};
506 +
507 +static void __init cambria_register_eeprom_notifier(void)
508 +{
509 + register_eeprom_notifier(&cambria_eeprom_notifier);
510 +}
511 +
512 +static void __init cambria_unregister_eeprom_notifier(void)
513 +{
514 + unregister_eeprom_notifier(&cambria_eeprom_notifier);
515 +}
516 +#else /* CONFIG_SENSORS_EEPROM */
517 +static inline void cambria_register_eeprom_notifier(void) {};
518 +static inline void cambria_unregister_eeprom_notifier(void) {};
519 +#endif /* CONFIG_SENSORS_EEPROM */
520 +
521 +static void __init cambria_init(void)
522 +{
523 + ixp4xx_sys_init();
524 +
525 + cambria_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
526 + cambria_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
527 +
528 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
529 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
530 +
531 + platform_add_devices(cambria_devices, ARRAY_SIZE(cambria_devices));
532 +
533 + cambria_pata_resources[0].start = 0x53e00000;
534 + cambria_pata_resources[0].end = 0x53e3ffff;
535 +
536 + cambria_pata_resources[1].start = 0x53e40000;
537 + cambria_pata_resources[1].end = 0x53e7ffff;
538 +
539 + cambria_pata_data.cs0_cfg = IXP4XX_EXP_CS3;
540 + cambria_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
541 +
542 + cambria_register_eeprom_notifier();
543 +}
544 +
545 +static int __init cambria_model_setup(void)
546 +{
547 + if (!machine_is_cambria())
548 + return 0;
549 +
550 + if (cambria_info) {
551 + printk(KERN_DEBUG "Running on Gateworks Cambria %s\n",
552 + cambria_info->model);
553 + cambria_info->setup();
554 + } else {
555 + printk(KERN_INFO "Unknown/missing Cambria model number"
556 + " -- defaults will be used\n");
557 + cambria_gw23xx_setup();
558 + }
559 +
560 + cambria_unregister_eeprom_notifier();
561 + return 0;
562 +}
563 +late_initcall(cambria_model_setup);
564 +
565 +#ifdef CONFIG_MACH_CAMBRIA
566 +MACHINE_START(CAMBRIA, "Gateworks Cambria series")
567 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
568 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
569 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
570 + .map_io = ixp4xx_map_io,
571 + .init_irq = ixp4xx_init_irq,
572 + .timer = &ixp4xx_timer,
573 + .boot_params = 0x0100,
574 + .init_machine = cambria_init,
575 +MACHINE_END
576 +#endif
577 Index: linux-2.6.25.4/include/asm-arm/arch-ixp4xx/hardware.h
578 ===================================================================
579 --- linux-2.6.25.4.orig/include/asm-arm/arch-ixp4xx/hardware.h
580 +++ linux-2.6.25.4/include/asm-arm/arch-ixp4xx/hardware.h
581 @@ -18,7 +18,7 @@
582 #define __ASM_ARCH_HARDWARE_H__
583
584 #define PCIBIOS_MIN_IO 0x00001000
585 -#define PCIBIOS_MIN_MEM (cpu_is_ixp43x() ? 0x40000000 : 0x48000000)
586 +#define PCIBIOS_MIN_MEM (cpu_is_ixp43x() ? 0x48000000 : 0x48000000)
587
588 /*
589 * We override the standard dma-mask routines for bouncing.
This page took 0.062159 seconds and 5 git commands to generate.