at91rm9200_devices.c 31 KB

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