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,280 @@ 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)
243 +static struct platform_device avila_gpio_dev = {
252 +static struct platform_device avila_hss_device[] = {
254 + .name = "gw_avila_hss",
257 + .name = "gw_avila_hss",
260 + .name = "gw_avila_hss",
263 + .name = "gw_avila_hss",
268 +static struct platform_device avila_pcm_device[] = {
270 + .name = "gw_avila-audio",
273 + .name = "gw_avila-audio",
276 + .name = "gw_avila-audio",
279 + .name = "gw_avila-audio",
284 +static void setup_audio_devices(void) {
285 + platform_device_register(&avila_hss_device[0]);
286 + platform_device_register(&avila_hss_device[1]);
287 + platform_device_register(&avila_hss_device[2]);
288 + platform_device_register(&avila_hss_device[3]);
290 + platform_device_register(&avila_pcm_device[0]);
291 + platform_device_register(&avila_pcm_device[1]);
292 + platform_device_register(&avila_pcm_device[2]);
293 + platform_device_register(&avila_pcm_device[3]);
296 +static void __init avila_gw23xx_setup(void)
299 + platform_device_register(&avila_npeb_device);
300 + platform_device_register(&avila_npec_device);
302 - avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
303 - avila_flash_resource.end =
304 - IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
305 + platform_device_register(&avila_gpio_leds_device);
308 - platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
309 +static void __init avila_gw2342_setup(void)
311 + platform_device_register(&avila_npeb_device);
312 + platform_device_register(&avila_npec_device);
314 + platform_device_register(&avila_gpio_leds_device);
316 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
317 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
319 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
320 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
322 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
323 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
325 + platform_device_register(&avila_pata);
328 +static void __init avila_gw2345_setup(void)
330 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
331 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
332 + platform_device_register(&avila_npeb_device);
334 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
335 + platform_device_register(&avila_npec_device);
337 + platform_device_register(&avila_gpio_leds_device);
339 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
340 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
342 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
343 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
345 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
346 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
348 + platform_device_register(&avila_pata);
351 +static void __init avila_gw2347_setup(void)
353 + platform_device_register(&avila_npeb_device);
355 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
356 + platform_device_register(&avila_gpio_leds_device);
359 +static void __init avila_gw2348_setup(void)
361 + platform_device_register(&avila_npeb_device);
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_gw2353_setup(void)
380 + platform_device_register(&avila_npeb_device);
381 + platform_device_register(&avila_gpio_leds_device);
384 +static void __init avila_gw2355_setup(void)
386 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
387 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
388 + platform_device_register(&avila_npeb_device);
390 + avila_npec_data.phy = 16;
391 + platform_device_register(&avila_npec_device);
393 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
394 + platform_device_register(&avila_gpio_leds_device);
396 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
397 + avila_latch_leds[0].name = "RXD";
398 + avila_latch_leds[1].name = "TXD";
399 + avila_latch_leds[2].name = "POL";
400 + avila_latch_leds[3].name = "LNK";
401 + avila_latch_leds[4].name = "ERR";
402 + avila_latch_leds_data.num_leds = 5;
403 + avila_latch_leds_data.mem = 0x54000000;
404 + platform_device_register(&avila_latch_leds_device);
406 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
407 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
408 @@ -159,8 +495,274 @@ static void __init avila_init(void)
409 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
411 platform_device_register(&avila_pata);
414 +static void __init avila_gw2357_setup(void)
416 + platform_device_register(&avila_npeb_device);
418 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
419 + platform_device_register(&avila_gpio_leds_device);
421 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
422 + platform_device_register(&avila_latch_leds_device);
425 +static void __init avila_gw2365_setup(void)
427 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
429 + *IXP4XX_EXP_CS4 = 0xBFFF3C43;
430 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_EDGE_RISING);
431 + avila_optional_uart_data[0].mapbase = 0x54000000;
432 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x54000000, 0x0fff);
433 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO0;
435 + *IXP4XX_EXP_CS5 = 0xBFFF3C43;
436 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_EDGE_RISING);
437 + avila_optional_uart_data[1].mapbase = 0x55000000;
438 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x55000000, 0x0fff);
439 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO1;
441 + *IXP4XX_EXP_CS6 = 0xBFFF3C43;
442 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
443 + avila_optional_uart_data[2].mapbase = 0x56000000;
444 + avila_optional_uart_data[2].membase = (void __iomem *)ioremap(0x56000000, 0x0fff);
445 + avila_optional_uart_data[2].irq = IRQ_IXP4XX_GPIO2;
447 + *IXP4XX_EXP_CS7 = 0xBFFF3C43;
448 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
449 + avila_optional_uart_data[3].mapbase = 0x57000000;
450 + avila_optional_uart_data[3].membase = (void __iomem *)ioremap(0x57000000, 0x0fff);
451 + avila_optional_uart_data[3].irq = IRQ_IXP4XX_GPIO3;
453 + platform_device_register(&avila_optional_uart);
455 + avila_npeb_data.phy = 1;
456 + platform_device_register(&avila_npeb_device);
458 + avila_npec_data.phy = 2;
459 + platform_device_register(&avila_npec_device);
461 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
462 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
464 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
465 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
467 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
468 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
470 + platform_device_register(&avila_pata);
472 + avila_gpio_leds[0].gpio = 109;
473 + avila_gpio_leds_data.num_leds = 5;
474 + platform_device_register(&avila_gpio_leds_device);
476 + setup_audio_devices();
479 +static void __init avila_gw2369_setup(void)
481 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
483 + avila_npeb_data.phy = 1;
484 + platform_device_register(&avila_npeb_device);
486 + avila_npec_data.phy = 2;
487 + platform_device_register(&avila_npec_device);
489 + setup_audio_devices();
492 +static void __init avila_gw2370_setup(void)
494 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
496 + avila_npeb_data.phy = 5;
497 + platform_device_register(&avila_npeb_device);
499 + avila_npec_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
500 + avila_npec_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
501 + platform_device_register(&avila_npec_device);
503 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
504 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
505 + avila_optional_uart_data[0].mapbase = 0x52000000;
506 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
507 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO2;
509 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
510 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
511 + avila_optional_uart_data[1].mapbase = 0x53000000;
512 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53000000, 0x0fff);
513 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO3;
515 + avila_optional_uart.num_resources = 2;
517 + platform_device_register(&avila_optional_uart);
519 + avila_gpio_leds[0].gpio = 101;
520 + platform_device_register(&avila_gpio_leds_device);
522 + setup_audio_devices();
527 +static struct avila_board_info avila_boards[] __initdata = {
530 + .setup = avila_gw2342_setup,
533 + .setup = avila_gw2345_setup,
536 + .setup = avila_gw2347_setup,
539 + .setup = avila_gw2348_setup,
542 + .setup = avila_gw2353_setup,
545 + .setup = avila_gw2355_setup,
548 + .setup = avila_gw2357_setup,
551 + .setup = avila_gw2365_setup,
554 + .setup = avila_gw2369_setup,
557 + .setup = avila_gw2370_setup,
560 + .setup = avila_gw2369_setup,
564 +static struct avila_board_info * __init avila_find_board_info(char *model)
569 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
570 + struct avila_board_info *info = &avila_boards[i];
571 + if (strcmp(info->model, model) == 0)
578 +static struct memory_accessor *at24_mem_acc;
580 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
582 + char mac_addr[ETH_ALEN];
585 + at24_mem_acc = mem_acc;
587 + /* Read MAC addresses */
588 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
589 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
591 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
592 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
595 + /* Read the first 6 bytes of the model number */
596 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
597 + avila_info = avila_find_board_info(model);
602 +static struct at24_platform_data avila_eeprom_info = {
605 +// .flags = AT24_FLAG_READONLY,
606 + .setup = at24_setup,
609 +static struct pca953x_platform_data avila_pca_data = {
613 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
615 + I2C_BOARD_INFO("ds1672", 0x68),
618 + I2C_BOARD_INFO("gsp", 0x29),
621 + I2C_BOARD_INFO("pca9555", 0x23),
622 + .platform_data = &avila_pca_data,
625 + I2C_BOARD_INFO("ad7418", 0x28),
628 + I2C_BOARD_INFO("24c08", 0x51),
629 + .platform_data = &avila_eeprom_info
632 + I2C_BOARD_INFO("tlv320aic33", 0x1b),
635 + I2C_BOARD_INFO("tlv320aic33", 0x1a),
638 + I2C_BOARD_INFO("tlv320aic33", 0x19),
641 + I2C_BOARD_INFO("tlv320aic33", 0x18),
645 +static void __init avila_init(void)
649 + platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
651 + i2c_register_board_info(0, avila_i2c_board_info,
652 + ARRAY_SIZE(avila_i2c_board_info));
654 + platform_device_register(&avila_gpio_dev);
657 +static int __init avila_model_setup(void)
659 + if (!machine_is_avila())
662 + /* default 16MB flash */
663 + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
664 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
667 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
668 + avila_info->model);
669 + avila_info->setup();
671 + printk(KERN_INFO "Unknown/missing Avila model number"
672 + " -- defaults will be used\n");
673 + avila_gw23xx_setup();
675 + platform_device_register(&avila_flash);
679 +late_initcall(avila_model_setup);
681 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
682 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
683 --- a/arch/arm/mach-ixp4xx/avila-pci.c
684 +++ b/arch/arm/mach-ixp4xx/avila-pci.c
686 #include <mach/hardware.h>
687 #include <asm/mach-types.h>
689 -#define AVILA_MAX_DEV 4
690 -#define LOFT_MAX_DEV 6
691 +#define AVILA_MAX_DEV 6
695 /* PCI controller GPIO to IRQ pin mappings */
696 @@ -55,9 +55,7 @@ static int __init avila_map_irq(const st
697 IXP4XX_GPIO_IRQ(INTD)
701 - slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
702 - pin >= 1 && pin <= IRQ_LINES)
703 + if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
704 return pci_irq_table[(slot + pin - 2) % 4];