ixp4xx: add v3.18 support
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-3.18 / 300-avila_support.patch
1 --- a/arch/arm/mach-ixp4xx/avila-pci.c
2 +++ b/arch/arm/mach-ixp4xx/avila-pci.c
3 @@ -27,8 +27,8 @@
4 #include <mach/hardware.h>
5 #include <asm/mach-types.h>
6
7 -#define AVILA_MAX_DEV 4
8 -#define LOFT_MAX_DEV 6
9 +#define AVILA_MAX_DEV 6
10 +
11 #define IRQ_LINES 4
12
13 /* PCI controller GPIO to IRQ pin mappings */
14 @@ -55,10 +55,8 @@ static int __init avila_map_irq(const st
15 IXP4XX_GPIO_IRQ(INTD)
16 };
17
18 - if (slot >= 1 &&
19 - slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) &&
20 - pin >= 1 && pin <= IRQ_LINES)
21 - return pci_irq_table[(slot + pin - 2) % 4];
22 + if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
23 + return pci_irq_table[(slot + pin - 2) % IRQ_LINES];
24
25 return -1;
26 }
27 --- a/arch/arm/mach-ixp4xx/avila-setup.c
28 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
29 @@ -14,9 +14,16 @@
30 #include <linux/kernel.h>
31 #include <linux/init.h>
32 #include <linux/device.h>
33 +#include <linux/if_ether.h>
34 +#include <linux/socket.h>
35 +#include <linux/netdevice.h>
36 #include <linux/serial.h>
37 #include <linux/tty.h>
38 #include <linux/serial_8250.h>
39 +#include <linux/i2c.h>
40 +#include <linux/platform_data/at24.h>
41 +#include <linux/leds.h>
42 +#include <linux/platform_data/pca953x.h>
43 #include <linux/i2c-gpio.h>
44 #include <asm/types.h>
45 #include <asm/setup.h>
46 @@ -26,10 +33,25 @@
47 #include <asm/irq.h>
48 #include <asm/mach/arch.h>
49 #include <asm/mach/flash.h>
50 +#include <linux/irq.h>
51
52 #define AVILA_SDA_PIN 7
53 #define AVILA_SCL_PIN 6
54
55 +/* User LEDs */
56 +#define AVILA_GW23XX_LED_USER_GPIO 3
57 +#define AVILA_GW23X7_LED_USER_GPIO 4
58 +
59 +/* gpio mask used by platform device */
60 +#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
61 +
62 +struct avila_board_info {
63 + unsigned char *model;
64 + void (*setup)(void);
65 +};
66 +
67 +static struct avila_board_info *avila_info __initdata;
68 +
69 static struct flash_platform_data avila_flash_data = {
70 .map_name = "cfi_probe",
71 .width = 2,
72 @@ -105,14 +127,69 @@ static struct platform_device avila_uart
73 .resource = avila_uart_resources
74 };
75
76 -static struct resource avila_pata_resources[] = {
77 +static struct resource avila_optional_uart_resources[] = {
78 {
79 - .flags = IORESOURCE_MEM
80 - },
81 + .start = 0x54000000,
82 + .end = 0x54000fff,
83 + .flags = IORESOURCE_MEM
84 + },{
85 + .start = 0x55000000,
86 + .end = 0x55000fff,
87 + .flags = IORESOURCE_MEM
88 + },{
89 + .start = 0x56000000,
90 + .end = 0x56000fff,
91 + .flags = IORESOURCE_MEM
92 + },{
93 + .start = 0x57000000,
94 + .end = 0x57000fff,
95 + .flags = IORESOURCE_MEM
96 + }
97 +};
98 +
99 +static struct plat_serial8250_port avila_optional_uart_data[] = {
100 {
101 - .flags = IORESOURCE_MEM,
102 + .flags = UPF_BOOT_AUTOCONF,
103 + .iotype = UPIO_MEM,
104 + .regshift = 0,
105 + .uartclk = 18432000,
106 + .rw_delay = 2,
107 + },{
108 + .flags = UPF_BOOT_AUTOCONF,
109 + .iotype = UPIO_MEM,
110 + .regshift = 0,
111 + .uartclk = 18432000,
112 + .rw_delay = 2,
113 + },{
114 + .flags = UPF_BOOT_AUTOCONF,
115 + .iotype = UPIO_MEM,
116 + .regshift = 0,
117 + .uartclk = 18432000,
118 + .rw_delay = 2,
119 + },{
120 + .flags = UPF_BOOT_AUTOCONF,
121 + .iotype = UPIO_MEM,
122 + .regshift = 0,
123 + .uartclk = 18432000,
124 + .rw_delay = 2,
125 },
126 + { }
127 +};
128 +
129 +static struct platform_device avila_optional_uart = {
130 + .name = "serial8250",
131 + .id = PLAT8250_DEV_PLATFORM1,
132 + .dev.platform_data = avila_optional_uart_data,
133 + .num_resources = 4,
134 + .resource = avila_optional_uart_resources,
135 +};
136 +
137 +static struct resource avila_pata_resources[] = {
138 {
139 + .flags = IORESOURCE_MEM
140 + },{
141 + .flags = IORESOURCE_MEM,
142 + },{
143 .name = "intrq",
144 .start = IRQ_IXP4XX_GPIO12,
145 .end = IRQ_IXP4XX_GPIO12,
146 @@ -133,21 +210,237 @@ static struct platform_device avila_pata
147 .resource = avila_pata_resources,
148 };
149
150 +/* Built-in 10/100 Ethernet MAC interfaces */
151 +static struct eth_plat_info avila_npeb_data = {
152 + .phy = 0,
153 + .rxq = 3,
154 + .txreadyq = 20,
155 +};
156 +
157 +static struct eth_plat_info avila_npec_data = {
158 + .phy = 1,
159 + .rxq = 4,
160 + .txreadyq = 21,
161 +};
162 +
163 +static struct platform_device avila_npeb_device = {
164 + .name = "ixp4xx_eth",
165 + .id = IXP4XX_ETH_NPEB,
166 + .dev.platform_data = &avila_npeb_data,
167 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
168 +};
169 +
170 +static struct platform_device avila_npec_device = {
171 + .name = "ixp4xx_eth",
172 + .id = IXP4XX_ETH_NPEC,
173 + .dev.platform_data = &avila_npec_data,
174 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
175 +};
176 +
177 +static struct gpio_led avila_gpio_leds[] = {
178 + {
179 + .name = "user", /* green led */
180 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
181 + .active_low = 1,
182 + },
183 + {
184 + .name = "radio1", /* green led */
185 + .gpio = 104,
186 + .active_low = 1,
187 + },
188 + {
189 + .name = "radio2", /* green led */
190 + .gpio = 105,
191 + .active_low = 1,
192 + },
193 + {
194 + .name = "radio3", /* green led */
195 + .gpio = 106,
196 + .active_low = 1,
197 + },
198 + {
199 + .name = "radio4", /* green led */
200 + .gpio = 107,
201 + .active_low = 1,
202 + },
203 +
204 +};
205 +
206 +static struct gpio_led_platform_data avila_gpio_leds_data = {
207 + .num_leds = 1,
208 + .leds = avila_gpio_leds,
209 +};
210 +
211 +static struct platform_device avila_gpio_leds_device = {
212 + .name = "leds-gpio",
213 + .id = -1,
214 + .dev.platform_data = &avila_gpio_leds_data,
215 +};
216 +
217 +static struct latch_led avila_latch_leds[] = {
218 + {
219 + .name = "led0", /* green led */
220 + .bit = 0,
221 + },
222 + {
223 + .name = "led1", /* green led */
224 + .bit = 1,
225 + },
226 + {
227 + .name = "led2", /* green led */
228 + .bit = 2,
229 + },
230 + {
231 + .name = "led3", /* green led */
232 + .bit = 3,
233 + },
234 + {
235 + .name = "led4", /* green led */
236 + .bit = 4,
237 + },
238 + {
239 + .name = "led5", /* green led */
240 + .bit = 5,
241 + },
242 + {
243 + .name = "led6", /* green led */
244 + .bit = 6,
245 + },
246 + {
247 + .name = "led7", /* green led */
248 + .bit = 7,
249 + }
250 +};
251 +
252 +static struct latch_led_platform_data avila_latch_leds_data = {
253 + .num_leds = 8,
254 + .leds = avila_latch_leds,
255 + .mem = 0x51000000,
256 +};
257 +
258 +static struct platform_device avila_latch_leds_device = {
259 + .name = "leds-latch",
260 + .id = -1,
261 + .dev.platform_data = &avila_latch_leds_data,
262 +};
263 +
264 static struct platform_device *avila_devices[] __initdata = {
265 &avila_i2c_gpio,
266 - &avila_flash,
267 &avila_uart
268 };
269
270 -static void __init avila_init(void)
271 +/*
272 + * Audio Devices
273 + */
274 +
275 +static struct platform_device avila_hss_device[] = {
276 + {
277 + .name = "gw_avila_hss",
278 + .id = 0,
279 + },{
280 + .name = "gw_avila_hss",
281 + .id = 1,
282 + },{
283 + .name = "gw_avila_hss",
284 + .id = 2,
285 + },{
286 + .name = "gw_avila_hss",
287 + .id = 3,
288 + },
289 +};
290 +
291 +static struct platform_device avila_pcm_device[] = {
292 + {
293 + .name = "gw_avila-audio",
294 + .id = 0,
295 + },{
296 + .name = "gw_avila-audio",
297 + .id = 1,
298 + },{
299 + .name = "gw_avila-audio",
300 + .id = 2,
301 + },{
302 + .name = "gw_avila-audio",
303 + .id = 3,
304 + }
305 +};
306 +
307 +static void setup_audio_devices(void) {
308 + platform_device_register(&avila_hss_device[0]);
309 + platform_device_register(&avila_hss_device[1]);
310 + platform_device_register(&avila_hss_device[2]);
311 + platform_device_register(&avila_hss_device[3]);
312 +
313 + platform_device_register(&avila_pcm_device[0]);
314 + platform_device_register(&avila_pcm_device[1]);
315 + platform_device_register(&avila_pcm_device[2]);
316 + platform_device_register(&avila_pcm_device[3]);
317 +}
318 +
319 +static void __init avila_gw23xx_setup(void)
320 {
321 - ixp4xx_sys_init();
322 + platform_device_register(&avila_npeb_device);
323 + platform_device_register(&avila_npec_device);
324
325 - avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
326 - avila_flash_resource.end =
327 - IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
328 + platform_device_register(&avila_gpio_leds_device);
329 +}
330
331 - platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
332 +static void __init avila_gw2342_setup(void)
333 +{
334 + platform_device_register(&avila_npeb_device);
335 + platform_device_register(&avila_npec_device);
336 +
337 + platform_device_register(&avila_gpio_leds_device);
338 +
339 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
340 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
341 +
342 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
343 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
344 +
345 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
346 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
347 +
348 + platform_device_register(&avila_pata);
349 +}
350 +
351 +static void __init avila_gw2345_setup(void)
352 +{
353 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
354 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
355 + platform_device_register(&avila_npeb_device);
356 +
357 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
358 + platform_device_register(&avila_npec_device);
359 +
360 + platform_device_register(&avila_gpio_leds_device);
361 +
362 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
363 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
364 +
365 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
366 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
367 +
368 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
369 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
370 +
371 + platform_device_register(&avila_pata);
372 +}
373 +
374 +static void __init avila_gw2347_setup(void)
375 +{
376 + platform_device_register(&avila_npeb_device);
377 +
378 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
379 + platform_device_register(&avila_gpio_leds_device);
380 +}
381 +
382 +static void __init avila_gw2348_setup(void)
383 +{
384 + platform_device_register(&avila_npeb_device);
385 + platform_device_register(&avila_npec_device);
386 +
387 + platform_device_register(&avila_gpio_leds_device);
388
389 avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
390 avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
391 @@ -159,8 +452,335 @@ static void __init avila_init(void)
392 avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
393
394 platform_device_register(&avila_pata);
395 +}
396 +
397 +static void __init avila_gw2353_setup(void)
398 +{
399 + platform_device_register(&avila_npeb_device);
400 + platform_device_register(&avila_gpio_leds_device);
401 +}
402 +
403 +static void __init avila_gw2355_setup(void)
404 +{
405 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
406 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
407 + platform_device_register(&avila_npeb_device);
408 +
409 + avila_npec_data.phy = 16;
410 + platform_device_register(&avila_npec_device);
411 +
412 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
413 + platform_device_register(&avila_gpio_leds_device);
414 +
415 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
416 + avila_latch_leds[0].name = "RXD";
417 + avila_latch_leds[1].name = "TXD";
418 + avila_latch_leds[2].name = "POL";
419 + avila_latch_leds[3].name = "LNK";
420 + avila_latch_leds[4].name = "ERR";
421 + avila_latch_leds_data.num_leds = 5;
422 + avila_latch_leds_data.mem = 0x54000000;
423 + platform_device_register(&avila_latch_leds_device);
424 +
425 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
426 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
427 +
428 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
429 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
430 +
431 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
432 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
433 +
434 + platform_device_register(&avila_pata);
435 +}
436 +
437 +static void __init avila_gw2357_setup(void)
438 +{
439 + platform_device_register(&avila_npeb_device);
440 +
441 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
442 + platform_device_register(&avila_gpio_leds_device);
443 +
444 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
445 + platform_device_register(&avila_latch_leds_device);
446 +}
447 +
448 +static void __init avila_gw2365_setup(void)
449 +{
450 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
451 +
452 + *IXP4XX_EXP_CS4 = 0xBFFF3C43;
453 + irq_set_irq_type(IRQ_IXP4XX_GPIO0, IRQ_TYPE_EDGE_RISING);
454 + avila_optional_uart_data[0].mapbase = 0x54000000;
455 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x54000000, 0x0fff);
456 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO0;
457 +
458 + *IXP4XX_EXP_CS5 = 0xBFFF3C43;
459 + irq_set_irq_type(IRQ_IXP4XX_GPIO1, IRQ_TYPE_EDGE_RISING);
460 + avila_optional_uart_data[1].mapbase = 0x55000000;
461 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x55000000, 0x0fff);
462 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO1;
463 +
464 + *IXP4XX_EXP_CS6 = 0xBFFF3C43;
465 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
466 + avila_optional_uart_data[2].mapbase = 0x56000000;
467 + avila_optional_uart_data[2].membase = (void __iomem *)ioremap(0x56000000, 0x0fff);
468 + avila_optional_uart_data[2].irq = IRQ_IXP4XX_GPIO2;
469 +
470 + *IXP4XX_EXP_CS7 = 0xBFFF3C43;
471 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
472 + avila_optional_uart_data[3].mapbase = 0x57000000;
473 + avila_optional_uart_data[3].membase = (void __iomem *)ioremap(0x57000000, 0x0fff);
474 + avila_optional_uart_data[3].irq = IRQ_IXP4XX_GPIO3;
475 +
476 + platform_device_register(&avila_optional_uart);
477 +
478 + avila_npeb_data.phy = 1;
479 + platform_device_register(&avila_npeb_device);
480 +
481 + avila_npec_data.phy = 2;
482 + platform_device_register(&avila_npec_device);
483 +
484 + avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
485 + avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
486 +
487 + avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
488 + avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
489 +
490 + avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
491 + avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
492 +
493 + platform_device_register(&avila_pata);
494 +
495 + avila_gpio_leds[0].gpio = 109;
496 + avila_gpio_leds_data.num_leds = 5;
497 + platform_device_register(&avila_gpio_leds_device);
498 +
499 + setup_audio_devices();
500 +}
501 +
502 +static void __init avila_gw2369_setup(void)
503 +{
504 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
505 +
506 + avila_npeb_data.phy = 1;
507 + platform_device_register(&avila_npeb_device);
508 +
509 + avila_npec_data.phy = 2;
510 + platform_device_register(&avila_npec_device);
511 +
512 + setup_audio_devices();
513 +}
514 +
515 +static void __init avila_gw2370_setup(void)
516 +{
517 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
518 +
519 + avila_npeb_data.phy = 5;
520 + platform_device_register(&avila_npeb_device);
521 +
522 + avila_npec_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
523 + avila_npec_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
524 + platform_device_register(&avila_npec_device);
525 +
526 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
527 + irq_set_irq_type(IRQ_IXP4XX_GPIO2, IRQ_TYPE_EDGE_RISING);
528 + avila_optional_uart_data[0].mapbase = 0x52000000;
529 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
530 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO2;
531 +
532 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
533 + irq_set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
534 + avila_optional_uart_data[1].mapbase = 0x53000000;
535 + avila_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53000000, 0x0fff);
536 + avila_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO3;
537 +
538 + avila_optional_uart.num_resources = 2;
539 +
540 + platform_device_register(&avila_optional_uart);
541 +
542 + avila_gpio_leds[0].gpio = 101;
543 + platform_device_register(&avila_gpio_leds_device);
544 +
545 + setup_audio_devices();
546 +}
547 +
548 +static void __init avila_gw2375_setup(void)
549 +{
550 + avila_npeb_data.phy = 1;
551 + platform_device_register(&avila_npeb_device);
552 +
553 + avila_npec_data.phy = 2;
554 + platform_device_register(&avila_npec_device);
555 +
556 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
557 + irq_set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_EDGE_RISING);
558 + avila_optional_uart_data[0].mapbase = 0x52000000;
559 + avila_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52000000, 0x0fff);
560 + avila_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO10;
561 +
562 + avila_optional_uart.num_resources = 1;
563 +
564 + platform_device_register(&avila_optional_uart);
565 +
566 + setup_audio_devices();
567 +}
568 +
569 +
570 +static struct avila_board_info avila_boards[] __initdata = {
571 + {
572 + .model = "GW2342",
573 + .setup = avila_gw2342_setup,
574 + }, {
575 + .model = "GW2345",
576 + .setup = avila_gw2345_setup,
577 + }, {
578 + .model = "GW2347",
579 + .setup = avila_gw2347_setup,
580 + }, {
581 + .model = "GW2348",
582 + .setup = avila_gw2348_setup,
583 + }, {
584 + .model = "GW2353",
585 + .setup = avila_gw2353_setup,
586 + }, {
587 + .model = "GW2355",
588 + .setup = avila_gw2355_setup,
589 + }, {
590 + .model = "GW2357",
591 + .setup = avila_gw2357_setup,
592 + }, {
593 + .model = "GW2365",
594 + .setup = avila_gw2365_setup,
595 + }, {
596 + .model = "GW2369",
597 + .setup = avila_gw2369_setup,
598 + }, {
599 + .model = "GW2370",
600 + .setup = avila_gw2370_setup,
601 + }, {
602 + .model = "GW2373",
603 + .setup = avila_gw2369_setup,
604 + }, {
605 + .model = "GW2375",
606 + .setup = avila_gw2375_setup,
607 + }
608 +};
609 +
610 +static struct avila_board_info * __init avila_find_board_info(char *model)
611 +{
612 + int i;
613 + model[6] = '\0';
614 +
615 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
616 + struct avila_board_info *info = &avila_boards[i];
617 + if (strcmp(info->model, model) == 0)
618 + return info;
619 + }
620 +
621 + return NULL;
622 +}
623 +
624 +static struct memory_accessor *at24_mem_acc;
625 +
626 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
627 +{
628 + char mac_addr[ETH_ALEN];
629 + char model[7];
630 +
631 + at24_mem_acc = mem_acc;
632 +
633 + /* Read MAC addresses */
634 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
635 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
636 + }
637 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
638 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
639 + }
640 +
641 + /* Read the first 6 bytes of the model number */
642 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
643 + avila_info = avila_find_board_info(model);
644 + }
645 +
646 +}
647 +
648 +static struct at24_platform_data avila_eeprom_info = {
649 + .byte_len = 1024,
650 + .page_size = 16,
651 +// .flags = AT24_FLAG_READONLY,
652 + .setup = at24_setup,
653 +};
654 +
655 +static struct pca953x_platform_data avila_pca_data = {
656 + .gpio_base = 100,
657 +};
658 +
659 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
660 + {
661 + I2C_BOARD_INFO("ds1672", 0x68),
662 + },
663 + {
664 + I2C_BOARD_INFO("gsp", 0x29),
665 + },
666 + {
667 + I2C_BOARD_INFO("pca9555", 0x23),
668 + .platform_data = &avila_pca_data,
669 + },
670 + {
671 + I2C_BOARD_INFO("ad7418", 0x28),
672 + },
673 + {
674 + I2C_BOARD_INFO("24c08", 0x51),
675 + .platform_data = &avila_eeprom_info
676 + },
677 + {
678 + I2C_BOARD_INFO("tlv320aic33", 0x1b),
679 + },
680 + {
681 + I2C_BOARD_INFO("tlv320aic33", 0x1a),
682 + },
683 + {
684 + I2C_BOARD_INFO("tlv320aic33", 0x19),
685 + },
686 + {
687 + I2C_BOARD_INFO("tlv320aic33", 0x18),
688 + },
689 +};
690 +
691 +static void __init avila_init(void)
692 +{
693 + ixp4xx_sys_init();
694 +
695 + platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
696 +
697 + i2c_register_board_info(0, avila_i2c_board_info,
698 + ARRAY_SIZE(avila_i2c_board_info));
699 +}
700 +
701 +static int __init avila_model_setup(void)
702 +{
703 + if (!machine_is_avila())
704 + return 0;
705 +
706 + /* default 16MB flash */
707 + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
708 + avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_16M - 1;
709 +
710 + if (avila_info) {
711 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
712 + avila_info->model);
713 + avila_info->setup();
714 + } else {
715 + printk(KERN_INFO "Unknown/missing Avila model number"
716 + " -- defaults will be used\n");
717 + avila_gw23xx_setup();
718 + }
719 + platform_device_register(&avila_flash);
720
721 + return 0;
722 }
723 +late_initcall(avila_model_setup);
724
725 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
726 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */