at91cap9_devices.c 31 KB

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