at91sam9263_devices.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. /*
  2. * arch/arm/mach-at91/at91sam9263_devices.c
  3. *
  4. * Copyright (C) 2007 Atmel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/i2c-gpio.h>
  17. #include <linux/fb.h>
  18. #include <video/atmel_lcdc.h>
  19. #include <asm/arch/board.h>
  20. #include <asm/arch/gpio.h>
  21. #include <asm/arch/at91sam9263.h>
  22. #include <asm/arch/at91sam926x_mc.h>
  23. #include <asm/arch/at91sam9263_matrix.h>
  24. #include "generic.h"
  25. /* --------------------------------------------------------------------
  26. * USB Host
  27. * -------------------------------------------------------------------- */
  28. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  29. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  30. static struct at91_usbh_data usbh_data;
  31. static struct resource usbh_resources[] = {
  32. [0] = {
  33. .start = AT91SAM9263_UHP_BASE,
  34. .end = AT91SAM9263_UHP_BASE + SZ_1M - 1,
  35. .flags = IORESOURCE_MEM,
  36. },
  37. [1] = {
  38. .start = AT91SAM9263_ID_UHP,
  39. .end = AT91SAM9263_ID_UHP,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct platform_device at91_usbh_device = {
  44. .name = "at91_ohci",
  45. .id = -1,
  46. .dev = {
  47. .dma_mask = &ohci_dmamask,
  48. .coherent_dma_mask = DMA_BIT_MASK(32),
  49. .platform_data = &usbh_data,
  50. },
  51. .resource = usbh_resources,
  52. .num_resources = ARRAY_SIZE(usbh_resources),
  53. };
  54. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  55. {
  56. int i;
  57. if (!data)
  58. return;
  59. /* Enable VBus control for UHP ports */
  60. for (i = 0; i < data->ports; i++) {
  61. if (data->vbus_pin[i])
  62. at91_set_gpio_output(data->vbus_pin[i], 0);
  63. }
  64. usbh_data = *data;
  65. platform_device_register(&at91_usbh_device);
  66. }
  67. #else
  68. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  69. #endif
  70. /* --------------------------------------------------------------------
  71. * USB Device (Gadget)
  72. * -------------------------------------------------------------------- */
  73. #ifdef CONFIG_USB_GADGET_AT91
  74. static struct at91_udc_data udc_data;
  75. static struct resource udc_resources[] = {
  76. [0] = {
  77. .start = AT91SAM9263_BASE_UDP,
  78. .end = AT91SAM9263_BASE_UDP + SZ_16K - 1,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. [1] = {
  82. .start = AT91SAM9263_ID_UDP,
  83. .end = AT91SAM9263_ID_UDP,
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. static struct platform_device at91_udc_device = {
  88. .name = "at91_udc",
  89. .id = -1,
  90. .dev = {
  91. .platform_data = &udc_data,
  92. },
  93. .resource = udc_resources,
  94. .num_resources = ARRAY_SIZE(udc_resources),
  95. };
  96. void __init at91_add_device_udc(struct at91_udc_data *data)
  97. {
  98. if (!data)
  99. return;
  100. if (data->vbus_pin) {
  101. at91_set_gpio_input(data->vbus_pin, 0);
  102. at91_set_deglitch(data->vbus_pin, 1);
  103. }
  104. /* Pullup pin is handled internally by USB device peripheral */
  105. udc_data = *data;
  106. platform_device_register(&at91_udc_device);
  107. }
  108. #else
  109. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  110. #endif
  111. /* --------------------------------------------------------------------
  112. * Ethernet
  113. * -------------------------------------------------------------------- */
  114. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
  115. static u64 eth_dmamask = DMA_BIT_MASK(32);
  116. static struct at91_eth_data eth_data;
  117. static struct resource eth_resources[] = {
  118. [0] = {
  119. .start = AT91SAM9263_BASE_EMAC,
  120. .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = AT91SAM9263_ID_EMAC,
  125. .end = AT91SAM9263_ID_EMAC,
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device at91sam9263_eth_device = {
  130. .name = "macb",
  131. .id = -1,
  132. .dev = {
  133. .dma_mask = &eth_dmamask,
  134. .coherent_dma_mask = DMA_BIT_MASK(32),
  135. .platform_data = &eth_data,
  136. },
  137. .resource = eth_resources,
  138. .num_resources = ARRAY_SIZE(eth_resources),
  139. };
  140. void __init at91_add_device_eth(struct at91_eth_data *data)
  141. {
  142. if (!data)
  143. return;
  144. if (data->phy_irq_pin) {
  145. at91_set_gpio_input(data->phy_irq_pin, 0);
  146. at91_set_deglitch(data->phy_irq_pin, 1);
  147. }
  148. /* Pins used for MII and RMII */
  149. at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */
  150. at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */
  151. at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */
  152. at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */
  153. at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */
  154. at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */
  155. at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */
  156. at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */
  157. at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */
  158. at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */
  159. if (!data->is_rmii) {
  160. at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */
  161. at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
  162. at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
  163. at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
  164. at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
  165. at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
  166. at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
  167. at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
  168. }
  169. eth_data = *data;
  170. platform_device_register(&at91sam9263_eth_device);
  171. }
  172. #else
  173. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  174. #endif
  175. /* --------------------------------------------------------------------
  176. * MMC / SD
  177. * -------------------------------------------------------------------- */
  178. #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
  179. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  180. static struct at91_mmc_data mmc0_data, mmc1_data;
  181. static struct resource mmc0_resources[] = {
  182. [0] = {
  183. .start = AT91SAM9263_BASE_MCI0,
  184. .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1,
  185. .flags = IORESOURCE_MEM,
  186. },
  187. [1] = {
  188. .start = AT91SAM9263_ID_MCI0,
  189. .end = AT91SAM9263_ID_MCI0,
  190. .flags = IORESOURCE_IRQ,
  191. },
  192. };
  193. static struct platform_device at91sam9263_mmc0_device = {
  194. .name = "at91_mci",
  195. .id = 0,
  196. .dev = {
  197. .dma_mask = &mmc_dmamask,
  198. .coherent_dma_mask = DMA_BIT_MASK(32),
  199. .platform_data = &mmc0_data,
  200. },
  201. .resource = mmc0_resources,
  202. .num_resources = ARRAY_SIZE(mmc0_resources),
  203. };
  204. static struct resource mmc1_resources[] = {
  205. [0] = {
  206. .start = AT91SAM9263_BASE_MCI1,
  207. .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1,
  208. .flags = IORESOURCE_MEM,
  209. },
  210. [1] = {
  211. .start = AT91SAM9263_ID_MCI1,
  212. .end = AT91SAM9263_ID_MCI1,
  213. .flags = IORESOURCE_IRQ,
  214. },
  215. };
  216. static struct platform_device at91sam9263_mmc1_device = {
  217. .name = "at91_mci",
  218. .id = 1,
  219. .dev = {
  220. .dma_mask = &mmc_dmamask,
  221. .coherent_dma_mask = DMA_BIT_MASK(32),
  222. .platform_data = &mmc1_data,
  223. },
  224. .resource = mmc1_resources,
  225. .num_resources = ARRAY_SIZE(mmc1_resources),
  226. };
  227. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
  228. {
  229. if (!data)
  230. return;
  231. /* input/irq */
  232. if (data->det_pin) {
  233. at91_set_gpio_input(data->det_pin, 1);
  234. at91_set_deglitch(data->det_pin, 1);
  235. }
  236. if (data->wp_pin)
  237. at91_set_gpio_input(data->wp_pin, 1);
  238. if (data->vcc_pin)
  239. at91_set_gpio_output(data->vcc_pin, 0);
  240. if (mmc_id == 0) { /* MCI0 */
  241. /* CLK */
  242. at91_set_A_periph(AT91_PIN_PA12, 0);
  243. if (data->slot_b) {
  244. /* CMD */
  245. at91_set_A_periph(AT91_PIN_PA16, 1);
  246. /* DAT0, maybe DAT1..DAT3 */
  247. at91_set_A_periph(AT91_PIN_PA17, 1);
  248. if (data->wire4) {
  249. at91_set_A_periph(AT91_PIN_PA18, 1);
  250. at91_set_A_periph(AT91_PIN_PA19, 1);
  251. at91_set_A_periph(AT91_PIN_PA20, 1);
  252. }
  253. } else {
  254. /* CMD */
  255. at91_set_A_periph(AT91_PIN_PA1, 1);
  256. /* DAT0, maybe DAT1..DAT3 */
  257. at91_set_A_periph(AT91_PIN_PA0, 1);
  258. if (data->wire4) {
  259. at91_set_A_periph(AT91_PIN_PA3, 1);
  260. at91_set_A_periph(AT91_PIN_PA4, 1);
  261. at91_set_A_periph(AT91_PIN_PA5, 1);
  262. }
  263. }
  264. mmc0_data = *data;
  265. at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk");
  266. platform_device_register(&at91sam9263_mmc0_device);
  267. } else { /* MCI1 */
  268. /* CLK */
  269. at91_set_A_periph(AT91_PIN_PA6, 0);
  270. if (data->slot_b) {
  271. /* CMD */
  272. at91_set_A_periph(AT91_PIN_PA21, 1);
  273. /* DAT0, maybe DAT1..DAT3 */
  274. at91_set_A_periph(AT91_PIN_PA22, 1);
  275. if (data->wire4) {
  276. at91_set_A_periph(AT91_PIN_PA23, 1);
  277. at91_set_A_periph(AT91_PIN_PA24, 1);
  278. at91_set_A_periph(AT91_PIN_PA25, 1);
  279. }
  280. } else {
  281. /* CMD */
  282. at91_set_A_periph(AT91_PIN_PA7, 1);
  283. /* DAT0, maybe DAT1..DAT3 */
  284. at91_set_A_periph(AT91_PIN_PA8, 1);
  285. if (data->wire4) {
  286. at91_set_A_periph(AT91_PIN_PA9, 1);
  287. at91_set_A_periph(AT91_PIN_PA10, 1);
  288. at91_set_A_periph(AT91_PIN_PA11, 1);
  289. }
  290. }
  291. mmc1_data = *data;
  292. at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device.dev, "mci_clk");
  293. platform_device_register(&at91sam9263_mmc1_device);
  294. }
  295. }
  296. #else
  297. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
  298. #endif
  299. /* --------------------------------------------------------------------
  300. * NAND / SmartMedia
  301. * -------------------------------------------------------------------- */
  302. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  303. static struct at91_nand_data nand_data;
  304. #define NAND_BASE AT91_CHIPSELECT_3
  305. static struct resource nand_resources[] = {
  306. {
  307. .start = NAND_BASE,
  308. .end = NAND_BASE + SZ_256M - 1,
  309. .flags = IORESOURCE_MEM,
  310. }
  311. };
  312. static struct platform_device at91sam9263_nand_device = {
  313. .name = "at91_nand",
  314. .id = -1,
  315. .dev = {
  316. .platform_data = &nand_data,
  317. },
  318. .resource = nand_resources,
  319. .num_resources = ARRAY_SIZE(nand_resources),
  320. };
  321. void __init at91_add_device_nand(struct at91_nand_data *data)
  322. {
  323. unsigned long csa, mode;
  324. if (!data)
  325. return;
  326. csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
  327. at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
  328. /* set the bus interface characteristics */
  329. at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
  330. | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
  331. at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
  332. | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
  333. at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
  334. if (data->bus_width_16)
  335. mode = AT91_SMC_DBW_16;
  336. else
  337. mode = AT91_SMC_DBW_8;
  338. at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
  339. /* enable pin */
  340. if (data->enable_pin)
  341. at91_set_gpio_output(data->enable_pin, 1);
  342. /* ready/busy pin */
  343. if (data->rdy_pin)
  344. at91_set_gpio_input(data->rdy_pin, 1);
  345. /* card detect pin */
  346. if (data->det_pin)
  347. at91_set_gpio_input(data->det_pin, 1);
  348. nand_data = *data;
  349. platform_device_register(&at91sam9263_nand_device);
  350. }
  351. #else
  352. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  353. #endif
  354. /* --------------------------------------------------------------------
  355. * TWI (i2c)
  356. * -------------------------------------------------------------------- */
  357. /*
  358. * Prefer the GPIO code since the TWI controller isn't robust
  359. * (gets overruns and underruns under load) and can only issue
  360. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  361. */
  362. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  363. static struct i2c_gpio_platform_data pdata = {
  364. .sda_pin = AT91_PIN_PB4,
  365. .sda_is_open_drain = 1,
  366. .scl_pin = AT91_PIN_PB5,
  367. .scl_is_open_drain = 1,
  368. .udelay = 2, /* ~100 kHz */
  369. };
  370. static struct platform_device at91sam9263_twi_device = {
  371. .name = "i2c-gpio",
  372. .id = -1,
  373. .dev.platform_data = &pdata,
  374. };
  375. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  376. {
  377. at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
  378. at91_set_multi_drive(AT91_PIN_PB4, 1);
  379. at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
  380. at91_set_multi_drive(AT91_PIN_PB5, 1);
  381. i2c_register_board_info(0, devices, nr_devices);
  382. platform_device_register(&at91sam9263_twi_device);
  383. }
  384. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  385. static struct resource twi_resources[] = {
  386. [0] = {
  387. .start = AT91SAM9263_BASE_TWI,
  388. .end = AT91SAM9263_BASE_TWI + SZ_16K - 1,
  389. .flags = IORESOURCE_MEM,
  390. },
  391. [1] = {
  392. .start = AT91SAM9263_ID_TWI,
  393. .end = AT91SAM9263_ID_TWI,
  394. .flags = IORESOURCE_IRQ,
  395. },
  396. };
  397. static struct platform_device at91sam9263_twi_device = {
  398. .name = "at91_i2c",
  399. .id = -1,
  400. .resource = twi_resources,
  401. .num_resources = ARRAY_SIZE(twi_resources),
  402. };
  403. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  404. {
  405. /* pins used for TWI interface */
  406. at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
  407. at91_set_multi_drive(AT91_PIN_PB4, 1);
  408. at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
  409. at91_set_multi_drive(AT91_PIN_PB5, 1);
  410. i2c_register_board_info(0, devices, nr_devices);
  411. platform_device_register(&at91sam9263_twi_device);
  412. }
  413. #else
  414. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  415. #endif
  416. /* --------------------------------------------------------------------
  417. * SPI
  418. * -------------------------------------------------------------------- */
  419. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  420. static u64 spi_dmamask = DMA_BIT_MASK(32);
  421. static struct resource spi0_resources[] = {
  422. [0] = {
  423. .start = AT91SAM9263_BASE_SPI0,
  424. .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
  425. .flags = IORESOURCE_MEM,
  426. },
  427. [1] = {
  428. .start = AT91SAM9263_ID_SPI0,
  429. .end = AT91SAM9263_ID_SPI0,
  430. .flags = IORESOURCE_IRQ,
  431. },
  432. };
  433. static struct platform_device at91sam9263_spi0_device = {
  434. .name = "atmel_spi",
  435. .id = 0,
  436. .dev = {
  437. .dma_mask = &spi_dmamask,
  438. .coherent_dma_mask = DMA_BIT_MASK(32),
  439. },
  440. .resource = spi0_resources,
  441. .num_resources = ARRAY_SIZE(spi0_resources),
  442. };
  443. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
  444. static struct resource spi1_resources[] = {
  445. [0] = {
  446. .start = AT91SAM9263_BASE_SPI1,
  447. .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
  448. .flags = IORESOURCE_MEM,
  449. },
  450. [1] = {
  451. .start = AT91SAM9263_ID_SPI1,
  452. .end = AT91SAM9263_ID_SPI1,
  453. .flags = IORESOURCE_IRQ,
  454. },
  455. };
  456. static struct platform_device at91sam9263_spi1_device = {
  457. .name = "atmel_spi",
  458. .id = 1,
  459. .dev = {
  460. .dma_mask = &spi_dmamask,
  461. .coherent_dma_mask = DMA_BIT_MASK(32),
  462. },
  463. .resource = spi1_resources,
  464. .num_resources = ARRAY_SIZE(spi1_resources),
  465. };
  466. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
  467. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  468. {
  469. int i;
  470. unsigned long cs_pin;
  471. short enable_spi0 = 0;
  472. short enable_spi1 = 0;
  473. /* Choose SPI chip-selects */
  474. for (i = 0; i < nr_devices; i++) {
  475. if (devices[i].controller_data)
  476. cs_pin = (unsigned long) devices[i].controller_data;
  477. else if (devices[i].bus_num == 0)
  478. cs_pin = spi0_standard_cs[devices[i].chip_select];
  479. else
  480. cs_pin = spi1_standard_cs[devices[i].chip_select];
  481. if (devices[i].bus_num == 0)
  482. enable_spi0 = 1;
  483. else
  484. enable_spi1 = 1;
  485. /* enable chip-select pin */
  486. at91_set_gpio_output(cs_pin, 1);
  487. /* pass chip-select pin to driver */
  488. devices[i].controller_data = (void *) cs_pin;
  489. }
  490. spi_register_board_info(devices, nr_devices);
  491. /* Configure SPI bus(es) */
  492. if (enable_spi0) {
  493. at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
  494. at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
  495. at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
  496. at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk");
  497. platform_device_register(&at91sam9263_spi0_device);
  498. }
  499. if (enable_spi1) {
  500. at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
  501. at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
  502. at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
  503. at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk");
  504. platform_device_register(&at91sam9263_spi1_device);
  505. }
  506. }
  507. #else
  508. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  509. #endif
  510. /* --------------------------------------------------------------------
  511. * AC97
  512. * -------------------------------------------------------------------- */
  513. #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
  514. static u64 ac97_dmamask = DMA_BIT_MASK(32);
  515. static struct atmel_ac97_data ac97_data;
  516. static struct resource ac97_resources[] = {
  517. [0] = {
  518. .start = AT91SAM9263_BASE_AC97C,
  519. .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
  520. .flags = IORESOURCE_MEM,
  521. },
  522. [1] = {
  523. .start = AT91SAM9263_ID_AC97C,
  524. .end = AT91SAM9263_ID_AC97C,
  525. .flags = IORESOURCE_IRQ,
  526. },
  527. };
  528. static struct platform_device at91sam9263_ac97_device = {
  529. .name = "ac97c",
  530. .id = 1,
  531. .dev = {
  532. .dma_mask = &ac97_dmamask,
  533. .coherent_dma_mask = DMA_BIT_MASK(32),
  534. .platform_data = &ac97_data,
  535. },
  536. .resource = ac97_resources,
  537. .num_resources = ARRAY_SIZE(ac97_resources),
  538. };
  539. void __init at91_add_device_ac97(struct atmel_ac97_data *data)
  540. {
  541. if (!data)
  542. return;
  543. at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
  544. at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
  545. at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
  546. at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
  547. /* reset */
  548. if (data->reset_pin)
  549. at91_set_gpio_output(data->reset_pin, 0);
  550. ac97_data = *ek_data;
  551. platform_device_register(&at91sam9263_ac97_device);
  552. }
  553. #else
  554. void __init at91_add_device_ac97(struct atmel_ac97_data *data) {}
  555. #endif
  556. /* --------------------------------------------------------------------
  557. * LCD Controller
  558. * -------------------------------------------------------------------- */
  559. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  560. static u64 lcdc_dmamask = DMA_BIT_MASK(32);
  561. static struct atmel_lcdfb_info lcdc_data;
  562. static struct resource lcdc_resources[] = {
  563. [0] = {
  564. .start = AT91SAM9263_LCDC_BASE,
  565. .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
  566. .flags = IORESOURCE_MEM,
  567. },
  568. [1] = {
  569. .start = AT91SAM9263_ID_LCDC,
  570. .end = AT91SAM9263_ID_LCDC,
  571. .flags = IORESOURCE_IRQ,
  572. },
  573. };
  574. static struct platform_device at91_lcdc_device = {
  575. .name = "atmel_lcdfb",
  576. .id = 0,
  577. .dev = {
  578. .dma_mask = &lcdc_dmamask,
  579. .coherent_dma_mask = DMA_BIT_MASK(32),
  580. .platform_data = &lcdc_data,
  581. },
  582. .resource = lcdc_resources,
  583. .num_resources = ARRAY_SIZE(lcdc_resources),
  584. };
  585. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  586. {
  587. if (!data)
  588. return;
  589. at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
  590. at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
  591. at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
  592. at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
  593. at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
  594. at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
  595. at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
  596. at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
  597. at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
  598. at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
  599. at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
  600. at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
  601. at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
  602. at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */
  603. at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
  604. at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
  605. at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
  606. at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
  607. at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
  608. at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */
  609. at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
  610. at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
  611. lcdc_data = *data;
  612. platform_device_register(&at91_lcdc_device);
  613. }
  614. #else
  615. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  616. #endif
  617. /* --------------------------------------------------------------------
  618. * Image Sensor Interface
  619. * -------------------------------------------------------------------- */
  620. #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
  621. struct resource isi_resources[] = {
  622. [0] = {
  623. .start = AT91SAM9263_BASE_ISI,
  624. .end = AT91SAM9263_BASE_ISI + SZ_16K - 1,
  625. .flags = IORESOURCE_MEM,
  626. },
  627. [1] = {
  628. .start = AT91SAM9263_ID_ISI,
  629. .end = AT91SAM9263_ID_ISI,
  630. .flags = IORESOURCE_IRQ,
  631. },
  632. };
  633. static struct platform_device at91sam9263_isi_device = {
  634. .name = "at91_isi",
  635. .id = -1,
  636. .resource = isi_resources,
  637. .num_resources = ARRAY_SIZE(isi_resources),
  638. };
  639. void __init at91_add_device_isi(void)
  640. {
  641. at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
  642. at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
  643. at91_set_A_periph(AT91_PIN_PE2, 0); /* ISI_D2 */
  644. at91_set_A_periph(AT91_PIN_PE3, 0); /* ISI_D3 */
  645. at91_set_A_periph(AT91_PIN_PE4, 0); /* ISI_D4 */
  646. at91_set_A_periph(AT91_PIN_PE5, 0); /* ISI_D5 */
  647. at91_set_A_periph(AT91_PIN_PE6, 0); /* ISI_D6 */
  648. at91_set_A_periph(AT91_PIN_PE7, 0); /* ISI_D7 */
  649. at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
  650. at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
  651. at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
  652. at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
  653. at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
  654. at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
  655. at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
  656. at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
  657. }
  658. #else
  659. void __init at91_add_device_isi(void) {}
  660. #endif
  661. /* --------------------------------------------------------------------
  662. * RTT
  663. * -------------------------------------------------------------------- */
  664. static struct resource rtt0_resources[] = {
  665. {
  666. .start = AT91_BASE_SYS + AT91_RTT0,
  667. .end = AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1,
  668. .flags = IORESOURCE_MEM,
  669. }
  670. };
  671. static struct platform_device at91sam9263_rtt0_device = {
  672. .name = "at91_rtt",
  673. .id = 0,
  674. .resource = rtt0_resources,
  675. .num_resources = ARRAY_SIZE(rtt0_resources),
  676. };
  677. static struct resource rtt1_resources[] = {
  678. {
  679. .start = AT91_BASE_SYS + AT91_RTT1,
  680. .end = AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1,
  681. .flags = IORESOURCE_MEM,
  682. }
  683. };
  684. static struct platform_device at91sam9263_rtt1_device = {
  685. .name = "at91_rtt",
  686. .id = 1,
  687. .resource = rtt1_resources,
  688. .num_resources = ARRAY_SIZE(rtt1_resources),
  689. };
  690. static void __init at91_add_device_rtt(void)
  691. {
  692. platform_device_register(&at91sam9263_rtt0_device);
  693. platform_device_register(&at91sam9263_rtt1_device);
  694. }
  695. /* --------------------------------------------------------------------
  696. * Watchdog
  697. * -------------------------------------------------------------------- */
  698. #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
  699. static struct platform_device at91sam9263_wdt_device = {
  700. .name = "at91_wdt",
  701. .id = -1,
  702. .num_resources = 0,
  703. };
  704. static void __init at91_add_device_watchdog(void)
  705. {
  706. platform_device_register(&at91sam9263_wdt_device);
  707. }
  708. #else
  709. static void __init at91_add_device_watchdog(void) {}
  710. #endif
  711. /* --------------------------------------------------------------------
  712. * SSC -- Synchronous Serial Controller
  713. * -------------------------------------------------------------------- */
  714. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  715. static u64 ssc0_dmamask = DMA_BIT_MASK(32);
  716. static struct resource ssc0_resources[] = {
  717. [0] = {
  718. .start = AT91SAM9263_BASE_SSC0,
  719. .end = AT91SAM9263_BASE_SSC0 + SZ_16K - 1,
  720. .flags = IORESOURCE_MEM,
  721. },
  722. [1] = {
  723. .start = AT91SAM9263_ID_SSC0,
  724. .end = AT91SAM9263_ID_SSC0,
  725. .flags = IORESOURCE_IRQ,
  726. },
  727. };
  728. static struct platform_device at91sam9263_ssc0_device = {
  729. .name = "ssc",
  730. .id = 0,
  731. .dev = {
  732. .dma_mask = &ssc0_dmamask,
  733. .coherent_dma_mask = DMA_BIT_MASK(32),
  734. },
  735. .resource = ssc0_resources,
  736. .num_resources = ARRAY_SIZE(ssc0_resources),
  737. };
  738. static inline void configure_ssc0_pins(unsigned pins)
  739. {
  740. if (pins & ATMEL_SSC_TF)
  741. at91_set_B_periph(AT91_PIN_PB0, 1);
  742. if (pins & ATMEL_SSC_TK)
  743. at91_set_B_periph(AT91_PIN_PB1, 1);
  744. if (pins & ATMEL_SSC_TD)
  745. at91_set_B_periph(AT91_PIN_PB2, 1);
  746. if (pins & ATMEL_SSC_RD)
  747. at91_set_B_periph(AT91_PIN_PB3, 1);
  748. if (pins & ATMEL_SSC_RK)
  749. at91_set_B_periph(AT91_PIN_PB4, 1);
  750. if (pins & ATMEL_SSC_RF)
  751. at91_set_B_periph(AT91_PIN_PB5, 1);
  752. }
  753. static u64 ssc1_dmamask = DMA_BIT_MASK(32);
  754. static struct resource ssc1_resources[] = {
  755. [0] = {
  756. .start = AT91SAM9263_BASE_SSC1,
  757. .end = AT91SAM9263_BASE_SSC1 + SZ_16K - 1,
  758. .flags = IORESOURCE_MEM,
  759. },
  760. [1] = {
  761. .start = AT91SAM9263_ID_SSC1,
  762. .end = AT91SAM9263_ID_SSC1,
  763. .flags = IORESOURCE_IRQ,
  764. },
  765. };
  766. static struct platform_device at91sam9263_ssc1_device = {
  767. .name = "ssc",
  768. .id = 1,
  769. .dev = {
  770. .dma_mask = &ssc1_dmamask,
  771. .coherent_dma_mask = DMA_BIT_MASK(32),
  772. },
  773. .resource = ssc1_resources,
  774. .num_resources = ARRAY_SIZE(ssc1_resources),
  775. };
  776. static inline void configure_ssc1_pins(unsigned pins)
  777. {
  778. if (pins & ATMEL_SSC_TF)
  779. at91_set_A_periph(AT91_PIN_PB6, 1);
  780. if (pins & ATMEL_SSC_TK)
  781. at91_set_A_periph(AT91_PIN_PB7, 1);
  782. if (pins & ATMEL_SSC_TD)
  783. at91_set_A_periph(AT91_PIN_PB8, 1);
  784. if (pins & ATMEL_SSC_RD)
  785. at91_set_A_periph(AT91_PIN_PB9, 1);
  786. if (pins & ATMEL_SSC_RK)
  787. at91_set_A_periph(AT91_PIN_PB10, 1);
  788. if (pins & ATMEL_SSC_RF)
  789. at91_set_A_periph(AT91_PIN_PB11, 1);
  790. }
  791. /*
  792. * Return the device node so that board init code can use it as the
  793. * parent for the device node reflecting how it's used on this board.
  794. *
  795. * SSC controllers are accessed through library code, instead of any
  796. * kind of all-singing/all-dancing driver. For example one could be
  797. * used by a particular I2S audio codec's driver, while another one
  798. * on the same system might be used by a custom data capture driver.
  799. */
  800. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  801. {
  802. struct platform_device *pdev;
  803. /*
  804. * NOTE: caller is responsible for passing information matching
  805. * "pins" to whatever will be using each particular controller.
  806. */
  807. switch (id) {
  808. case AT91SAM9263_ID_SSC0:
  809. pdev = &at91sam9263_ssc0_device;
  810. configure_ssc0_pins(pins);
  811. at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");
  812. break;
  813. case AT91SAM9263_ID_SSC1:
  814. pdev = &at91sam9263_ssc1_device;
  815. configure_ssc1_pins(pins);
  816. at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");
  817. break;
  818. default:
  819. return;
  820. }
  821. platform_device_register(pdev);
  822. }
  823. #else
  824. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  825. #endif
  826. /* --------------------------------------------------------------------
  827. * UART
  828. * -------------------------------------------------------------------- */
  829. #if defined(CONFIG_SERIAL_ATMEL)
  830. static struct resource dbgu_resources[] = {
  831. [0] = {
  832. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  833. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  834. .flags = IORESOURCE_MEM,
  835. },
  836. [1] = {
  837. .start = AT91_ID_SYS,
  838. .end = AT91_ID_SYS,
  839. .flags = IORESOURCE_IRQ,
  840. },
  841. };
  842. static struct atmel_uart_data dbgu_data = {
  843. .use_dma_tx = 0,
  844. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  845. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  846. };
  847. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  848. static struct platform_device at91sam9263_dbgu_device = {
  849. .name = "atmel_usart",
  850. .id = 0,
  851. .dev = {
  852. .dma_mask = &dbgu_dmamask,
  853. .coherent_dma_mask = DMA_BIT_MASK(32),
  854. .platform_data = &dbgu_data,
  855. },
  856. .resource = dbgu_resources,
  857. .num_resources = ARRAY_SIZE(dbgu_resources),
  858. };
  859. static inline void configure_dbgu_pins(void)
  860. {
  861. at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
  862. at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
  863. }
  864. static struct resource uart0_resources[] = {
  865. [0] = {
  866. .start = AT91SAM9263_BASE_US0,
  867. .end = AT91SAM9263_BASE_US0 + SZ_16K - 1,
  868. .flags = IORESOURCE_MEM,
  869. },
  870. [1] = {
  871. .start = AT91SAM9263_ID_US0,
  872. .end = AT91SAM9263_ID_US0,
  873. .flags = IORESOURCE_IRQ,
  874. },
  875. };
  876. static struct atmel_uart_data uart0_data = {
  877. .use_dma_tx = 1,
  878. .use_dma_rx = 1,
  879. };
  880. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  881. static struct platform_device at91sam9263_uart0_device = {
  882. .name = "atmel_usart",
  883. .id = 1,
  884. .dev = {
  885. .dma_mask = &uart0_dmamask,
  886. .coherent_dma_mask = DMA_BIT_MASK(32),
  887. .platform_data = &uart0_data,
  888. },
  889. .resource = uart0_resources,
  890. .num_resources = ARRAY_SIZE(uart0_resources),
  891. };
  892. static inline void configure_usart0_pins(unsigned pins)
  893. {
  894. at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */
  895. at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */
  896. if (pins & ATMEL_UART_RTS)
  897. at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */
  898. if (pins & ATMEL_UART_CTS)
  899. at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */
  900. }
  901. static struct resource uart1_resources[] = {
  902. [0] = {
  903. .start = AT91SAM9263_BASE_US1,
  904. .end = AT91SAM9263_BASE_US1 + SZ_16K - 1,
  905. .flags = IORESOURCE_MEM,
  906. },
  907. [1] = {
  908. .start = AT91SAM9263_ID_US1,
  909. .end = AT91SAM9263_ID_US1,
  910. .flags = IORESOURCE_IRQ,
  911. },
  912. };
  913. static struct atmel_uart_data uart1_data = {
  914. .use_dma_tx = 1,
  915. .use_dma_rx = 1,
  916. };
  917. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  918. static struct platform_device at91sam9263_uart1_device = {
  919. .name = "atmel_usart",
  920. .id = 2,
  921. .dev = {
  922. .dma_mask = &uart1_dmamask,
  923. .coherent_dma_mask = DMA_BIT_MASK(32),
  924. .platform_data = &uart1_data,
  925. },
  926. .resource = uart1_resources,
  927. .num_resources = ARRAY_SIZE(uart1_resources),
  928. };
  929. static inline void configure_usart1_pins(unsigned pins)
  930. {
  931. at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
  932. at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
  933. if (pins & ATMEL_UART_RTS)
  934. at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
  935. if (pins & ATMEL_UART_CTS)
  936. at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
  937. }
  938. static struct resource uart2_resources[] = {
  939. [0] = {
  940. .start = AT91SAM9263_BASE_US2,
  941. .end = AT91SAM9263_BASE_US2 + SZ_16K - 1,
  942. .flags = IORESOURCE_MEM,
  943. },
  944. [1] = {
  945. .start = AT91SAM9263_ID_US2,
  946. .end = AT91SAM9263_ID_US2,
  947. .flags = IORESOURCE_IRQ,
  948. },
  949. };
  950. static struct atmel_uart_data uart2_data = {
  951. .use_dma_tx = 1,
  952. .use_dma_rx = 1,
  953. };
  954. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  955. static struct platform_device at91sam9263_uart2_device = {
  956. .name = "atmel_usart",
  957. .id = 3,
  958. .dev = {
  959. .dma_mask = &uart2_dmamask,
  960. .coherent_dma_mask = DMA_BIT_MASK(32),
  961. .platform_data = &uart2_data,
  962. },
  963. .resource = uart2_resources,
  964. .num_resources = ARRAY_SIZE(uart2_resources),
  965. };
  966. static inline void configure_usart2_pins(unsigned pins)
  967. {
  968. at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
  969. at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
  970. if (pins & ATMEL_UART_RTS)
  971. at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
  972. if (pins & ATMEL_UART_CTS)
  973. at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
  974. }
  975. static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  976. struct platform_device *atmel_default_console_device; /* the serial console device */
  977. void __init __deprecated at91_init_serial(struct at91_uart_config *config)
  978. {
  979. int i;
  980. /* Fill in list of supported UARTs */
  981. for (i = 0; i < config->nr_tty; i++) {
  982. switch (config->tty_map[i]) {
  983. case 0:
  984. configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
  985. at91_uarts[i] = &at91sam9263_uart0_device;
  986. at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart");
  987. break;
  988. case 1:
  989. configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
  990. at91_uarts[i] = &at91sam9263_uart1_device;
  991. at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart");
  992. break;
  993. case 2:
  994. configure_usart2_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
  995. at91_uarts[i] = &at91sam9263_uart2_device;
  996. at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart");
  997. break;
  998. case 3:
  999. configure_dbgu_pins();
  1000. at91_uarts[i] = &at91sam9263_dbgu_device;
  1001. at91_clock_associate("mck", &at91sam9263_dbgu_device.dev, "usart");
  1002. break;
  1003. default:
  1004. continue;
  1005. }
  1006. at91_uarts[i]->id = i; /* update ID number to mapped ID */
  1007. }
  1008. /* Set serial console device */
  1009. if (config->console_tty < ATMEL_MAX_UART)
  1010. atmel_default_console_device = at91_uarts[config->console_tty];
  1011. if (!atmel_default_console_device)
  1012. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1013. }
  1014. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  1015. {
  1016. struct platform_device *pdev;
  1017. switch (id) {
  1018. case 0: /* DBGU */
  1019. pdev = &at91sam9263_dbgu_device;
  1020. configure_dbgu_pins();
  1021. at91_clock_associate("mck", &pdev->dev, "usart");
  1022. break;
  1023. case AT91SAM9263_ID_US0:
  1024. pdev = &at91sam9263_uart0_device;
  1025. configure_usart0_pins(pins);
  1026. at91_clock_associate("usart0_clk", &pdev->dev, "usart");
  1027. break;
  1028. case AT91SAM9263_ID_US1:
  1029. pdev = &at91sam9263_uart1_device;
  1030. configure_usart1_pins(pins);
  1031. at91_clock_associate("usart1_clk", &pdev->dev, "usart");
  1032. break;
  1033. case AT91SAM9263_ID_US2:
  1034. pdev = &at91sam9263_uart2_device;
  1035. configure_usart2_pins(pins);
  1036. at91_clock_associate("usart2_clk", &pdev->dev, "usart");
  1037. break;
  1038. default:
  1039. return;
  1040. }
  1041. pdev->id = portnr; /* update to mapped ID */
  1042. if (portnr < ATMEL_MAX_UART)
  1043. at91_uarts[portnr] = pdev;
  1044. }
  1045. void __init at91_set_serial_console(unsigned portnr)
  1046. {
  1047. if (portnr < ATMEL_MAX_UART)
  1048. atmel_default_console_device = at91_uarts[portnr];
  1049. if (!atmel_default_console_device)
  1050. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1051. }
  1052. void __init at91_add_device_serial(void)
  1053. {
  1054. int i;
  1055. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1056. if (at91_uarts[i])
  1057. platform_device_register(at91_uarts[i]);
  1058. }
  1059. }
  1060. #else
  1061. void __init at91_init_serial(struct at91_uart_config *config) {}
  1062. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1063. void __init at91_set_serial_console(unsigned portnr) {}
  1064. void __init at91_add_device_serial(void) {}
  1065. #endif
  1066. /* -------------------------------------------------------------------- */
  1067. /*
  1068. * These devices are always present and don't need any board-specific
  1069. * setup.
  1070. */
  1071. static int __init at91_add_standard_devices(void)
  1072. {
  1073. at91_add_device_rtt();
  1074. at91_add_device_watchdog();
  1075. return 0;
  1076. }
  1077. arch_initcall(at91_add_standard_devices);