at91sam9g45_devices.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766
  1. /*
  2. * On-Chip devices setup code for the AT91SAM9G45 family
  3. *
  4. * Copyright (C) 2009 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/gpio.h>
  16. #include <linux/clk.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c-gpio.h>
  19. #include <linux/atmel-mci.h>
  20. #include <linux/fb.h>
  21. #include <video/atmel_lcdc.h>
  22. #include <mach/board.h>
  23. #include <mach/at91sam9g45.h>
  24. #include <mach/at91sam9g45_matrix.h>
  25. #include <mach/at91_matrix.h>
  26. #include <mach/at91sam9_smc.h>
  27. #include <mach/at_hdmac.h>
  28. #include <mach/atmel-mci.h>
  29. #include <media/atmel-isi.h>
  30. #include "generic.h"
  31. #include "clock.h"
  32. /* --------------------------------------------------------------------
  33. * HDMAC - AHB DMA Controller
  34. * -------------------------------------------------------------------- */
  35. #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
  36. static u64 hdmac_dmamask = DMA_BIT_MASK(32);
  37. static struct resource hdmac_resources[] = {
  38. [0] = {
  39. .start = AT91SAM9G45_BASE_DMA,
  40. .end = AT91SAM9G45_BASE_DMA + SZ_512 - 1,
  41. .flags = IORESOURCE_MEM,
  42. },
  43. [1] = {
  44. .start = AT91SAM9G45_ID_DMA,
  45. .end = AT91SAM9G45_ID_DMA,
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. static struct platform_device at_hdmac_device = {
  50. .name = "at91sam9g45_dma",
  51. .id = -1,
  52. .dev = {
  53. .dma_mask = &hdmac_dmamask,
  54. .coherent_dma_mask = DMA_BIT_MASK(32),
  55. },
  56. .resource = hdmac_resources,
  57. .num_resources = ARRAY_SIZE(hdmac_resources),
  58. };
  59. void __init at91_add_device_hdmac(void)
  60. {
  61. #if defined(CONFIG_OF)
  62. struct device_node *of_node =
  63. of_find_node_by_name(NULL, "dma-controller");
  64. if (of_node)
  65. of_node_put(of_node);
  66. else
  67. #endif
  68. platform_device_register(&at_hdmac_device);
  69. }
  70. #else
  71. void __init at91_add_device_hdmac(void) {}
  72. #endif
  73. /* --------------------------------------------------------------------
  74. * USB Host (OHCI)
  75. * -------------------------------------------------------------------- */
  76. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  77. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  78. static struct at91_usbh_data usbh_ohci_data;
  79. static struct resource usbh_ohci_resources[] = {
  80. [0] = {
  81. .start = AT91SAM9G45_OHCI_BASE,
  82. .end = AT91SAM9G45_OHCI_BASE + SZ_1M - 1,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. [1] = {
  86. .start = AT91SAM9G45_ID_UHPHS,
  87. .end = AT91SAM9G45_ID_UHPHS,
  88. .flags = IORESOURCE_IRQ,
  89. },
  90. };
  91. static struct platform_device at91_usbh_ohci_device = {
  92. .name = "at91_ohci",
  93. .id = -1,
  94. .dev = {
  95. .dma_mask = &ohci_dmamask,
  96. .coherent_dma_mask = DMA_BIT_MASK(32),
  97. .platform_data = &usbh_ohci_data,
  98. },
  99. .resource = usbh_ohci_resources,
  100. .num_resources = ARRAY_SIZE(usbh_ohci_resources),
  101. };
  102. void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
  103. {
  104. int i;
  105. if (!data)
  106. return;
  107. /* Enable VBus control for UHP ports */
  108. for (i = 0; i < data->ports; i++) {
  109. if (gpio_is_valid(data->vbus_pin[i]))
  110. at91_set_gpio_output(data->vbus_pin[i], 0);
  111. }
  112. /* Enable overcurrent notification */
  113. for (i = 0; i < data->ports; i++) {
  114. if (data->overcurrent_pin[i])
  115. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  116. }
  117. usbh_ohci_data = *data;
  118. platform_device_register(&at91_usbh_ohci_device);
  119. }
  120. #else
  121. void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) {}
  122. #endif
  123. /* --------------------------------------------------------------------
  124. * USB Host HS (EHCI)
  125. * Needs an OHCI host for low and full speed management
  126. * -------------------------------------------------------------------- */
  127. #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
  128. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  129. static struct at91_usbh_data usbh_ehci_data;
  130. static struct resource usbh_ehci_resources[] = {
  131. [0] = {
  132. .start = AT91SAM9G45_EHCI_BASE,
  133. .end = AT91SAM9G45_EHCI_BASE + SZ_1M - 1,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = AT91SAM9G45_ID_UHPHS,
  138. .end = AT91SAM9G45_ID_UHPHS,
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. };
  142. static struct platform_device at91_usbh_ehci_device = {
  143. .name = "atmel-ehci",
  144. .id = -1,
  145. .dev = {
  146. .dma_mask = &ehci_dmamask,
  147. .coherent_dma_mask = DMA_BIT_MASK(32),
  148. .platform_data = &usbh_ehci_data,
  149. },
  150. .resource = usbh_ehci_resources,
  151. .num_resources = ARRAY_SIZE(usbh_ehci_resources),
  152. };
  153. void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)
  154. {
  155. int i;
  156. if (!data)
  157. return;
  158. /* Enable VBus control for UHP ports */
  159. for (i = 0; i < data->ports; i++) {
  160. if (gpio_is_valid(data->vbus_pin[i]))
  161. at91_set_gpio_output(data->vbus_pin[i], 0);
  162. }
  163. usbh_ehci_data = *data;
  164. platform_device_register(&at91_usbh_ehci_device);
  165. }
  166. #else
  167. void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}
  168. #endif
  169. /* --------------------------------------------------------------------
  170. * USB HS Device (Gadget)
  171. * -------------------------------------------------------------------- */
  172. #if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)
  173. static struct resource usba_udc_resources[] = {
  174. [0] = {
  175. .start = AT91SAM9G45_UDPHS_FIFO,
  176. .end = AT91SAM9G45_UDPHS_FIFO + SZ_512K - 1,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = AT91SAM9G45_BASE_UDPHS,
  181. .end = AT91SAM9G45_BASE_UDPHS + SZ_1K - 1,
  182. .flags = IORESOURCE_MEM,
  183. },
  184. [2] = {
  185. .start = AT91SAM9G45_ID_UDPHS,
  186. .end = AT91SAM9G45_ID_UDPHS,
  187. .flags = IORESOURCE_IRQ,
  188. },
  189. };
  190. #define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
  191. [idx] = { \
  192. .name = nam, \
  193. .index = idx, \
  194. .fifo_size = maxpkt, \
  195. .nr_banks = maxbk, \
  196. .can_dma = dma, \
  197. .can_isoc = isoc, \
  198. }
  199. static struct usba_ep_data usba_udc_ep[] __initdata = {
  200. EP("ep0", 0, 64, 1, 0, 0),
  201. EP("ep1", 1, 1024, 2, 1, 1),
  202. EP("ep2", 2, 1024, 2, 1, 1),
  203. EP("ep3", 3, 1024, 3, 1, 0),
  204. EP("ep4", 4, 1024, 3, 1, 0),
  205. EP("ep5", 5, 1024, 3, 1, 1),
  206. EP("ep6", 6, 1024, 3, 1, 1),
  207. };
  208. #undef EP
  209. /*
  210. * pdata doesn't have room for any endpoints, so we need to
  211. * append room for the ones we need right after it.
  212. */
  213. static struct {
  214. struct usba_platform_data pdata;
  215. struct usba_ep_data ep[7];
  216. } usba_udc_data;
  217. static struct platform_device at91_usba_udc_device = {
  218. .name = "atmel_usba_udc",
  219. .id = -1,
  220. .dev = {
  221. .platform_data = &usba_udc_data.pdata,
  222. },
  223. .resource = usba_udc_resources,
  224. .num_resources = ARRAY_SIZE(usba_udc_resources),
  225. };
  226. void __init at91_add_device_usba(struct usba_platform_data *data)
  227. {
  228. usba_udc_data.pdata.vbus_pin = -EINVAL;
  229. usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
  230. memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
  231. if (data && gpio_is_valid(data->vbus_pin)) {
  232. at91_set_gpio_input(data->vbus_pin, 0);
  233. at91_set_deglitch(data->vbus_pin, 1);
  234. usba_udc_data.pdata.vbus_pin = data->vbus_pin;
  235. }
  236. /* Pullup pin is handled internally by USB device peripheral */
  237. platform_device_register(&at91_usba_udc_device);
  238. }
  239. #else
  240. void __init at91_add_device_usba(struct usba_platform_data *data) {}
  241. #endif
  242. /* --------------------------------------------------------------------
  243. * Ethernet
  244. * -------------------------------------------------------------------- */
  245. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
  246. static u64 eth_dmamask = DMA_BIT_MASK(32);
  247. static struct macb_platform_data eth_data;
  248. static struct resource eth_resources[] = {
  249. [0] = {
  250. .start = AT91SAM9G45_BASE_EMAC,
  251. .end = AT91SAM9G45_BASE_EMAC + SZ_16K - 1,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. [1] = {
  255. .start = AT91SAM9G45_ID_EMAC,
  256. .end = AT91SAM9G45_ID_EMAC,
  257. .flags = IORESOURCE_IRQ,
  258. },
  259. };
  260. static struct platform_device at91sam9g45_eth_device = {
  261. .name = "macb",
  262. .id = -1,
  263. .dev = {
  264. .dma_mask = &eth_dmamask,
  265. .coherent_dma_mask = DMA_BIT_MASK(32),
  266. .platform_data = &eth_data,
  267. },
  268. .resource = eth_resources,
  269. .num_resources = ARRAY_SIZE(eth_resources),
  270. };
  271. void __init at91_add_device_eth(struct macb_platform_data *data)
  272. {
  273. if (!data)
  274. return;
  275. if (gpio_is_valid(data->phy_irq_pin)) {
  276. at91_set_gpio_input(data->phy_irq_pin, 0);
  277. at91_set_deglitch(data->phy_irq_pin, 1);
  278. }
  279. /* Pins used for MII and RMII */
  280. at91_set_A_periph(AT91_PIN_PA17, 0); /* ETXCK_EREFCK */
  281. at91_set_A_periph(AT91_PIN_PA15, 0); /* ERXDV */
  282. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  283. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  284. at91_set_A_periph(AT91_PIN_PA16, 0); /* ERXER */
  285. at91_set_A_periph(AT91_PIN_PA14, 0); /* ETXEN */
  286. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX0 */
  287. at91_set_A_periph(AT91_PIN_PA11, 0); /* ETX1 */
  288. at91_set_A_periph(AT91_PIN_PA19, 0); /* EMDIO */
  289. at91_set_A_periph(AT91_PIN_PA18, 0); /* EMDC */
  290. if (!data->is_rmii) {
  291. at91_set_B_periph(AT91_PIN_PA29, 0); /* ECRS */
  292. at91_set_B_periph(AT91_PIN_PA30, 0); /* ECOL */
  293. at91_set_B_periph(AT91_PIN_PA8, 0); /* ERX2 */
  294. at91_set_B_periph(AT91_PIN_PA9, 0); /* ERX3 */
  295. at91_set_B_periph(AT91_PIN_PA28, 0); /* ERXCK */
  296. at91_set_B_periph(AT91_PIN_PA6, 0); /* ETX2 */
  297. at91_set_B_periph(AT91_PIN_PA7, 0); /* ETX3 */
  298. at91_set_B_periph(AT91_PIN_PA27, 0); /* ETXER */
  299. }
  300. eth_data = *data;
  301. platform_device_register(&at91sam9g45_eth_device);
  302. }
  303. #else
  304. void __init at91_add_device_eth(struct macb_platform_data *data) {}
  305. #endif
  306. /* --------------------------------------------------------------------
  307. * MMC / SD
  308. * -------------------------------------------------------------------- */
  309. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  310. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  311. static struct mci_platform_data mmc0_data, mmc1_data;
  312. static struct resource mmc0_resources[] = {
  313. [0] = {
  314. .start = AT91SAM9G45_BASE_MCI0,
  315. .end = AT91SAM9G45_BASE_MCI0 + SZ_16K - 1,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. [1] = {
  319. .start = AT91SAM9G45_ID_MCI0,
  320. .end = AT91SAM9G45_ID_MCI0,
  321. .flags = IORESOURCE_IRQ,
  322. },
  323. };
  324. static struct platform_device at91sam9g45_mmc0_device = {
  325. .name = "atmel_mci",
  326. .id = 0,
  327. .dev = {
  328. .dma_mask = &mmc_dmamask,
  329. .coherent_dma_mask = DMA_BIT_MASK(32),
  330. .platform_data = &mmc0_data,
  331. },
  332. .resource = mmc0_resources,
  333. .num_resources = ARRAY_SIZE(mmc0_resources),
  334. };
  335. static struct resource mmc1_resources[] = {
  336. [0] = {
  337. .start = AT91SAM9G45_BASE_MCI1,
  338. .end = AT91SAM9G45_BASE_MCI1 + SZ_16K - 1,
  339. .flags = IORESOURCE_MEM,
  340. },
  341. [1] = {
  342. .start = AT91SAM9G45_ID_MCI1,
  343. .end = AT91SAM9G45_ID_MCI1,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct platform_device at91sam9g45_mmc1_device = {
  348. .name = "atmel_mci",
  349. .id = 1,
  350. .dev = {
  351. .dma_mask = &mmc_dmamask,
  352. .coherent_dma_mask = DMA_BIT_MASK(32),
  353. .platform_data = &mmc1_data,
  354. },
  355. .resource = mmc1_resources,
  356. .num_resources = ARRAY_SIZE(mmc1_resources),
  357. };
  358. /* Consider only one slot : slot 0 */
  359. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  360. {
  361. if (!data)
  362. return;
  363. /* Must have at least one usable slot */
  364. if (!data->slot[0].bus_width)
  365. return;
  366. #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
  367. {
  368. struct at_dma_slave *atslave;
  369. struct mci_dma_data *alt_atslave;
  370. alt_atslave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
  371. atslave = &alt_atslave->sdata;
  372. /* DMA slave channel configuration */
  373. atslave->dma_dev = &at_hdmac_device.dev;
  374. atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT;
  375. atslave->cfg = ATC_FIFOCFG_HALFFIFO
  376. | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW;
  377. atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16;
  378. if (mmc_id == 0) /* MCI0 */
  379. atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)
  380. | ATC_DST_PER(AT_DMA_ID_MCI0);
  381. else /* MCI1 */
  382. atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI1)
  383. | ATC_DST_PER(AT_DMA_ID_MCI1);
  384. data->dma_slave = alt_atslave;
  385. }
  386. #endif
  387. /* input/irq */
  388. if (gpio_is_valid(data->slot[0].detect_pin)) {
  389. at91_set_gpio_input(data->slot[0].detect_pin, 1);
  390. at91_set_deglitch(data->slot[0].detect_pin, 1);
  391. }
  392. if (gpio_is_valid(data->slot[0].wp_pin))
  393. at91_set_gpio_input(data->slot[0].wp_pin, 1);
  394. if (mmc_id == 0) { /* MCI0 */
  395. /* CLK */
  396. at91_set_A_periph(AT91_PIN_PA0, 0);
  397. /* CMD */
  398. at91_set_A_periph(AT91_PIN_PA1, 1);
  399. /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
  400. at91_set_A_periph(AT91_PIN_PA2, 1);
  401. if (data->slot[0].bus_width == 4) {
  402. at91_set_A_periph(AT91_PIN_PA3, 1);
  403. at91_set_A_periph(AT91_PIN_PA4, 1);
  404. at91_set_A_periph(AT91_PIN_PA5, 1);
  405. if (data->slot[0].bus_width == 8) {
  406. at91_set_A_periph(AT91_PIN_PA6, 1);
  407. at91_set_A_periph(AT91_PIN_PA7, 1);
  408. at91_set_A_periph(AT91_PIN_PA8, 1);
  409. at91_set_A_periph(AT91_PIN_PA9, 1);
  410. }
  411. }
  412. mmc0_data = *data;
  413. platform_device_register(&at91sam9g45_mmc0_device);
  414. } else { /* MCI1 */
  415. /* CLK */
  416. at91_set_A_periph(AT91_PIN_PA31, 0);
  417. /* CMD */
  418. at91_set_A_periph(AT91_PIN_PA22, 1);
  419. /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
  420. at91_set_A_periph(AT91_PIN_PA23, 1);
  421. if (data->slot[0].bus_width == 4) {
  422. at91_set_A_periph(AT91_PIN_PA24, 1);
  423. at91_set_A_periph(AT91_PIN_PA25, 1);
  424. at91_set_A_periph(AT91_PIN_PA26, 1);
  425. if (data->slot[0].bus_width == 8) {
  426. at91_set_A_periph(AT91_PIN_PA27, 1);
  427. at91_set_A_periph(AT91_PIN_PA28, 1);
  428. at91_set_A_periph(AT91_PIN_PA29, 1);
  429. at91_set_A_periph(AT91_PIN_PA30, 1);
  430. }
  431. }
  432. mmc1_data = *data;
  433. platform_device_register(&at91sam9g45_mmc1_device);
  434. }
  435. }
  436. #else
  437. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  438. #endif
  439. /* --------------------------------------------------------------------
  440. * NAND / SmartMedia
  441. * -------------------------------------------------------------------- */
  442. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  443. static struct atmel_nand_data nand_data;
  444. #define NAND_BASE AT91_CHIPSELECT_3
  445. static struct resource nand_resources[] = {
  446. [0] = {
  447. .start = NAND_BASE,
  448. .end = NAND_BASE + SZ_256M - 1,
  449. .flags = IORESOURCE_MEM,
  450. },
  451. [1] = {
  452. .start = AT91SAM9G45_BASE_ECC,
  453. .end = AT91SAM9G45_BASE_ECC + SZ_512 - 1,
  454. .flags = IORESOURCE_MEM,
  455. }
  456. };
  457. static struct platform_device at91sam9g45_nand_device = {
  458. .name = "atmel_nand",
  459. .id = -1,
  460. .dev = {
  461. .platform_data = &nand_data,
  462. },
  463. .resource = nand_resources,
  464. .num_resources = ARRAY_SIZE(nand_resources),
  465. };
  466. void __init at91_add_device_nand(struct atmel_nand_data *data)
  467. {
  468. unsigned long csa;
  469. if (!data)
  470. return;
  471. csa = at91_matrix_read(AT91_MATRIX_EBICSA);
  472. at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
  473. /* enable pin */
  474. if (gpio_is_valid(data->enable_pin))
  475. at91_set_gpio_output(data->enable_pin, 1);
  476. /* ready/busy pin */
  477. if (gpio_is_valid(data->rdy_pin))
  478. at91_set_gpio_input(data->rdy_pin, 1);
  479. /* card detect pin */
  480. if (gpio_is_valid(data->det_pin))
  481. at91_set_gpio_input(data->det_pin, 1);
  482. nand_data = *data;
  483. platform_device_register(&at91sam9g45_nand_device);
  484. }
  485. #else
  486. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  487. #endif
  488. /* --------------------------------------------------------------------
  489. * TWI (i2c)
  490. * -------------------------------------------------------------------- */
  491. /*
  492. * Prefer the GPIO code since the TWI controller isn't robust
  493. * (gets overruns and underruns under load) and can only issue
  494. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  495. */
  496. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  497. static struct i2c_gpio_platform_data pdata_i2c0 = {
  498. .sda_pin = AT91_PIN_PA20,
  499. .sda_is_open_drain = 1,
  500. .scl_pin = AT91_PIN_PA21,
  501. .scl_is_open_drain = 1,
  502. .udelay = 5, /* ~100 kHz */
  503. };
  504. static struct platform_device at91sam9g45_twi0_device = {
  505. .name = "i2c-gpio",
  506. .id = 0,
  507. .dev.platform_data = &pdata_i2c0,
  508. };
  509. static struct i2c_gpio_platform_data pdata_i2c1 = {
  510. .sda_pin = AT91_PIN_PB10,
  511. .sda_is_open_drain = 1,
  512. .scl_pin = AT91_PIN_PB11,
  513. .scl_is_open_drain = 1,
  514. .udelay = 5, /* ~100 kHz */
  515. };
  516. static struct platform_device at91sam9g45_twi1_device = {
  517. .name = "i2c-gpio",
  518. .id = 1,
  519. .dev.platform_data = &pdata_i2c1,
  520. };
  521. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
  522. {
  523. i2c_register_board_info(i2c_id, devices, nr_devices);
  524. if (i2c_id == 0) {
  525. at91_set_GPIO_periph(AT91_PIN_PA20, 1); /* TWD (SDA) */
  526. at91_set_multi_drive(AT91_PIN_PA20, 1);
  527. at91_set_GPIO_periph(AT91_PIN_PA21, 1); /* TWCK (SCL) */
  528. at91_set_multi_drive(AT91_PIN_PA21, 1);
  529. platform_device_register(&at91sam9g45_twi0_device);
  530. } else {
  531. at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* TWD (SDA) */
  532. at91_set_multi_drive(AT91_PIN_PB10, 1);
  533. at91_set_GPIO_periph(AT91_PIN_PB11, 1); /* TWCK (SCL) */
  534. at91_set_multi_drive(AT91_PIN_PB11, 1);
  535. platform_device_register(&at91sam9g45_twi1_device);
  536. }
  537. }
  538. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  539. static struct resource twi0_resources[] = {
  540. [0] = {
  541. .start = AT91SAM9G45_BASE_TWI0,
  542. .end = AT91SAM9G45_BASE_TWI0 + SZ_16K - 1,
  543. .flags = IORESOURCE_MEM,
  544. },
  545. [1] = {
  546. .start = AT91SAM9G45_ID_TWI0,
  547. .end = AT91SAM9G45_ID_TWI0,
  548. .flags = IORESOURCE_IRQ,
  549. },
  550. };
  551. static struct platform_device at91sam9g45_twi0_device = {
  552. .name = "at91_i2c",
  553. .id = 0,
  554. .resource = twi0_resources,
  555. .num_resources = ARRAY_SIZE(twi0_resources),
  556. };
  557. static struct resource twi1_resources[] = {
  558. [0] = {
  559. .start = AT91SAM9G45_BASE_TWI1,
  560. .end = AT91SAM9G45_BASE_TWI1 + SZ_16K - 1,
  561. .flags = IORESOURCE_MEM,
  562. },
  563. [1] = {
  564. .start = AT91SAM9G45_ID_TWI1,
  565. .end = AT91SAM9G45_ID_TWI1,
  566. .flags = IORESOURCE_IRQ,
  567. },
  568. };
  569. static struct platform_device at91sam9g45_twi1_device = {
  570. .name = "at91_i2c",
  571. .id = 1,
  572. .resource = twi1_resources,
  573. .num_resources = ARRAY_SIZE(twi1_resources),
  574. };
  575. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
  576. {
  577. i2c_register_board_info(i2c_id, devices, nr_devices);
  578. /* pins used for TWI interface */
  579. if (i2c_id == 0) {
  580. at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */
  581. at91_set_multi_drive(AT91_PIN_PA20, 1);
  582. at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */
  583. at91_set_multi_drive(AT91_PIN_PA21, 1);
  584. platform_device_register(&at91sam9g45_twi0_device);
  585. } else {
  586. at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */
  587. at91_set_multi_drive(AT91_PIN_PB10, 1);
  588. at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */
  589. at91_set_multi_drive(AT91_PIN_PB11, 1);
  590. platform_device_register(&at91sam9g45_twi1_device);
  591. }
  592. }
  593. #else
  594. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
  595. #endif
  596. /* --------------------------------------------------------------------
  597. * SPI
  598. * -------------------------------------------------------------------- */
  599. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  600. static u64 spi_dmamask = DMA_BIT_MASK(32);
  601. static struct resource spi0_resources[] = {
  602. [0] = {
  603. .start = AT91SAM9G45_BASE_SPI0,
  604. .end = AT91SAM9G45_BASE_SPI0 + SZ_16K - 1,
  605. .flags = IORESOURCE_MEM,
  606. },
  607. [1] = {
  608. .start = AT91SAM9G45_ID_SPI0,
  609. .end = AT91SAM9G45_ID_SPI0,
  610. .flags = IORESOURCE_IRQ,
  611. },
  612. };
  613. static struct platform_device at91sam9g45_spi0_device = {
  614. .name = "atmel_spi",
  615. .id = 0,
  616. .dev = {
  617. .dma_mask = &spi_dmamask,
  618. .coherent_dma_mask = DMA_BIT_MASK(32),
  619. },
  620. .resource = spi0_resources,
  621. .num_resources = ARRAY_SIZE(spi0_resources),
  622. };
  623. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PB18, AT91_PIN_PB19, AT91_PIN_PD27 };
  624. static struct resource spi1_resources[] = {
  625. [0] = {
  626. .start = AT91SAM9G45_BASE_SPI1,
  627. .end = AT91SAM9G45_BASE_SPI1 + SZ_16K - 1,
  628. .flags = IORESOURCE_MEM,
  629. },
  630. [1] = {
  631. .start = AT91SAM9G45_ID_SPI1,
  632. .end = AT91SAM9G45_ID_SPI1,
  633. .flags = IORESOURCE_IRQ,
  634. },
  635. };
  636. static struct platform_device at91sam9g45_spi1_device = {
  637. .name = "atmel_spi",
  638. .id = 1,
  639. .dev = {
  640. .dma_mask = &spi_dmamask,
  641. .coherent_dma_mask = DMA_BIT_MASK(32),
  642. },
  643. .resource = spi1_resources,
  644. .num_resources = ARRAY_SIZE(spi1_resources),
  645. };
  646. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB17, AT91_PIN_PD28, AT91_PIN_PD18, AT91_PIN_PD19 };
  647. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  648. {
  649. int i;
  650. unsigned long cs_pin;
  651. short enable_spi0 = 0;
  652. short enable_spi1 = 0;
  653. /* Choose SPI chip-selects */
  654. for (i = 0; i < nr_devices; i++) {
  655. if (devices[i].controller_data)
  656. cs_pin = (unsigned long) devices[i].controller_data;
  657. else if (devices[i].bus_num == 0)
  658. cs_pin = spi0_standard_cs[devices[i].chip_select];
  659. else
  660. cs_pin = spi1_standard_cs[devices[i].chip_select];
  661. if (devices[i].bus_num == 0)
  662. enable_spi0 = 1;
  663. else
  664. enable_spi1 = 1;
  665. /* enable chip-select pin */
  666. at91_set_gpio_output(cs_pin, 1);
  667. /* pass chip-select pin to driver */
  668. devices[i].controller_data = (void *) cs_pin;
  669. }
  670. spi_register_board_info(devices, nr_devices);
  671. /* Configure SPI bus(es) */
  672. if (enable_spi0) {
  673. at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
  674. at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
  675. at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
  676. platform_device_register(&at91sam9g45_spi0_device);
  677. }
  678. if (enable_spi1) {
  679. at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
  680. at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
  681. at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
  682. platform_device_register(&at91sam9g45_spi1_device);
  683. }
  684. }
  685. #else
  686. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  687. #endif
  688. /* --------------------------------------------------------------------
  689. * AC97
  690. * -------------------------------------------------------------------- */
  691. #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
  692. static u64 ac97_dmamask = DMA_BIT_MASK(32);
  693. static struct ac97c_platform_data ac97_data;
  694. static struct resource ac97_resources[] = {
  695. [0] = {
  696. .start = AT91SAM9G45_BASE_AC97C,
  697. .end = AT91SAM9G45_BASE_AC97C + SZ_16K - 1,
  698. .flags = IORESOURCE_MEM,
  699. },
  700. [1] = {
  701. .start = AT91SAM9G45_ID_AC97C,
  702. .end = AT91SAM9G45_ID_AC97C,
  703. .flags = IORESOURCE_IRQ,
  704. },
  705. };
  706. static struct platform_device at91sam9g45_ac97_device = {
  707. .name = "atmel_ac97c",
  708. .id = 0,
  709. .dev = {
  710. .dma_mask = &ac97_dmamask,
  711. .coherent_dma_mask = DMA_BIT_MASK(32),
  712. .platform_data = &ac97_data,
  713. },
  714. .resource = ac97_resources,
  715. .num_resources = ARRAY_SIZE(ac97_resources),
  716. };
  717. void __init at91_add_device_ac97(struct ac97c_platform_data *data)
  718. {
  719. if (!data)
  720. return;
  721. at91_set_A_periph(AT91_PIN_PD8, 0); /* AC97FS */
  722. at91_set_A_periph(AT91_PIN_PD9, 0); /* AC97CK */
  723. at91_set_A_periph(AT91_PIN_PD7, 0); /* AC97TX */
  724. at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
  725. /* reset */
  726. if (gpio_is_valid(data->reset_pin))
  727. at91_set_gpio_output(data->reset_pin, 0);
  728. ac97_data = *data;
  729. platform_device_register(&at91sam9g45_ac97_device);
  730. }
  731. #else
  732. void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
  733. #endif
  734. /* --------------------------------------------------------------------
  735. * Image Sensor Interface
  736. * -------------------------------------------------------------------- */
  737. #if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE)
  738. static u64 isi_dmamask = DMA_BIT_MASK(32);
  739. static struct isi_platform_data isi_data;
  740. struct resource isi_resources[] = {
  741. [0] = {
  742. .start = AT91SAM9G45_BASE_ISI,
  743. .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1,
  744. .flags = IORESOURCE_MEM,
  745. },
  746. [1] = {
  747. .start = AT91SAM9G45_ID_ISI,
  748. .end = AT91SAM9G45_ID_ISI,
  749. .flags = IORESOURCE_IRQ,
  750. },
  751. };
  752. static struct platform_device at91sam9g45_isi_device = {
  753. .name = "atmel_isi",
  754. .id = 0,
  755. .dev = {
  756. .dma_mask = &isi_dmamask,
  757. .coherent_dma_mask = DMA_BIT_MASK(32),
  758. .platform_data = &isi_data,
  759. },
  760. .resource = isi_resources,
  761. .num_resources = ARRAY_SIZE(isi_resources),
  762. };
  763. static struct clk_lookup isi_mck_lookups[] = {
  764. CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL),
  765. };
  766. void __init at91_add_device_isi(struct isi_platform_data *data,
  767. bool use_pck_as_mck)
  768. {
  769. struct clk *pck;
  770. struct clk *parent;
  771. if (!data)
  772. return;
  773. isi_data = *data;
  774. at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */
  775. at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */
  776. at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */
  777. at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */
  778. at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */
  779. at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */
  780. at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */
  781. at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */
  782. at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */
  783. at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */
  784. at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */
  785. at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */
  786. at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */
  787. at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */
  788. at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */
  789. platform_device_register(&at91sam9g45_isi_device);
  790. if (use_pck_as_mck) {
  791. at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */
  792. pck = clk_get(NULL, "pck1");
  793. parent = clk_get(NULL, "plla");
  794. BUG_ON(IS_ERR(pck) || IS_ERR(parent));
  795. if (clk_set_parent(pck, parent)) {
  796. pr_err("Failed to set PCK's parent\n");
  797. } else {
  798. /* Register PCK as ISI_MCK */
  799. isi_mck_lookups[0].clk = pck;
  800. clkdev_add_table(isi_mck_lookups,
  801. ARRAY_SIZE(isi_mck_lookups));
  802. }
  803. clk_put(pck);
  804. clk_put(parent);
  805. }
  806. }
  807. #else
  808. void __init at91_add_device_isi(struct isi_platform_data *data,
  809. bool use_pck_as_mck) {}
  810. #endif
  811. /* --------------------------------------------------------------------
  812. * LCD Controller
  813. * -------------------------------------------------------------------- */
  814. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  815. static u64 lcdc_dmamask = DMA_BIT_MASK(32);
  816. static struct atmel_lcdfb_info lcdc_data;
  817. static struct resource lcdc_resources[] = {
  818. [0] = {
  819. .start = AT91SAM9G45_LCDC_BASE,
  820. .end = AT91SAM9G45_LCDC_BASE + SZ_4K - 1,
  821. .flags = IORESOURCE_MEM,
  822. },
  823. [1] = {
  824. .start = AT91SAM9G45_ID_LCDC,
  825. .end = AT91SAM9G45_ID_LCDC,
  826. .flags = IORESOURCE_IRQ,
  827. },
  828. };
  829. static struct platform_device at91_lcdc_device = {
  830. .name = "atmel_lcdfb",
  831. .id = 0,
  832. .dev = {
  833. .dma_mask = &lcdc_dmamask,
  834. .coherent_dma_mask = DMA_BIT_MASK(32),
  835. .platform_data = &lcdc_data,
  836. },
  837. .resource = lcdc_resources,
  838. .num_resources = ARRAY_SIZE(lcdc_resources),
  839. };
  840. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  841. {
  842. if (!data)
  843. return;
  844. at91_set_A_periph(AT91_PIN_PE0, 0); /* LCDDPWR */
  845. at91_set_A_periph(AT91_PIN_PE2, 0); /* LCDCC */
  846. at91_set_A_periph(AT91_PIN_PE3, 0); /* LCDVSYNC */
  847. at91_set_A_periph(AT91_PIN_PE4, 0); /* LCDHSYNC */
  848. at91_set_A_periph(AT91_PIN_PE5, 0); /* LCDDOTCK */
  849. at91_set_A_periph(AT91_PIN_PE6, 0); /* LCDDEN */
  850. at91_set_A_periph(AT91_PIN_PE7, 0); /* LCDD0 */
  851. at91_set_A_periph(AT91_PIN_PE8, 0); /* LCDD1 */
  852. at91_set_A_periph(AT91_PIN_PE9, 0); /* LCDD2 */
  853. at91_set_A_periph(AT91_PIN_PE10, 0); /* LCDD3 */
  854. at91_set_A_periph(AT91_PIN_PE11, 0); /* LCDD4 */
  855. at91_set_A_periph(AT91_PIN_PE12, 0); /* LCDD5 */
  856. at91_set_A_periph(AT91_PIN_PE13, 0); /* LCDD6 */
  857. at91_set_A_periph(AT91_PIN_PE14, 0); /* LCDD7 */
  858. at91_set_A_periph(AT91_PIN_PE15, 0); /* LCDD8 */
  859. at91_set_A_periph(AT91_PIN_PE16, 0); /* LCDD9 */
  860. at91_set_A_periph(AT91_PIN_PE17, 0); /* LCDD10 */
  861. at91_set_A_periph(AT91_PIN_PE18, 0); /* LCDD11 */
  862. at91_set_A_periph(AT91_PIN_PE19, 0); /* LCDD12 */
  863. at91_set_A_periph(AT91_PIN_PE20, 0); /* LCDD13 */
  864. at91_set_A_periph(AT91_PIN_PE21, 0); /* LCDD14 */
  865. at91_set_A_periph(AT91_PIN_PE22, 0); /* LCDD15 */
  866. at91_set_A_periph(AT91_PIN_PE23, 0); /* LCDD16 */
  867. at91_set_A_periph(AT91_PIN_PE24, 0); /* LCDD17 */
  868. at91_set_A_periph(AT91_PIN_PE25, 0); /* LCDD18 */
  869. at91_set_A_periph(AT91_PIN_PE26, 0); /* LCDD19 */
  870. at91_set_A_periph(AT91_PIN_PE27, 0); /* LCDD20 */
  871. at91_set_A_periph(AT91_PIN_PE28, 0); /* LCDD21 */
  872. at91_set_A_periph(AT91_PIN_PE29, 0); /* LCDD22 */
  873. at91_set_A_periph(AT91_PIN_PE30, 0); /* LCDD23 */
  874. lcdc_data = *data;
  875. platform_device_register(&at91_lcdc_device);
  876. }
  877. #else
  878. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  879. #endif
  880. /* --------------------------------------------------------------------
  881. * Timer/Counter block
  882. * -------------------------------------------------------------------- */
  883. #ifdef CONFIG_ATMEL_TCLIB
  884. static struct resource tcb0_resources[] = {
  885. [0] = {
  886. .start = AT91SAM9G45_BASE_TCB0,
  887. .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1,
  888. .flags = IORESOURCE_MEM,
  889. },
  890. [1] = {
  891. .start = AT91SAM9G45_ID_TCB,
  892. .end = AT91SAM9G45_ID_TCB,
  893. .flags = IORESOURCE_IRQ,
  894. },
  895. };
  896. static struct platform_device at91sam9g45_tcb0_device = {
  897. .name = "atmel_tcb",
  898. .id = 0,
  899. .resource = tcb0_resources,
  900. .num_resources = ARRAY_SIZE(tcb0_resources),
  901. };
  902. /* TCB1 begins with TC3 */
  903. static struct resource tcb1_resources[] = {
  904. [0] = {
  905. .start = AT91SAM9G45_BASE_TCB1,
  906. .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1,
  907. .flags = IORESOURCE_MEM,
  908. },
  909. [1] = {
  910. .start = AT91SAM9G45_ID_TCB,
  911. .end = AT91SAM9G45_ID_TCB,
  912. .flags = IORESOURCE_IRQ,
  913. },
  914. };
  915. static struct platform_device at91sam9g45_tcb1_device = {
  916. .name = "atmel_tcb",
  917. .id = 1,
  918. .resource = tcb1_resources,
  919. .num_resources = ARRAY_SIZE(tcb1_resources),
  920. };
  921. static void __init at91_add_device_tc(void)
  922. {
  923. platform_device_register(&at91sam9g45_tcb0_device);
  924. platform_device_register(&at91sam9g45_tcb1_device);
  925. }
  926. #else
  927. static void __init at91_add_device_tc(void) { }
  928. #endif
  929. /* --------------------------------------------------------------------
  930. * RTC
  931. * -------------------------------------------------------------------- */
  932. #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
  933. static struct resource rtc_resources[] = {
  934. [0] = {
  935. .start = AT91SAM9G45_BASE_RTC,
  936. .end = AT91SAM9G45_BASE_RTC + SZ_256 - 1,
  937. .flags = IORESOURCE_MEM,
  938. },
  939. [1] = {
  940. .start = AT91_ID_SYS,
  941. .end = AT91_ID_SYS,
  942. .flags = IORESOURCE_IRQ,
  943. },
  944. };
  945. static struct platform_device at91sam9g45_rtc_device = {
  946. .name = "at91_rtc",
  947. .id = -1,
  948. .resource = rtc_resources,
  949. .num_resources = ARRAY_SIZE(rtc_resources),
  950. };
  951. static void __init at91_add_device_rtc(void)
  952. {
  953. platform_device_register(&at91sam9g45_rtc_device);
  954. }
  955. #else
  956. static void __init at91_add_device_rtc(void) {}
  957. #endif
  958. /* --------------------------------------------------------------------
  959. * Touchscreen
  960. * -------------------------------------------------------------------- */
  961. #if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
  962. static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
  963. static struct at91_tsadcc_data tsadcc_data;
  964. static struct resource tsadcc_resources[] = {
  965. [0] = {
  966. .start = AT91SAM9G45_BASE_TSC,
  967. .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
  968. .flags = IORESOURCE_MEM,
  969. },
  970. [1] = {
  971. .start = AT91SAM9G45_ID_TSC,
  972. .end = AT91SAM9G45_ID_TSC,
  973. .flags = IORESOURCE_IRQ,
  974. }
  975. };
  976. static struct platform_device at91sam9g45_tsadcc_device = {
  977. .name = "atmel_tsadcc",
  978. .id = -1,
  979. .dev = {
  980. .dma_mask = &tsadcc_dmamask,
  981. .coherent_dma_mask = DMA_BIT_MASK(32),
  982. .platform_data = &tsadcc_data,
  983. },
  984. .resource = tsadcc_resources,
  985. .num_resources = ARRAY_SIZE(tsadcc_resources),
  986. };
  987. void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
  988. {
  989. if (!data)
  990. return;
  991. at91_set_gpio_input(AT91_PIN_PD20, 0); /* AD0_XR */
  992. at91_set_gpio_input(AT91_PIN_PD21, 0); /* AD1_XL */
  993. at91_set_gpio_input(AT91_PIN_PD22, 0); /* AD2_YT */
  994. at91_set_gpio_input(AT91_PIN_PD23, 0); /* AD3_TB */
  995. tsadcc_data = *data;
  996. platform_device_register(&at91sam9g45_tsadcc_device);
  997. }
  998. #else
  999. void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
  1000. #endif
  1001. /* --------------------------------------------------------------------
  1002. * RTT
  1003. * -------------------------------------------------------------------- */
  1004. static struct resource rtt_resources[] = {
  1005. {
  1006. .start = AT91SAM9G45_BASE_RTT,
  1007. .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1,
  1008. .flags = IORESOURCE_MEM,
  1009. }, {
  1010. .flags = IORESOURCE_MEM,
  1011. }
  1012. };
  1013. static struct platform_device at91sam9g45_rtt_device = {
  1014. .name = "at91_rtt",
  1015. .id = 0,
  1016. .resource = rtt_resources,
  1017. };
  1018. #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
  1019. static void __init at91_add_device_rtt_rtc(void)
  1020. {
  1021. at91sam9g45_rtt_device.name = "rtc-at91sam9";
  1022. /*
  1023. * The second resource is needed:
  1024. * GPBR will serve as the storage for RTC time offset
  1025. */
  1026. at91sam9g45_rtt_device.num_resources = 2;
  1027. rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
  1028. 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
  1029. rtt_resources[1].end = rtt_resources[1].start + 3;
  1030. }
  1031. #else
  1032. static void __init at91_add_device_rtt_rtc(void)
  1033. {
  1034. /* Only one resource is needed: RTT not used as RTC */
  1035. at91sam9g45_rtt_device.num_resources = 1;
  1036. }
  1037. #endif
  1038. static void __init at91_add_device_rtt(void)
  1039. {
  1040. at91_add_device_rtt_rtc();
  1041. platform_device_register(&at91sam9g45_rtt_device);
  1042. }
  1043. /* --------------------------------------------------------------------
  1044. * TRNG
  1045. * -------------------------------------------------------------------- */
  1046. #if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE)
  1047. static struct resource trng_resources[] = {
  1048. {
  1049. .start = AT91SAM9G45_BASE_TRNG,
  1050. .end = AT91SAM9G45_BASE_TRNG + SZ_16K - 1,
  1051. .flags = IORESOURCE_MEM,
  1052. },
  1053. };
  1054. static struct platform_device at91sam9g45_trng_device = {
  1055. .name = "atmel-trng",
  1056. .id = -1,
  1057. .resource = trng_resources,
  1058. .num_resources = ARRAY_SIZE(trng_resources),
  1059. };
  1060. static void __init at91_add_device_trng(void)
  1061. {
  1062. platform_device_register(&at91sam9g45_trng_device);
  1063. }
  1064. #else
  1065. static void __init at91_add_device_trng(void) {}
  1066. #endif
  1067. /* --------------------------------------------------------------------
  1068. * Watchdog
  1069. * -------------------------------------------------------------------- */
  1070. #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
  1071. static struct resource wdt_resources[] = {
  1072. {
  1073. .start = AT91SAM9G45_BASE_WDT,
  1074. .end = AT91SAM9G45_BASE_WDT + SZ_16 - 1,
  1075. .flags = IORESOURCE_MEM,
  1076. }
  1077. };
  1078. static struct platform_device at91sam9g45_wdt_device = {
  1079. .name = "at91_wdt",
  1080. .id = -1,
  1081. .resource = wdt_resources,
  1082. .num_resources = ARRAY_SIZE(wdt_resources),
  1083. };
  1084. static void __init at91_add_device_watchdog(void)
  1085. {
  1086. platform_device_register(&at91sam9g45_wdt_device);
  1087. }
  1088. #else
  1089. static void __init at91_add_device_watchdog(void) {}
  1090. #endif
  1091. /* --------------------------------------------------------------------
  1092. * PWM
  1093. * --------------------------------------------------------------------*/
  1094. #if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE)
  1095. static u32 pwm_mask;
  1096. static struct resource pwm_resources[] = {
  1097. [0] = {
  1098. .start = AT91SAM9G45_BASE_PWMC,
  1099. .end = AT91SAM9G45_BASE_PWMC + SZ_16K - 1,
  1100. .flags = IORESOURCE_MEM,
  1101. },
  1102. [1] = {
  1103. .start = AT91SAM9G45_ID_PWMC,
  1104. .end = AT91SAM9G45_ID_PWMC,
  1105. .flags = IORESOURCE_IRQ,
  1106. },
  1107. };
  1108. static struct platform_device at91sam9g45_pwm0_device = {
  1109. .name = "atmel_pwm",
  1110. .id = -1,
  1111. .dev = {
  1112. .platform_data = &pwm_mask,
  1113. },
  1114. .resource = pwm_resources,
  1115. .num_resources = ARRAY_SIZE(pwm_resources),
  1116. };
  1117. void __init at91_add_device_pwm(u32 mask)
  1118. {
  1119. if (mask & (1 << AT91_PWM0))
  1120. at91_set_B_periph(AT91_PIN_PD24, 1); /* enable PWM0 */
  1121. if (mask & (1 << AT91_PWM1))
  1122. at91_set_B_periph(AT91_PIN_PD31, 1); /* enable PWM1 */
  1123. if (mask & (1 << AT91_PWM2))
  1124. at91_set_B_periph(AT91_PIN_PD26, 1); /* enable PWM2 */
  1125. if (mask & (1 << AT91_PWM3))
  1126. at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */
  1127. pwm_mask = mask;
  1128. platform_device_register(&at91sam9g45_pwm0_device);
  1129. }
  1130. #else
  1131. void __init at91_add_device_pwm(u32 mask) {}
  1132. #endif
  1133. /* --------------------------------------------------------------------
  1134. * SSC -- Synchronous Serial Controller
  1135. * -------------------------------------------------------------------- */
  1136. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  1137. static u64 ssc0_dmamask = DMA_BIT_MASK(32);
  1138. static struct resource ssc0_resources[] = {
  1139. [0] = {
  1140. .start = AT91SAM9G45_BASE_SSC0,
  1141. .end = AT91SAM9G45_BASE_SSC0 + SZ_16K - 1,
  1142. .flags = IORESOURCE_MEM,
  1143. },
  1144. [1] = {
  1145. .start = AT91SAM9G45_ID_SSC0,
  1146. .end = AT91SAM9G45_ID_SSC0,
  1147. .flags = IORESOURCE_IRQ,
  1148. },
  1149. };
  1150. static struct platform_device at91sam9g45_ssc0_device = {
  1151. .name = "ssc",
  1152. .id = 0,
  1153. .dev = {
  1154. .dma_mask = &ssc0_dmamask,
  1155. .coherent_dma_mask = DMA_BIT_MASK(32),
  1156. },
  1157. .resource = ssc0_resources,
  1158. .num_resources = ARRAY_SIZE(ssc0_resources),
  1159. };
  1160. static inline void configure_ssc0_pins(unsigned pins)
  1161. {
  1162. if (pins & ATMEL_SSC_TF)
  1163. at91_set_A_periph(AT91_PIN_PD1, 1);
  1164. if (pins & ATMEL_SSC_TK)
  1165. at91_set_A_periph(AT91_PIN_PD0, 1);
  1166. if (pins & ATMEL_SSC_TD)
  1167. at91_set_A_periph(AT91_PIN_PD2, 1);
  1168. if (pins & ATMEL_SSC_RD)
  1169. at91_set_A_periph(AT91_PIN_PD3, 1);
  1170. if (pins & ATMEL_SSC_RK)
  1171. at91_set_A_periph(AT91_PIN_PD4, 1);
  1172. if (pins & ATMEL_SSC_RF)
  1173. at91_set_A_periph(AT91_PIN_PD5, 1);
  1174. }
  1175. static u64 ssc1_dmamask = DMA_BIT_MASK(32);
  1176. static struct resource ssc1_resources[] = {
  1177. [0] = {
  1178. .start = AT91SAM9G45_BASE_SSC1,
  1179. .end = AT91SAM9G45_BASE_SSC1 + SZ_16K - 1,
  1180. .flags = IORESOURCE_MEM,
  1181. },
  1182. [1] = {
  1183. .start = AT91SAM9G45_ID_SSC1,
  1184. .end = AT91SAM9G45_ID_SSC1,
  1185. .flags = IORESOURCE_IRQ,
  1186. },
  1187. };
  1188. static struct platform_device at91sam9g45_ssc1_device = {
  1189. .name = "ssc",
  1190. .id = 1,
  1191. .dev = {
  1192. .dma_mask = &ssc1_dmamask,
  1193. .coherent_dma_mask = DMA_BIT_MASK(32),
  1194. },
  1195. .resource = ssc1_resources,
  1196. .num_resources = ARRAY_SIZE(ssc1_resources),
  1197. };
  1198. static inline void configure_ssc1_pins(unsigned pins)
  1199. {
  1200. if (pins & ATMEL_SSC_TF)
  1201. at91_set_A_periph(AT91_PIN_PD14, 1);
  1202. if (pins & ATMEL_SSC_TK)
  1203. at91_set_A_periph(AT91_PIN_PD12, 1);
  1204. if (pins & ATMEL_SSC_TD)
  1205. at91_set_A_periph(AT91_PIN_PD10, 1);
  1206. if (pins & ATMEL_SSC_RD)
  1207. at91_set_A_periph(AT91_PIN_PD11, 1);
  1208. if (pins & ATMEL_SSC_RK)
  1209. at91_set_A_periph(AT91_PIN_PD13, 1);
  1210. if (pins & ATMEL_SSC_RF)
  1211. at91_set_A_periph(AT91_PIN_PD15, 1);
  1212. }
  1213. /*
  1214. * SSC controllers are accessed through library code, instead of any
  1215. * kind of all-singing/all-dancing driver. For example one could be
  1216. * used by a particular I2S audio codec's driver, while another one
  1217. * on the same system might be used by a custom data capture driver.
  1218. */
  1219. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  1220. {
  1221. struct platform_device *pdev;
  1222. /*
  1223. * NOTE: caller is responsible for passing information matching
  1224. * "pins" to whatever will be using each particular controller.
  1225. */
  1226. switch (id) {
  1227. case AT91SAM9G45_ID_SSC0:
  1228. pdev = &at91sam9g45_ssc0_device;
  1229. configure_ssc0_pins(pins);
  1230. break;
  1231. case AT91SAM9G45_ID_SSC1:
  1232. pdev = &at91sam9g45_ssc1_device;
  1233. configure_ssc1_pins(pins);
  1234. break;
  1235. default:
  1236. return;
  1237. }
  1238. platform_device_register(pdev);
  1239. }
  1240. #else
  1241. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  1242. #endif
  1243. /* --------------------------------------------------------------------
  1244. * UART
  1245. * -------------------------------------------------------------------- */
  1246. #if defined(CONFIG_SERIAL_ATMEL)
  1247. static struct resource dbgu_resources[] = {
  1248. [0] = {
  1249. .start = AT91SAM9G45_BASE_DBGU,
  1250. .end = AT91SAM9G45_BASE_DBGU + SZ_512 - 1,
  1251. .flags = IORESOURCE_MEM,
  1252. },
  1253. [1] = {
  1254. .start = AT91_ID_SYS,
  1255. .end = AT91_ID_SYS,
  1256. .flags = IORESOURCE_IRQ,
  1257. },
  1258. };
  1259. static struct atmel_uart_data dbgu_data = {
  1260. .use_dma_tx = 0,
  1261. .use_dma_rx = 0,
  1262. };
  1263. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  1264. static struct platform_device at91sam9g45_dbgu_device = {
  1265. .name = "atmel_usart",
  1266. .id = 0,
  1267. .dev = {
  1268. .dma_mask = &dbgu_dmamask,
  1269. .coherent_dma_mask = DMA_BIT_MASK(32),
  1270. .platform_data = &dbgu_data,
  1271. },
  1272. .resource = dbgu_resources,
  1273. .num_resources = ARRAY_SIZE(dbgu_resources),
  1274. };
  1275. static inline void configure_dbgu_pins(void)
  1276. {
  1277. at91_set_A_periph(AT91_PIN_PB12, 0); /* DRXD */
  1278. at91_set_A_periph(AT91_PIN_PB13, 1); /* DTXD */
  1279. }
  1280. static struct resource uart0_resources[] = {
  1281. [0] = {
  1282. .start = AT91SAM9G45_BASE_US0,
  1283. .end = AT91SAM9G45_BASE_US0 + SZ_16K - 1,
  1284. .flags = IORESOURCE_MEM,
  1285. },
  1286. [1] = {
  1287. .start = AT91SAM9G45_ID_US0,
  1288. .end = AT91SAM9G45_ID_US0,
  1289. .flags = IORESOURCE_IRQ,
  1290. },
  1291. };
  1292. static struct atmel_uart_data uart0_data = {
  1293. .use_dma_tx = 1,
  1294. .use_dma_rx = 1,
  1295. };
  1296. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  1297. static struct platform_device at91sam9g45_uart0_device = {
  1298. .name = "atmel_usart",
  1299. .id = 1,
  1300. .dev = {
  1301. .dma_mask = &uart0_dmamask,
  1302. .coherent_dma_mask = DMA_BIT_MASK(32),
  1303. .platform_data = &uart0_data,
  1304. },
  1305. .resource = uart0_resources,
  1306. .num_resources = ARRAY_SIZE(uart0_resources),
  1307. };
  1308. static inline void configure_usart0_pins(unsigned pins)
  1309. {
  1310. at91_set_A_periph(AT91_PIN_PB19, 1); /* TXD0 */
  1311. at91_set_A_periph(AT91_PIN_PB18, 0); /* RXD0 */
  1312. if (pins & ATMEL_UART_RTS)
  1313. at91_set_B_periph(AT91_PIN_PB17, 0); /* RTS0 */
  1314. if (pins & ATMEL_UART_CTS)
  1315. at91_set_B_periph(AT91_PIN_PB15, 0); /* CTS0 */
  1316. }
  1317. static struct resource uart1_resources[] = {
  1318. [0] = {
  1319. .start = AT91SAM9G45_BASE_US1,
  1320. .end = AT91SAM9G45_BASE_US1 + SZ_16K - 1,
  1321. .flags = IORESOURCE_MEM,
  1322. },
  1323. [1] = {
  1324. .start = AT91SAM9G45_ID_US1,
  1325. .end = AT91SAM9G45_ID_US1,
  1326. .flags = IORESOURCE_IRQ,
  1327. },
  1328. };
  1329. static struct atmel_uart_data uart1_data = {
  1330. .use_dma_tx = 1,
  1331. .use_dma_rx = 1,
  1332. };
  1333. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  1334. static struct platform_device at91sam9g45_uart1_device = {
  1335. .name = "atmel_usart",
  1336. .id = 2,
  1337. .dev = {
  1338. .dma_mask = &uart1_dmamask,
  1339. .coherent_dma_mask = DMA_BIT_MASK(32),
  1340. .platform_data = &uart1_data,
  1341. },
  1342. .resource = uart1_resources,
  1343. .num_resources = ARRAY_SIZE(uart1_resources),
  1344. };
  1345. static inline void configure_usart1_pins(unsigned pins)
  1346. {
  1347. at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD1 */
  1348. at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD1 */
  1349. if (pins & ATMEL_UART_RTS)
  1350. at91_set_A_periph(AT91_PIN_PD16, 0); /* RTS1 */
  1351. if (pins & ATMEL_UART_CTS)
  1352. at91_set_A_periph(AT91_PIN_PD17, 0); /* CTS1 */
  1353. }
  1354. static struct resource uart2_resources[] = {
  1355. [0] = {
  1356. .start = AT91SAM9G45_BASE_US2,
  1357. .end = AT91SAM9G45_BASE_US2 + SZ_16K - 1,
  1358. .flags = IORESOURCE_MEM,
  1359. },
  1360. [1] = {
  1361. .start = AT91SAM9G45_ID_US2,
  1362. .end = AT91SAM9G45_ID_US2,
  1363. .flags = IORESOURCE_IRQ,
  1364. },
  1365. };
  1366. static struct atmel_uart_data uart2_data = {
  1367. .use_dma_tx = 1,
  1368. .use_dma_rx = 1,
  1369. };
  1370. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  1371. static struct platform_device at91sam9g45_uart2_device = {
  1372. .name = "atmel_usart",
  1373. .id = 3,
  1374. .dev = {
  1375. .dma_mask = &uart2_dmamask,
  1376. .coherent_dma_mask = DMA_BIT_MASK(32),
  1377. .platform_data = &uart2_data,
  1378. },
  1379. .resource = uart2_resources,
  1380. .num_resources = ARRAY_SIZE(uart2_resources),
  1381. };
  1382. static inline void configure_usart2_pins(unsigned pins)
  1383. {
  1384. at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD2 */
  1385. at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD2 */
  1386. if (pins & ATMEL_UART_RTS)
  1387. at91_set_B_periph(AT91_PIN_PC9, 0); /* RTS2 */
  1388. if (pins & ATMEL_UART_CTS)
  1389. at91_set_B_periph(AT91_PIN_PC11, 0); /* CTS2 */
  1390. }
  1391. static struct resource uart3_resources[] = {
  1392. [0] = {
  1393. .start = AT91SAM9G45_BASE_US3,
  1394. .end = AT91SAM9G45_BASE_US3 + SZ_16K - 1,
  1395. .flags = IORESOURCE_MEM,
  1396. },
  1397. [1] = {
  1398. .start = AT91SAM9G45_ID_US3,
  1399. .end = AT91SAM9G45_ID_US3,
  1400. .flags = IORESOURCE_IRQ,
  1401. },
  1402. };
  1403. static struct atmel_uart_data uart3_data = {
  1404. .use_dma_tx = 1,
  1405. .use_dma_rx = 1,
  1406. };
  1407. static u64 uart3_dmamask = DMA_BIT_MASK(32);
  1408. static struct platform_device at91sam9g45_uart3_device = {
  1409. .name = "atmel_usart",
  1410. .id = 4,
  1411. .dev = {
  1412. .dma_mask = &uart3_dmamask,
  1413. .coherent_dma_mask = DMA_BIT_MASK(32),
  1414. .platform_data = &uart3_data,
  1415. },
  1416. .resource = uart3_resources,
  1417. .num_resources = ARRAY_SIZE(uart3_resources),
  1418. };
  1419. static inline void configure_usart3_pins(unsigned pins)
  1420. {
  1421. at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD3 */
  1422. at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD3 */
  1423. if (pins & ATMEL_UART_RTS)
  1424. at91_set_B_periph(AT91_PIN_PA23, 0); /* RTS3 */
  1425. if (pins & ATMEL_UART_CTS)
  1426. at91_set_B_periph(AT91_PIN_PA24, 0); /* CTS3 */
  1427. }
  1428. static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  1429. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  1430. {
  1431. struct platform_device *pdev;
  1432. struct atmel_uart_data *pdata;
  1433. switch (id) {
  1434. case 0: /* DBGU */
  1435. pdev = &at91sam9g45_dbgu_device;
  1436. configure_dbgu_pins();
  1437. break;
  1438. case AT91SAM9G45_ID_US0:
  1439. pdev = &at91sam9g45_uart0_device;
  1440. configure_usart0_pins(pins);
  1441. break;
  1442. case AT91SAM9G45_ID_US1:
  1443. pdev = &at91sam9g45_uart1_device;
  1444. configure_usart1_pins(pins);
  1445. break;
  1446. case AT91SAM9G45_ID_US2:
  1447. pdev = &at91sam9g45_uart2_device;
  1448. configure_usart2_pins(pins);
  1449. break;
  1450. case AT91SAM9G45_ID_US3:
  1451. pdev = &at91sam9g45_uart3_device;
  1452. configure_usart3_pins(pins);
  1453. break;
  1454. default:
  1455. return;
  1456. }
  1457. pdata = pdev->dev.platform_data;
  1458. pdata->num = portnr; /* update to mapped ID */
  1459. if (portnr < ATMEL_MAX_UART)
  1460. at91_uarts[portnr] = pdev;
  1461. }
  1462. void __init at91_set_serial_console(unsigned portnr)
  1463. {
  1464. if (portnr < ATMEL_MAX_UART) {
  1465. atmel_default_console_device = at91_uarts[portnr];
  1466. at91sam9g45_set_console_clock(at91_uarts[portnr]->id);
  1467. }
  1468. }
  1469. void __init at91_add_device_serial(void)
  1470. {
  1471. int i;
  1472. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1473. if (at91_uarts[i])
  1474. platform_device_register(at91_uarts[i]);
  1475. }
  1476. if (!atmel_default_console_device)
  1477. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1478. }
  1479. #else
  1480. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1481. void __init at91_set_serial_console(unsigned portnr) {}
  1482. void __init at91_add_device_serial(void) {}
  1483. #endif
  1484. /* -------------------------------------------------------------------- */
  1485. /*
  1486. * These devices are always present and don't need any board-specific
  1487. * setup.
  1488. */
  1489. static int __init at91_add_standard_devices(void)
  1490. {
  1491. at91_add_device_hdmac();
  1492. at91_add_device_rtc();
  1493. at91_add_device_rtt();
  1494. at91_add_device_trng();
  1495. at91_add_device_watchdog();
  1496. at91_add_device_tc();
  1497. return 0;
  1498. }
  1499. arch_initcall(at91_add_standard_devices);