1 --- a/arch/arm/mach-ixp4xx/avila-pci.c
2 +++ b/arch/arm/mach-ixp4xx/avila-pci.c
4 #include <mach/hardware.h>
5 #include <asm/mach-types.h>
7 -#define AVILA_MAX_DEV 4
8 -#define LOFT_MAX_DEV 6
9 +#define AVILA_MAX_DEV 6
13 /* PCI controller GPIO to IRQ pin mappings */
14 @@ -55,9 +55,7 @@ static int __init avila_map_irq(const st
19 - slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
20 - pin >= 1 && pin <= IRQ_LINES)
21 + if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
22 return pci_irq_table[(slot + pin - 2) % 4];
25 --- a/arch/arm/mach-ixp4xx/avila-setup.c
26 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
28 #include <linux/kernel.h>
29 #include <linux/init.h>
30 #include <linux/device.h>
31 +#include <linux/if_ether.h>
32 +#include <linux/socket.h>
33 +#include <linux/netdevice.h>
34 #include <linux/serial.h>
35 #include <linux/tty.h>
36 #include <linux/serial_8250.h>
37 +#include <linux/i2c.h>
38 +#include <linux/i2c/at24.h>
39 +#include <linux/leds.h>
40 +#include <linux/i2c/pca953x.h>
41 #include <linux/i2c-gpio.h>
42 #include <asm/types.h>
43 #include <asm/setup.h>
46 #include <asm/mach/arch.h>
47 #include <asm/mach/flash.h>
48 +#include <linux/irq.h>
50 #define AVILA_SDA_PIN 7
51 #define AVILA_SCL_PIN 6
54 +#define AVILA_GW23XX_LED_USER_GPIO 3
55 +#define AVILA_GW23X7_LED_USER_GPIO 4
57 +/* gpio mask used by platform device */
58 +#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
60 +struct avila_board_info {
61 + unsigned char *model;
62 + void (*setup)(void);
65 +static struct avila_board_info *avila_info __initdata;
67 static struct flash_platform_data avila_flash_data = {
68 .map_name = "cfi_probe",
70 @@ -105,14 +127,69 @@ static struct platform_device avila_uart
71 .resource = avila_uart_resources
74 -static struct resource avila_pata_resources[] = {
75 +static struct resource avila_optional_uart_resources[] = {
77 - .flags = IORESOURCE_MEM
79 + .start = 0x54000000,
81 + .flags = IORESOURCE_MEM
83 + .start = 0x55000000,
85 + .flags = IORESOURCE_MEM
87 + .start = 0x56000000,
89 + .flags = IORESOURCE_MEM
91 + .start = 0x57000000,
93 + .flags = IORESOURCE_MEM
97 +static struct plat_serial8250_port avila_optional_uart_data[] = {
99 - .flags = IORESOURCE_MEM,
100 + .flags = UPF_BOOT_AUTOCONF,
101 + .iotype = UPIO_MEM,
103 + .uartclk = 18432000,
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,
127 +static struct platform_device avila_optional_uart = {
128 + .name = "serial8250",
129 + .id = PLAT8250_DEV_PLATFORM1,
130 + .dev.platform_data = avila_optional_uart_data,
131 + .num_resources = 4,
132 + .resource = avila_optional_uart_resources,
135 +static struct resource avila_pata_resources[] = {
137 + .flags = IORESOURCE_MEM
139 + .flags = IORESOURCE_MEM,
142 .start = IRQ_IXP4XX_GPIO12,
143 .end = IRQ_IXP4XX_GPIO12,
144 @@ -133,21 +210,210 @@ static struct platform_device avila_pata
145 .resource = avila_pata_resources,
148 +/* Built-in 10/100 Ethernet MAC interfaces */
149 +static struct eth_plat_info avila_npeb_data = {
155 +static struct eth_plat_info avila_npec_data = {
161 +static struct platform_device avila_npeb_device = {
162 + .name = "ixp4xx_eth",
163 + .id = IXP4XX_ETH_NPEB,
164 + .dev.platform_data = &avila_npeb_data,
165 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
168 +static struct platform_device avila_npec_device = {
169 + .name = "ixp4xx_eth",
170 + .id = IXP4XX_ETH_NPEC,
171 + .dev.platform_data = &avila_npec_data,
172 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
175 +static struct gpio_led avila_gpio_leds[] = {
177 + .name = "user", /* green led */
178 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
182 + .name = "radio1", /* green led */
187 + .name = "radio2", /* green led */
192 + .name = "radio3", /* green led */
197 + .name = "radio4", /* green led */
204 +static struct gpio_led_platform_data avila_gpio_leds_data = {
206 + .leds = avila_gpio_leds,
209 +static struct platform_device avila_gpio_leds_device = {
210 + .name = "leds-gpio",
212 + .dev.platform_data = &avila_gpio_leds_data,
215 +static struct latch_led avila_latch_leds[] = {
217 + .name = "led0", /* green led */
221 + .name = "led1", /* green led */
225 + .name = "led2", /* green led */
229 + .name = "led3", /* green led */
233 + .name = "led4", /* green led */
237 + .name = "led5", /* green led */
241 + .name = "led6", /* green led */
245 + .name = "led7", /* green led */
250 +static struct latch_led_platform_data avila_latch_leds_data = {
252 + .leds = avila_latch_leds,
256 +static struct platform_device avila_latch_leds_device = {
257 + .name = "leds-latch",
259 + .dev.platform_data = &avila_latch_leds_data,
262 static struct platform_device *avila_devices[] __initdata = {
268 -static void __init avila_init(void)
273 +static struct platform_device avila_hss_device[] = {
275 + .name = "gw_avila_hss",
278 + .name = "gw_avila_hss",
281 + .name = "gw_avila_hss",
284 + .name = "gw_avila_hss",
289 +static struct platform_device avila_pcm_device[] = {
291 + .name = "gw_avila-audio",
294 + .name = "gw_avila-audio",
297 + .name = "gw_avila-audio",
300 + .name = "gw_avila-audio",
305 +static void setup_audio_devices(void) {
306 + platform_device_register(&avila_hss_device[0]);
307 + platform_device_register(&avila_hss_device[1]);
308 + platform_device_register(&avila_hss_device[2]);
309 + platform_device_register(&avila_hss_device[3]);
311 + platform_device_register(&avila_pcm_device[0]);
312 + platform_device_register(&avila_pcm_device[1]);
313 + platform_device_register(&avila_pcm_device[2]);
314 + platform_device_register(&avila_pcm_device[3]);
317 +static void __init avila_gw23xx_setup(void)
320 + platform_device_register(&avila_npeb_device);
321 + platform_device_register(&avila_npec_device);
323 - avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
324 - avila_flash_resource.end =
325 - IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
326 + platform_device_register(&avila_gpio_leds_device);
329 - platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
330 +static void __init avila_gw2342_setup(void)
332 + platform_device_register(&avila_npeb_device);
333 + platform_device_register(&avila_npec_device);
335 + platform_device_register(&avila_gpio_leds_device);
337 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
338 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
340 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
341 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
343 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
344 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
346 + platform_device_register(&avila_pata);
349 +static void __init avila_gw2345_setup(void)
351 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
352 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
353 + platform_device_register(&avila_npeb_device);
355 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
356 + platform_device_register(&avila_npec_device);
358 + platform_device_register(&avila_gpio_leds_device);
360 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
361 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
362 @@ -159,8 +425,339 @@ static void __init avila_init(void)
363 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
365 platform_device_register(&avila_pata);
368 +static void __init avila_gw2347_setup(void)
370 + platform_device_register(&avila_npeb_device);
372 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
373 + platform_device_register(&avila_gpio_leds_device);
376 +static void __init avila_gw2348_setup(void)
378 + platform_device_register(&avila_npeb_device);
379 + platform_device_register(&avila_npec_device);
381 + platform_device_register(&avila_gpio_leds_device);
383 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
384 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
386 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
387 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
389 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
390 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
392 + platform_device_register(&avila_pata);
395 +static void __init avila_gw2353_setup(void)
397 + platform_device_register(&avila_npeb_device);
398 + platform_device_register(&avila_gpio_leds_device);
401 +static void __init avila_gw2355_setup(void)
403 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
404 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
405 + platform_device_register(&avila_npeb_device);
407 + avila_npec_data.phy = 16;
408 + platform_device_register(&avila_npec_device);
410 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
411 + platform_device_register(&avila_gpio_leds_device);
413 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
414 + avila_latch_leds[0].name = "RXD";
415 + avila_latch_leds[1].name = "TXD";
416 + avila_latch_leds[2].name = "POL";
417 + avila_latch_leds[3].name = "LNK";
418 + avila_latch_leds[4].name = "ERR";
419 + avila_latch_leds_data.num_leds = 5;
420 + avila_latch_leds_data.mem = 0x54000000;
421 + platform_device_register(&avila_latch_leds_device);
423 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
424 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
426 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
427 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
429 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
430 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
432 + platform_device_register(&avila_pata);
435 +static void __init avila_gw2357_setup(void)
437 + platform_device_register(&avila_npeb_device);
439 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
440 + platform_device_register(&avila_gpio_leds_device);
442 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
443 + platform_device_register(&avila_latch_leds_device);
446 +static void __init avila_gw2365_setup(void)
448 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
450 + *IXP4XX_EXP_CS4 = 0xBFFF3C43;
451 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_EDGE_RISING);
452 + avila_optional_uart_data[0].mapbase = 0x54000000;
453 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x54000000, 0x0fff);
454 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO0;
456 + *IXP4XX_EXP_CS5 = 0xBFFF3C43;
457 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_EDGE_RISING);
458 + avila_optional_uart_data[1].mapbase = 0x55000000;
459 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x55000000, 0x0fff);
460 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO1;
462 + *IXP4XX_EXP_CS6 = 0xBFFF3C43;
463 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
464 + avila_optional_uart_data[2].mapbase = 0x56000000;
465 + avila_optional_uart_data[2].membase = (void __iomem *)ioremap(0x56000000, 0x0fff);
466 + avila_optional_uart_data[2].irq = IRQ_IXP4XX_GPIO2;
468 + *IXP4XX_EXP_CS7 = 0xBFFF3C43;
469 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
470 + avila_optional_uart_data[3].mapbase = 0x57000000;
471 + avila_optional_uart_data[3].membase = (void __iomem *)ioremap(0x57000000, 0x0fff);
472 + avila_optional_uart_data[3].irq = IRQ_IXP4XX_GPIO3;
474 + platform_device_register(&avila_optional_uart);
476 + avila_npeb_data.phy = 1;
477 + platform_device_register(&avila_npeb_device);
479 + avila_npec_data.phy = 2;
480 + platform_device_register(&avila_npec_device);
482 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
483 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
485 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
486 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
488 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
489 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
491 + platform_device_register(&avila_pata);
493 + avila_gpio_leds[0].gpio = 109;
494 + avila_gpio_leds_data.num_leds = 5;
495 + platform_device_register(&avila_gpio_leds_device);
497 + setup_audio_devices();
500 +static void __init avila_gw2369_setup(void)
502 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
504 + avila_npeb_data.phy = 1;
505 + platform_device_register(&avila_npeb_device);
507 + avila_npec_data.phy = 2;
508 + platform_device_register(&avila_npec_device);
510 + setup_audio_devices();
513 +static void __init avila_gw2370_setup(void)
515 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
517 + avila_npeb_data.phy = 5;
518 + platform_device_register(&avila_npeb_device);
520 + avila_npec_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
521 + avila_npec_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
522 + platform_device_register(&avila_npec_device);
524 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
525 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
526 + avila_optional_uart_data[0].mapbase = 0x52000000;
527 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
528 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO2;
530 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
531 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
532 + avila_optional_uart_data[1].mapbase = 0x53000000;
533 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53000000, 0x0fff);
534 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO3;
536 + avila_optional_uart.num_resources = 2;
538 + platform_device_register(&avila_optional_uart);
540 + avila_gpio_leds[0].gpio = 101;
541 + platform_device_register(&avila_gpio_leds_device);
543 + setup_audio_devices();
548 +static struct avila_board_info avila_boards[] __initdata = {
551 + .setup = avila_gw2342_setup,
554 + .setup = avila_gw2345_setup,
557 + .setup = avila_gw2347_setup,
560 + .setup = avila_gw2348_setup,
563 + .setup = avila_gw2353_setup,
566 + .setup = avila_gw2355_setup,
569 + .setup = avila_gw2357_setup,
572 + .setup = avila_gw2365_setup,
575 + .setup = avila_gw2369_setup,
578 + .setup = avila_gw2370_setup,
581 + .setup = avila_gw2369_setup,
585 +static struct avila_board_info * __init avila_find_board_info(char *model)
590 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
591 + struct avila_board_info *info = &avila_boards[i];
592 + if (strcmp(info->model, model) == 0)
599 +static struct memory_accessor *at24_mem_acc;
601 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
603 + char mac_addr[ETH_ALEN];
606 + at24_mem_acc = mem_acc;
608 + /* Read MAC addresses */
609 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
610 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
612 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
613 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
616 + /* Read the first 6 bytes of the model number */
617 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
618 + avila_info = avila_find_board_info(model);
623 +static struct at24_platform_data avila_eeprom_info = {
626 +// .flags = AT24_FLAG_READONLY,
627 + .setup = at24_setup,
630 +static struct pca953x_platform_data avila_pca_data = {
634 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
636 + I2C_BOARD_INFO("ds1672", 0x68),
639 + I2C_BOARD_INFO("gsp", 0x29),
642 + I2C_BOARD_INFO("pca9555", 0x23),
643 + .platform_data = &avila_pca_data,
646 + I2C_BOARD_INFO("ad7418", 0x28),
649 + I2C_BOARD_INFO("24c08", 0x51),
650 + .platform_data = &avila_eeprom_info
653 + I2C_BOARD_INFO("tlv320aic33", 0x1b),
656 + I2C_BOARD_INFO("tlv320aic33", 0x1a),
659 + I2C_BOARD_INFO("tlv320aic33", 0x19),
662 + I2C_BOARD_INFO("tlv320aic33", 0x18),
666 +static void __init avila_init(void)
670 + platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
672 + i2c_register_board_info(0, avila_i2c_board_info,
673 + ARRAY_SIZE(avila_i2c_board_info));
676 +static int __init avila_model_setup(void)
678 + if (!machine_is_avila())
681 + /* default 16MB flash */
682 + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
683 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
686 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
687 + avila_info->model);
688 + avila_info->setup();
690 + printk(KERN_INFO "Unknown/missing Avila model number"
691 + " -- defaults will be used\n");
692 + avila_gw23xx_setup();
694 + platform_device_register(&avila_flash);
698 +late_initcall(avila_model_setup);
700 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
701 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */