at91rm9200_devices.c 31 KB

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