at91sam9263_devices.c 32 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/at91sam9263_matrix.h>
  23. #include <asm/arch/at91sam9_smc.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_mmc0_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_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  303. static struct atmel_nand_data nand_data;
  304. #define NAND_BASE AT91_CHIPSELECT_3
  305. static struct resource nand_resources[] = {
  306. [0] = {
  307. .start = NAND_BASE,
  308. .end = NAND_BASE + SZ_256M - 1,
  309. .flags = IORESOURCE_MEM,
  310. },
  311. [1] = {
  312. .start = AT91_BASE_SYS + AT91_ECC0,
  313. .end = AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1,
  314. .flags = IORESOURCE_MEM,
  315. }
  316. };
  317. static struct platform_device at91sam9263_nand_device = {
  318. .name = "atmel_nand",
  319. .id = -1,
  320. .dev = {
  321. .platform_data = &nand_data,
  322. },
  323. .resource = nand_resources,
  324. .num_resources = ARRAY_SIZE(nand_resources),
  325. };
  326. void __init at91_add_device_nand(struct atmel_nand_data *data)
  327. {
  328. unsigned long csa, mode;
  329. if (!data)
  330. return;
  331. csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
  332. at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
  333. /* set the bus interface characteristics */
  334. at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0)
  335. | AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
  336. at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
  337. | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
  338. at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
  339. if (data->bus_width_16)
  340. mode = AT91_SMC_DBW_16;
  341. else
  342. mode = AT91_SMC_DBW_8;
  343. at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
  344. /* enable pin */
  345. if (data->enable_pin)
  346. at91_set_gpio_output(data->enable_pin, 1);
  347. /* ready/busy pin */
  348. if (data->rdy_pin)
  349. at91_set_gpio_input(data->rdy_pin, 1);
  350. /* card detect pin */
  351. if (data->det_pin)
  352. at91_set_gpio_input(data->det_pin, 1);
  353. nand_data = *data;
  354. platform_device_register(&at91sam9263_nand_device);
  355. }
  356. #else
  357. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  358. #endif
  359. /* --------------------------------------------------------------------
  360. * TWI (i2c)
  361. * -------------------------------------------------------------------- */
  362. /*
  363. * Prefer the GPIO code since the TWI controller isn't robust
  364. * (gets overruns and underruns under load) and can only issue
  365. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  366. */
  367. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  368. static struct i2c_gpio_platform_data pdata = {
  369. .sda_pin = AT91_PIN_PB4,
  370. .sda_is_open_drain = 1,
  371. .scl_pin = AT91_PIN_PB5,
  372. .scl_is_open_drain = 1,
  373. .udelay = 2, /* ~100 kHz */
  374. };
  375. static struct platform_device at91sam9263_twi_device = {
  376. .name = "i2c-gpio",
  377. .id = -1,
  378. .dev.platform_data = &pdata,
  379. };
  380. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  381. {
  382. at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
  383. at91_set_multi_drive(AT91_PIN_PB4, 1);
  384. at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
  385. at91_set_multi_drive(AT91_PIN_PB5, 1);
  386. i2c_register_board_info(0, devices, nr_devices);
  387. platform_device_register(&at91sam9263_twi_device);
  388. }
  389. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  390. static struct resource twi_resources[] = {
  391. [0] = {
  392. .start = AT91SAM9263_BASE_TWI,
  393. .end = AT91SAM9263_BASE_TWI + SZ_16K - 1,
  394. .flags = IORESOURCE_MEM,
  395. },
  396. [1] = {
  397. .start = AT91SAM9263_ID_TWI,
  398. .end = AT91SAM9263_ID_TWI,
  399. .flags = IORESOURCE_IRQ,
  400. },
  401. };
  402. static struct platform_device at91sam9263_twi_device = {
  403. .name = "at91_i2c",
  404. .id = -1,
  405. .resource = twi_resources,
  406. .num_resources = ARRAY_SIZE(twi_resources),
  407. };
  408. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  409. {
  410. /* pins used for TWI interface */
  411. at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
  412. at91_set_multi_drive(AT91_PIN_PB4, 1);
  413. at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
  414. at91_set_multi_drive(AT91_PIN_PB5, 1);
  415. i2c_register_board_info(0, devices, nr_devices);
  416. platform_device_register(&at91sam9263_twi_device);
  417. }
  418. #else
  419. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  420. #endif
  421. /* --------------------------------------------------------------------
  422. * SPI
  423. * -------------------------------------------------------------------- */
  424. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  425. static u64 spi_dmamask = DMA_BIT_MASK(32);
  426. static struct resource spi0_resources[] = {
  427. [0] = {
  428. .start = AT91SAM9263_BASE_SPI0,
  429. .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
  430. .flags = IORESOURCE_MEM,
  431. },
  432. [1] = {
  433. .start = AT91SAM9263_ID_SPI0,
  434. .end = AT91SAM9263_ID_SPI0,
  435. .flags = IORESOURCE_IRQ,
  436. },
  437. };
  438. static struct platform_device at91sam9263_spi0_device = {
  439. .name = "atmel_spi",
  440. .id = 0,
  441. .dev = {
  442. .dma_mask = &spi_dmamask,
  443. .coherent_dma_mask = DMA_BIT_MASK(32),
  444. },
  445. .resource = spi0_resources,
  446. .num_resources = ARRAY_SIZE(spi0_resources),
  447. };
  448. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
  449. static struct resource spi1_resources[] = {
  450. [0] = {
  451. .start = AT91SAM9263_BASE_SPI1,
  452. .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
  453. .flags = IORESOURCE_MEM,
  454. },
  455. [1] = {
  456. .start = AT91SAM9263_ID_SPI1,
  457. .end = AT91SAM9263_ID_SPI1,
  458. .flags = IORESOURCE_IRQ,
  459. },
  460. };
  461. static struct platform_device at91sam9263_spi1_device = {
  462. .name = "atmel_spi",
  463. .id = 1,
  464. .dev = {
  465. .dma_mask = &spi_dmamask,
  466. .coherent_dma_mask = DMA_BIT_MASK(32),
  467. },
  468. .resource = spi1_resources,
  469. .num_resources = ARRAY_SIZE(spi1_resources),
  470. };
  471. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
  472. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  473. {
  474. int i;
  475. unsigned long cs_pin;
  476. short enable_spi0 = 0;
  477. short enable_spi1 = 0;
  478. /* Choose SPI chip-selects */
  479. for (i = 0; i < nr_devices; i++) {
  480. if (devices[i].controller_data)
  481. cs_pin = (unsigned long) devices[i].controller_data;
  482. else if (devices[i].bus_num == 0)
  483. cs_pin = spi0_standard_cs[devices[i].chip_select];
  484. else
  485. cs_pin = spi1_standard_cs[devices[i].chip_select];
  486. if (devices[i].bus_num == 0)
  487. enable_spi0 = 1;
  488. else
  489. enable_spi1 = 1;
  490. /* enable chip-select pin */
  491. at91_set_gpio_output(cs_pin, 1);
  492. /* pass chip-select pin to driver */
  493. devices[i].controller_data = (void *) cs_pin;
  494. }
  495. spi_register_board_info(devices, nr_devices);
  496. /* Configure SPI bus(es) */
  497. if (enable_spi0) {
  498. at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
  499. at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
  500. at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
  501. at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk");
  502. platform_device_register(&at91sam9263_spi0_device);
  503. }
  504. if (enable_spi1) {
  505. at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
  506. at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
  507. at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
  508. at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk");
  509. platform_device_register(&at91sam9263_spi1_device);
  510. }
  511. }
  512. #else
  513. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  514. #endif
  515. /* --------------------------------------------------------------------
  516. * AC97
  517. * -------------------------------------------------------------------- */
  518. #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
  519. static u64 ac97_dmamask = DMA_BIT_MASK(32);
  520. static struct atmel_ac97_data ac97_data;
  521. static struct resource ac97_resources[] = {
  522. [0] = {
  523. .start = AT91SAM9263_BASE_AC97C,
  524. .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
  525. .flags = IORESOURCE_MEM,
  526. },
  527. [1] = {
  528. .start = AT91SAM9263_ID_AC97C,
  529. .end = AT91SAM9263_ID_AC97C,
  530. .flags = IORESOURCE_IRQ,
  531. },
  532. };
  533. static struct platform_device at91sam9263_ac97_device = {
  534. .name = "ac97c",
  535. .id = 1,
  536. .dev = {
  537. .dma_mask = &ac97_dmamask,
  538. .coherent_dma_mask = DMA_BIT_MASK(32),
  539. .platform_data = &ac97_data,
  540. },
  541. .resource = ac97_resources,
  542. .num_resources = ARRAY_SIZE(ac97_resources),
  543. };
  544. void __init at91_add_device_ac97(struct atmel_ac97_data *data)
  545. {
  546. if (!data)
  547. return;
  548. at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
  549. at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
  550. at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
  551. at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
  552. /* reset */
  553. if (data->reset_pin)
  554. at91_set_gpio_output(data->reset_pin, 0);
  555. ac97_data = *ek_data;
  556. platform_device_register(&at91sam9263_ac97_device);
  557. }
  558. #else
  559. void __init at91_add_device_ac97(struct atmel_ac97_data *data) {}
  560. #endif
  561. /* --------------------------------------------------------------------
  562. * LCD Controller
  563. * -------------------------------------------------------------------- */
  564. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  565. static u64 lcdc_dmamask = DMA_BIT_MASK(32);
  566. static struct atmel_lcdfb_info lcdc_data;
  567. static struct resource lcdc_resources[] = {
  568. [0] = {
  569. .start = AT91SAM9263_LCDC_BASE,
  570. .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
  571. .flags = IORESOURCE_MEM,
  572. },
  573. [1] = {
  574. .start = AT91SAM9263_ID_LCDC,
  575. .end = AT91SAM9263_ID_LCDC,
  576. .flags = IORESOURCE_IRQ,
  577. },
  578. };
  579. static struct platform_device at91_lcdc_device = {
  580. .name = "atmel_lcdfb",
  581. .id = 0,
  582. .dev = {
  583. .dma_mask = &lcdc_dmamask,
  584. .coherent_dma_mask = DMA_BIT_MASK(32),
  585. .platform_data = &lcdc_data,
  586. },
  587. .resource = lcdc_resources,
  588. .num_resources = ARRAY_SIZE(lcdc_resources),
  589. };
  590. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  591. {
  592. if (!data)
  593. return;
  594. at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
  595. at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
  596. at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
  597. at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
  598. at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
  599. at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
  600. at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
  601. at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
  602. at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
  603. at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
  604. at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
  605. at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
  606. at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
  607. at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */
  608. at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
  609. at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
  610. at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
  611. at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
  612. at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
  613. at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */
  614. at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
  615. at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
  616. lcdc_data = *data;
  617. platform_device_register(&at91_lcdc_device);
  618. }
  619. #else
  620. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  621. #endif
  622. /* --------------------------------------------------------------------
  623. * Image Sensor Interface
  624. * -------------------------------------------------------------------- */
  625. #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
  626. struct resource isi_resources[] = {
  627. [0] = {
  628. .start = AT91SAM9263_BASE_ISI,
  629. .end = AT91SAM9263_BASE_ISI + SZ_16K - 1,
  630. .flags = IORESOURCE_MEM,
  631. },
  632. [1] = {
  633. .start = AT91SAM9263_ID_ISI,
  634. .end = AT91SAM9263_ID_ISI,
  635. .flags = IORESOURCE_IRQ,
  636. },
  637. };
  638. static struct platform_device at91sam9263_isi_device = {
  639. .name = "at91_isi",
  640. .id = -1,
  641. .resource = isi_resources,
  642. .num_resources = ARRAY_SIZE(isi_resources),
  643. };
  644. void __init at91_add_device_isi(void)
  645. {
  646. at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
  647. at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
  648. at91_set_A_periph(AT91_PIN_PE2, 0); /* ISI_D2 */
  649. at91_set_A_periph(AT91_PIN_PE3, 0); /* ISI_D3 */
  650. at91_set_A_periph(AT91_PIN_PE4, 0); /* ISI_D4 */
  651. at91_set_A_periph(AT91_PIN_PE5, 0); /* ISI_D5 */
  652. at91_set_A_periph(AT91_PIN_PE6, 0); /* ISI_D6 */
  653. at91_set_A_periph(AT91_PIN_PE7, 0); /* ISI_D7 */
  654. at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
  655. at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
  656. at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
  657. at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
  658. at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
  659. at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
  660. at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
  661. at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
  662. }
  663. #else
  664. void __init at91_add_device_isi(void) {}
  665. #endif
  666. /* --------------------------------------------------------------------
  667. * Timer/Counter block
  668. * -------------------------------------------------------------------- */
  669. #ifdef CONFIG_ATMEL_TCLIB
  670. static struct resource tcb_resources[] = {
  671. [0] = {
  672. .start = AT91SAM9263_BASE_TCB0,
  673. .end = AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
  674. .flags = IORESOURCE_MEM,
  675. },
  676. [1] = {
  677. .start = AT91SAM9263_ID_TCB,
  678. .end = AT91SAM9263_ID_TCB,
  679. .flags = IORESOURCE_IRQ,
  680. },
  681. };
  682. static struct platform_device at91sam9263_tcb_device = {
  683. .name = "atmel_tcb",
  684. .id = 0,
  685. .resource = tcb_resources,
  686. .num_resources = ARRAY_SIZE(tcb_resources),
  687. };
  688. static void __init at91_add_device_tc(void)
  689. {
  690. /* this chip has one clock and irq for all three TC channels */
  691. at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk");
  692. platform_device_register(&at91sam9263_tcb_device);
  693. }
  694. #else
  695. static void __init at91_add_device_tc(void) { }
  696. #endif
  697. /* --------------------------------------------------------------------
  698. * RTT
  699. * -------------------------------------------------------------------- */
  700. static struct resource rtt0_resources[] = {
  701. {
  702. .start = AT91_BASE_SYS + AT91_RTT0,
  703. .end = AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1,
  704. .flags = IORESOURCE_MEM,
  705. }
  706. };
  707. static struct platform_device at91sam9263_rtt0_device = {
  708. .name = "at91_rtt",
  709. .id = 0,
  710. .resource = rtt0_resources,
  711. .num_resources = ARRAY_SIZE(rtt0_resources),
  712. };
  713. static struct resource rtt1_resources[] = {
  714. {
  715. .start = AT91_BASE_SYS + AT91_RTT1,
  716. .end = AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1,
  717. .flags = IORESOURCE_MEM,
  718. }
  719. };
  720. static struct platform_device at91sam9263_rtt1_device = {
  721. .name = "at91_rtt",
  722. .id = 1,
  723. .resource = rtt1_resources,
  724. .num_resources = ARRAY_SIZE(rtt1_resources),
  725. };
  726. static void __init at91_add_device_rtt(void)
  727. {
  728. platform_device_register(&at91sam9263_rtt0_device);
  729. platform_device_register(&at91sam9263_rtt1_device);
  730. }
  731. /* --------------------------------------------------------------------
  732. * Watchdog
  733. * -------------------------------------------------------------------- */
  734. #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
  735. static struct platform_device at91sam9263_wdt_device = {
  736. .name = "at91_wdt",
  737. .id = -1,
  738. .num_resources = 0,
  739. };
  740. static void __init at91_add_device_watchdog(void)
  741. {
  742. platform_device_register(&at91sam9263_wdt_device);
  743. }
  744. #else
  745. static void __init at91_add_device_watchdog(void) {}
  746. #endif
  747. /* --------------------------------------------------------------------
  748. * SSC -- Synchronous Serial Controller
  749. * -------------------------------------------------------------------- */
  750. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  751. static u64 ssc0_dmamask = DMA_BIT_MASK(32);
  752. static struct resource ssc0_resources[] = {
  753. [0] = {
  754. .start = AT91SAM9263_BASE_SSC0,
  755. .end = AT91SAM9263_BASE_SSC0 + SZ_16K - 1,
  756. .flags = IORESOURCE_MEM,
  757. },
  758. [1] = {
  759. .start = AT91SAM9263_ID_SSC0,
  760. .end = AT91SAM9263_ID_SSC0,
  761. .flags = IORESOURCE_IRQ,
  762. },
  763. };
  764. static struct platform_device at91sam9263_ssc0_device = {
  765. .name = "ssc",
  766. .id = 0,
  767. .dev = {
  768. .dma_mask = &ssc0_dmamask,
  769. .coherent_dma_mask = DMA_BIT_MASK(32),
  770. },
  771. .resource = ssc0_resources,
  772. .num_resources = ARRAY_SIZE(ssc0_resources),
  773. };
  774. static inline void configure_ssc0_pins(unsigned pins)
  775. {
  776. if (pins & ATMEL_SSC_TF)
  777. at91_set_B_periph(AT91_PIN_PB0, 1);
  778. if (pins & ATMEL_SSC_TK)
  779. at91_set_B_periph(AT91_PIN_PB1, 1);
  780. if (pins & ATMEL_SSC_TD)
  781. at91_set_B_periph(AT91_PIN_PB2, 1);
  782. if (pins & ATMEL_SSC_RD)
  783. at91_set_B_periph(AT91_PIN_PB3, 1);
  784. if (pins & ATMEL_SSC_RK)
  785. at91_set_B_periph(AT91_PIN_PB4, 1);
  786. if (pins & ATMEL_SSC_RF)
  787. at91_set_B_periph(AT91_PIN_PB5, 1);
  788. }
  789. static u64 ssc1_dmamask = DMA_BIT_MASK(32);
  790. static struct resource ssc1_resources[] = {
  791. [0] = {
  792. .start = AT91SAM9263_BASE_SSC1,
  793. .end = AT91SAM9263_BASE_SSC1 + SZ_16K - 1,
  794. .flags = IORESOURCE_MEM,
  795. },
  796. [1] = {
  797. .start = AT91SAM9263_ID_SSC1,
  798. .end = AT91SAM9263_ID_SSC1,
  799. .flags = IORESOURCE_IRQ,
  800. },
  801. };
  802. static struct platform_device at91sam9263_ssc1_device = {
  803. .name = "ssc",
  804. .id = 1,
  805. .dev = {
  806. .dma_mask = &ssc1_dmamask,
  807. .coherent_dma_mask = DMA_BIT_MASK(32),
  808. },
  809. .resource = ssc1_resources,
  810. .num_resources = ARRAY_SIZE(ssc1_resources),
  811. };
  812. static inline void configure_ssc1_pins(unsigned pins)
  813. {
  814. if (pins & ATMEL_SSC_TF)
  815. at91_set_A_periph(AT91_PIN_PB6, 1);
  816. if (pins & ATMEL_SSC_TK)
  817. at91_set_A_periph(AT91_PIN_PB7, 1);
  818. if (pins & ATMEL_SSC_TD)
  819. at91_set_A_periph(AT91_PIN_PB8, 1);
  820. if (pins & ATMEL_SSC_RD)
  821. at91_set_A_periph(AT91_PIN_PB9, 1);
  822. if (pins & ATMEL_SSC_RK)
  823. at91_set_A_periph(AT91_PIN_PB10, 1);
  824. if (pins & ATMEL_SSC_RF)
  825. at91_set_A_periph(AT91_PIN_PB11, 1);
  826. }
  827. /*
  828. * SSC controllers are accessed through library code, instead of any
  829. * kind of all-singing/all-dancing driver. For example one could be
  830. * used by a particular I2S audio codec's driver, while another one
  831. * on the same system might be used by a custom data capture driver.
  832. */
  833. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  834. {
  835. struct platform_device *pdev;
  836. /*
  837. * NOTE: caller is responsible for passing information matching
  838. * "pins" to whatever will be using each particular controller.
  839. */
  840. switch (id) {
  841. case AT91SAM9263_ID_SSC0:
  842. pdev = &at91sam9263_ssc0_device;
  843. configure_ssc0_pins(pins);
  844. at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");
  845. break;
  846. case AT91SAM9263_ID_SSC1:
  847. pdev = &at91sam9263_ssc1_device;
  848. configure_ssc1_pins(pins);
  849. at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");
  850. break;
  851. default:
  852. return;
  853. }
  854. platform_device_register(pdev);
  855. }
  856. #else
  857. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  858. #endif
  859. /* --------------------------------------------------------------------
  860. * UART
  861. * -------------------------------------------------------------------- */
  862. #if defined(CONFIG_SERIAL_ATMEL)
  863. static struct resource dbgu_resources[] = {
  864. [0] = {
  865. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  866. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  867. .flags = IORESOURCE_MEM,
  868. },
  869. [1] = {
  870. .start = AT91_ID_SYS,
  871. .end = AT91_ID_SYS,
  872. .flags = IORESOURCE_IRQ,
  873. },
  874. };
  875. static struct atmel_uart_data dbgu_data = {
  876. .use_dma_tx = 0,
  877. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  878. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  879. };
  880. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  881. static struct platform_device at91sam9263_dbgu_device = {
  882. .name = "atmel_usart",
  883. .id = 0,
  884. .dev = {
  885. .dma_mask = &dbgu_dmamask,
  886. .coherent_dma_mask = DMA_BIT_MASK(32),
  887. .platform_data = &dbgu_data,
  888. },
  889. .resource = dbgu_resources,
  890. .num_resources = ARRAY_SIZE(dbgu_resources),
  891. };
  892. static inline void configure_dbgu_pins(void)
  893. {
  894. at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
  895. at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
  896. }
  897. static struct resource uart0_resources[] = {
  898. [0] = {
  899. .start = AT91SAM9263_BASE_US0,
  900. .end = AT91SAM9263_BASE_US0 + SZ_16K - 1,
  901. .flags = IORESOURCE_MEM,
  902. },
  903. [1] = {
  904. .start = AT91SAM9263_ID_US0,
  905. .end = AT91SAM9263_ID_US0,
  906. .flags = IORESOURCE_IRQ,
  907. },
  908. };
  909. static struct atmel_uart_data uart0_data = {
  910. .use_dma_tx = 1,
  911. .use_dma_rx = 1,
  912. };
  913. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  914. static struct platform_device at91sam9263_uart0_device = {
  915. .name = "atmel_usart",
  916. .id = 1,
  917. .dev = {
  918. .dma_mask = &uart0_dmamask,
  919. .coherent_dma_mask = DMA_BIT_MASK(32),
  920. .platform_data = &uart0_data,
  921. },
  922. .resource = uart0_resources,
  923. .num_resources = ARRAY_SIZE(uart0_resources),
  924. };
  925. static inline void configure_usart0_pins(unsigned pins)
  926. {
  927. at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */
  928. at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */
  929. if (pins & ATMEL_UART_RTS)
  930. at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */
  931. if (pins & ATMEL_UART_CTS)
  932. at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */
  933. }
  934. static struct resource uart1_resources[] = {
  935. [0] = {
  936. .start = AT91SAM9263_BASE_US1,
  937. .end = AT91SAM9263_BASE_US1 + SZ_16K - 1,
  938. .flags = IORESOURCE_MEM,
  939. },
  940. [1] = {
  941. .start = AT91SAM9263_ID_US1,
  942. .end = AT91SAM9263_ID_US1,
  943. .flags = IORESOURCE_IRQ,
  944. },
  945. };
  946. static struct atmel_uart_data uart1_data = {
  947. .use_dma_tx = 1,
  948. .use_dma_rx = 1,
  949. };
  950. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  951. static struct platform_device at91sam9263_uart1_device = {
  952. .name = "atmel_usart",
  953. .id = 2,
  954. .dev = {
  955. .dma_mask = &uart1_dmamask,
  956. .coherent_dma_mask = DMA_BIT_MASK(32),
  957. .platform_data = &uart1_data,
  958. },
  959. .resource = uart1_resources,
  960. .num_resources = ARRAY_SIZE(uart1_resources),
  961. };
  962. static inline void configure_usart1_pins(unsigned pins)
  963. {
  964. at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
  965. at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
  966. if (pins & ATMEL_UART_RTS)
  967. at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
  968. if (pins & ATMEL_UART_CTS)
  969. at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
  970. }
  971. static struct resource uart2_resources[] = {
  972. [0] = {
  973. .start = AT91SAM9263_BASE_US2,
  974. .end = AT91SAM9263_BASE_US2 + SZ_16K - 1,
  975. .flags = IORESOURCE_MEM,
  976. },
  977. [1] = {
  978. .start = AT91SAM9263_ID_US2,
  979. .end = AT91SAM9263_ID_US2,
  980. .flags = IORESOURCE_IRQ,
  981. },
  982. };
  983. static struct atmel_uart_data uart2_data = {
  984. .use_dma_tx = 1,
  985. .use_dma_rx = 1,
  986. };
  987. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  988. static struct platform_device at91sam9263_uart2_device = {
  989. .name = "atmel_usart",
  990. .id = 3,
  991. .dev = {
  992. .dma_mask = &uart2_dmamask,
  993. .coherent_dma_mask = DMA_BIT_MASK(32),
  994. .platform_data = &uart2_data,
  995. },
  996. .resource = uart2_resources,
  997. .num_resources = ARRAY_SIZE(uart2_resources),
  998. };
  999. static inline void configure_usart2_pins(unsigned pins)
  1000. {
  1001. at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
  1002. at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
  1003. if (pins & ATMEL_UART_RTS)
  1004. at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
  1005. if (pins & ATMEL_UART_CTS)
  1006. at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
  1007. }
  1008. static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  1009. struct platform_device *atmel_default_console_device; /* the serial console device */
  1010. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  1011. {
  1012. struct platform_device *pdev;
  1013. switch (id) {
  1014. case 0: /* DBGU */
  1015. pdev = &at91sam9263_dbgu_device;
  1016. configure_dbgu_pins();
  1017. at91_clock_associate("mck", &pdev->dev, "usart");
  1018. break;
  1019. case AT91SAM9263_ID_US0:
  1020. pdev = &at91sam9263_uart0_device;
  1021. configure_usart0_pins(pins);
  1022. at91_clock_associate("usart0_clk", &pdev->dev, "usart");
  1023. break;
  1024. case AT91SAM9263_ID_US1:
  1025. pdev = &at91sam9263_uart1_device;
  1026. configure_usart1_pins(pins);
  1027. at91_clock_associate("usart1_clk", &pdev->dev, "usart");
  1028. break;
  1029. case AT91SAM9263_ID_US2:
  1030. pdev = &at91sam9263_uart2_device;
  1031. configure_usart2_pins(pins);
  1032. at91_clock_associate("usart2_clk", &pdev->dev, "usart");
  1033. break;
  1034. default:
  1035. return;
  1036. }
  1037. pdev->id = portnr; /* update to mapped ID */
  1038. if (portnr < ATMEL_MAX_UART)
  1039. at91_uarts[portnr] = pdev;
  1040. }
  1041. void __init at91_set_serial_console(unsigned portnr)
  1042. {
  1043. if (portnr < ATMEL_MAX_UART)
  1044. atmel_default_console_device = at91_uarts[portnr];
  1045. }
  1046. void __init at91_add_device_serial(void)
  1047. {
  1048. int i;
  1049. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1050. if (at91_uarts[i])
  1051. platform_device_register(at91_uarts[i]);
  1052. }
  1053. if (!atmel_default_console_device)
  1054. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1055. }
  1056. #else
  1057. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1058. void __init at91_set_serial_console(unsigned portnr) {}
  1059. void __init at91_add_device_serial(void) {}
  1060. #endif
  1061. /* -------------------------------------------------------------------- */
  1062. /*
  1063. * These devices are always present and don't need any board-specific
  1064. * setup.
  1065. */
  1066. static int __init at91_add_standard_devices(void)
  1067. {
  1068. at91_add_device_rtt();
  1069. at91_add_device_watchdog();
  1070. at91_add_device_tc();
  1071. return 0;
  1072. }
  1073. arch_initcall(at91_add_standard_devices);