at91sam9263_devices.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. /*
  2. * arch/arm/mach-at91/at91sam9263_devices.c
  3. *
  4. * Copyright (C) 2007 Atmel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <linux/platform_device.h>
  15. #include <video/atmel_lcdc.h>
  16. #include <asm/arch/board.h>
  17. #include <asm/arch/gpio.h>
  18. #include <asm/arch/at91sam9263.h>
  19. #include <asm/arch/at91sam926x_mc.h>
  20. #include <asm/arch/at91sam9263_matrix.h>
  21. #include "generic.h"
  22. /* --------------------------------------------------------------------
  23. * USB Host
  24. * -------------------------------------------------------------------- */
  25. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  26. static u64 ohci_dmamask = 0xffffffffUL;
  27. static struct at91_usbh_data usbh_data;
  28. static struct resource usbh_resources[] = {
  29. [0] = {
  30. .start = AT91SAM9263_UHP_BASE,
  31. .end = AT91SAM9263_UHP_BASE + SZ_1M - 1,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = {
  35. .start = AT91SAM9263_ID_UHP,
  36. .end = AT91SAM9263_ID_UHP,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. static struct platform_device at91_usbh_device = {
  41. .name = "at91_ohci",
  42. .id = -1,
  43. .dev = {
  44. .dma_mask = &ohci_dmamask,
  45. .coherent_dma_mask = 0xffffffff,
  46. .platform_data = &usbh_data,
  47. },
  48. .resource = usbh_resources,
  49. .num_resources = ARRAY_SIZE(usbh_resources),
  50. };
  51. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  52. {
  53. int i;
  54. if (!data)
  55. return;
  56. /* Enable VBus control for UHP ports */
  57. for (i = 0; i < data->ports; i++) {
  58. if (data->vbus_pin[i])
  59. at91_set_gpio_output(data->vbus_pin[i], 0);
  60. }
  61. usbh_data = *data;
  62. platform_device_register(&at91_usbh_device);
  63. }
  64. #else
  65. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  66. #endif
  67. /* --------------------------------------------------------------------
  68. * USB Device (Gadget)
  69. * -------------------------------------------------------------------- */
  70. #ifdef CONFIG_USB_GADGET_AT91
  71. static struct at91_udc_data udc_data;
  72. static struct resource udc_resources[] = {
  73. [0] = {
  74. .start = AT91SAM9263_BASE_UDP,
  75. .end = AT91SAM9263_BASE_UDP + SZ_16K - 1,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .start = AT91SAM9263_ID_UDP,
  80. .end = AT91SAM9263_ID_UDP,
  81. .flags = IORESOURCE_IRQ,
  82. },
  83. };
  84. static struct platform_device at91_udc_device = {
  85. .name = "at91_udc",
  86. .id = -1,
  87. .dev = {
  88. .platform_data = &udc_data,
  89. },
  90. .resource = udc_resources,
  91. .num_resources = ARRAY_SIZE(udc_resources),
  92. };
  93. void __init at91_add_device_udc(struct at91_udc_data *data)
  94. {
  95. if (!data)
  96. return;
  97. if (data->vbus_pin) {
  98. at91_set_gpio_input(data->vbus_pin, 0);
  99. at91_set_deglitch(data->vbus_pin, 1);
  100. }
  101. /* Pullup pin is handled internally by USB device peripheral */
  102. udc_data = *data;
  103. platform_device_register(&at91_udc_device);
  104. }
  105. #else
  106. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  107. #endif
  108. /* --------------------------------------------------------------------
  109. * Ethernet
  110. * -------------------------------------------------------------------- */
  111. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
  112. static u64 eth_dmamask = 0xffffffffUL;
  113. static struct at91_eth_data eth_data;
  114. static struct resource eth_resources[] = {
  115. [0] = {
  116. .start = AT91SAM9263_BASE_EMAC,
  117. .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1,
  118. .flags = IORESOURCE_MEM,
  119. },
  120. [1] = {
  121. .start = AT91SAM9263_ID_EMAC,
  122. .end = AT91SAM9263_ID_EMAC,
  123. .flags = IORESOURCE_IRQ,
  124. },
  125. };
  126. static struct platform_device at91sam9263_eth_device = {
  127. .name = "macb",
  128. .id = -1,
  129. .dev = {
  130. .dma_mask = &eth_dmamask,
  131. .coherent_dma_mask = 0xffffffff,
  132. .platform_data = &eth_data,
  133. },
  134. .resource = eth_resources,
  135. .num_resources = ARRAY_SIZE(eth_resources),
  136. };
  137. void __init at91_add_device_eth(struct at91_eth_data *data)
  138. {
  139. if (!data)
  140. return;
  141. if (data->phy_irq_pin) {
  142. at91_set_gpio_input(data->phy_irq_pin, 0);
  143. at91_set_deglitch(data->phy_irq_pin, 1);
  144. }
  145. /* Pins used for MII and RMII */
  146. at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */
  147. at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */
  148. at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */
  149. at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */
  150. at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */
  151. at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */
  152. at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */
  153. at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */
  154. at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */
  155. at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */
  156. if (!data->is_rmii) {
  157. at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */
  158. at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
  159. at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
  160. at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
  161. at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
  162. at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
  163. at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
  164. at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
  165. }
  166. eth_data = *data;
  167. platform_device_register(&at91sam9263_eth_device);
  168. }
  169. #else
  170. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  171. #endif
  172. /* --------------------------------------------------------------------
  173. * MMC / SD
  174. * -------------------------------------------------------------------- */
  175. #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
  176. static u64 mmc_dmamask = 0xffffffffUL;
  177. static struct at91_mmc_data mmc0_data, mmc1_data;
  178. static struct resource mmc0_resources[] = {
  179. [0] = {
  180. .start = AT91SAM9263_BASE_MCI0,
  181. .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1,
  182. .flags = IORESOURCE_MEM,
  183. },
  184. [1] = {
  185. .start = AT91SAM9263_ID_MCI0,
  186. .end = AT91SAM9263_ID_MCI0,
  187. .flags = IORESOURCE_IRQ,
  188. },
  189. };
  190. static struct platform_device at91sam9263_mmc0_device = {
  191. .name = "at91_mci",
  192. .id = 0,
  193. .dev = {
  194. .dma_mask = &mmc_dmamask,
  195. .coherent_dma_mask = 0xffffffff,
  196. .platform_data = &mmc0_data,
  197. },
  198. .resource = mmc0_resources,
  199. .num_resources = ARRAY_SIZE(mmc0_resources),
  200. };
  201. static struct resource mmc1_resources[] = {
  202. [0] = {
  203. .start = AT91SAM9263_BASE_MCI1,
  204. .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1,
  205. .flags = IORESOURCE_MEM,
  206. },
  207. [1] = {
  208. .start = AT91SAM9263_ID_MCI1,
  209. .end = AT91SAM9263_ID_MCI1,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. };
  213. static struct platform_device at91sam9263_mmc1_device = {
  214. .name = "at91_mci",
  215. .id = 1,
  216. .dev = {
  217. .dma_mask = &mmc_dmamask,
  218. .coherent_dma_mask = 0xffffffff,
  219. .platform_data = &mmc1_data,
  220. },
  221. .resource = mmc1_resources,
  222. .num_resources = ARRAY_SIZE(mmc1_resources),
  223. };
  224. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
  225. {
  226. if (!data)
  227. return;
  228. /* input/irq */
  229. if (data->det_pin) {
  230. at91_set_gpio_input(data->det_pin, 1);
  231. at91_set_deglitch(data->det_pin, 1);
  232. }
  233. if (data->wp_pin)
  234. at91_set_gpio_input(data->wp_pin, 1);
  235. if (data->vcc_pin)
  236. at91_set_gpio_output(data->vcc_pin, 0);
  237. if (mmc_id == 0) { /* MCI0 */
  238. /* CLK */
  239. at91_set_A_periph(AT91_PIN_PA12, 0);
  240. if (data->slot_b) {
  241. /* CMD */
  242. at91_set_A_periph(AT91_PIN_PA16, 1);
  243. /* DAT0, maybe DAT1..DAT3 */
  244. at91_set_A_periph(AT91_PIN_PA17, 1);
  245. if (data->wire4) {
  246. at91_set_A_periph(AT91_PIN_PA18, 1);
  247. at91_set_A_periph(AT91_PIN_PA19, 1);
  248. at91_set_A_periph(AT91_PIN_PA20, 1);
  249. }
  250. } else {
  251. /* CMD */
  252. at91_set_A_periph(AT91_PIN_PA1, 1);
  253. /* DAT0, maybe DAT1..DAT3 */
  254. at91_set_A_periph(AT91_PIN_PA0, 1);
  255. if (data->wire4) {
  256. at91_set_A_periph(AT91_PIN_PA3, 1);
  257. at91_set_A_periph(AT91_PIN_PA4, 1);
  258. at91_set_A_periph(AT91_PIN_PA5, 1);
  259. }
  260. }
  261. mmc0_data = *data;
  262. at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk");
  263. platform_device_register(&at91sam9263_mmc0_device);
  264. } else { /* MCI1 */
  265. /* CLK */
  266. at91_set_A_periph(AT91_PIN_PA6, 0);
  267. if (data->slot_b) {
  268. /* CMD */
  269. at91_set_A_periph(AT91_PIN_PA21, 1);
  270. /* DAT0, maybe DAT1..DAT3 */
  271. at91_set_A_periph(AT91_PIN_PA22, 1);
  272. if (data->wire4) {
  273. at91_set_A_periph(AT91_PIN_PA23, 1);
  274. at91_set_A_periph(AT91_PIN_PA24, 1);
  275. at91_set_A_periph(AT91_PIN_PA25, 1);
  276. }
  277. } else {
  278. /* CMD */
  279. at91_set_A_periph(AT91_PIN_PA7, 1);
  280. /* DAT0, maybe DAT1..DAT3 */
  281. at91_set_A_periph(AT91_PIN_PA8, 1);
  282. if (data->wire4) {
  283. at91_set_A_periph(AT91_PIN_PA9, 1);
  284. at91_set_A_periph(AT91_PIN_PA10, 1);
  285. at91_set_A_periph(AT91_PIN_PA11, 1);
  286. }
  287. }
  288. mmc1_data = *data;
  289. at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device.dev, "mci_clk");
  290. platform_device_register(&at91sam9263_mmc1_device);
  291. }
  292. }
  293. #else
  294. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
  295. #endif
  296. /* --------------------------------------------------------------------
  297. * NAND / SmartMedia
  298. * -------------------------------------------------------------------- */
  299. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  300. static struct at91_nand_data nand_data;
  301. #define NAND_BASE AT91_CHIPSELECT_3
  302. static struct resource nand_resources[] = {
  303. {
  304. .start = NAND_BASE,
  305. .end = NAND_BASE + SZ_256M - 1,
  306. .flags = IORESOURCE_MEM,
  307. }
  308. };
  309. static struct platform_device at91sam9263_nand_device = {
  310. .name = "at91_nand",
  311. .id = -1,
  312. .dev = {
  313. .platform_data = &nand_data,
  314. },
  315. .resource = nand_resources,
  316. .num_resources = ARRAY_SIZE(nand_resources),
  317. };
  318. void __init at91_add_device_nand(struct at91_nand_data *data)
  319. {
  320. unsigned long csa, mode;
  321. if (!data)
  322. return;
  323. csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
  324. at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC);
  325. /* set the bus interface characteristics */
  326. at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
  327. | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
  328. at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
  329. | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
  330. at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
  331. if (data->bus_width_16)
  332. mode = AT91_SMC_DBW_16;
  333. else
  334. mode = AT91_SMC_DBW_8;
  335. at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
  336. /* enable pin */
  337. if (data->enable_pin)
  338. at91_set_gpio_output(data->enable_pin, 1);
  339. /* ready/busy pin */
  340. if (data->rdy_pin)
  341. at91_set_gpio_input(data->rdy_pin, 1);
  342. /* card detect pin */
  343. if (data->det_pin)
  344. at91_set_gpio_input(data->det_pin, 1);
  345. nand_data = *data;
  346. platform_device_register(&at91sam9263_nand_device);
  347. }
  348. #else
  349. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  350. #endif
  351. /* --------------------------------------------------------------------
  352. * TWI (i2c)
  353. * -------------------------------------------------------------------- */
  354. #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  355. static struct resource twi_resources[] = {
  356. [0] = {
  357. .start = AT91SAM9263_BASE_TWI,
  358. .end = AT91SAM9263_BASE_TWI + SZ_16K - 1,
  359. .flags = IORESOURCE_MEM,
  360. },
  361. [1] = {
  362. .start = AT91SAM9263_ID_TWI,
  363. .end = AT91SAM9263_ID_TWI,
  364. .flags = IORESOURCE_IRQ,
  365. },
  366. };
  367. static struct platform_device at91sam9263_twi_device = {
  368. .name = "at91_i2c",
  369. .id = -1,
  370. .resource = twi_resources,
  371. .num_resources = ARRAY_SIZE(twi_resources),
  372. };
  373. void __init at91_add_device_i2c(void)
  374. {
  375. /* pins used for TWI interface */
  376. at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
  377. at91_set_multi_drive(AT91_PIN_PB4, 1);
  378. at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
  379. at91_set_multi_drive(AT91_PIN_PB5, 1);
  380. platform_device_register(&at91sam9263_twi_device);
  381. }
  382. #else
  383. void __init at91_add_device_i2c(void) {}
  384. #endif
  385. /* --------------------------------------------------------------------
  386. * SPI
  387. * -------------------------------------------------------------------- */
  388. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  389. static u64 spi_dmamask = 0xffffffffUL;
  390. static struct resource spi0_resources[] = {
  391. [0] = {
  392. .start = AT91SAM9263_BASE_SPI0,
  393. .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
  394. .flags = IORESOURCE_MEM,
  395. },
  396. [1] = {
  397. .start = AT91SAM9263_ID_SPI0,
  398. .end = AT91SAM9263_ID_SPI0,
  399. .flags = IORESOURCE_IRQ,
  400. },
  401. };
  402. static struct platform_device at91sam9263_spi0_device = {
  403. .name = "atmel_spi",
  404. .id = 0,
  405. .dev = {
  406. .dma_mask = &spi_dmamask,
  407. .coherent_dma_mask = 0xffffffff,
  408. },
  409. .resource = spi0_resources,
  410. .num_resources = ARRAY_SIZE(spi0_resources),
  411. };
  412. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
  413. static struct resource spi1_resources[] = {
  414. [0] = {
  415. .start = AT91SAM9263_BASE_SPI1,
  416. .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
  417. .flags = IORESOURCE_MEM,
  418. },
  419. [1] = {
  420. .start = AT91SAM9263_ID_SPI1,
  421. .end = AT91SAM9263_ID_SPI1,
  422. .flags = IORESOURCE_IRQ,
  423. },
  424. };
  425. static struct platform_device at91sam9263_spi1_device = {
  426. .name = "atmel_spi",
  427. .id = 1,
  428. .dev = {
  429. .dma_mask = &spi_dmamask,
  430. .coherent_dma_mask = 0xffffffff,
  431. },
  432. .resource = spi1_resources,
  433. .num_resources = ARRAY_SIZE(spi1_resources),
  434. };
  435. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
  436. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  437. {
  438. int i;
  439. unsigned long cs_pin;
  440. short enable_spi0 = 0;
  441. short enable_spi1 = 0;
  442. /* Choose SPI chip-selects */
  443. for (i = 0; i < nr_devices; i++) {
  444. if (devices[i].controller_data)
  445. cs_pin = (unsigned long) devices[i].controller_data;
  446. else if (devices[i].bus_num == 0)
  447. cs_pin = spi0_standard_cs[devices[i].chip_select];
  448. else
  449. cs_pin = spi1_standard_cs[devices[i].chip_select];
  450. if (devices[i].bus_num == 0)
  451. enable_spi0 = 1;
  452. else
  453. enable_spi1 = 1;
  454. /* enable chip-select pin */
  455. at91_set_gpio_output(cs_pin, 1);
  456. /* pass chip-select pin to driver */
  457. devices[i].controller_data = (void *) cs_pin;
  458. }
  459. spi_register_board_info(devices, nr_devices);
  460. /* Configure SPI bus(es) */
  461. if (enable_spi0) {
  462. at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
  463. at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
  464. at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
  465. at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk");
  466. platform_device_register(&at91sam9263_spi0_device);
  467. }
  468. if (enable_spi1) {
  469. at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
  470. at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
  471. at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
  472. at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk");
  473. platform_device_register(&at91sam9263_spi1_device);
  474. }
  475. }
  476. #else
  477. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  478. #endif
  479. /* --------------------------------------------------------------------
  480. * AC97
  481. * -------------------------------------------------------------------- */
  482. #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
  483. static u64 ac97_dmamask = 0xffffffffUL;
  484. static struct atmel_ac97_data ac97_data;
  485. static struct resource ac97_resources[] = {
  486. [0] = {
  487. .start = AT91SAM9263_BASE_AC97C,
  488. .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
  489. .flags = IORESOURCE_MEM,
  490. },
  491. [1] = {
  492. .start = AT91SAM9263_ID_AC97C,
  493. .end = AT91SAM9263_ID_AC97C,
  494. .flags = IORESOURCE_IRQ,
  495. },
  496. };
  497. static struct platform_device at91sam9263_ac97_device = {
  498. .name = "ac97c",
  499. .id = 1,
  500. .dev = {
  501. .dma_mask = &ac97_dmamask,
  502. .coherent_dma_mask = 0xffffffff,
  503. .platform_data = &ac97_data,
  504. },
  505. .resource = ac97_resources,
  506. .num_resources = ARRAY_SIZE(ac97_resources),
  507. };
  508. void __init at91_add_device_ac97(struct atmel_ac97_data *data)
  509. {
  510. if (!data)
  511. return;
  512. at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
  513. at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
  514. at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
  515. at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
  516. /* reset */
  517. if (data->reset_pin)
  518. at91_set_gpio_output(data->reset_pin, 0);
  519. ac97_data = *ek_data;
  520. platform_device_register(&at91sam9263_ac97_device);
  521. }
  522. #else
  523. void __init at91_add_device_ac97(struct atmel_ac97_data *data) {}
  524. #endif
  525. /* --------------------------------------------------------------------
  526. * LCD Controller
  527. * -------------------------------------------------------------------- */
  528. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  529. static u64 lcdc_dmamask = 0xffffffffUL;
  530. static struct atmel_lcdfb_info lcdc_data;
  531. static struct resource lcdc_resources[] = {
  532. [0] = {
  533. .start = AT91SAM9263_LCDC_BASE,
  534. .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
  535. .flags = IORESOURCE_MEM,
  536. },
  537. [1] = {
  538. .start = AT91SAM9263_ID_LCDC,
  539. .end = AT91SAM9263_ID_LCDC,
  540. .flags = IORESOURCE_IRQ,
  541. },
  542. };
  543. static struct platform_device at91_lcdc_device = {
  544. .name = "atmel_lcdfb",
  545. .id = 0,
  546. .dev = {
  547. .dma_mask = &lcdc_dmamask,
  548. .coherent_dma_mask = 0xffffffff,
  549. .platform_data = &lcdc_data,
  550. },
  551. .resource = lcdc_resources,
  552. .num_resources = ARRAY_SIZE(lcdc_resources),
  553. };
  554. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  555. {
  556. if (!data)
  557. return;
  558. at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
  559. at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
  560. at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
  561. at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
  562. at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
  563. at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
  564. at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
  565. at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
  566. at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
  567. at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
  568. at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
  569. at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
  570. at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
  571. at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */
  572. at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
  573. at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
  574. at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
  575. at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
  576. at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
  577. at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */
  578. at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
  579. at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
  580. lcdc_data = *data;
  581. platform_device_register(&at91_lcdc_device);
  582. }
  583. #else
  584. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  585. #endif
  586. /* --------------------------------------------------------------------
  587. * LEDs
  588. * -------------------------------------------------------------------- */
  589. #if defined(CONFIG_LEDS)
  590. u8 at91_leds_cpu;
  591. u8 at91_leds_timer;
  592. void __init at91_init_leds(u8 cpu_led, u8 timer_led)
  593. {
  594. /* Enable GPIO to access the LEDs */
  595. at91_set_gpio_output(cpu_led, 1);
  596. at91_set_gpio_output(timer_led, 1);
  597. at91_leds_cpu = cpu_led;
  598. at91_leds_timer = timer_led;
  599. }
  600. #else
  601. void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
  602. #endif
  603. /* --------------------------------------------------------------------
  604. * UART
  605. * -------------------------------------------------------------------- */
  606. #if defined(CONFIG_SERIAL_ATMEL)
  607. static struct resource dbgu_resources[] = {
  608. [0] = {
  609. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  610. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  611. .flags = IORESOURCE_MEM,
  612. },
  613. [1] = {
  614. .start = AT91_ID_SYS,
  615. .end = AT91_ID_SYS,
  616. .flags = IORESOURCE_IRQ,
  617. },
  618. };
  619. static struct atmel_uart_data dbgu_data = {
  620. .use_dma_tx = 0,
  621. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  622. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  623. };
  624. static struct platform_device at91sam9263_dbgu_device = {
  625. .name = "atmel_usart",
  626. .id = 0,
  627. .dev = {
  628. .platform_data = &dbgu_data,
  629. .coherent_dma_mask = 0xffffffff,
  630. },
  631. .resource = dbgu_resources,
  632. .num_resources = ARRAY_SIZE(dbgu_resources),
  633. };
  634. static inline void configure_dbgu_pins(void)
  635. {
  636. at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
  637. at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
  638. }
  639. static struct resource uart0_resources[] = {
  640. [0] = {
  641. .start = AT91SAM9263_BASE_US0,
  642. .end = AT91SAM9263_BASE_US0 + SZ_16K - 1,
  643. .flags = IORESOURCE_MEM,
  644. },
  645. [1] = {
  646. .start = AT91SAM9263_ID_US0,
  647. .end = AT91SAM9263_ID_US0,
  648. .flags = IORESOURCE_IRQ,
  649. },
  650. };
  651. static struct atmel_uart_data uart0_data = {
  652. .use_dma_tx = 1,
  653. .use_dma_rx = 1,
  654. };
  655. static struct platform_device at91sam9263_uart0_device = {
  656. .name = "atmel_usart",
  657. .id = 1,
  658. .dev = {
  659. .platform_data = &uart0_data,
  660. .coherent_dma_mask = 0xffffffff,
  661. },
  662. .resource = uart0_resources,
  663. .num_resources = ARRAY_SIZE(uart0_resources),
  664. };
  665. static inline void configure_usart0_pins(void)
  666. {
  667. at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */
  668. at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */
  669. at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */
  670. at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */
  671. }
  672. static struct resource uart1_resources[] = {
  673. [0] = {
  674. .start = AT91SAM9263_BASE_US1,
  675. .end = AT91SAM9263_BASE_US1 + SZ_16K - 1,
  676. .flags = IORESOURCE_MEM,
  677. },
  678. [1] = {
  679. .start = AT91SAM9263_ID_US1,
  680. .end = AT91SAM9263_ID_US1,
  681. .flags = IORESOURCE_IRQ,
  682. },
  683. };
  684. static struct atmel_uart_data uart1_data = {
  685. .use_dma_tx = 1,
  686. .use_dma_rx = 1,
  687. };
  688. static struct platform_device at91sam9263_uart1_device = {
  689. .name = "atmel_usart",
  690. .id = 2,
  691. .dev = {
  692. .platform_data = &uart1_data,
  693. .coherent_dma_mask = 0xffffffff,
  694. },
  695. .resource = uart1_resources,
  696. .num_resources = ARRAY_SIZE(uart1_resources),
  697. };
  698. static inline void configure_usart1_pins(void)
  699. {
  700. at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
  701. at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
  702. at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
  703. at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
  704. }
  705. static struct resource uart2_resources[] = {
  706. [0] = {
  707. .start = AT91SAM9263_BASE_US2,
  708. .end = AT91SAM9263_BASE_US2 + SZ_16K - 1,
  709. .flags = IORESOURCE_MEM,
  710. },
  711. [1] = {
  712. .start = AT91SAM9263_ID_US2,
  713. .end = AT91SAM9263_ID_US2,
  714. .flags = IORESOURCE_IRQ,
  715. },
  716. };
  717. static struct atmel_uart_data uart2_data = {
  718. .use_dma_tx = 1,
  719. .use_dma_rx = 1,
  720. };
  721. static struct platform_device at91sam9263_uart2_device = {
  722. .name = "atmel_usart",
  723. .id = 3,
  724. .dev = {
  725. .platform_data = &uart2_data,
  726. .coherent_dma_mask = 0xffffffff,
  727. },
  728. .resource = uart2_resources,
  729. .num_resources = ARRAY_SIZE(uart2_resources),
  730. };
  731. static inline void configure_usart2_pins(void)
  732. {
  733. at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
  734. at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
  735. at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
  736. at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
  737. }
  738. struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  739. struct platform_device *atmel_default_console_device; /* the serial console device */
  740. void __init at91_init_serial(struct at91_uart_config *config)
  741. {
  742. int i;
  743. /* Fill in list of supported UARTs */
  744. for (i = 0; i < config->nr_tty; i++) {
  745. switch (config->tty_map[i]) {
  746. case 0:
  747. configure_usart0_pins();
  748. at91_uarts[i] = &at91sam9263_uart0_device;
  749. at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart");
  750. break;
  751. case 1:
  752. configure_usart1_pins();
  753. at91_uarts[i] = &at91sam9263_uart1_device;
  754. at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart");
  755. break;
  756. case 2:
  757. configure_usart2_pins();
  758. at91_uarts[i] = &at91sam9263_uart2_device;
  759. at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart");
  760. break;
  761. case 3:
  762. configure_dbgu_pins();
  763. at91_uarts[i] = &at91sam9263_dbgu_device;
  764. at91_clock_associate("mck", &at91sam9263_dbgu_device.dev, "usart");
  765. break;
  766. default:
  767. continue;
  768. }
  769. at91_uarts[i]->id = i; /* update ID number to mapped ID */
  770. }
  771. /* Set serial console device */
  772. if (config->console_tty < ATMEL_MAX_UART)
  773. atmel_default_console_device = at91_uarts[config->console_tty];
  774. if (!atmel_default_console_device)
  775. printk(KERN_INFO "AT91: No default serial console defined.\n");
  776. }
  777. void __init at91_add_device_serial(void)
  778. {
  779. int i;
  780. for (i = 0; i < ATMEL_MAX_UART; i++) {
  781. if (at91_uarts[i])
  782. platform_device_register(at91_uarts[i]);
  783. }
  784. }
  785. #else
  786. void __init at91_init_serial(struct at91_uart_config *config) {}
  787. void __init at91_add_device_serial(void) {}
  788. #endif
  789. /* -------------------------------------------------------------------- */
  790. /*
  791. * These devices are always present and don't need any board-specific
  792. * setup.
  793. */
  794. static int __init at91_add_standard_devices(void)
  795. {
  796. return 0;
  797. }
  798. arch_initcall(at91_add_standard_devices);