ixp4xx: add support for linux 3.10
[openwrt.git] / target / linux / ixp4xx / patches-3.10 / 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,9 +55,7 @@ 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 +       if (slot >= 1 && slot <= AVILA_MAX_DEV && pin >= 1 && pin <= IRQ_LINES)
22                 return pci_irq_table[(slot + pin - 2) % 4];
23  
24         return -1;
25 --- a/arch/arm/mach-ixp4xx/avila-setup.c
26 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
27 @@ -14,9 +14,16 @@
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>
44 @@ -26,10 +33,25 @@
45  #include <asm/irq.h>
46  #include <asm/mach/arch.h>
47  #include <asm/mach/flash.h>
48 +#include <linux/irq.h>
49  
50  #define AVILA_SDA_PIN  7
51  #define AVILA_SCL_PIN  6
52  
53 +/* User LEDs */
54 +#define AVILA_GW23XX_LED_USER_GPIO     3
55 +#define AVILA_GW23X7_LED_USER_GPIO     4
56 +
57 +/* gpio mask used by platform device */
58 +#define AVILA_GPIO_MASK        (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
59 +
60 +struct avila_board_info {
61 +       unsigned char   *model;
62 +       void            (*setup)(void);
63 +};
64 +
65 +static struct avila_board_info *avila_info __initdata;
66 +
67  static struct flash_platform_data avila_flash_data = {
68         .map_name       = "cfi_probe",
69         .width          = 2,
70 @@ -105,14 +127,69 @@ static struct platform_device avila_uart
71         .resource               = avila_uart_resources
72  };
73  
74 -static struct resource avila_pata_resources[] = {
75 +static struct resource avila_optional_uart_resources[] = {
76         {
77 -               .flags  = IORESOURCE_MEM
78 -       },
79 +               .start  = 0x54000000,
80 +               .end  = 0x54000fff,
81 +               .flags  = IORESOURCE_MEM
82 +       },{
83 +               .start  = 0x55000000,
84 +               .end  = 0x55000fff,
85 +               .flags  = IORESOURCE_MEM
86 +       },{
87 +               .start  = 0x56000000,
88 +               .end  = 0x56000fff,
89 +               .flags  = IORESOURCE_MEM
90 +       },{
91 +               .start  = 0x57000000,
92 +               .end  = 0x57000fff,
93 +               .flags  = IORESOURCE_MEM
94 +       }
95 +};
96 +
97 +static struct plat_serial8250_port avila_optional_uart_data[] = {
98         {
99 -               .flags  = IORESOURCE_MEM,
100 +               .flags    = UPF_BOOT_AUTOCONF,
101 +               .iotype   = UPIO_MEM,
102 +               .regshift = 0,
103 +               .uartclk  = 18432000,
104 +               .rw_delay = 2,
105 +       },{
106 +               .flags    = UPF_BOOT_AUTOCONF,
107 +               .iotype   = UPIO_MEM,
108 +               .regshift = 0,
109 +               .uartclk  = 18432000,
110 +               .rw_delay = 2,
111 +       },{
112 +               .flags    = UPF_BOOT_AUTOCONF,
113 +               .iotype   = UPIO_MEM,
114 +               .regshift = 0,
115 +               .uartclk  = 18432000,
116 +               .rw_delay = 2,
117 +       },{
118 +               .flags    = UPF_BOOT_AUTOCONF,
119 +               .iotype   = UPIO_MEM,
120 +               .regshift = 0,
121 +               .uartclk  = 18432000,
122 +               .rw_delay = 2,
123         },
124 +       { }
125 +};
126 +
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,
133 +};
134 +
135 +static struct resource avila_pata_resources[] = {
136         {
137 +               .flags  = IORESOURCE_MEM
138 +       },{
139 +               .flags  = IORESOURCE_MEM,
140 +       },{
141                 .name   = "intrq",
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,
146  };
147  
148 +/* Built-in 10/100 Ethernet MAC interfaces */
149 +static struct eth_plat_info avila_npeb_data = {
150 +       .phy            = 0,
151 +       .rxq            = 3,
152 +       .txreadyq       = 20,
153 +};
154 +
155 +static struct eth_plat_info avila_npec_data = {
156 +       .phy            = 1,
157 +       .rxq            = 4,
158 +       .txreadyq       = 21,
159 +};
160 +
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),
166 +};
167 +
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),
173 +};
174 +
175 +static struct gpio_led avila_gpio_leds[] = {
176 +       {
177 +               .name           = "user",  /* green led */
178 +               .gpio           = AVILA_GW23XX_LED_USER_GPIO,
179 +               .active_low     = 1,
180 +       },
181 +       {
182 +               .name           = "radio1",  /* green led */
183 +               .gpio           = 104,
184 +               .active_low     = 1,
185 +       },
186 +       {
187 +               .name           = "radio2",  /* green led */
188 +               .gpio           = 105,
189 +               .active_low     = 1,
190 +       },
191 +       {
192 +               .name           = "radio3",  /* green led */
193 +               .gpio           = 106,
194 +               .active_low     = 1,
195 +       },
196 +       {
197 +               .name           = "radio4",  /* green led */
198 +               .gpio           = 107,
199 +               .active_low     = 1,
200 +       },
201 +
202 +};
203 +
204 +static struct gpio_led_platform_data avila_gpio_leds_data = {
205 +       .num_leds               = 1,
206 +       .leds                   = avila_gpio_leds,
207 +};
208 +
209 +static struct platform_device avila_gpio_leds_device = {
210 +       .name                   = "leds-gpio",
211 +       .id                     = -1,
212 +       .dev.platform_data      = &avila_gpio_leds_data,
213 +};
214 +
215 +static struct latch_led avila_latch_leds[] = {
216 +       {
217 +               .name   = "led0",  /* green led */
218 +               .bit    = 0,
219 +       },
220 +       {
221 +               .name   = "led1",  /* green led */
222 +               .bit    = 1,
223 +       },
224 +       {
225 +               .name   = "led2",  /* green led */
226 +               .bit    = 2,
227 +       },
228 +       {
229 +               .name   = "led3",  /* green led */
230 +               .bit    = 3,
231 +       },
232 +       {
233 +               .name   = "led4",  /* green led */
234 +               .bit    = 4,
235 +       },
236 +       {
237 +               .name   = "led5",  /* green led */
238 +               .bit    = 5,
239 +       },
240 +       {
241 +               .name   = "led6",  /* green led */
242 +               .bit    = 6,
243 +       },
244 +       {
245 +               .name   = "led7",  /* green led */
246 +               .bit    = 7,
247 +       }
248 +};
249 +
250 +static struct latch_led_platform_data avila_latch_leds_data = {
251 +       .num_leds       = 8,
252 +       .leds           = avila_latch_leds,
253 +       .mem            = 0x51000000,
254 +};
255 +
256 +static struct platform_device avila_latch_leds_device = {
257 +       .name                   = "leds-latch",
258 +       .id                     = -1,
259 +       .dev.platform_data      = &avila_latch_leds_data,
260 +};
261 +
262  static struct platform_device *avila_devices[] __initdata = {
263         &avila_i2c_gpio,
264 -       &avila_flash,
265         &avila_uart
266  };
267  
268 -static void __init avila_init(void)
269 +/*
270 + * Audio Devices
271 + */
272 +
273 +static struct platform_device avila_hss_device[] = {
274 +       {
275 +               .name = "gw_avila_hss",
276 +               .id = 0,
277 +       },{
278 +               .name = "gw_avila_hss",
279 +               .id = 1,
280 +       },{
281 +               .name = "gw_avila_hss",
282 +               .id = 2,
283 +       },{
284 +               .name = "gw_avila_hss",
285 +               .id = 3,
286 +       },
287 +};
288 +
289 +static struct platform_device avila_pcm_device[] = {
290 +       {
291 +               .name = "gw_avila-audio",
292 +               .id = 0,
293 +       },{
294 +               .name = "gw_avila-audio",
295 +               .id = 1,
296 +       },{
297 +               .name = "gw_avila-audio",
298 +               .id = 2,
299 +       },{
300 +               .name = "gw_avila-audio",
301 +               .id = 3,
302 +       }
303 +};
304 +
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]);
310 +
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]);
315 +}
316 +
317 +static void __init avila_gw23xx_setup(void)
318  {
319 -       ixp4xx_sys_init();
320 +       platform_device_register(&avila_npeb_device);
321 +       platform_device_register(&avila_npec_device);
322  
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);
327 +}
328  
329 -       platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
330 +static void __init avila_gw2342_setup(void)
331 +{
332 +       platform_device_register(&avila_npeb_device);
333 +       platform_device_register(&avila_npec_device);
334 +
335 +       platform_device_register(&avila_gpio_leds_device);
336 +
337 +       avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
338 +       avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
339 +
340 +       avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
341 +       avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
342 +
343 +       avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
344 +       avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
345 +
346 +       platform_device_register(&avila_pata);
347 +}
348 +
349 +static void __init avila_gw2345_setup(void)
350 +{
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);
354 +
355 +       avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
356 +       platform_device_register(&avila_npec_device);
357 +
358 +       platform_device_register(&avila_gpio_leds_device);
359  
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;
364  
365         platform_device_register(&avila_pata);
366 +}
367 +
368 +static void __init avila_gw2347_setup(void)
369 +{
370 +       platform_device_register(&avila_npeb_device);
371 +
372 +       avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
373 +       platform_device_register(&avila_gpio_leds_device);
374 +}
375 +
376 +static void __init avila_gw2348_setup(void)
377 +{
378 +       platform_device_register(&avila_npeb_device);
379 +       platform_device_register(&avila_npec_device);
380 +
381 +       platform_device_register(&avila_gpio_leds_device);
382 +
383 +       avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
384 +       avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
385 +
386 +       avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
387 +       avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
388 +
389 +       avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
390 +       avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
391 +
392 +       platform_device_register(&avila_pata);
393 +}
394 +
395 +static void __init avila_gw2353_setup(void)
396 +{
397 +       platform_device_register(&avila_npeb_device);
398 +       platform_device_register(&avila_gpio_leds_device);
399 +}
400 +
401 +static void __init avila_gw2355_setup(void)
402 +{
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);
406 +
407 +       avila_npec_data.phy = 16;
408 +       platform_device_register(&avila_npec_device);
409 +
410 +       avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
411 +       platform_device_register(&avila_gpio_leds_device);
412 +
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);
422 +
423 +       avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(1);
424 +       avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(1);
425 +
426 +       avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(2);
427 +       avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(2);
428 +
429 +       avila_pata_data.cs0_cfg = IXP4XX_EXP_CS1;
430 +       avila_pata_data.cs1_cfg = IXP4XX_EXP_CS2;
431 +
432 +       platform_device_register(&avila_pata);
433 +}
434 +
435 +static void __init avila_gw2357_setup(void)
436 +{
437 +       platform_device_register(&avila_npeb_device);
438 +
439 +       avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
440 +       platform_device_register(&avila_gpio_leds_device);
441 +
442 +       *IXP4XX_EXP_CS1 |= 0xbfff3c03;
443 +       platform_device_register(&avila_latch_leds_device);
444 +}
445 +
446 +static void __init avila_gw2365_setup(void)
447 +{
448 +       avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
449 +
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;
455 +
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;
461 +
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;
467 +
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;
473 +
474 +       platform_device_register(&avila_optional_uart);
475 +
476 +       avila_npeb_data.phy = 1;
477 +       platform_device_register(&avila_npeb_device);
478 +
479 +       avila_npec_data.phy = 2;
480 +       platform_device_register(&avila_npec_device);
481 +
482 +       avila_pata_resources[0].start = IXP4XX_EXP_BUS_BASE(2);
483 +       avila_pata_resources[0].end = IXP4XX_EXP_BUS_END(2);
484 +
485 +       avila_pata_resources[1].start = IXP4XX_EXP_BUS_BASE(3);
486 +       avila_pata_resources[1].end = IXP4XX_EXP_BUS_END(3);
487 +
488 +       avila_pata_data.cs0_cfg = IXP4XX_EXP_CS2;
489 +       avila_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
490 +
491 +       platform_device_register(&avila_pata);
492 +
493 +       avila_gpio_leds[0].gpio = 109;
494 +       avila_gpio_leds_data.num_leds = 5;
495 +       platform_device_register(&avila_gpio_leds_device);
496 +
497 +       setup_audio_devices();
498 +}
499 +
500 +static void __init avila_gw2369_setup(void)
501 +{
502 +       avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
503 +
504 +       avila_npeb_data.phy = 1;
505 +       platform_device_register(&avila_npeb_device);
506 +
507 +       avila_npec_data.phy = 2;
508 +       platform_device_register(&avila_npec_device);
509 +
510 +       setup_audio_devices();
511 +}
512 +
513 +static void __init avila_gw2370_setup(void)
514 +{
515 +       avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
516 +
517 +       avila_npeb_data.phy = 5;
518 +       platform_device_register(&avila_npeb_device);
519 +
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);
523 +
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;
529 +
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;
535 +
536 +       avila_optional_uart.num_resources = 2;
537 +
538 +       platform_device_register(&avila_optional_uart);
539 +
540 +       avila_gpio_leds[0].gpio = 101;
541 +       platform_device_register(&avila_gpio_leds_device);
542 +
543 +       setup_audio_devices();
544 +}
545 +
546 +
547 +
548 +static struct avila_board_info avila_boards[] __initdata = {
549 +       {
550 +               .model          = "GW2342",
551 +               .setup          = avila_gw2342_setup,
552 +       }, {
553 +               .model          = "GW2345",
554 +               .setup          = avila_gw2345_setup,
555 +       }, {
556 +               .model          = "GW2347",
557 +               .setup          = avila_gw2347_setup,
558 +       }, {
559 +               .model          = "GW2348",
560 +               .setup          = avila_gw2348_setup,
561 +       }, {
562 +               .model          = "GW2353",
563 +               .setup          = avila_gw2353_setup,
564 +       }, {
565 +               .model          = "GW2355",
566 +               .setup          = avila_gw2355_setup,
567 +       }, {
568 +               .model          = "GW2357",
569 +               .setup          = avila_gw2357_setup,
570 +       }, {
571 +               .model          = "GW2365",
572 +               .setup          = avila_gw2365_setup,
573 +       }, {
574 +               .model          = "GW2369",
575 +               .setup          = avila_gw2369_setup,
576 +       }, {
577 +               .model          = "GW2370",
578 +               .setup          = avila_gw2370_setup,
579 +       }, {
580 +               .model          = "GW2373",
581 +               .setup          = avila_gw2369_setup,
582 +       }
583 +};
584 +
585 +static struct avila_board_info * __init avila_find_board_info(char *model)
586 +{
587 +       int i;
588 +       model[6] = '\0';
589 +
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)
593 +                       return info;
594 +       }
595 +
596 +       return NULL;
597 +}
598 +
599 +static struct memory_accessor *at24_mem_acc;
600 +
601 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
602 +{
603 +       char mac_addr[ETH_ALEN];
604 +       char model[7];
605 +
606 +       at24_mem_acc = mem_acc;
607 +
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);
611 +       }
612 +       if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
613 +               memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
614 +       }
615 +
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);
619 +       }
620 +
621 +}
622 +
623 +static struct at24_platform_data avila_eeprom_info = {
624 +       .byte_len       = 1024,
625 +       .page_size      = 16,
626 +//     .flags          = AT24_FLAG_READONLY,
627 +       .setup          = at24_setup,
628 +};
629 +
630 +static struct pca953x_platform_data avila_pca_data = {
631 +       .gpio_base  = 100,
632 +};
633 +
634 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
635 +       {
636 +               I2C_BOARD_INFO("ds1672", 0x68),
637 +       },
638 +       {
639 +               I2C_BOARD_INFO("gsp", 0x29),
640 +       },
641 +       {
642 +               I2C_BOARD_INFO("pca9555", 0x23),
643 +               .platform_data = &avila_pca_data,
644 +       },
645 +       {
646 +               I2C_BOARD_INFO("ad7418", 0x28),
647 +       },
648 +       {
649 +               I2C_BOARD_INFO("24c08", 0x51),
650 +               .platform_data  = &avila_eeprom_info
651 +       },
652 +       {
653 +               I2C_BOARD_INFO("tlv320aic33", 0x1b),
654 +       },
655 +       {
656 +               I2C_BOARD_INFO("tlv320aic33", 0x1a),
657 +       },
658 +       {
659 +               I2C_BOARD_INFO("tlv320aic33", 0x19),
660 +       },
661 +       {
662 +               I2C_BOARD_INFO("tlv320aic33", 0x18),
663 +       },
664 +};
665 +
666 +static void __init avila_init(void)
667 +{
668 +       ixp4xx_sys_init();
669 +
670 +       platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
671 +
672 +       i2c_register_board_info(0, avila_i2c_board_info,
673 +                       ARRAY_SIZE(avila_i2c_board_info));
674 +}
675 +
676 +static int __init avila_model_setup(void)
677 +{
678 +       if (!machine_is_avila())
679 +               return 0;
680 +
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;
684 +
685 +       if (avila_info) {
686 +               printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
687 +                                                       avila_info->model);
688 +               avila_info->setup();
689 +       } else {
690 +               printk(KERN_INFO "Unknown/missing Avila model number"
691 +                                               " -- defaults will be used\n");
692 +               avila_gw23xx_setup();
693 +       }
694 +       platform_device_register(&avila_flash);
695  
696 +       return 0;
697  }
698 +late_initcall(avila_model_setup);
699  
700  MACHINE_START(AVILA, "Gateworks Avila Network Platform")
701         /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */