1 --- a/arch/arm/mach-ixp4xx/avila-setup.c
2 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
4 #include <linux/kernel.h>
5 #include <linux/init.h>
6 #include <linux/device.h>
7 +#include <linux/if_ether.h>
8 +#include <linux/socket.h>
9 +#include <linux/netdevice.h>
10 #include <linux/serial.h>
11 #include <linux/tty.h>
12 #include <linux/serial_8250.h>
13 +#include <linux/i2c.h>
14 +#include <linux/i2c/at24.h>
15 +#include <linux/leds.h>
16 +#include <linux/i2c/pca953x.h>
17 #include <linux/i2c-gpio.h>
18 #include <asm/types.h>
19 #include <asm/setup.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/flash.h>
24 +#include <linux/irq.h>
26 #define AVILA_SDA_PIN 7
27 #define AVILA_SCL_PIN 6
30 +#define AVILA_GW23XX_LED_USER_GPIO 3
31 +#define AVILA_GW23X7_LED_USER_GPIO 4
33 +/* gpio mask used by platform device */
34 +#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
36 +struct avila_board_info {
37 + unsigned char *model;
38 + void (*setup)(void);
41 +static struct avila_board_info *avila_info __initdata;
43 static struct flash_platform_data avila_flash_data = {
44 .map_name = "cfi_probe",
46 @@ -105,14 +127,69 @@ static struct platform_device avila_uart
47 .resource = avila_uart_resources
50 -static struct resource avila_pata_resources[] = {
51 +static struct resource avila_optional_uart_resources[] = {
53 - .flags = IORESOURCE_MEM
55 + .start = 0x54000000,
57 + .flags = IORESOURCE_MEM
59 + .start = 0x55000000,
61 + .flags = IORESOURCE_MEM
63 + .start = 0x56000000,
65 + .flags = IORESOURCE_MEM
67 + .start = 0x57000000,
69 + .flags = IORESOURCE_MEM
73 +static struct plat_serial8250_port avila_optional_uart_data[] = {
75 - .flags = IORESOURCE_MEM,
76 + .flags = UPF_BOOT_AUTOCONF,
79 + .uartclk = 18432000,
82 + .flags = UPF_BOOT_AUTOCONF,
85 + .uartclk = 18432000,
88 + .flags = UPF_BOOT_AUTOCONF,
91 + .uartclk = 18432000,
94 + .flags = UPF_BOOT_AUTOCONF,
97 + .uartclk = 18432000,
103 +static struct platform_device avila_optional_uart = {
104 + .name = "serial8250",
105 + .id = PLAT8250_DEV_PLATFORM1,
106 + .dev.platform_data = avila_optional_uart_data,
107 + .num_resources = 4,
108 + .resource = avila_optional_uart_resources,
111 +static struct resource avila_pata_resources[] = {
113 + .flags = IORESOURCE_MEM
115 + .flags = IORESOURCE_MEM,
118 .start = IRQ_IXP4XX_GPIO12,
119 .end = IRQ_IXP4XX_GPIO12,
120 @@ -133,21 +210,275 @@ static struct platform_device avila_pata
121 .resource = avila_pata_resources,
124 +/* Built-in 10/100 Ethernet MAC interfaces */
125 +static struct eth_plat_info avila_npeb_data = {
131 +static struct eth_plat_info avila_npec_data = {
137 +static struct platform_device avila_npeb_device = {
138 + .name = "ixp4xx_eth",
139 + .id = IXP4XX_ETH_NPEB,
140 + .dev.platform_data = &avila_npeb_data,
143 +static struct platform_device avila_npec_device = {
144 + .name = "ixp4xx_eth",
145 + .id = IXP4XX_ETH_NPEC,
146 + .dev.platform_data = &avila_npec_data,
149 +static struct gpio_led avila_gpio_leds[] = {
151 + .name = "user", /* green led */
152 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
156 + .name = "radio1", /* green led */
161 + .name = "radio2", /* green led */
166 + .name = "radio3", /* green led */
171 + .name = "radio4", /* green led */
178 +static struct gpio_led_platform_data avila_gpio_leds_data = {
180 + .leds = avila_gpio_leds,
183 +static struct platform_device avila_gpio_leds_device = {
184 + .name = "leds-gpio",
186 + .dev.platform_data = &avila_gpio_leds_data,
189 +static struct latch_led avila_latch_leds[] = {
191 + .name = "led0", /* green led */
195 + .name = "led1", /* green led */
199 + .name = "led2", /* green led */
203 + .name = "led3", /* green led */
207 + .name = "led4", /* green led */
211 + .name = "led5", /* green led */
215 + .name = "led6", /* green led */
219 + .name = "led7", /* green led */
224 +static struct latch_led_platform_data avila_latch_leds_data = {
226 + .leds = avila_latch_leds,
230 +static struct platform_device avila_latch_leds_device = {
231 + .name = "leds-latch",
233 + .dev.platform_data = &avila_latch_leds_data,
236 static struct platform_device *avila_devices[] __initdata = {
242 -static void __init avila_init(void)
247 +static struct platform_device avila_hss_device[] = {
249 + .name = "gw_avila_hss",
252 + .name = "gw_avila_hss",
255 + .name = "gw_avila_hss",
258 + .name = "gw_avila_hss",
263 +static struct platform_device avila_pcm_device[] = {
265 + .name = "gw_avila-audio",
268 + .name = "gw_avila-audio",
271 + .name = "gw_avila-audio",
274 + .name = "gw_avila-audio",
279 +static void setup_audio_devices(void) {
280 + platform_device_register(&avila_hss_device[0]);
281 + platform_device_register(&avila_hss_device[1]);
282 + platform_device_register(&avila_hss_device[2]);
283 + platform_device_register(&avila_hss_device[3]);
285 + platform_device_register(&avila_pcm_device[0]);
286 + platform_device_register(&avila_pcm_device[1]);
287 + platform_device_register(&avila_pcm_device[2]);
288 + platform_device_register(&avila_pcm_device[3]);
291 +static void __init avila_gw23xx_setup(void)
294 + platform_device_register(&avila_npeb_device);
295 + platform_device_register(&avila_npec_device);
297 - avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
298 - avila_flash_resource.end =
299 - IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
300 + platform_device_register(&avila_gpio_leds_device);
303 - platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
304 +static void __init avila_gw2342_setup(void)
306 + platform_device_register(&avila_npeb_device);
307 + platform_device_register(&avila_npec_device);
309 + platform_device_register(&avila_gpio_leds_device);
311 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
312 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
314 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
315 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
317 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
318 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
320 + platform_device_register(&avila_pata);
323 +static void __init avila_gw2345_setup(void)
325 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
326 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
327 + platform_device_register(&avila_npeb_device);
329 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
330 + platform_device_register(&avila_npec_device);
332 + platform_device_register(&avila_gpio_leds_device);
334 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
335 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
337 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
338 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
340 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
341 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
343 + platform_device_register(&avila_pata);
346 +static void __init avila_gw2347_setup(void)
348 + platform_device_register(&avila_npeb_device);
350 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
351 + platform_device_register(&avila_gpio_leds_device);
354 +static void __init avila_gw2348_setup(void)
356 + platform_device_register(&avila_npeb_device);
357 + platform_device_register(&avila_npec_device);
359 + platform_device_register(&avila_gpio_leds_device);
361 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
362 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
364 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
365 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
367 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
368 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
370 + platform_device_register(&avila_pata);
373 +static void __init avila_gw2353_setup(void)
375 + platform_device_register(&avila_npeb_device);
376 + platform_device_register(&avila_gpio_leds_device);
379 +static void __init avila_gw2355_setup(void)
381 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
382 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
383 + platform_device_register(&avila_npeb_device);
385 + avila_npec_data.phy = 16;
386 + platform_device_register(&avila_npec_device);
388 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
389 + platform_device_register(&avila_gpio_leds_device);
391 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
392 + avila_latch_leds[0].name = "RXD";
393 + avila_latch_leds[1].name = "TXD";
394 + avila_latch_leds[2].name = "POL";
395 + avila_latch_leds[3].name = "LNK";
396 + avila_latch_leds[4].name = "ERR";
397 + avila_latch_leds_data.num_leds = 5;
398 + avila_latch_leds_data.mem = 0x54000000;
399 + platform_device_register(&avila_latch_leds_device);
401 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
402 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
403 @@ -159,8 +495,272 @@ static void __init avila_init(void)
404 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
406 platform_device_register(&avila_pata);
409 +static void __init avila_gw2357_setup(void)
411 + platform_device_register(&avila_npeb_device);
413 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
414 + platform_device_register(&avila_gpio_leds_device);
416 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
417 + platform_device_register(&avila_latch_leds_device);
420 +static void __init avila_gw2365_setup(void)
422 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
424 + *IXP4XX_EXP_CS4 = 0xBFFF3C43;
425 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_EDGE_RISING);
426 + avila_optional_uart_data[0].mapbase = 0x54000000;
427 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x54000000, 0x0fff);
428 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO0;
430 + *IXP4XX_EXP_CS5 = 0xBFFF3C43;
431 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_EDGE_RISING);
432 + avila_optional_uart_data[1].mapbase = 0x55000000;
433 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x55000000, 0x0fff);
434 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO1;
436 + *IXP4XX_EXP_CS6 = 0xBFFF3C43;
437 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
438 + avila_optional_uart_data[2].mapbase = 0x56000000;
439 + avila_optional_uart_data[2].membase = (void __iomem *)ioremap(0x56000000, 0x0fff);
440 + avila_optional_uart_data[2].irq = IRQ_IXP4XX_GPIO2;
442 + *IXP4XX_EXP_CS7 = 0xBFFF3C43;
443 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
444 + avila_optional_uart_data[3].mapbase = 0x57000000;
445 + avila_optional_uart_data[3].membase = (void __iomem *)ioremap(0x57000000, 0x0fff);
446 + avila_optional_uart_data[3].irq = IRQ_IXP4XX_GPIO3;
448 + platform_device_register(&avila_optional_uart);
450 + avila_npeb_data.phy = 1;
451 + platform_device_register(&avila_npeb_device);
453 + avila_npec_data.phy = 2;
454 + platform_device_register(&avila_npec_device);
456 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
457 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
459 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
460 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
462 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
463 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
465 + platform_device_register(&avila_pata);
467 + avila_gpio_leds[0].gpio = 109;
468 + avila_gpio_leds_data.num_leds = 5;
469 + platform_device_register(&avila_gpio_leds_device);
471 + setup_audio_devices();
474 +static void __init avila_gw2369_setup(void)
476 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
478 + avila_npeb_data.phy = 1;
479 + platform_device_register(&avila_npeb_device);
481 + avila_npec_data.phy = 2;
482 + platform_device_register(&avila_npec_device);
484 + setup_audio_devices();
487 +static void __init avila_gw2370_setup(void)
489 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
491 + avila_npeb_data.phy = 5;
492 + platform_device_register(&avila_npeb_device);
494 + avila_npec_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
495 + avila_npec_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
496 + platform_device_register(&avila_npec_device);
498 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
499 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
500 + avila_optional_uart_data[0].mapbase = 0x52000000;
501 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
502 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO2;
504 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
505 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
506 + avila_optional_uart_data[1].mapbase = 0x53000000;
507 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53000000, 0x0fff);
508 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO3;
510 + avila_optional_uart.num_resources = 2;
512 + platform_device_register(&avila_optional_uart);
514 + avila_gpio_leds[0].gpio = 101;
515 + platform_device_register(&avila_gpio_leds_device);
517 + setup_audio_devices();
522 +static struct avila_board_info avila_boards[] __initdata = {
525 + .setup = avila_gw2342_setup,
528 + .setup = avila_gw2345_setup,
531 + .setup = avila_gw2347_setup,
534 + .setup = avila_gw2348_setup,
537 + .setup = avila_gw2353_setup,
540 + .setup = avila_gw2355_setup,
543 + .setup = avila_gw2357_setup,
546 + .setup = avila_gw2365_setup,
549 + .setup = avila_gw2369_setup,
552 + .setup = avila_gw2370_setup,
555 + .setup = avila_gw2369_setup,
559 +static struct avila_board_info * __init avila_find_board_info(char *model)
564 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
565 + struct avila_board_info *info = &avila_boards[i];
566 + if (strcmp(info->model, model) == 0)
573 +static struct memory_accessor *at24_mem_acc;
575 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
577 + char mac_addr[ETH_ALEN];
580 + at24_mem_acc = mem_acc;
582 + /* Read MAC addresses */
583 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
584 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
586 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
587 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
590 + /* Read the first 6 bytes of the model number */
591 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
592 + avila_info = avila_find_board_info(model);
597 +static struct at24_platform_data avila_eeprom_info = {
600 +// .flags = AT24_FLAG_READONLY,
601 + .setup = at24_setup,
604 +static struct pca953x_platform_data avila_pca_data = {
608 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
610 + I2C_BOARD_INFO("ds1672", 0x68),
613 + I2C_BOARD_INFO("gsp", 0x29),
616 + I2C_BOARD_INFO("pca9555", 0x23),
617 + .platform_data = &avila_pca_data,
620 + I2C_BOARD_INFO("ad7418", 0x28),
623 + I2C_BOARD_INFO("24c08", 0x51),
624 + .platform_data = &avila_eeprom_info
627 + I2C_BOARD_INFO("tlv320aic33", 0x1b),
630 + I2C_BOARD_INFO("tlv320aic33", 0x1a),
633 + I2C_BOARD_INFO("tlv320aic33", 0x19),
636 + I2C_BOARD_INFO("tlv320aic33", 0x18),
640 +static void __init avila_init(void)
644 + platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
646 + i2c_register_board_info(0, avila_i2c_board_info,
647 + ARRAY_SIZE(avila_i2c_board_info));
650 +static int __init avila_model_setup(void)
652 + if (!machine_is_avila())
655 + /* default 16MB flash */
656 + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
657 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
660 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
661 + avila_info->model);
662 + avila_info->setup();
664 + printk(KERN_INFO "Unknown/missing Avila model number"
665 + " -- defaults will be used\n");
666 + avila_gw23xx_setup();
668 + platform_device_register(&avila_flash);
672 +late_initcall(avila_model_setup);
674 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
675 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
676 --- a/arch/arm/mach-ixp4xx/avila-pci.c
677 +++ b/arch/arm/mach-ixp4xx/avila-pci.c
679 #include <mach/hardware.h>
680 #include <asm/mach-types.h>
682 -#define AVILA_MAX_DEV 4
683 -#define LOFT_MAX_DEV 6
684 +#define AVILA_MAX_DEV 6
688 /* PCI controller GPIO to IRQ pin mappings */
689 @@ -55,9 +55,7 @@ static int __init avila_map_irq(const st
690 IXP4XX_GPIO_IRQ(INTD)
694 - slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
695 - pin >= 1 && pin <= IRQ_LINES)
696 + if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
697 return pci_irq_table[(slot + pin - 2) % 4];