at91sam9263_devices.c 24 KB

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