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