at91rm9200_devices.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. /*
  2. * arch/arm/mach-at91/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/dma-mapping.h>
  16. #include <linux/gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c-gpio.h>
  19. #include <mach/at91rm9200.h>
  20. #include <mach/at91rm9200_mc.h>
  21. #include <mach/at91_ramc.h>
  22. #include <mach/hardware.h>
  23. #include "board.h"
  24. #include "generic.h"
  25. /* --------------------------------------------------------------------
  26. * USB Host
  27. * -------------------------------------------------------------------- */
  28. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  29. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  30. static struct at91_usbh_data usbh_data;
  31. static struct resource usbh_resources[] = {
  32. [0] = {
  33. .start = AT91RM9200_UHP_BASE,
  34. .end = AT91RM9200_UHP_BASE + SZ_1M - 1,
  35. .flags = IORESOURCE_MEM,
  36. },
  37. [1] = {
  38. .start = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
  39. .end = NR_IRQS_LEGACY + AT91RM9200_ID_UHP,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct platform_device at91rm9200_usbh_device = {
  44. .name = "at91_ohci",
  45. .id = -1,
  46. .dev = {
  47. .dma_mask = &ohci_dmamask,
  48. .coherent_dma_mask = DMA_BIT_MASK(32),
  49. .platform_data = &usbh_data,
  50. },
  51. .resource = usbh_resources,
  52. .num_resources = ARRAY_SIZE(usbh_resources),
  53. };
  54. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  55. {
  56. int i;
  57. if (!data)
  58. return;
  59. /* Enable overcurrent notification */
  60. for (i = 0; i < data->ports; i++) {
  61. if (gpio_is_valid(data->overcurrent_pin[i]))
  62. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  63. }
  64. usbh_data = *data;
  65. platform_device_register(&at91rm9200_usbh_device);
  66. }
  67. #else
  68. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  69. #endif
  70. /* --------------------------------------------------------------------
  71. * USB Device (Gadget)
  72. * -------------------------------------------------------------------- */
  73. #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
  74. static struct at91_udc_data udc_data;
  75. static struct resource udc_resources[] = {
  76. [0] = {
  77. .start = AT91RM9200_BASE_UDP,
  78. .end = AT91RM9200_BASE_UDP + SZ_16K - 1,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. [1] = {
  82. .start = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
  83. .end = NR_IRQS_LEGACY + AT91RM9200_ID_UDP,
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. static struct platform_device at91rm9200_udc_device = {
  88. .name = "at91_udc",
  89. .id = -1,
  90. .dev = {
  91. .platform_data = &udc_data,
  92. },
  93. .resource = udc_resources,
  94. .num_resources = ARRAY_SIZE(udc_resources),
  95. };
  96. void __init at91_add_device_udc(struct at91_udc_data *data)
  97. {
  98. if (!data)
  99. return;
  100. if (gpio_is_valid(data->vbus_pin)) {
  101. at91_set_gpio_input(data->vbus_pin, 0);
  102. at91_set_deglitch(data->vbus_pin, 1);
  103. }
  104. if (gpio_is_valid(data->pullup_pin))
  105. at91_set_gpio_output(data->pullup_pin, 0);
  106. udc_data = *data;
  107. platform_device_register(&at91rm9200_udc_device);
  108. }
  109. #else
  110. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  111. #endif
  112. /* --------------------------------------------------------------------
  113. * Ethernet
  114. * -------------------------------------------------------------------- */
  115. #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
  116. static u64 eth_dmamask = DMA_BIT_MASK(32);
  117. static struct macb_platform_data eth_data;
  118. static struct resource eth_resources[] = {
  119. [0] = {
  120. .start = AT91RM9200_BASE_EMAC,
  121. .end = AT91RM9200_BASE_EMAC + SZ_16K - 1,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
  126. .end = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC,
  127. .flags = IORESOURCE_IRQ,
  128. },
  129. };
  130. static struct platform_device at91rm9200_eth_device = {
  131. .name = "at91_ether",
  132. .id = -1,
  133. .dev = {
  134. .dma_mask = &eth_dmamask,
  135. .coherent_dma_mask = DMA_BIT_MASK(32),
  136. .platform_data = &eth_data,
  137. },
  138. .resource = eth_resources,
  139. .num_resources = ARRAY_SIZE(eth_resources),
  140. };
  141. void __init at91_add_device_eth(struct macb_platform_data *data)
  142. {
  143. if (!data)
  144. return;
  145. if (gpio_is_valid(data->phy_irq_pin)) {
  146. at91_set_gpio_input(data->phy_irq_pin, 0);
  147. at91_set_deglitch(data->phy_irq_pin, 1);
  148. }
  149. /* Pins used for MII and RMII */
  150. at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
  151. at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
  152. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
  153. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  154. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  155. at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
  156. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
  157. at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
  158. at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
  159. at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
  160. if (!data->is_rmii) {
  161. at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
  162. at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
  163. at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
  164. at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
  165. at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
  166. at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
  167. at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
  168. at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
  169. }
  170. eth_data = *data;
  171. platform_device_register(&at91rm9200_eth_device);
  172. }
  173. #else
  174. void __init at91_add_device_eth(struct macb_platform_data *data) {}
  175. #endif
  176. /* --------------------------------------------------------------------
  177. * Compact Flash / PCMCIA
  178. * -------------------------------------------------------------------- */
  179. #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  180. static struct at91_cf_data cf_data;
  181. #define CF_BASE AT91_CHIPSELECT_4
  182. static struct resource cf_resources[] = {
  183. [0] = {
  184. .start = CF_BASE,
  185. /* ties up CS4, CS5 and CS6 */
  186. .end = CF_BASE + (0x30000000 - 1),
  187. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  188. },
  189. };
  190. static struct platform_device at91rm9200_cf_device = {
  191. .name = "at91_cf",
  192. .id = -1,
  193. .dev = {
  194. .platform_data = &cf_data,
  195. },
  196. .resource = cf_resources,
  197. .num_resources = ARRAY_SIZE(cf_resources),
  198. };
  199. void __init at91_add_device_cf(struct at91_cf_data *data)
  200. {
  201. unsigned int csa;
  202. if (!data)
  203. return;
  204. data->chipselect = 4; /* can only use EBI ChipSelect 4 */
  205. /* CF takes over CS4, CS5, CS6 */
  206. csa = at91_ramc_read(0, AT91_EBI_CSA);
  207. at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
  208. /*
  209. * Static memory controller timing adjustments.
  210. * REVISIT: these timings are in terms of MCK cycles, so
  211. * when MCK changes (cpufreq etc) so must these values...
  212. */
  213. at91_ramc_write(0, AT91_SMC_CSR(4),
  214. AT91_SMC_ACSS_STD
  215. | AT91_SMC_DBW_16
  216. | AT91_SMC_BAT
  217. | AT91_SMC_WSEN
  218. | AT91_SMC_NWS_(32) /* wait states */
  219. | AT91_SMC_RWSETUP_(6) /* setup time */
  220. | AT91_SMC_RWHOLD_(4) /* hold time */
  221. );
  222. /* input/irq */
  223. if (gpio_is_valid(data->irq_pin)) {
  224. at91_set_gpio_input(data->irq_pin, 1);
  225. at91_set_deglitch(data->irq_pin, 1);
  226. }
  227. at91_set_gpio_input(data->det_pin, 1);
  228. at91_set_deglitch(data->det_pin, 1);
  229. /* outputs, initially off */
  230. if (gpio_is_valid(data->vcc_pin))
  231. at91_set_gpio_output(data->vcc_pin, 0);
  232. at91_set_gpio_output(data->rst_pin, 0);
  233. /* force poweron defaults for these pins ... */
  234. at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
  235. at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
  236. at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
  237. at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
  238. /* nWAIT is _not_ a default setting */
  239. at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
  240. cf_data = *data;
  241. platform_device_register(&at91rm9200_cf_device);
  242. }
  243. #else
  244. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  245. #endif
  246. /* --------------------------------------------------------------------
  247. * MMC / SD
  248. * -------------------------------------------------------------------- */
  249. #if IS_ENABLED(CONFIG_MMC_ATMELMCI)
  250. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  251. static struct mci_platform_data mmc_data;
  252. static struct resource mmc_resources[] = {
  253. [0] = {
  254. .start = AT91RM9200_BASE_MCI,
  255. .end = AT91RM9200_BASE_MCI + SZ_16K - 1,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. [1] = {
  259. .start = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
  260. .end = NR_IRQS_LEGACY + AT91RM9200_ID_MCI,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. static struct platform_device at91rm9200_mmc_device = {
  265. .name = "atmel_mci",
  266. .id = -1,
  267. .dev = {
  268. .dma_mask = &mmc_dmamask,
  269. .coherent_dma_mask = DMA_BIT_MASK(32),
  270. .platform_data = &mmc_data,
  271. },
  272. .resource = mmc_resources,
  273. .num_resources = ARRAY_SIZE(mmc_resources),
  274. };
  275. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  276. {
  277. unsigned int i;
  278. unsigned int slot_count = 0;
  279. if (!data)
  280. return;
  281. for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
  282. if (!data->slot[i].bus_width)
  283. continue;
  284. /* input/irq */
  285. if (gpio_is_valid(data->slot[i].detect_pin)) {
  286. at91_set_gpio_input(data->slot[i].detect_pin, 1);
  287. at91_set_deglitch(data->slot[i].detect_pin, 1);
  288. }
  289. if (gpio_is_valid(data->slot[i].wp_pin))
  290. at91_set_gpio_input(data->slot[i].wp_pin, 1);
  291. switch (i) {
  292. case 0: /* slot A */
  293. /* CMD */
  294. at91_set_A_periph(AT91_PIN_PA28, 1);
  295. /* DAT0, maybe DAT1..DAT3 */
  296. at91_set_A_periph(AT91_PIN_PA29, 1);
  297. if (data->slot[i].bus_width == 4) {
  298. at91_set_B_periph(AT91_PIN_PB3, 1);
  299. at91_set_B_periph(AT91_PIN_PB4, 1);
  300. at91_set_B_periph(AT91_PIN_PB5, 1);
  301. }
  302. slot_count++;
  303. break;
  304. case 1: /* slot B */
  305. /* CMD */
  306. at91_set_B_periph(AT91_PIN_PA8, 1);
  307. /* DAT0, maybe DAT1..DAT3 */
  308. at91_set_B_periph(AT91_PIN_PA9, 1);
  309. if (data->slot[i].bus_width == 4) {
  310. at91_set_B_periph(AT91_PIN_PA10, 1);
  311. at91_set_B_periph(AT91_PIN_PA11, 1);
  312. at91_set_B_periph(AT91_PIN_PA12, 1);
  313. }
  314. slot_count++;
  315. break;
  316. default:
  317. printk(KERN_ERR
  318. "AT91: SD/MMC slot %d not available\n", i);
  319. break;
  320. }
  321. if (slot_count) {
  322. /* CLK */
  323. at91_set_A_periph(AT91_PIN_PA27, 0);
  324. mmc_data = *data;
  325. platform_device_register(&at91rm9200_mmc_device);
  326. }
  327. }
  328. }
  329. #else
  330. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  331. #endif
  332. /* --------------------------------------------------------------------
  333. * NAND / SmartMedia
  334. * -------------------------------------------------------------------- */
  335. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  336. static struct atmel_nand_data nand_data;
  337. #define NAND_BASE AT91_CHIPSELECT_3
  338. static struct resource nand_resources[] = {
  339. {
  340. .start = NAND_BASE,
  341. .end = NAND_BASE + SZ_256M - 1,
  342. .flags = IORESOURCE_MEM,
  343. }
  344. };
  345. static struct platform_device at91rm9200_nand_device = {
  346. .name = "atmel_nand",
  347. .id = -1,
  348. .dev = {
  349. .platform_data = &nand_data,
  350. },
  351. .resource = nand_resources,
  352. .num_resources = ARRAY_SIZE(nand_resources),
  353. };
  354. void __init at91_add_device_nand(struct atmel_nand_data *data)
  355. {
  356. unsigned int csa;
  357. if (!data)
  358. return;
  359. /* enable the address range of CS3 */
  360. csa = at91_ramc_read(0, AT91_EBI_CSA);
  361. at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
  362. /* set the bus interface characteristics */
  363. at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
  364. | AT91_SMC_NWS_(5)
  365. | AT91_SMC_TDF_(1)
  366. | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
  367. | AT91_SMC_RWHOLD_(1) /* tDH Data Hold Time 20 - ns */
  368. );
  369. /* enable pin */
  370. if (gpio_is_valid(data->enable_pin))
  371. at91_set_gpio_output(data->enable_pin, 1);
  372. /* ready/busy pin */
  373. if (gpio_is_valid(data->rdy_pin))
  374. at91_set_gpio_input(data->rdy_pin, 1);
  375. /* card detect pin */
  376. if (gpio_is_valid(data->det_pin))
  377. at91_set_gpio_input(data->det_pin, 1);
  378. at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
  379. at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
  380. nand_data = *data;
  381. platform_device_register(&at91rm9200_nand_device);
  382. }
  383. #else
  384. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  385. #endif
  386. /* --------------------------------------------------------------------
  387. * TWI (i2c)
  388. * -------------------------------------------------------------------- */
  389. /*
  390. * Prefer the GPIO code since the TWI controller isn't robust
  391. * (gets overruns and underruns under load) and can only issue
  392. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  393. */
  394. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  395. static struct i2c_gpio_platform_data pdata = {
  396. .sda_pin = AT91_PIN_PA25,
  397. .sda_is_open_drain = 1,
  398. .scl_pin = AT91_PIN_PA26,
  399. .scl_is_open_drain = 1,
  400. .udelay = 2, /* ~100 kHz */
  401. };
  402. static struct platform_device at91rm9200_twi_device = {
  403. .name = "i2c-gpio",
  404. .id = 0,
  405. .dev.platform_data = &pdata,
  406. };
  407. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  408. {
  409. at91_set_GPIO_periph(AT91_PIN_PA25, 1); /* TWD (SDA) */
  410. at91_set_multi_drive(AT91_PIN_PA25, 1);
  411. at91_set_GPIO_periph(AT91_PIN_PA26, 1); /* TWCK (SCL) */
  412. at91_set_multi_drive(AT91_PIN_PA26, 1);
  413. i2c_register_board_info(0, devices, nr_devices);
  414. platform_device_register(&at91rm9200_twi_device);
  415. }
  416. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  417. static struct resource twi_resources[] = {
  418. [0] = {
  419. .start = AT91RM9200_BASE_TWI,
  420. .end = AT91RM9200_BASE_TWI + SZ_16K - 1,
  421. .flags = IORESOURCE_MEM,
  422. },
  423. [1] = {
  424. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
  425. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TWI,
  426. .flags = IORESOURCE_IRQ,
  427. },
  428. };
  429. static struct platform_device at91rm9200_twi_device = {
  430. .name = "i2c-at91rm9200",
  431. .id = 0,
  432. .resource = twi_resources,
  433. .num_resources = ARRAY_SIZE(twi_resources),
  434. };
  435. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  436. {
  437. /* pins used for TWI interface */
  438. at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
  439. at91_set_multi_drive(AT91_PIN_PA25, 1);
  440. at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
  441. at91_set_multi_drive(AT91_PIN_PA26, 1);
  442. i2c_register_board_info(0, devices, nr_devices);
  443. platform_device_register(&at91rm9200_twi_device);
  444. }
  445. #else
  446. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  447. #endif
  448. /* --------------------------------------------------------------------
  449. * SPI
  450. * -------------------------------------------------------------------- */
  451. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  452. static u64 spi_dmamask = DMA_BIT_MASK(32);
  453. static struct resource spi_resources[] = {
  454. [0] = {
  455. .start = AT91RM9200_BASE_SPI,
  456. .end = AT91RM9200_BASE_SPI + SZ_16K - 1,
  457. .flags = IORESOURCE_MEM,
  458. },
  459. [1] = {
  460. .start = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
  461. .end = NR_IRQS_LEGACY + AT91RM9200_ID_SPI,
  462. .flags = IORESOURCE_IRQ,
  463. },
  464. };
  465. static struct platform_device at91rm9200_spi_device = {
  466. .name = "atmel_spi",
  467. .id = 0,
  468. .dev = {
  469. .dma_mask = &spi_dmamask,
  470. .coherent_dma_mask = DMA_BIT_MASK(32),
  471. },
  472. .resource = spi_resources,
  473. .num_resources = ARRAY_SIZE(spi_resources),
  474. };
  475. static const unsigned spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
  476. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  477. {
  478. int i;
  479. unsigned long cs_pin;
  480. at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */
  481. at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */
  482. at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */
  483. /* Enable SPI chip-selects */
  484. for (i = 0; i < nr_devices; i++) {
  485. if (devices[i].controller_data)
  486. cs_pin = (unsigned long) devices[i].controller_data;
  487. else
  488. cs_pin = spi_standard_cs[devices[i].chip_select];
  489. if (devices[i].chip_select == 0) /* for CS0 errata */
  490. at91_set_A_periph(cs_pin, 0);
  491. else
  492. at91_set_gpio_output(cs_pin, 1);
  493. /* pass chip-select pin to driver */
  494. devices[i].controller_data = (void *) cs_pin;
  495. }
  496. spi_register_board_info(devices, nr_devices);
  497. platform_device_register(&at91rm9200_spi_device);
  498. }
  499. #else
  500. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  501. #endif
  502. /* --------------------------------------------------------------------
  503. * Timer/Counter blocks
  504. * -------------------------------------------------------------------- */
  505. #ifdef CONFIG_ATMEL_TCLIB
  506. static struct resource tcb0_resources[] = {
  507. [0] = {
  508. .start = AT91RM9200_BASE_TCB0,
  509. .end = AT91RM9200_BASE_TCB0 + SZ_16K - 1,
  510. .flags = IORESOURCE_MEM,
  511. },
  512. [1] = {
  513. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
  514. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC0,
  515. .flags = IORESOURCE_IRQ,
  516. },
  517. [2] = {
  518. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
  519. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC1,
  520. .flags = IORESOURCE_IRQ,
  521. },
  522. [3] = {
  523. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
  524. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC2,
  525. .flags = IORESOURCE_IRQ,
  526. },
  527. };
  528. static struct platform_device at91rm9200_tcb0_device = {
  529. .name = "atmel_tcb",
  530. .id = 0,
  531. .resource = tcb0_resources,
  532. .num_resources = ARRAY_SIZE(tcb0_resources),
  533. };
  534. static struct resource tcb1_resources[] = {
  535. [0] = {
  536. .start = AT91RM9200_BASE_TCB1,
  537. .end = AT91RM9200_BASE_TCB1 + SZ_16K - 1,
  538. .flags = IORESOURCE_MEM,
  539. },
  540. [1] = {
  541. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
  542. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC3,
  543. .flags = IORESOURCE_IRQ,
  544. },
  545. [2] = {
  546. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
  547. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC4,
  548. .flags = IORESOURCE_IRQ,
  549. },
  550. [3] = {
  551. .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
  552. .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC5,
  553. .flags = IORESOURCE_IRQ,
  554. },
  555. };
  556. static struct platform_device at91rm9200_tcb1_device = {
  557. .name = "atmel_tcb",
  558. .id = 1,
  559. .resource = tcb1_resources,
  560. .num_resources = ARRAY_SIZE(tcb1_resources),
  561. };
  562. static void __init at91_add_device_tc(void)
  563. {
  564. platform_device_register(&at91rm9200_tcb0_device);
  565. platform_device_register(&at91rm9200_tcb1_device);
  566. }
  567. #else
  568. static void __init at91_add_device_tc(void) { }
  569. #endif
  570. /* --------------------------------------------------------------------
  571. * RTC
  572. * -------------------------------------------------------------------- */
  573. #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
  574. static struct resource rtc_resources[] = {
  575. [0] = {
  576. .start = AT91RM9200_BASE_RTC,
  577. .end = AT91RM9200_BASE_RTC + SZ_256 - 1,
  578. .flags = IORESOURCE_MEM,
  579. },
  580. [1] = {
  581. .start = NR_IRQS_LEGACY + AT91_ID_SYS,
  582. .end = NR_IRQS_LEGACY + AT91_ID_SYS,
  583. .flags = IORESOURCE_IRQ,
  584. },
  585. };
  586. static struct platform_device at91rm9200_rtc_device = {
  587. .name = "at91_rtc",
  588. .id = -1,
  589. .resource = rtc_resources,
  590. .num_resources = ARRAY_SIZE(rtc_resources),
  591. };
  592. static void __init at91_add_device_rtc(void)
  593. {
  594. platform_device_register(&at91rm9200_rtc_device);
  595. }
  596. #else
  597. static void __init at91_add_device_rtc(void) {}
  598. #endif
  599. /* --------------------------------------------------------------------
  600. * Watchdog
  601. * -------------------------------------------------------------------- */
  602. #if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE)
  603. static struct platform_device at91rm9200_wdt_device = {
  604. .name = "at91_wdt",
  605. .id = -1,
  606. .num_resources = 0,
  607. };
  608. static void __init at91_add_device_watchdog(void)
  609. {
  610. platform_device_register(&at91rm9200_wdt_device);
  611. }
  612. #else
  613. static void __init at91_add_device_watchdog(void) {}
  614. #endif
  615. /* --------------------------------------------------------------------
  616. * SSC -- Synchronous Serial Controller
  617. * -------------------------------------------------------------------- */
  618. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  619. static u64 ssc0_dmamask = DMA_BIT_MASK(32);
  620. static struct resource ssc0_resources[] = {
  621. [0] = {
  622. .start = AT91RM9200_BASE_SSC0,
  623. .end = AT91RM9200_BASE_SSC0 + SZ_16K - 1,
  624. .flags = IORESOURCE_MEM,
  625. },
  626. [1] = {
  627. .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0,
  628. .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0,
  629. .flags = IORESOURCE_IRQ,
  630. },
  631. };
  632. static struct platform_device at91rm9200_ssc0_device = {
  633. .name = "at91rm9200_ssc",
  634. .id = 0,
  635. .dev = {
  636. .dma_mask = &ssc0_dmamask,
  637. .coherent_dma_mask = DMA_BIT_MASK(32),
  638. },
  639. .resource = ssc0_resources,
  640. .num_resources = ARRAY_SIZE(ssc0_resources),
  641. };
  642. static inline void configure_ssc0_pins(unsigned pins)
  643. {
  644. if (pins & ATMEL_SSC_TF)
  645. at91_set_A_periph(AT91_PIN_PB0, 1);
  646. if (pins & ATMEL_SSC_TK)
  647. at91_set_A_periph(AT91_PIN_PB1, 1);
  648. if (pins & ATMEL_SSC_TD)
  649. at91_set_A_periph(AT91_PIN_PB2, 1);
  650. if (pins & ATMEL_SSC_RD)
  651. at91_set_A_periph(AT91_PIN_PB3, 1);
  652. if (pins & ATMEL_SSC_RK)
  653. at91_set_A_periph(AT91_PIN_PB4, 1);
  654. if (pins & ATMEL_SSC_RF)
  655. at91_set_A_periph(AT91_PIN_PB5, 1);
  656. }
  657. static u64 ssc1_dmamask = DMA_BIT_MASK(32);
  658. static struct resource ssc1_resources[] = {
  659. [0] = {
  660. .start = AT91RM9200_BASE_SSC1,
  661. .end = AT91RM9200_BASE_SSC1 + SZ_16K - 1,
  662. .flags = IORESOURCE_MEM,
  663. },
  664. [1] = {
  665. .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1,
  666. .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1,
  667. .flags = IORESOURCE_IRQ,
  668. },
  669. };
  670. static struct platform_device at91rm9200_ssc1_device = {
  671. .name = "at91rm9200_ssc",
  672. .id = 1,
  673. .dev = {
  674. .dma_mask = &ssc1_dmamask,
  675. .coherent_dma_mask = DMA_BIT_MASK(32),
  676. },
  677. .resource = ssc1_resources,
  678. .num_resources = ARRAY_SIZE(ssc1_resources),
  679. };
  680. static inline void configure_ssc1_pins(unsigned pins)
  681. {
  682. if (pins & ATMEL_SSC_TF)
  683. at91_set_A_periph(AT91_PIN_PB6, 1);
  684. if (pins & ATMEL_SSC_TK)
  685. at91_set_A_periph(AT91_PIN_PB7, 1);
  686. if (pins & ATMEL_SSC_TD)
  687. at91_set_A_periph(AT91_PIN_PB8, 1);
  688. if (pins & ATMEL_SSC_RD)
  689. at91_set_A_periph(AT91_PIN_PB9, 1);
  690. if (pins & ATMEL_SSC_RK)
  691. at91_set_A_periph(AT91_PIN_PB10, 1);
  692. if (pins & ATMEL_SSC_RF)
  693. at91_set_A_periph(AT91_PIN_PB11, 1);
  694. }
  695. static u64 ssc2_dmamask = DMA_BIT_MASK(32);
  696. static struct resource ssc2_resources[] = {
  697. [0] = {
  698. .start = AT91RM9200_BASE_SSC2,
  699. .end = AT91RM9200_BASE_SSC2 + SZ_16K - 1,
  700. .flags = IORESOURCE_MEM,
  701. },
  702. [1] = {
  703. .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2,
  704. .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2,
  705. .flags = IORESOURCE_IRQ,
  706. },
  707. };
  708. static struct platform_device at91rm9200_ssc2_device = {
  709. .name = "at91rm9200_ssc",
  710. .id = 2,
  711. .dev = {
  712. .dma_mask = &ssc2_dmamask,
  713. .coherent_dma_mask = DMA_BIT_MASK(32),
  714. },
  715. .resource = ssc2_resources,
  716. .num_resources = ARRAY_SIZE(ssc2_resources),
  717. };
  718. static inline void configure_ssc2_pins(unsigned pins)
  719. {
  720. if (pins & ATMEL_SSC_TF)
  721. at91_set_A_periph(AT91_PIN_PB12, 1);
  722. if (pins & ATMEL_SSC_TK)
  723. at91_set_A_periph(AT91_PIN_PB13, 1);
  724. if (pins & ATMEL_SSC_TD)
  725. at91_set_A_periph(AT91_PIN_PB14, 1);
  726. if (pins & ATMEL_SSC_RD)
  727. at91_set_A_periph(AT91_PIN_PB15, 1);
  728. if (pins & ATMEL_SSC_RK)
  729. at91_set_A_periph(AT91_PIN_PB16, 1);
  730. if (pins & ATMEL_SSC_RF)
  731. at91_set_A_periph(AT91_PIN_PB17, 1);
  732. }
  733. /*
  734. * SSC controllers are accessed through library code, instead of any
  735. * kind of all-singing/all-dancing driver. For example one could be
  736. * used by a particular I2S audio codec's driver, while another one
  737. * on the same system might be used by a custom data capture driver.
  738. */
  739. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  740. {
  741. struct platform_device *pdev;
  742. /*
  743. * NOTE: caller is responsible for passing information matching
  744. * "pins" to whatever will be using each particular controller.
  745. */
  746. switch (id) {
  747. case AT91RM9200_ID_SSC0:
  748. pdev = &at91rm9200_ssc0_device;
  749. configure_ssc0_pins(pins);
  750. break;
  751. case AT91RM9200_ID_SSC1:
  752. pdev = &at91rm9200_ssc1_device;
  753. configure_ssc1_pins(pins);
  754. break;
  755. case AT91RM9200_ID_SSC2:
  756. pdev = &at91rm9200_ssc2_device;
  757. configure_ssc2_pins(pins);
  758. break;
  759. default:
  760. return;
  761. }
  762. platform_device_register(pdev);
  763. }
  764. #else
  765. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  766. #endif
  767. /* --------------------------------------------------------------------
  768. * UART
  769. * -------------------------------------------------------------------- */
  770. #if defined(CONFIG_SERIAL_ATMEL)
  771. static struct resource dbgu_resources[] = {
  772. [0] = {
  773. .start = AT91RM9200_BASE_DBGU,
  774. .end = AT91RM9200_BASE_DBGU + SZ_512 - 1,
  775. .flags = IORESOURCE_MEM,
  776. },
  777. [1] = {
  778. .start = NR_IRQS_LEGACY + AT91_ID_SYS,
  779. .end = NR_IRQS_LEGACY + AT91_ID_SYS,
  780. .flags = IORESOURCE_IRQ,
  781. },
  782. };
  783. static struct atmel_uart_data dbgu_data = {
  784. .use_dma_tx = 0,
  785. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  786. .rts_gpio = -EINVAL,
  787. };
  788. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  789. static struct platform_device at91rm9200_dbgu_device = {
  790. .name = "atmel_usart",
  791. .id = 0,
  792. .dev = {
  793. .dma_mask = &dbgu_dmamask,
  794. .coherent_dma_mask = DMA_BIT_MASK(32),
  795. .platform_data = &dbgu_data,
  796. },
  797. .resource = dbgu_resources,
  798. .num_resources = ARRAY_SIZE(dbgu_resources),
  799. };
  800. static inline void configure_dbgu_pins(void)
  801. {
  802. at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */
  803. at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */
  804. }
  805. static struct resource uart0_resources[] = {
  806. [0] = {
  807. .start = AT91RM9200_BASE_US0,
  808. .end = AT91RM9200_BASE_US0 + SZ_16K - 1,
  809. .flags = IORESOURCE_MEM,
  810. },
  811. [1] = {
  812. .start = NR_IRQS_LEGACY + AT91RM9200_ID_US0,
  813. .end = NR_IRQS_LEGACY + AT91RM9200_ID_US0,
  814. .flags = IORESOURCE_IRQ,
  815. },
  816. };
  817. static struct atmel_uart_data uart0_data = {
  818. .use_dma_tx = 1,
  819. .use_dma_rx = 1,
  820. .rts_gpio = -EINVAL,
  821. };
  822. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  823. static struct platform_device at91rm9200_uart0_device = {
  824. .name = "atmel_usart",
  825. .id = 1,
  826. .dev = {
  827. .dma_mask = &uart0_dmamask,
  828. .coherent_dma_mask = DMA_BIT_MASK(32),
  829. .platform_data = &uart0_data,
  830. },
  831. .resource = uart0_resources,
  832. .num_resources = ARRAY_SIZE(uart0_resources),
  833. };
  834. static inline void configure_usart0_pins(unsigned pins)
  835. {
  836. at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */
  837. at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */
  838. if (pins & ATMEL_UART_CTS)
  839. at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */
  840. if (pins & ATMEL_UART_RTS) {
  841. /*
  842. * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21.
  843. * We need to drive the pin manually. The serial driver will driver
  844. * this to high when initializing.
  845. */
  846. uart0_data.rts_gpio = AT91_PIN_PA21;
  847. }
  848. }
  849. static struct resource uart1_resources[] = {
  850. [0] = {
  851. .start = AT91RM9200_BASE_US1,
  852. .end = AT91RM9200_BASE_US1 + SZ_16K - 1,
  853. .flags = IORESOURCE_MEM,
  854. },
  855. [1] = {
  856. .start = NR_IRQS_LEGACY + AT91RM9200_ID_US1,
  857. .end = NR_IRQS_LEGACY + AT91RM9200_ID_US1,
  858. .flags = IORESOURCE_IRQ,
  859. },
  860. };
  861. static struct atmel_uart_data uart1_data = {
  862. .use_dma_tx = 1,
  863. .use_dma_rx = 1,
  864. .rts_gpio = -EINVAL,
  865. };
  866. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  867. static struct platform_device at91rm9200_uart1_device = {
  868. .name = "atmel_usart",
  869. .id = 2,
  870. .dev = {
  871. .dma_mask = &uart1_dmamask,
  872. .coherent_dma_mask = DMA_BIT_MASK(32),
  873. .platform_data = &uart1_data,
  874. },
  875. .resource = uart1_resources,
  876. .num_resources = ARRAY_SIZE(uart1_resources),
  877. };
  878. static inline void configure_usart1_pins(unsigned pins)
  879. {
  880. at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */
  881. at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */
  882. if (pins & ATMEL_UART_RI)
  883. at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */
  884. if (pins & ATMEL_UART_DTR)
  885. at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */
  886. if (pins & ATMEL_UART_DCD)
  887. at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */
  888. if (pins & ATMEL_UART_CTS)
  889. at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */
  890. if (pins & ATMEL_UART_DSR)
  891. at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */
  892. if (pins & ATMEL_UART_RTS)
  893. at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */
  894. }
  895. static struct resource uart2_resources[] = {
  896. [0] = {
  897. .start = AT91RM9200_BASE_US2,
  898. .end = AT91RM9200_BASE_US2 + SZ_16K - 1,
  899. .flags = IORESOURCE_MEM,
  900. },
  901. [1] = {
  902. .start = NR_IRQS_LEGACY + AT91RM9200_ID_US2,
  903. .end = NR_IRQS_LEGACY + AT91RM9200_ID_US2,
  904. .flags = IORESOURCE_IRQ,
  905. },
  906. };
  907. static struct atmel_uart_data uart2_data = {
  908. .use_dma_tx = 1,
  909. .use_dma_rx = 1,
  910. .rts_gpio = -EINVAL,
  911. };
  912. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  913. static struct platform_device at91rm9200_uart2_device = {
  914. .name = "atmel_usart",
  915. .id = 3,
  916. .dev = {
  917. .dma_mask = &uart2_dmamask,
  918. .coherent_dma_mask = DMA_BIT_MASK(32),
  919. .platform_data = &uart2_data,
  920. },
  921. .resource = uart2_resources,
  922. .num_resources = ARRAY_SIZE(uart2_resources),
  923. };
  924. static inline void configure_usart2_pins(unsigned pins)
  925. {
  926. at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */
  927. at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */
  928. if (pins & ATMEL_UART_CTS)
  929. at91_set_B_periph(AT91_PIN_PA30, 0); /* CTS2 */
  930. if (pins & ATMEL_UART_RTS)
  931. at91_set_B_periph(AT91_PIN_PA31, 0); /* RTS2 */
  932. }
  933. static struct resource uart3_resources[] = {
  934. [0] = {
  935. .start = AT91RM9200_BASE_US3,
  936. .end = AT91RM9200_BASE_US3 + SZ_16K - 1,
  937. .flags = IORESOURCE_MEM,
  938. },
  939. [1] = {
  940. .start = NR_IRQS_LEGACY + AT91RM9200_ID_US3,
  941. .end = NR_IRQS_LEGACY + AT91RM9200_ID_US3,
  942. .flags = IORESOURCE_IRQ,
  943. },
  944. };
  945. static struct atmel_uart_data uart3_data = {
  946. .use_dma_tx = 1,
  947. .use_dma_rx = 1,
  948. .rts_gpio = -EINVAL,
  949. };
  950. static u64 uart3_dmamask = DMA_BIT_MASK(32);
  951. static struct platform_device at91rm9200_uart3_device = {
  952. .name = "atmel_usart",
  953. .id = 4,
  954. .dev = {
  955. .dma_mask = &uart3_dmamask,
  956. .coherent_dma_mask = DMA_BIT_MASK(32),
  957. .platform_data = &uart3_data,
  958. },
  959. .resource = uart3_resources,
  960. .num_resources = ARRAY_SIZE(uart3_resources),
  961. };
  962. static inline void configure_usart3_pins(unsigned pins)
  963. {
  964. at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */
  965. at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */
  966. if (pins & ATMEL_UART_CTS)
  967. at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */
  968. if (pins & ATMEL_UART_RTS)
  969. at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */
  970. }
  971. static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  972. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  973. {
  974. struct platform_device *pdev;
  975. struct atmel_uart_data *pdata;
  976. switch (id) {
  977. case 0: /* DBGU */
  978. pdev = &at91rm9200_dbgu_device;
  979. configure_dbgu_pins();
  980. break;
  981. case AT91RM9200_ID_US0:
  982. pdev = &at91rm9200_uart0_device;
  983. configure_usart0_pins(pins);
  984. break;
  985. case AT91RM9200_ID_US1:
  986. pdev = &at91rm9200_uart1_device;
  987. configure_usart1_pins(pins);
  988. break;
  989. case AT91RM9200_ID_US2:
  990. pdev = &at91rm9200_uart2_device;
  991. configure_usart2_pins(pins);
  992. break;
  993. case AT91RM9200_ID_US3:
  994. pdev = &at91rm9200_uart3_device;
  995. configure_usart3_pins(pins);
  996. break;
  997. default:
  998. return;
  999. }
  1000. pdata = pdev->dev.platform_data;
  1001. pdata->num = portnr; /* update to mapped ID */
  1002. if (portnr < ATMEL_MAX_UART)
  1003. at91_uarts[portnr] = pdev;
  1004. }
  1005. void __init at91_add_device_serial(void)
  1006. {
  1007. int i;
  1008. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1009. if (at91_uarts[i])
  1010. platform_device_register(at91_uarts[i]);
  1011. }
  1012. }
  1013. #else
  1014. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1015. void __init at91_add_device_serial(void) {}
  1016. #endif
  1017. /* -------------------------------------------------------------------- */
  1018. /*
  1019. * These devices are always present and don't need any board-specific
  1020. * setup.
  1021. */
  1022. static int __init at91_add_standard_devices(void)
  1023. {
  1024. at91_add_device_rtc();
  1025. at91_add_device_watchdog();
  1026. at91_add_device_tc();
  1027. return 0;
  1028. }
  1029. arch_initcall(at91_add_standard_devices);