1 Index: linux-3.14.25/arch/arm/mach-ixp4xx/avila-pci.c
2 ===================================================================
3 --- linux-3.14.25.orig/arch/arm/mach-ixp4xx/avila-pci.c 2014-11-30 15:25:58.890640602 +0100
4 +++ linux-3.14.25/arch/arm/mach-ixp4xx/avila-pci.c 2014-11-30 15:26:43.548148782 +0100
6 #include <mach/hardware.h>
7 #include <asm/mach-types.h>
9 -#define AVILA_MAX_DEV 4
10 -#define LOFT_MAX_DEV 6
11 +#define AVILA_MAX_DEV 6
15 /* PCI controller GPIO to IRQ pin mappings */
21 - slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
22 - pin >= 1 && pin <= IRQ_LINES)
23 - return pci_irq_table[(slot + pin - 2) % 4];
24 + if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
25 + return pci_irq_table[(slot + pin - 2) % IRQ_LINES];
29 Index: linux-3.14.25/arch/arm/mach-ixp4xx/avila-setup.c
30 ===================================================================
31 --- linux-3.14.25.orig/arch/arm/mach-ixp4xx/avila-setup.c 2014-11-30 15:25:58.890640602 +0100
32 +++ linux-3.14.25/arch/arm/mach-ixp4xx/avila-setup.c 2014-11-30 16:03:14.803148025 +0100
34 #include <linux/kernel.h>
35 #include <linux/init.h>
36 #include <linux/device.h>
37 +#include <linux/if_ether.h>
38 +#include <linux/socket.h>
39 +#include <linux/netdevice.h>
40 #include <linux/serial.h>
41 #include <linux/tty.h>
42 #include <linux/serial_8250.h>
43 +#include <linux/i2c.h>
44 +#include <linux/platform_data/at24.h>
45 +#include <linux/leds.h>
46 +#include <linux/platform_data/pca953x.h>
47 #include <linux/i2c-gpio.h>
48 #include <asm/types.h>
49 #include <asm/setup.h>
52 #include <asm/mach/arch.h>
53 #include <asm/mach/flash.h>
54 +#include <linux/irq.h>
56 #define AVILA_SDA_PIN 7
57 #define AVILA_SCL_PIN 6
60 +#define AVILA_GW23XX_LED_USER_GPIO 3
61 +#define AVILA_GW23X7_LED_USER_GPIO 4
63 +/* gpio mask used by platform device */
64 +#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
66 +struct avila_board_info {
67 + unsigned char *model;
68 + void (*setup)(void);
71 +static struct avila_board_info *avila_info __initdata;
73 static struct flash_platform_data avila_flash_data = {
74 .map_name = "cfi_probe",
77 .resource = avila_uart_resources
80 -static struct resource avila_pata_resources[] = {
81 +static struct resource avila_optional_uart_resources[] = {
83 - .flags = IORESOURCE_MEM
85 + .start = 0x54000000,
87 + .flags = IORESOURCE_MEM
89 + .start = 0x55000000,
91 + .flags = IORESOURCE_MEM
93 + .start = 0x56000000,
95 + .flags = IORESOURCE_MEM
97 + .start = 0x57000000,
99 + .flags = IORESOURCE_MEM
103 +static struct plat_serial8250_port avila_optional_uart_data[] = {
105 - .flags = IORESOURCE_MEM,
106 + .flags = UPF_BOOT_AUTOCONF,
107 + .iotype = UPIO_MEM,
109 + .uartclk = 18432000,
112 + .flags = UPF_BOOT_AUTOCONF,
113 + .iotype = UPIO_MEM,
115 + .uartclk = 18432000,
118 + .flags = UPF_BOOT_AUTOCONF,
119 + .iotype = UPIO_MEM,
121 + .uartclk = 18432000,
124 + .flags = UPF_BOOT_AUTOCONF,
125 + .iotype = UPIO_MEM,
127 + .uartclk = 18432000,
133 +static struct platform_device avila_optional_uart = {
134 + .name = "serial8250",
135 + .id = PLAT8250_DEV_PLATFORM1,
136 + .dev.platform_data = avila_optional_uart_data,
137 + .num_resources = 4,
138 + .resource = avila_optional_uart_resources,
141 +static struct resource avila_pata_resources[] = {
143 + .flags = IORESOURCE_MEM
145 + .flags = IORESOURCE_MEM,
148 .start = IRQ_IXP4XX_GPIO12,
149 .end = IRQ_IXP4XX_GPIO12,
150 @@ -133,21 +210,237 @@
151 .resource = avila_pata_resources,
154 +/* Built-in 10/100 Ethernet MAC interfaces */
155 +static struct eth_plat_info avila_npeb_data = {
161 +static struct eth_plat_info avila_npec_data = {
167 +static struct platform_device avila_npeb_device = {
168 + .name = "ixp4xx_eth",
169 + .id = IXP4XX_ETH_NPEB,
170 + .dev.platform_data = &avila_npeb_data,
171 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
174 +static struct platform_device avila_npec_device = {
175 + .name = "ixp4xx_eth",
176 + .id = IXP4XX_ETH_NPEC,
177 + .dev.platform_data = &avila_npec_data,
178 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
181 +static struct gpio_led avila_gpio_leds[] = {
183 + .name = "user", /* green led */
184 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
188 + .name = "radio1", /* green led */
193 + .name = "radio2", /* green led */
198 + .name = "radio3", /* green led */
203 + .name = "radio4", /* green led */
210 +static struct gpio_led_platform_data avila_gpio_leds_data = {
212 + .leds = avila_gpio_leds,
215 +static struct platform_device avila_gpio_leds_device = {
216 + .name = "leds-gpio",
218 + .dev.platform_data = &avila_gpio_leds_data,
221 +static struct latch_led avila_latch_leds[] = {
223 + .name = "led0", /* green led */
227 + .name = "led1", /* green led */
231 + .name = "led2", /* green led */
235 + .name = "led3", /* green led */
239 + .name = "led4", /* green led */
243 + .name = "led5", /* green led */
247 + .name = "led6", /* green led */
251 + .name = "led7", /* green led */
256 +static struct latch_led_platform_data avila_latch_leds_data = {
258 + .leds = avila_latch_leds,
262 +static struct platform_device avila_latch_leds_device = {
263 + .name = "leds-latch",
265 + .dev.platform_data = &avila_latch_leds_data,
268 static struct platform_device *avila_devices[] __initdata = {
274 -static void __init avila_init(void)
279 +static struct platform_device avila_hss_device[] = {
281 + .name = "gw_avila_hss",
284 + .name = "gw_avila_hss",
287 + .name = "gw_avila_hss",
290 + .name = "gw_avila_hss",
295 +static struct platform_device avila_pcm_device[] = {
297 + .name = "gw_avila-audio",
300 + .name = "gw_avila-audio",
303 + .name = "gw_avila-audio",
306 + .name = "gw_avila-audio",
311 +static void setup_audio_devices(void) {
312 + platform_device_register(&avila_hss_device[0]);
313 + platform_device_register(&avila_hss_device[1]);
314 + platform_device_register(&avila_hss_device[2]);
315 + platform_device_register(&avila_hss_device[3]);
317 + platform_device_register(&avila_pcm_device[0]);
318 + platform_device_register(&avila_pcm_device[1]);
319 + platform_device_register(&avila_pcm_device[2]);
320 + platform_device_register(&avila_pcm_device[3]);
323 +static void __init avila_gw23xx_setup(void)
326 + platform_device_register(&avila_npeb_device);
327 + platform_device_register(&avila_npec_device);
329 - avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
330 - avila_flash_resource.end =
331 - IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
332 + platform_device_register(&avila_gpio_leds_device);
335 - platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
336 +static void __init avila_gw2342_setup(void)
338 + platform_device_register(&avila_npeb_device);
339 + platform_device_register(&avila_npec_device);
341 + platform_device_register(&avila_gpio_leds_device);
343 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
344 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
346 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
347 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
349 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
350 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
352 + platform_device_register(&avila_pata);
355 +static void __init avila_gw2345_setup(void)
357 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
358 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
359 + platform_device_register(&avila_npeb_device);
361 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
362 + platform_device_register(&avila_npec_device);
364 + platform_device_register(&avila_gpio_leds_device);
366 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
367 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
369 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
370 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
372 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
373 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
375 + platform_device_register(&avila_pata);
378 +static void __init avila_gw2347_setup(void)
380 + platform_device_register(&avila_npeb_device);
382 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
383 + platform_device_register(&avila_gpio_leds_device);
386 +static void __init avila_gw2348_setup(void)
388 + platform_device_register(&avila_npeb_device);
389 + platform_device_register(&avila_npec_device);
391 + platform_device_register(&avila_gpio_leds_device);
393 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
394 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
395 @@ -159,8 +452,335 @@
396 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
398 platform_device_register(&avila_pata);
401 +static void __init avila_gw2353_setup(void)
403 + platform_device_register(&avila_npeb_device);
404 + platform_device_register(&avila_gpio_leds_device);
407 +static void __init avila_gw2355_setup(void)
409 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
410 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
411 + platform_device_register(&avila_npeb_device);
413 + avila_npec_data.phy = 16;
414 + platform_device_register(&avila_npec_device);
416 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
417 + platform_device_register(&avila_gpio_leds_device);
419 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
420 + avila_latch_leds[0].name = "RXD";
421 + avila_latch_leds[1].name = "TXD";
422 + avila_latch_leds[2].name = "POL";
423 + avila_latch_leds[3].name = "LNK";
424 + avila_latch_leds[4].name = "ERR";
425 + avila_latch_leds_data.num_leds = 5;
426 + avila_latch_leds_data.mem = 0x54000000;
427 + platform_device_register(&avila_latch_leds_device);
429 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
430 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
432 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
433 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
435 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
436 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
438 + platform_device_register(&avila_pata);
441 +static void __init avila_gw2357_setup(void)
443 + platform_device_register(&avila_npeb_device);
445 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
446 + platform_device_register(&avila_gpio_leds_device);
448 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
449 + platform_device_register(&avila_latch_leds_device);
452 +static void __init avila_gw2365_setup(void)
454 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
456 + *IXP4XX_EXP_CS4 = 0xBFFF3C43;
457 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_EDGE_RISING);
458 + avila_optional_uart_data[0].mapbase = 0x54000000;
459 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x54000000, 0x0fff);
460 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO0;
462 + *IXP4XX_EXP_CS5 = 0xBFFF3C43;
463 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_EDGE_RISING);
464 + avila_optional_uart_data[1].mapbase = 0x55000000;
465 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x55000000, 0x0fff);
466 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO1;
468 + *IXP4XX_EXP_CS6 = 0xBFFF3C43;
469 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
470 + avila_optional_uart_data[2].mapbase = 0x56000000;
471 + avila_optional_uart_data[2].membase = (void __iomem *)ioremap(0x56000000, 0x0fff);
472 + avila_optional_uart_data[2].irq = IRQ_IXP4XX_GPIO2;
474 + *IXP4XX_EXP_CS7 = 0xBFFF3C43;
475 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
476 + avila_optional_uart_data[3].mapbase = 0x57000000;
477 + avila_optional_uart_data[3].membase = (void __iomem *)ioremap(0x57000000, 0x0fff);
478 + avila_optional_uart_data[3].irq = IRQ_IXP4XX_GPIO3;
480 + platform_device_register(&avila_optional_uart);
482 + avila_npeb_data.phy = 1;
483 + platform_device_register(&avila_npeb_device);
485 + avila_npec_data.phy = 2;
486 + platform_device_register(&avila_npec_device);
488 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
489 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
491 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
492 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
494 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
495 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
497 + platform_device_register(&avila_pata);
499 + avila_gpio_leds[0].gpio = 109;
500 + avila_gpio_leds_data.num_leds = 5;
501 + platform_device_register(&avila_gpio_leds_device);
503 + setup_audio_devices();
506 +static void __init avila_gw2369_setup(void)
508 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
510 + avila_npeb_data.phy = 1;
511 + platform_device_register(&avila_npeb_device);
513 + avila_npec_data.phy = 2;
514 + platform_device_register(&avila_npec_device);
516 + setup_audio_devices();
519 +static void __init avila_gw2370_setup(void)
521 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
523 + avila_npeb_data.phy = 5;
524 + platform_device_register(&avila_npeb_device);
526 + avila_npec_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
527 + avila_npec_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
528 + platform_device_register(&avila_npec_device);
530 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
531 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
532 + avila_optional_uart_data[0].mapbase = 0x52000000;
533 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
534 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO2;
536 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
537 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
538 + avila_optional_uart_data[1].mapbase = 0x53000000;
539 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53000000, 0x0fff);
540 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO3;
542 + avila_optional_uart.num_resources = 2;
544 + platform_device_register(&avila_optional_uart);
546 + avila_gpio_leds[0].gpio = 101;
547 + platform_device_register(&avila_gpio_leds_device);
549 + setup_audio_devices();
552 +static void __init avila_gw2375_setup(void)
554 + avila_npeb_data.phy = 1;
555 + platform_device_register(&avila_npeb_device);
557 + avila_npec_data.phy = 2;
558 + platform_device_register(&avila_npec_device);
560 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
561 + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_EDGE_RISING);
562 + avila_optional_uart_data[0].mapbase = 0x52000000;
563 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
564 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO10;
566 + avila_optional_uart.num_resources = 1;
568 + platform_device_register(&avila_optional_uart);
570 + setup_audio_devices();
574 +static struct avila_board_info avila_boards[] __initdata = {
577 + .setup = avila_gw2342_setup,
580 + .setup = avila_gw2345_setup,
583 + .setup = avila_gw2347_setup,
586 + .setup = avila_gw2348_setup,
589 + .setup = avila_gw2353_setup,
592 + .setup = avila_gw2355_setup,
595 + .setup = avila_gw2357_setup,
598 + .setup = avila_gw2365_setup,
601 + .setup = avila_gw2369_setup,
604 + .setup = avila_gw2370_setup,
607 + .setup = avila_gw2369_setup,
610 + .setup = avila_gw2375_setup,
614 +static struct avila_board_info * __init avila_find_board_info(char *model)
619 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
620 + struct avila_board_info *info = &avila_boards[i];
621 + if (strcmp(info->model, model) == 0)
628 +static struct memory_accessor *at24_mem_acc;
630 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
632 + char mac_addr[ETH_ALEN];
635 + at24_mem_acc = mem_acc;
637 + /* Read MAC addresses */
638 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
639 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
641 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
642 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
645 + /* Read the first 6 bytes of the model number */
646 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
647 + avila_info = avila_find_board_info(model);
652 +static struct at24_platform_data avila_eeprom_info = {
655 +// .flags = AT24_FLAG_READONLY,
656 + .setup = at24_setup,
659 +static struct pca953x_platform_data avila_pca_data = {
663 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
665 + I2C_BOARD_INFO("ds1672", 0x68),
668 + I2C_BOARD_INFO("gsp", 0x29),
671 + I2C_BOARD_INFO("pca9555", 0x23),
672 + .platform_data = &avila_pca_data,
675 + I2C_BOARD_INFO("ad7418", 0x28),
678 + I2C_BOARD_INFO("24c08", 0x51),
679 + .platform_data = &avila_eeprom_info
682 + I2C_BOARD_INFO("tlv320aic33", 0x1b),
685 + I2C_BOARD_INFO("tlv320aic33", 0x1a),
688 + I2C_BOARD_INFO("tlv320aic33", 0x19),
691 + I2C_BOARD_INFO("tlv320aic33", 0x18),
695 +static void __init avila_init(void)
699 + platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
701 + i2c_register_board_info(0, avila_i2c_board_info,
702 + ARRAY_SIZE(avila_i2c_board_info));
705 +static int __init avila_model_setup(void)
707 + if (!machine_is_avila())
710 + /* default 16MB flash */
711 + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
712 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
715 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
716 + avila_info->model);
717 + avila_info->setup();
719 + printk(KERN_INFO "Unknown/missing Avila model number"
720 + " -- defaults will be used\n");
721 + avila_gw23xx_setup();
723 + platform_device_register(&avila_flash);
727 +late_initcall(avila_model_setup);
729 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
730 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */