300-avila_support.patch 18 KB

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