at91rm9200_devices.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. /*
  2. * arch/arm/mach-at91rm9200/at91rm9200_devices.c
  3. *
  4. * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
  5. * Copyright (C) 2005 David Brownell
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. */
  13. #include <asm/mach/arch.h>
  14. #include <asm/mach/map.h>
  15. #include <linux/platform_device.h>
  16. #include <asm/arch/board.h>
  17. #include <asm/arch/gpio.h>
  18. #include <asm/arch/at91rm9200.h>
  19. #include <asm/arch/at91rm9200_mc.h>
  20. #include "generic.h"
  21. #define SZ_512 0x00000200
  22. #define SZ_256 0x00000100
  23. #define SZ_16 0x00000010
  24. /* --------------------------------------------------------------------
  25. * USB Host
  26. * -------------------------------------------------------------------- */
  27. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  28. static u64 ohci_dmamask = 0xffffffffUL;
  29. static struct at91_usbh_data usbh_data;
  30. static struct resource usbh_resources[] = {
  31. [0] = {
  32. .start = AT91RM9200_UHP_BASE,
  33. .end = AT91RM9200_UHP_BASE + SZ_1M - 1,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. [1] = {
  37. .start = AT91RM9200_ID_UHP,
  38. .end = AT91RM9200_ID_UHP,
  39. .flags = IORESOURCE_IRQ,
  40. },
  41. };
  42. static struct platform_device at91rm9200_usbh_device = {
  43. .name = "at91_ohci",
  44. .id = -1,
  45. .dev = {
  46. .dma_mask = &ohci_dmamask,
  47. .coherent_dma_mask = 0xffffffff,
  48. .platform_data = &usbh_data,
  49. },
  50. .resource = usbh_resources,
  51. .num_resources = ARRAY_SIZE(usbh_resources),
  52. };
  53. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  54. {
  55. if (!data)
  56. return;
  57. usbh_data = *data;
  58. platform_device_register(&at91rm9200_usbh_device);
  59. }
  60. #else
  61. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  62. #endif
  63. /* --------------------------------------------------------------------
  64. * USB Device (Gadget)
  65. * -------------------------------------------------------------------- */
  66. #ifdef CONFIG_USB_GADGET_AT91
  67. static struct at91_udc_data udc_data;
  68. static struct resource udc_resources[] = {
  69. [0] = {
  70. .start = AT91RM9200_BASE_UDP,
  71. .end = AT91RM9200_BASE_UDP + SZ_16K - 1,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. [1] = {
  75. .start = AT91RM9200_ID_UDP,
  76. .end = AT91RM9200_ID_UDP,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct platform_device at91rm9200_udc_device = {
  81. .name = "at91_udc",
  82. .id = -1,
  83. .dev = {
  84. .platform_data = &udc_data,
  85. },
  86. .resource = udc_resources,
  87. .num_resources = ARRAY_SIZE(udc_resources),
  88. };
  89. void __init at91_add_device_udc(struct at91_udc_data *data)
  90. {
  91. if (!data)
  92. return;
  93. if (data->vbus_pin) {
  94. at91_set_gpio_input(data->vbus_pin, 0);
  95. at91_set_deglitch(data->vbus_pin, 1);
  96. }
  97. if (data->pullup_pin)
  98. at91_set_gpio_output(data->pullup_pin, 0);
  99. udc_data = *data;
  100. platform_device_register(&at91rm9200_udc_device);
  101. }
  102. #else
  103. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  104. #endif
  105. /* --------------------------------------------------------------------
  106. * Ethernet
  107. * -------------------------------------------------------------------- */
  108. #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
  109. static u64 eth_dmamask = 0xffffffffUL;
  110. static struct at91_eth_data eth_data;
  111. static struct resource eth_resources[] = {
  112. [0] = {
  113. .start = AT91_VA_BASE_EMAC,
  114. .end = AT91_VA_BASE_EMAC + SZ_16K - 1,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = AT91RM9200_ID_EMAC,
  119. .end = AT91RM9200_ID_EMAC,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device at91rm9200_eth_device = {
  124. .name = "at91_ether",
  125. .id = -1,
  126. .dev = {
  127. .dma_mask = &eth_dmamask,
  128. .coherent_dma_mask = 0xffffffff,
  129. .platform_data = &eth_data,
  130. },
  131. .resource = eth_resources,
  132. .num_resources = ARRAY_SIZE(eth_resources),
  133. };
  134. void __init at91_add_device_eth(struct at91_eth_data *data)
  135. {
  136. if (!data)
  137. return;
  138. if (data->phy_irq_pin) {
  139. at91_set_gpio_input(data->phy_irq_pin, 0);
  140. at91_set_deglitch(data->phy_irq_pin, 1);
  141. }
  142. /* Pins used for MII and RMII */
  143. at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
  144. at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
  145. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
  146. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  147. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  148. at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
  149. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
  150. at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
  151. at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
  152. at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
  153. if (!data->is_rmii) {
  154. at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
  155. at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
  156. at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
  157. at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
  158. at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
  159. at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
  160. at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
  161. at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
  162. }
  163. eth_data = *data;
  164. platform_device_register(&at91rm9200_eth_device);
  165. }
  166. #else
  167. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  168. #endif
  169. /* --------------------------------------------------------------------
  170. * Compact Flash / PCMCIA
  171. * -------------------------------------------------------------------- */
  172. #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  173. static struct at91_cf_data cf_data;
  174. #define CF_BASE AT91_CHIPSELECT_4
  175. static struct resource cf_resources[] = {
  176. [0] = {
  177. .start = CF_BASE,
  178. /* ties up CS4, CS5 and CS6 */
  179. .end = CF_BASE + (0x30000000 - 1),
  180. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  181. },
  182. };
  183. static struct platform_device at91rm9200_cf_device = {
  184. .name = "at91_cf",
  185. .id = -1,
  186. .dev = {
  187. .platform_data = &cf_data,
  188. },
  189. .resource = cf_resources,
  190. .num_resources = ARRAY_SIZE(cf_resources),
  191. };
  192. void __init at91_add_device_cf(struct at91_cf_data *data)
  193. {
  194. unsigned int csa;
  195. if (!data)
  196. return;
  197. data->chipselect = 4; /* can only use EBI ChipSelect 4 */
  198. /* CF takes over CS4, CS5, CS6 */
  199. csa = at91_sys_read(AT91_EBI_CSA);
  200. at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
  201. /*
  202. * Static memory controller timing adjustments.
  203. * REVISIT: these timings are in terms of MCK cycles, so
  204. * when MCK changes (cpufreq etc) so must these values...
  205. */
  206. at91_sys_write(AT91_SMC_CSR(4),
  207. AT91_SMC_ACSS_STD
  208. | AT91_SMC_DBW_16
  209. | AT91_SMC_BAT
  210. | AT91_SMC_WSEN
  211. | AT91_SMC_NWS_(32) /* wait states */
  212. | AT91_SMC_RWSETUP_(6) /* setup time */
  213. | AT91_SMC_RWHOLD_(4) /* hold time */
  214. );
  215. /* input/irq */
  216. if (data->irq_pin) {
  217. at91_set_gpio_input(data->irq_pin, 1);
  218. at91_set_deglitch(data->irq_pin, 1);
  219. }
  220. at91_set_gpio_input(data->det_pin, 1);
  221. at91_set_deglitch(data->det_pin, 1);
  222. /* outputs, initially off */
  223. if (data->vcc_pin)
  224. at91_set_gpio_output(data->vcc_pin, 0);
  225. at91_set_gpio_output(data->rst_pin, 0);
  226. /* force poweron defaults for these pins ... */
  227. at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
  228. at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
  229. at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
  230. at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
  231. /* nWAIT is _not_ a default setting */
  232. at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
  233. cf_data = *data;
  234. platform_device_register(&at91rm9200_cf_device);
  235. }
  236. #else
  237. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  238. #endif
  239. /* --------------------------------------------------------------------
  240. * MMC / SD
  241. * -------------------------------------------------------------------- */
  242. #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
  243. static u64 mmc_dmamask = 0xffffffffUL;
  244. static struct at91_mmc_data mmc_data;
  245. static struct resource mmc_resources[] = {
  246. [0] = {
  247. .start = AT91RM9200_BASE_MCI,
  248. .end = AT91RM9200_BASE_MCI + SZ_16K - 1,
  249. .flags = IORESOURCE_MEM,
  250. },
  251. [1] = {
  252. .start = AT91RM9200_ID_MCI,
  253. .end = AT91RM9200_ID_MCI,
  254. .flags = IORESOURCE_IRQ,
  255. },
  256. };
  257. static struct platform_device at91rm9200_mmc_device = {
  258. .name = "at91_mci",
  259. .id = -1,
  260. .dev = {
  261. .dma_mask = &mmc_dmamask,
  262. .coherent_dma_mask = 0xffffffff,
  263. .platform_data = &mmc_data,
  264. },
  265. .resource = mmc_resources,
  266. .num_resources = ARRAY_SIZE(mmc_resources),
  267. };
  268. void __init at91_add_device_mmc(struct at91_mmc_data *data)
  269. {
  270. if (!data)
  271. return;
  272. /* input/irq */
  273. if (data->det_pin) {
  274. at91_set_gpio_input(data->det_pin, 1);
  275. at91_set_deglitch(data->det_pin, 1);
  276. }
  277. if (data->wp_pin)
  278. at91_set_gpio_input(data->wp_pin, 1);
  279. if (data->vcc_pin)
  280. at91_set_gpio_output(data->vcc_pin, 0);
  281. /* CLK */
  282. at91_set_A_periph(AT91_PIN_PA27, 0);
  283. if (data->slot_b) {
  284. /* CMD */
  285. at91_set_B_periph(AT91_PIN_PA8, 1);
  286. /* DAT0, maybe DAT1..DAT3 */
  287. at91_set_B_periph(AT91_PIN_PA9, 1);
  288. if (data->wire4) {
  289. at91_set_B_periph(AT91_PIN_PA10, 1);
  290. at91_set_B_periph(AT91_PIN_PA11, 1);
  291. at91_set_B_periph(AT91_PIN_PA12, 1);
  292. }
  293. } else {
  294. /* CMD */
  295. at91_set_A_periph(AT91_PIN_PA28, 1);
  296. /* DAT0, maybe DAT1..DAT3 */
  297. at91_set_A_periph(AT91_PIN_PA29, 1);
  298. if (data->wire4) {
  299. at91_set_B_periph(AT91_PIN_PB3, 1);
  300. at91_set_B_periph(AT91_PIN_PB4, 1);
  301. at91_set_B_periph(AT91_PIN_PB5, 1);
  302. }
  303. }
  304. mmc_data = *data;
  305. platform_device_register(&at91rm9200_mmc_device);
  306. }
  307. #else
  308. void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
  309. #endif
  310. /* --------------------------------------------------------------------
  311. * NAND / SmartMedia
  312. * -------------------------------------------------------------------- */
  313. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  314. static struct at91_nand_data nand_data;
  315. #define NAND_BASE AT91_CHIPSELECT_3
  316. static struct resource nand_resources[] = {
  317. {
  318. .start = NAND_BASE,
  319. .end = NAND_BASE + SZ_8M - 1,
  320. .flags = IORESOURCE_MEM,
  321. }
  322. };
  323. static struct platform_device at91rm9200_nand_device = {
  324. .name = "at91_nand",
  325. .id = -1,
  326. .dev = {
  327. .platform_data = &nand_data,
  328. },
  329. .resource = nand_resources,
  330. .num_resources = ARRAY_SIZE(nand_resources),
  331. };
  332. void __init at91_add_device_nand(struct at91_nand_data *data)
  333. {
  334. unsigned int csa;
  335. if (!data)
  336. return;
  337. /* enable the address range of CS3 */
  338. csa = at91_sys_read(AT91_EBI_CSA);
  339. at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
  340. /* set the bus interface characteristics */
  341. at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
  342. | AT91_SMC_NWS_(5)
  343. | AT91_SMC_TDF_(1)
  344. | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
  345. | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */
  346. );
  347. /* enable pin */
  348. if (data->enable_pin)
  349. at91_set_gpio_output(data->enable_pin, 1);
  350. /* ready/busy pin */
  351. if (data->rdy_pin)
  352. at91_set_gpio_input(data->rdy_pin, 1);
  353. /* card detect pin */
  354. if (data->det_pin)
  355. at91_set_gpio_input(data->det_pin, 1);
  356. at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
  357. at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
  358. nand_data = *data;
  359. platform_device_register(&at91rm9200_nand_device);
  360. }
  361. #else
  362. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  363. #endif
  364. /* --------------------------------------------------------------------
  365. * TWI (i2c)
  366. * -------------------------------------------------------------------- */
  367. #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  368. static struct resource twi_resources[] = {
  369. [0] = {
  370. .start = AT91RM9200_BASE_TWI,
  371. .end = AT91RM9200_BASE_TWI + SZ_16K - 1,
  372. .flags = IORESOURCE_MEM,
  373. },
  374. [1] = {
  375. .start = AT91RM9200_ID_TWI,
  376. .end = AT91RM9200_ID_TWI,
  377. .flags = IORESOURCE_IRQ,
  378. },
  379. };
  380. static struct platform_device at91rm9200_twi_device = {
  381. .name = "at91_i2c",
  382. .id = -1,
  383. .resource = twi_resources,
  384. .num_resources = ARRAY_SIZE(twi_resources),
  385. };
  386. void __init at91_add_device_i2c(void)
  387. {
  388. /* pins used for TWI interface */
  389. at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
  390. at91_set_multi_drive(AT91_PIN_PA25, 1);
  391. at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
  392. at91_set_multi_drive(AT91_PIN_PA26, 1);
  393. platform_device_register(&at91rm9200_twi_device);
  394. }
  395. #else
  396. void __init at91_add_device_i2c(void) {}
  397. #endif
  398. /* --------------------------------------------------------------------
  399. * SPI
  400. * -------------------------------------------------------------------- */
  401. #if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE)
  402. static u64 spi_dmamask = 0xffffffffUL;
  403. static struct resource spi_resources[] = {
  404. [0] = {
  405. .start = AT91RM9200_BASE_SPI,
  406. .end = AT91RM9200_BASE_SPI + SZ_16K - 1,
  407. .flags = IORESOURCE_MEM,
  408. },
  409. [1] = {
  410. .start = AT91RM9200_ID_SPI,
  411. .end = AT91RM9200_ID_SPI,
  412. .flags = IORESOURCE_IRQ,
  413. },
  414. };
  415. static struct platform_device at91rm9200_spi_device = {
  416. .name = "at91_spi",
  417. .id = 0,
  418. .dev = {
  419. .dma_mask = &spi_dmamask,
  420. .coherent_dma_mask = 0xffffffff,
  421. },
  422. .resource = spi_resources,
  423. .num_resources = ARRAY_SIZE(spi_resources),
  424. };
  425. static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
  426. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  427. {
  428. int i;
  429. unsigned long cs_pin;
  430. at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */
  431. at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */
  432. at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */
  433. /* Enable SPI chip-selects */
  434. for (i = 0; i < nr_devices; i++) {
  435. if (devices[i].controller_data)
  436. cs_pin = (unsigned long) devices[i].controller_data;
  437. else
  438. cs_pin = spi_standard_cs[devices[i].chip_select];
  439. #ifdef CONFIG_SPI_AT91_MANUAL_CS
  440. at91_set_gpio_output(cs_pin, 1);
  441. #else
  442. at91_set_A_periph(cs_pin, 0);
  443. #endif
  444. /* pass chip-select pin to driver */
  445. devices[i].controller_data = (void *) cs_pin;
  446. }
  447. spi_register_board_info(devices, nr_devices);
  448. at91_clock_associate("spi_clk", &at91rm9200_spi_device.dev, "spi");
  449. platform_device_register(&at91rm9200_spi_device);
  450. }
  451. #else
  452. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  453. #endif
  454. /* --------------------------------------------------------------------
  455. * RTC
  456. * -------------------------------------------------------------------- */
  457. #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
  458. static struct platform_device at91rm9200_rtc_device = {
  459. .name = "at91_rtc",
  460. .id = -1,
  461. .num_resources = 0,
  462. };
  463. static void __init at91_add_device_rtc(void)
  464. {
  465. platform_device_register(&at91rm9200_rtc_device);
  466. }
  467. #else
  468. static void __init at91_add_device_rtc(void) {}
  469. #endif
  470. /* --------------------------------------------------------------------
  471. * Watchdog
  472. * -------------------------------------------------------------------- */
  473. #if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE)
  474. static struct platform_device at91rm9200_wdt_device = {
  475. .name = "at91_wdt",
  476. .id = -1,
  477. .num_resources = 0,
  478. };
  479. static void __init at91_add_device_watchdog(void)
  480. {
  481. platform_device_register(&at91rm9200_wdt_device);
  482. }
  483. #else
  484. static void __init at91_add_device_watchdog(void) {}
  485. #endif
  486. /* --------------------------------------------------------------------
  487. * LEDs
  488. * -------------------------------------------------------------------- */
  489. #if defined(CONFIG_LEDS)
  490. u8 at91_leds_cpu;
  491. u8 at91_leds_timer;
  492. void __init at91_init_leds(u8 cpu_led, u8 timer_led)
  493. {
  494. at91_leds_cpu = cpu_led;
  495. at91_leds_timer = timer_led;
  496. }
  497. #else
  498. void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
  499. #endif
  500. /* --------------------------------------------------------------------
  501. * UART
  502. * -------------------------------------------------------------------- */
  503. #if defined(CONFIG_SERIAL_ATMEL)
  504. static struct resource dbgu_resources[] = {
  505. [0] = {
  506. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  507. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  508. .flags = IORESOURCE_MEM,
  509. },
  510. [1] = {
  511. .start = AT91_ID_SYS,
  512. .end = AT91_ID_SYS,
  513. .flags = IORESOURCE_IRQ,
  514. },
  515. };
  516. static struct atmel_uart_data dbgu_data = {
  517. .use_dma_tx = 0,
  518. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  519. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  520. };
  521. static struct platform_device at91rm9200_dbgu_device = {
  522. .name = "atmel_usart",
  523. .id = 0,
  524. .dev = {
  525. .platform_data = &dbgu_data,
  526. .coherent_dma_mask = 0xffffffff,
  527. },
  528. .resource = dbgu_resources,
  529. .num_resources = ARRAY_SIZE(dbgu_resources),
  530. };
  531. static inline void configure_dbgu_pins(void)
  532. {
  533. at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */
  534. at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */
  535. }
  536. static struct resource uart0_resources[] = {
  537. [0] = {
  538. .start = AT91RM9200_BASE_US0,
  539. .end = AT91RM9200_BASE_US0 + SZ_16K - 1,
  540. .flags = IORESOURCE_MEM,
  541. },
  542. [1] = {
  543. .start = AT91RM9200_ID_US0,
  544. .end = AT91RM9200_ID_US0,
  545. .flags = IORESOURCE_IRQ,
  546. },
  547. };
  548. static struct atmel_uart_data uart0_data = {
  549. .use_dma_tx = 1,
  550. .use_dma_rx = 1,
  551. };
  552. static struct platform_device at91rm9200_uart0_device = {
  553. .name = "atmel_usart",
  554. .id = 1,
  555. .dev = {
  556. .platform_data = &uart0_data,
  557. .coherent_dma_mask = 0xffffffff,
  558. },
  559. .resource = uart0_resources,
  560. .num_resources = ARRAY_SIZE(uart0_resources),
  561. };
  562. static inline void configure_usart0_pins(void)
  563. {
  564. at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */
  565. at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */
  566. at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */
  567. /*
  568. * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21.
  569. * We need to drive the pin manually. Default is off (RTS is active low).
  570. */
  571. at91_set_gpio_output(AT91_PIN_PA21, 1);
  572. }
  573. static struct resource uart1_resources[] = {
  574. [0] = {
  575. .start = AT91RM9200_BASE_US1,
  576. .end = AT91RM9200_BASE_US1 + SZ_16K - 1,
  577. .flags = IORESOURCE_MEM,
  578. },
  579. [1] = {
  580. .start = AT91RM9200_ID_US1,
  581. .end = AT91RM9200_ID_US1,
  582. .flags = IORESOURCE_IRQ,
  583. },
  584. };
  585. static struct atmel_uart_data uart1_data = {
  586. .use_dma_tx = 1,
  587. .use_dma_rx = 1,
  588. };
  589. static struct platform_device at91rm9200_uart1_device = {
  590. .name = "atmel_usart",
  591. .id = 2,
  592. .dev = {
  593. .platform_data = &uart1_data,
  594. .coherent_dma_mask = 0xffffffff,
  595. },
  596. .resource = uart1_resources,
  597. .num_resources = ARRAY_SIZE(uart1_resources),
  598. };
  599. static inline void configure_usart1_pins(void)
  600. {
  601. at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */
  602. at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */
  603. at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */
  604. at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */
  605. at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */
  606. at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */
  607. at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */
  608. at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */
  609. }
  610. static struct resource uart2_resources[] = {
  611. [0] = {
  612. .start = AT91RM9200_BASE_US2,
  613. .end = AT91RM9200_BASE_US2 + SZ_16K - 1,
  614. .flags = IORESOURCE_MEM,
  615. },
  616. [1] = {
  617. .start = AT91RM9200_ID_US2,
  618. .end = AT91RM9200_ID_US2,
  619. .flags = IORESOURCE_IRQ,
  620. },
  621. };
  622. static struct atmel_uart_data uart2_data = {
  623. .use_dma_tx = 1,
  624. .use_dma_rx = 1,
  625. };
  626. static struct platform_device at91rm9200_uart2_device = {
  627. .name = "atmel_usart",
  628. .id = 3,
  629. .dev = {
  630. .platform_data = &uart2_data,
  631. .coherent_dma_mask = 0xffffffff,
  632. },
  633. .resource = uart2_resources,
  634. .num_resources = ARRAY_SIZE(uart2_resources),
  635. };
  636. static inline void configure_usart2_pins(void)
  637. {
  638. at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */
  639. at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */
  640. }
  641. static struct resource uart3_resources[] = {
  642. [0] = {
  643. .start = AT91RM9200_BASE_US3,
  644. .end = AT91RM9200_BASE_US3 + SZ_16K - 1,
  645. .flags = IORESOURCE_MEM,
  646. },
  647. [1] = {
  648. .start = AT91RM9200_ID_US3,
  649. .end = AT91RM9200_ID_US3,
  650. .flags = IORESOURCE_IRQ,
  651. },
  652. };
  653. static struct atmel_uart_data uart3_data = {
  654. .use_dma_tx = 1,
  655. .use_dma_rx = 1,
  656. };
  657. static struct platform_device at91rm9200_uart3_device = {
  658. .name = "atmel_usart",
  659. .id = 4,
  660. .dev = {
  661. .platform_data = &uart3_data,
  662. .coherent_dma_mask = 0xffffffff,
  663. },
  664. .resource = uart3_resources,
  665. .num_resources = ARRAY_SIZE(uart3_resources),
  666. };
  667. static inline void configure_usart3_pins(void)
  668. {
  669. at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */
  670. at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */
  671. }
  672. struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  673. struct platform_device *atmel_default_console_device; /* the serial console device */
  674. void __init at91_init_serial(struct at91_uart_config *config)
  675. {
  676. int i;
  677. /* Fill in list of supported UARTs */
  678. for (i = 0; i < config->nr_tty; i++) {
  679. switch (config->tty_map[i]) {
  680. case 0:
  681. configure_usart0_pins();
  682. at91_uarts[i] = &at91rm9200_uart0_device;
  683. at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart");
  684. break;
  685. case 1:
  686. configure_usart1_pins();
  687. at91_uarts[i] = &at91rm9200_uart1_device;
  688. at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart");
  689. break;
  690. case 2:
  691. configure_usart2_pins();
  692. at91_uarts[i] = &at91rm9200_uart2_device;
  693. at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart");
  694. break;
  695. case 3:
  696. configure_usart3_pins();
  697. at91_uarts[i] = &at91rm9200_uart3_device;
  698. at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart");
  699. break;
  700. case 4:
  701. configure_dbgu_pins();
  702. at91_uarts[i] = &at91rm9200_dbgu_device;
  703. at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart");
  704. break;
  705. default:
  706. continue;
  707. }
  708. at91_uarts[i]->id = i; /* update ID number to mapped ID */
  709. }
  710. /* Set serial console device */
  711. if (config->console_tty < ATMEL_MAX_UART)
  712. atmel_default_console_device = at91_uarts[config->console_tty];
  713. if (!atmel_default_console_device)
  714. printk(KERN_INFO "AT91: No default serial console defined.\n");
  715. }
  716. void __init at91_add_device_serial(void)
  717. {
  718. int i;
  719. for (i = 0; i < ATMEL_MAX_UART; i++) {
  720. if (at91_uarts[i])
  721. platform_device_register(at91_uarts[i]);
  722. }
  723. }
  724. #else
  725. void __init at91_init_serial(struct at91_uart_config *config) {}
  726. void __init at91_add_device_serial(void) {}
  727. #endif
  728. /* -------------------------------------------------------------------- */
  729. /*
  730. * These devices are always present and don't need any board-specific
  731. * setup.
  732. */
  733. static int __init at91_add_standard_devices(void)
  734. {
  735. at91_add_device_rtc();
  736. at91_add_device_watchdog();
  737. return 0;
  738. }
  739. arch_initcall(at91_add_standard_devices);