at91sam9rl_devices.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. * Copyright (C) 2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file COPYING in the main directory of this archive for
  6. * more details.
  7. */
  8. #include <asm/mach/arch.h>
  9. #include <asm/mach/map.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/i2c-gpio.h>
  12. #include <linux/fb.h>
  13. #include <video/atmel_lcdc.h>
  14. #include <asm/arch/board.h>
  15. #include <asm/arch/gpio.h>
  16. #include <asm/arch/at91sam9rl.h>
  17. #include <asm/arch/at91sam9rl_matrix.h>
  18. #include <asm/arch/at91sam926x_mc.h>
  19. #include "generic.h"
  20. /* --------------------------------------------------------------------
  21. * MMC / SD
  22. * -------------------------------------------------------------------- */
  23. #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
  24. static u64 mmc_dmamask = 0xffffffffUL;
  25. static struct at91_mmc_data mmc_data;
  26. static struct resource mmc_resources[] = {
  27. [0] = {
  28. .start = AT91SAM9RL_BASE_MCI,
  29. .end = AT91SAM9RL_BASE_MCI + SZ_16K - 1,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. [1] = {
  33. .start = AT91SAM9RL_ID_MCI,
  34. .end = AT91SAM9RL_ID_MCI,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct platform_device at91sam9rl_mmc_device = {
  39. .name = "at91_mci",
  40. .id = -1,
  41. .dev = {
  42. .dma_mask = &mmc_dmamask,
  43. .coherent_dma_mask = 0xffffffff,
  44. .platform_data = &mmc_data,
  45. },
  46. .resource = mmc_resources,
  47. .num_resources = ARRAY_SIZE(mmc_resources),
  48. };
  49. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
  50. {
  51. if (!data)
  52. return;
  53. /* input/irq */
  54. if (data->det_pin) {
  55. at91_set_gpio_input(data->det_pin, 1);
  56. at91_set_deglitch(data->det_pin, 1);
  57. }
  58. if (data->wp_pin)
  59. at91_set_gpio_input(data->wp_pin, 1);
  60. if (data->vcc_pin)
  61. at91_set_gpio_output(data->vcc_pin, 0);
  62. /* CLK */
  63. at91_set_A_periph(AT91_PIN_PA2, 0);
  64. /* CMD */
  65. at91_set_A_periph(AT91_PIN_PA1, 1);
  66. /* DAT0, maybe DAT1..DAT3 */
  67. at91_set_A_periph(AT91_PIN_PA0, 1);
  68. if (data->wire4) {
  69. at91_set_A_periph(AT91_PIN_PA3, 1);
  70. at91_set_A_periph(AT91_PIN_PA4, 1);
  71. at91_set_A_periph(AT91_PIN_PA5, 1);
  72. }
  73. mmc_data = *data;
  74. platform_device_register(&at91sam9rl_mmc_device);
  75. }
  76. #else
  77. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
  78. #endif
  79. /* --------------------------------------------------------------------
  80. * NAND / SmartMedia
  81. * -------------------------------------------------------------------- */
  82. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  83. static struct at91_nand_data nand_data;
  84. #define NAND_BASE AT91_CHIPSELECT_3
  85. static struct resource nand_resources[] = {
  86. {
  87. .start = NAND_BASE,
  88. .end = NAND_BASE + SZ_256M - 1,
  89. .flags = IORESOURCE_MEM,
  90. }
  91. };
  92. static struct platform_device at91_nand_device = {
  93. .name = "at91_nand",
  94. .id = -1,
  95. .dev = {
  96. .platform_data = &nand_data,
  97. },
  98. .resource = nand_resources,
  99. .num_resources = ARRAY_SIZE(nand_resources),
  100. };
  101. void __init at91_add_device_nand(struct at91_nand_data *data)
  102. {
  103. unsigned long csa;
  104. if (!data)
  105. return;
  106. csa = at91_sys_read(AT91_MATRIX_EBICSA);
  107. at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
  108. /* set the bus interface characteristics */
  109. at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
  110. | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
  111. at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)
  112. | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));
  113. at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
  114. at91_sys_write(AT91_SMC_MODE(3), AT91_SMC_DBW_8 | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1));
  115. /* enable pin */
  116. if (data->enable_pin)
  117. at91_set_gpio_output(data->enable_pin, 1);
  118. /* ready/busy pin */
  119. if (data->rdy_pin)
  120. at91_set_gpio_input(data->rdy_pin, 1);
  121. /* card detect pin */
  122. if (data->det_pin)
  123. at91_set_gpio_input(data->det_pin, 1);
  124. at91_set_A_periph(AT91_PIN_PB4, 0); /* NANDOE */
  125. at91_set_A_periph(AT91_PIN_PB5, 0); /* NANDWE */
  126. nand_data = *data;
  127. platform_device_register(&at91_nand_device);
  128. }
  129. #else
  130. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  131. #endif
  132. /* --------------------------------------------------------------------
  133. * TWI (i2c)
  134. * -------------------------------------------------------------------- */
  135. /*
  136. * Prefer the GPIO code since the TWI controller isn't robust
  137. * (gets overruns and underruns under load) and can only issue
  138. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  139. */
  140. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  141. static struct i2c_gpio_platform_data pdata = {
  142. .sda_pin = AT91_PIN_PA23,
  143. .sda_is_open_drain = 1,
  144. .scl_pin = AT91_PIN_PA24,
  145. .scl_is_open_drain = 1,
  146. .udelay = 2, /* ~100 kHz */
  147. };
  148. static struct platform_device at91sam9rl_twi_device = {
  149. .name = "i2c-gpio",
  150. .id = -1,
  151. .dev.platform_data = &pdata,
  152. };
  153. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  154. {
  155. at91_set_GPIO_periph(AT91_PIN_PA23, 1); /* TWD (SDA) */
  156. at91_set_multi_drive(AT91_PIN_PA23, 1);
  157. at91_set_GPIO_periph(AT91_PIN_PA24, 1); /* TWCK (SCL) */
  158. at91_set_multi_drive(AT91_PIN_PA24, 1);
  159. i2c_register_board_info(0, devices, nr_devices);
  160. platform_device_register(&at91sam9rl_twi_device);
  161. }
  162. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  163. static struct resource twi_resources[] = {
  164. [0] = {
  165. .start = AT91SAM9RL_BASE_TWI0,
  166. .end = AT91SAM9RL_BASE_TWI0 + SZ_16K - 1,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. [1] = {
  170. .start = AT91SAM9RL_ID_TWI0,
  171. .end = AT91SAM9RL_ID_TWI0,
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device at91sam9rl_twi_device = {
  176. .name = "at91_i2c",
  177. .id = -1,
  178. .resource = twi_resources,
  179. .num_resources = ARRAY_SIZE(twi_resources),
  180. };
  181. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  182. {
  183. /* pins used for TWI interface */
  184. at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */
  185. at91_set_multi_drive(AT91_PIN_PA23, 1);
  186. at91_set_A_periph(AT91_PIN_PA24, 0); /* TWCK */
  187. at91_set_multi_drive(AT91_PIN_PA24, 1);
  188. i2c_register_board_info(0, devices, nr_devices);
  189. platform_device_register(&at91sam9rl_twi_device);
  190. }
  191. #else
  192. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  193. #endif
  194. /* --------------------------------------------------------------------
  195. * SPI
  196. * -------------------------------------------------------------------- */
  197. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  198. static u64 spi_dmamask = 0xffffffffUL;
  199. static struct resource spi_resources[] = {
  200. [0] = {
  201. .start = AT91SAM9RL_BASE_SPI,
  202. .end = AT91SAM9RL_BASE_SPI + SZ_16K - 1,
  203. .flags = IORESOURCE_MEM,
  204. },
  205. [1] = {
  206. .start = AT91SAM9RL_ID_SPI,
  207. .end = AT91SAM9RL_ID_SPI,
  208. .flags = IORESOURCE_IRQ,
  209. },
  210. };
  211. static struct platform_device at91sam9rl_spi_device = {
  212. .name = "atmel_spi",
  213. .id = 0,
  214. .dev = {
  215. .dma_mask = &spi_dmamask,
  216. .coherent_dma_mask = 0xffffffff,
  217. },
  218. .resource = spi_resources,
  219. .num_resources = ARRAY_SIZE(spi_resources),
  220. };
  221. static const unsigned spi_standard_cs[4] = { AT91_PIN_PA28, AT91_PIN_PB7, AT91_PIN_PD8, AT91_PIN_PD9 };
  222. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  223. {
  224. int i;
  225. unsigned long cs_pin;
  226. at91_set_A_periph(AT91_PIN_PA25, 0); /* MISO */
  227. at91_set_A_periph(AT91_PIN_PA26, 0); /* MOSI */
  228. at91_set_A_periph(AT91_PIN_PA27, 0); /* SPCK */
  229. /* Enable SPI chip-selects */
  230. for (i = 0; i < nr_devices; i++) {
  231. if (devices[i].controller_data)
  232. cs_pin = (unsigned long) devices[i].controller_data;
  233. else
  234. cs_pin = spi_standard_cs[devices[i].chip_select];
  235. /* enable chip-select pin */
  236. at91_set_gpio_output(cs_pin, 1);
  237. /* pass chip-select pin to driver */
  238. devices[i].controller_data = (void *) cs_pin;
  239. }
  240. spi_register_board_info(devices, nr_devices);
  241. platform_device_register(&at91sam9rl_spi_device);
  242. }
  243. #else
  244. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  245. #endif
  246. /* --------------------------------------------------------------------
  247. * LCD Controller
  248. * -------------------------------------------------------------------- */
  249. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  250. static u64 lcdc_dmamask = 0xffffffffUL;
  251. static struct atmel_lcdfb_info lcdc_data;
  252. static struct resource lcdc_resources[] = {
  253. [0] = {
  254. .start = AT91SAM9RL_LCDC_BASE,
  255. .end = AT91SAM9RL_LCDC_BASE + SZ_4K - 1,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. [1] = {
  259. .start = AT91SAM9RL_ID_LCDC,
  260. .end = AT91SAM9RL_ID_LCDC,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. #if defined(CONFIG_FB_INTSRAM)
  264. [2] = {
  265. .start = AT91SAM9RL_SRAM_BASE,
  266. .end = AT91SAM9RL_SRAM_BASE + AT91SAM9RL_SRAM_SIZE - 1,
  267. .flags = IORESOURCE_MEM,
  268. },
  269. #endif
  270. };
  271. static struct platform_device at91_lcdc_device = {
  272. .name = "atmel_lcdfb",
  273. .id = 0,
  274. .dev = {
  275. .dma_mask = &lcdc_dmamask,
  276. .coherent_dma_mask = 0xffffffff,
  277. .platform_data = &lcdc_data,
  278. },
  279. .resource = lcdc_resources,
  280. .num_resources = ARRAY_SIZE(lcdc_resources),
  281. };
  282. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  283. {
  284. if (!data) {
  285. return;
  286. }
  287. at91_set_B_periph(AT91_PIN_PC1, 0); /* LCDPWR */
  288. at91_set_A_periph(AT91_PIN_PC5, 0); /* LCDHSYNC */
  289. at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDDOTCK */
  290. at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDDEN */
  291. at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDCC */
  292. at91_set_B_periph(AT91_PIN_PC9, 0); /* LCDD3 */
  293. at91_set_B_periph(AT91_PIN_PC10, 0); /* LCDD4 */
  294. at91_set_B_periph(AT91_PIN_PC11, 0); /* LCDD5 */
  295. at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD6 */
  296. at91_set_B_periph(AT91_PIN_PC13, 0); /* LCDD7 */
  297. at91_set_B_periph(AT91_PIN_PC15, 0); /* LCDD11 */
  298. at91_set_B_periph(AT91_PIN_PC16, 0); /* LCDD12 */
  299. at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD13 */
  300. at91_set_B_periph(AT91_PIN_PC18, 0); /* LCDD14 */
  301. at91_set_B_periph(AT91_PIN_PC19, 0); /* LCDD15 */
  302. at91_set_B_periph(AT91_PIN_PC20, 0); /* LCDD18 */
  303. at91_set_B_periph(AT91_PIN_PC21, 0); /* LCDD19 */
  304. at91_set_B_periph(AT91_PIN_PC22, 0); /* LCDD20 */
  305. at91_set_B_periph(AT91_PIN_PC23, 0); /* LCDD21 */
  306. at91_set_B_periph(AT91_PIN_PC24, 0); /* LCDD22 */
  307. at91_set_B_periph(AT91_PIN_PC25, 0); /* LCDD23 */
  308. lcdc_data = *data;
  309. platform_device_register(&at91_lcdc_device);
  310. }
  311. #else
  312. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  313. #endif
  314. /* --------------------------------------------------------------------
  315. * LEDs
  316. * -------------------------------------------------------------------- */
  317. #if defined(CONFIG_LEDS)
  318. u8 at91_leds_cpu;
  319. u8 at91_leds_timer;
  320. void __init at91_init_leds(u8 cpu_led, u8 timer_led)
  321. {
  322. /* Enable GPIO to access the LEDs */
  323. at91_set_gpio_output(cpu_led, 1);
  324. at91_set_gpio_output(timer_led, 1);
  325. at91_leds_cpu = cpu_led;
  326. at91_leds_timer = timer_led;
  327. }
  328. #else
  329. void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
  330. #endif
  331. /* --------------------------------------------------------------------
  332. * UART
  333. * -------------------------------------------------------------------- */
  334. #if defined(CONFIG_SERIAL_ATMEL)
  335. static struct resource dbgu_resources[] = {
  336. [0] = {
  337. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  338. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  339. .flags = IORESOURCE_MEM,
  340. },
  341. [1] = {
  342. .start = AT91_ID_SYS,
  343. .end = AT91_ID_SYS,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct atmel_uart_data dbgu_data = {
  348. .use_dma_tx = 0,
  349. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  350. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  351. };
  352. static struct platform_device at91sam9rl_dbgu_device = {
  353. .name = "atmel_usart",
  354. .id = 0,
  355. .dev = {
  356. .platform_data = &dbgu_data,
  357. .coherent_dma_mask = 0xffffffff,
  358. },
  359. .resource = dbgu_resources,
  360. .num_resources = ARRAY_SIZE(dbgu_resources),
  361. };
  362. static inline void configure_dbgu_pins(void)
  363. {
  364. at91_set_A_periph(AT91_PIN_PA21, 0); /* DRXD */
  365. at91_set_A_periph(AT91_PIN_PA22, 1); /* DTXD */
  366. }
  367. static struct resource uart0_resources[] = {
  368. [0] = {
  369. .start = AT91SAM9RL_BASE_US0,
  370. .end = AT91SAM9RL_BASE_US0 + SZ_16K - 1,
  371. .flags = IORESOURCE_MEM,
  372. },
  373. [1] = {
  374. .start = AT91SAM9RL_ID_US0,
  375. .end = AT91SAM9RL_ID_US0,
  376. .flags = IORESOURCE_IRQ,
  377. },
  378. };
  379. static struct atmel_uart_data uart0_data = {
  380. .use_dma_tx = 1,
  381. .use_dma_rx = 1,
  382. };
  383. static struct platform_device at91sam9rl_uart0_device = {
  384. .name = "atmel_usart",
  385. .id = 1,
  386. .dev = {
  387. .platform_data = &uart0_data,
  388. .coherent_dma_mask = 0xffffffff,
  389. },
  390. .resource = uart0_resources,
  391. .num_resources = ARRAY_SIZE(uart0_resources),
  392. };
  393. static inline void configure_usart0_pins(void)
  394. {
  395. at91_set_A_periph(AT91_PIN_PA6, 1); /* TXD0 */
  396. at91_set_A_periph(AT91_PIN_PA7, 0); /* RXD0 */
  397. at91_set_A_periph(AT91_PIN_PA9, 0); /* RTS0 */
  398. at91_set_A_periph(AT91_PIN_PA10, 0); /* CTS0 */
  399. }
  400. static struct resource uart1_resources[] = {
  401. [0] = {
  402. .start = AT91SAM9RL_BASE_US1,
  403. .end = AT91SAM9RL_BASE_US1 + SZ_16K - 1,
  404. .flags = IORESOURCE_MEM,
  405. },
  406. [1] = {
  407. .start = AT91SAM9RL_ID_US1,
  408. .end = AT91SAM9RL_ID_US1,
  409. .flags = IORESOURCE_IRQ,
  410. },
  411. };
  412. static struct atmel_uart_data uart1_data = {
  413. .use_dma_tx = 1,
  414. .use_dma_rx = 1,
  415. };
  416. static struct platform_device at91sam9rl_uart1_device = {
  417. .name = "atmel_usart",
  418. .id = 2,
  419. .dev = {
  420. .platform_data = &uart1_data,
  421. .coherent_dma_mask = 0xffffffff,
  422. },
  423. .resource = uart1_resources,
  424. .num_resources = ARRAY_SIZE(uart1_resources),
  425. };
  426. static inline void configure_usart1_pins(void)
  427. {
  428. at91_set_A_periph(AT91_PIN_PA11, 1); /* TXD1 */
  429. at91_set_A_periph(AT91_PIN_PA12, 0); /* RXD1 */
  430. }
  431. static struct resource uart2_resources[] = {
  432. [0] = {
  433. .start = AT91SAM9RL_BASE_US2,
  434. .end = AT91SAM9RL_BASE_US2 + SZ_16K - 1,
  435. .flags = IORESOURCE_MEM,
  436. },
  437. [1] = {
  438. .start = AT91SAM9RL_ID_US2,
  439. .end = AT91SAM9RL_ID_US2,
  440. .flags = IORESOURCE_IRQ,
  441. },
  442. };
  443. static struct atmel_uart_data uart2_data = {
  444. .use_dma_tx = 1,
  445. .use_dma_rx = 1,
  446. };
  447. static struct platform_device at91sam9rl_uart2_device = {
  448. .name = "atmel_usart",
  449. .id = 3,
  450. .dev = {
  451. .platform_data = &uart2_data,
  452. .coherent_dma_mask = 0xffffffff,
  453. },
  454. .resource = uart2_resources,
  455. .num_resources = ARRAY_SIZE(uart2_resources),
  456. };
  457. static inline void configure_usart2_pins(void)
  458. {
  459. at91_set_A_periph(AT91_PIN_PA13, 1); /* TXD2 */
  460. at91_set_A_periph(AT91_PIN_PA14, 0); /* RXD2 */
  461. }
  462. static struct resource uart3_resources[] = {
  463. [0] = {
  464. .start = AT91SAM9RL_BASE_US3,
  465. .end = AT91SAM9RL_BASE_US3 + SZ_16K - 1,
  466. .flags = IORESOURCE_MEM,
  467. },
  468. [1] = {
  469. .start = AT91SAM9RL_ID_US3,
  470. .end = AT91SAM9RL_ID_US3,
  471. .flags = IORESOURCE_IRQ,
  472. },
  473. };
  474. static struct atmel_uart_data uart3_data = {
  475. .use_dma_tx = 1,
  476. .use_dma_rx = 1,
  477. };
  478. static struct platform_device at91sam9rl_uart3_device = {
  479. .name = "atmel_usart",
  480. .id = 4,
  481. .dev = {
  482. .platform_data = &uart3_data,
  483. .coherent_dma_mask = 0xffffffff,
  484. },
  485. .resource = uart3_resources,
  486. .num_resources = ARRAY_SIZE(uart3_resources),
  487. };
  488. static inline void configure_usart3_pins(void)
  489. {
  490. at91_set_A_periph(AT91_PIN_PB0, 1); /* TXD3 */
  491. at91_set_A_periph(AT91_PIN_PB1, 0); /* RXD3 */
  492. }
  493. struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  494. struct platform_device *atmel_default_console_device; /* the serial console device */
  495. void __init at91_init_serial(struct at91_uart_config *config)
  496. {
  497. int i;
  498. /* Fill in list of supported UARTs */
  499. for (i = 0; i < config->nr_tty; i++) {
  500. switch (config->tty_map[i]) {
  501. case 0:
  502. configure_usart0_pins();
  503. at91_uarts[i] = &at91sam9rl_uart0_device;
  504. at91_clock_associate("usart0_clk", &at91sam9rl_uart0_device.dev, "usart");
  505. break;
  506. case 1:
  507. configure_usart1_pins();
  508. at91_uarts[i] = &at91sam9rl_uart1_device;
  509. at91_clock_associate("usart1_clk", &at91sam9rl_uart1_device.dev, "usart");
  510. break;
  511. case 2:
  512. configure_usart2_pins();
  513. at91_uarts[i] = &at91sam9rl_uart2_device;
  514. at91_clock_associate("usart2_clk", &at91sam9rl_uart2_device.dev, "usart");
  515. break;
  516. case 3:
  517. configure_usart3_pins();
  518. at91_uarts[i] = &at91sam9rl_uart3_device;
  519. at91_clock_associate("usart3_clk", &at91sam9rl_uart3_device.dev, "usart");
  520. break;
  521. case 4:
  522. configure_dbgu_pins();
  523. at91_uarts[i] = &at91sam9rl_dbgu_device;
  524. at91_clock_associate("mck", &at91sam9rl_dbgu_device.dev, "usart");
  525. break;
  526. default:
  527. continue;
  528. }
  529. at91_uarts[i]->id = i; /* update ID number to mapped ID */
  530. }
  531. /* Set serial console device */
  532. if (config->console_tty < ATMEL_MAX_UART)
  533. atmel_default_console_device = at91_uarts[config->console_tty];
  534. if (!atmel_default_console_device)
  535. printk(KERN_INFO "AT91: No default serial console defined.\n");
  536. }
  537. void __init at91_add_device_serial(void)
  538. {
  539. int i;
  540. for (i = 0; i < ATMEL_MAX_UART; i++) {
  541. if (at91_uarts[i])
  542. platform_device_register(at91_uarts[i]);
  543. }
  544. }
  545. #else
  546. void __init at91_init_serial(struct at91_uart_config *config) {}
  547. void __init at91_add_device_serial(void) {}
  548. #endif
  549. /* -------------------------------------------------------------------- */
  550. /*
  551. * These devices are always present and don't need any board-specific
  552. * setup.
  553. */
  554. static int __init at91_add_standard_devices(void)
  555. {
  556. return 0;
  557. }
  558. arch_initcall(at91_add_standard_devices);