at91sam9g45_devices.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781
  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->cfg = ATC_FIFOCFG_HALFFIFO
  375. | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW;
  376. if (mmc_id == 0) /* MCI0 */
  377. atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)
  378. | ATC_DST_PER(AT_DMA_ID_MCI0);
  379. else /* MCI1 */
  380. atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI1)
  381. | ATC_DST_PER(AT_DMA_ID_MCI1);
  382. data->dma_slave = alt_atslave;
  383. }
  384. #endif
  385. /* input/irq */
  386. if (gpio_is_valid(data->slot[0].detect_pin)) {
  387. at91_set_gpio_input(data->slot[0].detect_pin, 1);
  388. at91_set_deglitch(data->slot[0].detect_pin, 1);
  389. }
  390. if (gpio_is_valid(data->slot[0].wp_pin))
  391. at91_set_gpio_input(data->slot[0].wp_pin, 1);
  392. if (mmc_id == 0) { /* MCI0 */
  393. /* CLK */
  394. at91_set_A_periph(AT91_PIN_PA0, 0);
  395. /* CMD */
  396. at91_set_A_periph(AT91_PIN_PA1, 1);
  397. /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
  398. at91_set_A_periph(AT91_PIN_PA2, 1);
  399. if (data->slot[0].bus_width == 4) {
  400. at91_set_A_periph(AT91_PIN_PA3, 1);
  401. at91_set_A_periph(AT91_PIN_PA4, 1);
  402. at91_set_A_periph(AT91_PIN_PA5, 1);
  403. if (data->slot[0].bus_width == 8) {
  404. at91_set_A_periph(AT91_PIN_PA6, 1);
  405. at91_set_A_periph(AT91_PIN_PA7, 1);
  406. at91_set_A_periph(AT91_PIN_PA8, 1);
  407. at91_set_A_periph(AT91_PIN_PA9, 1);
  408. }
  409. }
  410. mmc0_data = *data;
  411. platform_device_register(&at91sam9g45_mmc0_device);
  412. } else { /* MCI1 */
  413. /* CLK */
  414. at91_set_A_periph(AT91_PIN_PA31, 0);
  415. /* CMD */
  416. at91_set_A_periph(AT91_PIN_PA22, 1);
  417. /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
  418. at91_set_A_periph(AT91_PIN_PA23, 1);
  419. if (data->slot[0].bus_width == 4) {
  420. at91_set_A_periph(AT91_PIN_PA24, 1);
  421. at91_set_A_periph(AT91_PIN_PA25, 1);
  422. at91_set_A_periph(AT91_PIN_PA26, 1);
  423. if (data->slot[0].bus_width == 8) {
  424. at91_set_A_periph(AT91_PIN_PA27, 1);
  425. at91_set_A_periph(AT91_PIN_PA28, 1);
  426. at91_set_A_periph(AT91_PIN_PA29, 1);
  427. at91_set_A_periph(AT91_PIN_PA30, 1);
  428. }
  429. }
  430. mmc1_data = *data;
  431. platform_device_register(&at91sam9g45_mmc1_device);
  432. }
  433. }
  434. #else
  435. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  436. #endif
  437. /* --------------------------------------------------------------------
  438. * NAND / SmartMedia
  439. * -------------------------------------------------------------------- */
  440. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  441. static struct atmel_nand_data nand_data;
  442. #define NAND_BASE AT91_CHIPSELECT_3
  443. static struct resource nand_resources[] = {
  444. [0] = {
  445. .start = NAND_BASE,
  446. .end = NAND_BASE + SZ_256M - 1,
  447. .flags = IORESOURCE_MEM,
  448. },
  449. [1] = {
  450. .start = AT91SAM9G45_BASE_ECC,
  451. .end = AT91SAM9G45_BASE_ECC + SZ_512 - 1,
  452. .flags = IORESOURCE_MEM,
  453. }
  454. };
  455. static struct platform_device at91sam9g45_nand_device = {
  456. .name = "atmel_nand",
  457. .id = -1,
  458. .dev = {
  459. .platform_data = &nand_data,
  460. },
  461. .resource = nand_resources,
  462. .num_resources = ARRAY_SIZE(nand_resources),
  463. };
  464. void __init at91_add_device_nand(struct atmel_nand_data *data)
  465. {
  466. unsigned long csa;
  467. if (!data)
  468. return;
  469. csa = at91_matrix_read(AT91_MATRIX_EBICSA);
  470. at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
  471. /* enable pin */
  472. if (gpio_is_valid(data->enable_pin))
  473. at91_set_gpio_output(data->enable_pin, 1);
  474. /* ready/busy pin */
  475. if (gpio_is_valid(data->rdy_pin))
  476. at91_set_gpio_input(data->rdy_pin, 1);
  477. /* card detect pin */
  478. if (gpio_is_valid(data->det_pin))
  479. at91_set_gpio_input(data->det_pin, 1);
  480. nand_data = *data;
  481. platform_device_register(&at91sam9g45_nand_device);
  482. }
  483. #else
  484. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  485. #endif
  486. /* --------------------------------------------------------------------
  487. * TWI (i2c)
  488. * -------------------------------------------------------------------- */
  489. /*
  490. * Prefer the GPIO code since the TWI controller isn't robust
  491. * (gets overruns and underruns under load) and can only issue
  492. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  493. */
  494. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  495. static struct i2c_gpio_platform_data pdata_i2c0 = {
  496. .sda_pin = AT91_PIN_PA20,
  497. .sda_is_open_drain = 1,
  498. .scl_pin = AT91_PIN_PA21,
  499. .scl_is_open_drain = 1,
  500. .udelay = 5, /* ~100 kHz */
  501. };
  502. static struct platform_device at91sam9g45_twi0_device = {
  503. .name = "i2c-gpio",
  504. .id = 0,
  505. .dev.platform_data = &pdata_i2c0,
  506. };
  507. static struct i2c_gpio_platform_data pdata_i2c1 = {
  508. .sda_pin = AT91_PIN_PB10,
  509. .sda_is_open_drain = 1,
  510. .scl_pin = AT91_PIN_PB11,
  511. .scl_is_open_drain = 1,
  512. .udelay = 5, /* ~100 kHz */
  513. };
  514. static struct platform_device at91sam9g45_twi1_device = {
  515. .name = "i2c-gpio",
  516. .id = 1,
  517. .dev.platform_data = &pdata_i2c1,
  518. };
  519. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
  520. {
  521. i2c_register_board_info(i2c_id, devices, nr_devices);
  522. if (i2c_id == 0) {
  523. at91_set_GPIO_periph(AT91_PIN_PA20, 1); /* TWD (SDA) */
  524. at91_set_multi_drive(AT91_PIN_PA20, 1);
  525. at91_set_GPIO_periph(AT91_PIN_PA21, 1); /* TWCK (SCL) */
  526. at91_set_multi_drive(AT91_PIN_PA21, 1);
  527. platform_device_register(&at91sam9g45_twi0_device);
  528. } else {
  529. at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* TWD (SDA) */
  530. at91_set_multi_drive(AT91_PIN_PB10, 1);
  531. at91_set_GPIO_periph(AT91_PIN_PB11, 1); /* TWCK (SCL) */
  532. at91_set_multi_drive(AT91_PIN_PB11, 1);
  533. platform_device_register(&at91sam9g45_twi1_device);
  534. }
  535. }
  536. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  537. static struct resource twi0_resources[] = {
  538. [0] = {
  539. .start = AT91SAM9G45_BASE_TWI0,
  540. .end = AT91SAM9G45_BASE_TWI0 + SZ_16K - 1,
  541. .flags = IORESOURCE_MEM,
  542. },
  543. [1] = {
  544. .start = AT91SAM9G45_ID_TWI0,
  545. .end = AT91SAM9G45_ID_TWI0,
  546. .flags = IORESOURCE_IRQ,
  547. },
  548. };
  549. static struct platform_device at91sam9g45_twi0_device = {
  550. .name = "at91_i2c",
  551. .id = 0,
  552. .resource = twi0_resources,
  553. .num_resources = ARRAY_SIZE(twi0_resources),
  554. };
  555. static struct resource twi1_resources[] = {
  556. [0] = {
  557. .start = AT91SAM9G45_BASE_TWI1,
  558. .end = AT91SAM9G45_BASE_TWI1 + SZ_16K - 1,
  559. .flags = IORESOURCE_MEM,
  560. },
  561. [1] = {
  562. .start = AT91SAM9G45_ID_TWI1,
  563. .end = AT91SAM9G45_ID_TWI1,
  564. .flags = IORESOURCE_IRQ,
  565. },
  566. };
  567. static struct platform_device at91sam9g45_twi1_device = {
  568. .name = "at91_i2c",
  569. .id = 1,
  570. .resource = twi1_resources,
  571. .num_resources = ARRAY_SIZE(twi1_resources),
  572. };
  573. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
  574. {
  575. i2c_register_board_info(i2c_id, devices, nr_devices);
  576. /* pins used for TWI interface */
  577. if (i2c_id == 0) {
  578. at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */
  579. at91_set_multi_drive(AT91_PIN_PA20, 1);
  580. at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */
  581. at91_set_multi_drive(AT91_PIN_PA21, 1);
  582. platform_device_register(&at91sam9g45_twi0_device);
  583. } else {
  584. at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */
  585. at91_set_multi_drive(AT91_PIN_PB10, 1);
  586. at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */
  587. at91_set_multi_drive(AT91_PIN_PB11, 1);
  588. platform_device_register(&at91sam9g45_twi1_device);
  589. }
  590. }
  591. #else
  592. void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
  593. #endif
  594. /* --------------------------------------------------------------------
  595. * SPI
  596. * -------------------------------------------------------------------- */
  597. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  598. static u64 spi_dmamask = DMA_BIT_MASK(32);
  599. static struct resource spi0_resources[] = {
  600. [0] = {
  601. .start = AT91SAM9G45_BASE_SPI0,
  602. .end = AT91SAM9G45_BASE_SPI0 + SZ_16K - 1,
  603. .flags = IORESOURCE_MEM,
  604. },
  605. [1] = {
  606. .start = AT91SAM9G45_ID_SPI0,
  607. .end = AT91SAM9G45_ID_SPI0,
  608. .flags = IORESOURCE_IRQ,
  609. },
  610. };
  611. static struct platform_device at91sam9g45_spi0_device = {
  612. .name = "atmel_spi",
  613. .id = 0,
  614. .dev = {
  615. .dma_mask = &spi_dmamask,
  616. .coherent_dma_mask = DMA_BIT_MASK(32),
  617. },
  618. .resource = spi0_resources,
  619. .num_resources = ARRAY_SIZE(spi0_resources),
  620. };
  621. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PB18, AT91_PIN_PB19, AT91_PIN_PD27 };
  622. static struct resource spi1_resources[] = {
  623. [0] = {
  624. .start = AT91SAM9G45_BASE_SPI1,
  625. .end = AT91SAM9G45_BASE_SPI1 + SZ_16K - 1,
  626. .flags = IORESOURCE_MEM,
  627. },
  628. [1] = {
  629. .start = AT91SAM9G45_ID_SPI1,
  630. .end = AT91SAM9G45_ID_SPI1,
  631. .flags = IORESOURCE_IRQ,
  632. },
  633. };
  634. static struct platform_device at91sam9g45_spi1_device = {
  635. .name = "atmel_spi",
  636. .id = 1,
  637. .dev = {
  638. .dma_mask = &spi_dmamask,
  639. .coherent_dma_mask = DMA_BIT_MASK(32),
  640. },
  641. .resource = spi1_resources,
  642. .num_resources = ARRAY_SIZE(spi1_resources),
  643. };
  644. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB17, AT91_PIN_PD28, AT91_PIN_PD18, AT91_PIN_PD19 };
  645. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  646. {
  647. int i;
  648. unsigned long cs_pin;
  649. short enable_spi0 = 0;
  650. short enable_spi1 = 0;
  651. /* Choose SPI chip-selects */
  652. for (i = 0; i < nr_devices; i++) {
  653. if (devices[i].controller_data)
  654. cs_pin = (unsigned long) devices[i].controller_data;
  655. else if (devices[i].bus_num == 0)
  656. cs_pin = spi0_standard_cs[devices[i].chip_select];
  657. else
  658. cs_pin = spi1_standard_cs[devices[i].chip_select];
  659. if (devices[i].bus_num == 0)
  660. enable_spi0 = 1;
  661. else
  662. enable_spi1 = 1;
  663. /* enable chip-select pin */
  664. at91_set_gpio_output(cs_pin, 1);
  665. /* pass chip-select pin to driver */
  666. devices[i].controller_data = (void *) cs_pin;
  667. }
  668. spi_register_board_info(devices, nr_devices);
  669. /* Configure SPI bus(es) */
  670. if (enable_spi0) {
  671. at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
  672. at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
  673. at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
  674. platform_device_register(&at91sam9g45_spi0_device);
  675. }
  676. if (enable_spi1) {
  677. at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
  678. at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
  679. at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
  680. platform_device_register(&at91sam9g45_spi1_device);
  681. }
  682. }
  683. #else
  684. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  685. #endif
  686. /* --------------------------------------------------------------------
  687. * AC97
  688. * -------------------------------------------------------------------- */
  689. #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
  690. static u64 ac97_dmamask = DMA_BIT_MASK(32);
  691. static struct ac97c_platform_data ac97_data;
  692. static struct resource ac97_resources[] = {
  693. [0] = {
  694. .start = AT91SAM9G45_BASE_AC97C,
  695. .end = AT91SAM9G45_BASE_AC97C + SZ_16K - 1,
  696. .flags = IORESOURCE_MEM,
  697. },
  698. [1] = {
  699. .start = AT91SAM9G45_ID_AC97C,
  700. .end = AT91SAM9G45_ID_AC97C,
  701. .flags = IORESOURCE_IRQ,
  702. },
  703. };
  704. static struct platform_device at91sam9g45_ac97_device = {
  705. .name = "atmel_ac97c",
  706. .id = 0,
  707. .dev = {
  708. .dma_mask = &ac97_dmamask,
  709. .coherent_dma_mask = DMA_BIT_MASK(32),
  710. .platform_data = &ac97_data,
  711. },
  712. .resource = ac97_resources,
  713. .num_resources = ARRAY_SIZE(ac97_resources),
  714. };
  715. void __init at91_add_device_ac97(struct ac97c_platform_data *data)
  716. {
  717. if (!data)
  718. return;
  719. at91_set_A_periph(AT91_PIN_PD8, 0); /* AC97FS */
  720. at91_set_A_periph(AT91_PIN_PD9, 0); /* AC97CK */
  721. at91_set_A_periph(AT91_PIN_PD7, 0); /* AC97TX */
  722. at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
  723. /* reset */
  724. if (gpio_is_valid(data->reset_pin))
  725. at91_set_gpio_output(data->reset_pin, 0);
  726. ac97_data = *data;
  727. platform_device_register(&at91sam9g45_ac97_device);
  728. }
  729. #else
  730. void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
  731. #endif
  732. /* --------------------------------------------------------------------
  733. * Image Sensor Interface
  734. * -------------------------------------------------------------------- */
  735. #if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE)
  736. static u64 isi_dmamask = DMA_BIT_MASK(32);
  737. static struct isi_platform_data isi_data;
  738. struct resource isi_resources[] = {
  739. [0] = {
  740. .start = AT91SAM9G45_BASE_ISI,
  741. .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1,
  742. .flags = IORESOURCE_MEM,
  743. },
  744. [1] = {
  745. .start = AT91SAM9G45_ID_ISI,
  746. .end = AT91SAM9G45_ID_ISI,
  747. .flags = IORESOURCE_IRQ,
  748. },
  749. };
  750. static struct platform_device at91sam9g45_isi_device = {
  751. .name = "atmel_isi",
  752. .id = 0,
  753. .dev = {
  754. .dma_mask = &isi_dmamask,
  755. .coherent_dma_mask = DMA_BIT_MASK(32),
  756. .platform_data = &isi_data,
  757. },
  758. .resource = isi_resources,
  759. .num_resources = ARRAY_SIZE(isi_resources),
  760. };
  761. static struct clk_lookup isi_mck_lookups[] = {
  762. CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL),
  763. };
  764. void __init at91_add_device_isi(struct isi_platform_data *data,
  765. bool use_pck_as_mck)
  766. {
  767. struct clk *pck;
  768. struct clk *parent;
  769. if (!data)
  770. return;
  771. isi_data = *data;
  772. at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */
  773. at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */
  774. at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */
  775. at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */
  776. at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */
  777. at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */
  778. at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */
  779. at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */
  780. at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */
  781. at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */
  782. at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */
  783. at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */
  784. at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */
  785. at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */
  786. at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */
  787. platform_device_register(&at91sam9g45_isi_device);
  788. if (use_pck_as_mck) {
  789. at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */
  790. pck = clk_get(NULL, "pck1");
  791. parent = clk_get(NULL, "plla");
  792. BUG_ON(IS_ERR(pck) || IS_ERR(parent));
  793. if (clk_set_parent(pck, parent)) {
  794. pr_err("Failed to set PCK's parent\n");
  795. } else {
  796. /* Register PCK as ISI_MCK */
  797. isi_mck_lookups[0].clk = pck;
  798. clkdev_add_table(isi_mck_lookups,
  799. ARRAY_SIZE(isi_mck_lookups));
  800. }
  801. clk_put(pck);
  802. clk_put(parent);
  803. }
  804. }
  805. #else
  806. void __init at91_add_device_isi(struct isi_platform_data *data,
  807. bool use_pck_as_mck) {}
  808. #endif
  809. /* --------------------------------------------------------------------
  810. * LCD Controller
  811. * -------------------------------------------------------------------- */
  812. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  813. static u64 lcdc_dmamask = DMA_BIT_MASK(32);
  814. static struct atmel_lcdfb_info lcdc_data;
  815. static struct resource lcdc_resources[] = {
  816. [0] = {
  817. .start = AT91SAM9G45_LCDC_BASE,
  818. .end = AT91SAM9G45_LCDC_BASE + SZ_4K - 1,
  819. .flags = IORESOURCE_MEM,
  820. },
  821. [1] = {
  822. .start = AT91SAM9G45_ID_LCDC,
  823. .end = AT91SAM9G45_ID_LCDC,
  824. .flags = IORESOURCE_IRQ,
  825. },
  826. };
  827. static struct platform_device at91_lcdc_device = {
  828. .name = "atmel_lcdfb",
  829. .id = 0,
  830. .dev = {
  831. .dma_mask = &lcdc_dmamask,
  832. .coherent_dma_mask = DMA_BIT_MASK(32),
  833. .platform_data = &lcdc_data,
  834. },
  835. .resource = lcdc_resources,
  836. .num_resources = ARRAY_SIZE(lcdc_resources),
  837. };
  838. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
  839. {
  840. if (!data)
  841. return;
  842. at91_set_A_periph(AT91_PIN_PE0, 0); /* LCDDPWR */
  843. at91_set_A_periph(AT91_PIN_PE2, 0); /* LCDCC */
  844. at91_set_A_periph(AT91_PIN_PE3, 0); /* LCDVSYNC */
  845. at91_set_A_periph(AT91_PIN_PE4, 0); /* LCDHSYNC */
  846. at91_set_A_periph(AT91_PIN_PE5, 0); /* LCDDOTCK */
  847. at91_set_A_periph(AT91_PIN_PE6, 0); /* LCDDEN */
  848. at91_set_A_periph(AT91_PIN_PE7, 0); /* LCDD0 */
  849. at91_set_A_periph(AT91_PIN_PE8, 0); /* LCDD1 */
  850. at91_set_A_periph(AT91_PIN_PE9, 0); /* LCDD2 */
  851. at91_set_A_periph(AT91_PIN_PE10, 0); /* LCDD3 */
  852. at91_set_A_periph(AT91_PIN_PE11, 0); /* LCDD4 */
  853. at91_set_A_periph(AT91_PIN_PE12, 0); /* LCDD5 */
  854. at91_set_A_periph(AT91_PIN_PE13, 0); /* LCDD6 */
  855. at91_set_A_periph(AT91_PIN_PE14, 0); /* LCDD7 */
  856. at91_set_A_periph(AT91_PIN_PE15, 0); /* LCDD8 */
  857. at91_set_A_periph(AT91_PIN_PE16, 0); /* LCDD9 */
  858. at91_set_A_periph(AT91_PIN_PE17, 0); /* LCDD10 */
  859. at91_set_A_periph(AT91_PIN_PE18, 0); /* LCDD11 */
  860. at91_set_A_periph(AT91_PIN_PE19, 0); /* LCDD12 */
  861. at91_set_A_periph(AT91_PIN_PE20, 0); /* LCDD13 */
  862. at91_set_A_periph(AT91_PIN_PE21, 0); /* LCDD14 */
  863. at91_set_A_periph(AT91_PIN_PE22, 0); /* LCDD15 */
  864. at91_set_A_periph(AT91_PIN_PE23, 0); /* LCDD16 */
  865. at91_set_A_periph(AT91_PIN_PE24, 0); /* LCDD17 */
  866. at91_set_A_periph(AT91_PIN_PE25, 0); /* LCDD18 */
  867. at91_set_A_periph(AT91_PIN_PE26, 0); /* LCDD19 */
  868. at91_set_A_periph(AT91_PIN_PE27, 0); /* LCDD20 */
  869. at91_set_A_periph(AT91_PIN_PE28, 0); /* LCDD21 */
  870. at91_set_A_periph(AT91_PIN_PE29, 0); /* LCDD22 */
  871. at91_set_A_periph(AT91_PIN_PE30, 0); /* LCDD23 */
  872. lcdc_data = *data;
  873. platform_device_register(&at91_lcdc_device);
  874. }
  875. #else
  876. void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  877. #endif
  878. /* --------------------------------------------------------------------
  879. * Timer/Counter block
  880. * -------------------------------------------------------------------- */
  881. #ifdef CONFIG_ATMEL_TCLIB
  882. static struct resource tcb0_resources[] = {
  883. [0] = {
  884. .start = AT91SAM9G45_BASE_TCB0,
  885. .end = AT91SAM9G45_BASE_TCB0 + SZ_256 - 1,
  886. .flags = IORESOURCE_MEM,
  887. },
  888. [1] = {
  889. .start = AT91SAM9G45_ID_TCB,
  890. .end = AT91SAM9G45_ID_TCB,
  891. .flags = IORESOURCE_IRQ,
  892. },
  893. };
  894. static struct platform_device at91sam9g45_tcb0_device = {
  895. .name = "atmel_tcb",
  896. .id = 0,
  897. .resource = tcb0_resources,
  898. .num_resources = ARRAY_SIZE(tcb0_resources),
  899. };
  900. /* TCB1 begins with TC3 */
  901. static struct resource tcb1_resources[] = {
  902. [0] = {
  903. .start = AT91SAM9G45_BASE_TCB1,
  904. .end = AT91SAM9G45_BASE_TCB1 + SZ_256 - 1,
  905. .flags = IORESOURCE_MEM,
  906. },
  907. [1] = {
  908. .start = AT91SAM9G45_ID_TCB,
  909. .end = AT91SAM9G45_ID_TCB,
  910. .flags = IORESOURCE_IRQ,
  911. },
  912. };
  913. static struct platform_device at91sam9g45_tcb1_device = {
  914. .name = "atmel_tcb",
  915. .id = 1,
  916. .resource = tcb1_resources,
  917. .num_resources = ARRAY_SIZE(tcb1_resources),
  918. };
  919. #if defined(CONFIG_OF)
  920. static struct of_device_id tcb_ids[] = {
  921. { .compatible = "atmel,at91rm9200-tcb" },
  922. { /*sentinel*/ }
  923. };
  924. #endif
  925. static void __init at91_add_device_tc(void)
  926. {
  927. #if defined(CONFIG_OF)
  928. struct device_node *np;
  929. np = of_find_matching_node(NULL, tcb_ids);
  930. if (np) {
  931. of_node_put(np);
  932. return;
  933. }
  934. #endif
  935. platform_device_register(&at91sam9g45_tcb0_device);
  936. platform_device_register(&at91sam9g45_tcb1_device);
  937. }
  938. #else
  939. static void __init at91_add_device_tc(void) { }
  940. #endif
  941. /* --------------------------------------------------------------------
  942. * RTC
  943. * -------------------------------------------------------------------- */
  944. #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
  945. static struct resource rtc_resources[] = {
  946. [0] = {
  947. .start = AT91SAM9G45_BASE_RTC,
  948. .end = AT91SAM9G45_BASE_RTC + SZ_256 - 1,
  949. .flags = IORESOURCE_MEM,
  950. },
  951. [1] = {
  952. .start = AT91_ID_SYS,
  953. .end = AT91_ID_SYS,
  954. .flags = IORESOURCE_IRQ,
  955. },
  956. };
  957. static struct platform_device at91sam9g45_rtc_device = {
  958. .name = "at91_rtc",
  959. .id = -1,
  960. .resource = rtc_resources,
  961. .num_resources = ARRAY_SIZE(rtc_resources),
  962. };
  963. static void __init at91_add_device_rtc(void)
  964. {
  965. platform_device_register(&at91sam9g45_rtc_device);
  966. }
  967. #else
  968. static void __init at91_add_device_rtc(void) {}
  969. #endif
  970. /* --------------------------------------------------------------------
  971. * Touchscreen
  972. * -------------------------------------------------------------------- */
  973. #if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
  974. static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
  975. static struct at91_tsadcc_data tsadcc_data;
  976. static struct resource tsadcc_resources[] = {
  977. [0] = {
  978. .start = AT91SAM9G45_BASE_TSC,
  979. .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
  980. .flags = IORESOURCE_MEM,
  981. },
  982. [1] = {
  983. .start = AT91SAM9G45_ID_TSC,
  984. .end = AT91SAM9G45_ID_TSC,
  985. .flags = IORESOURCE_IRQ,
  986. }
  987. };
  988. static struct platform_device at91sam9g45_tsadcc_device = {
  989. .name = "atmel_tsadcc",
  990. .id = -1,
  991. .dev = {
  992. .dma_mask = &tsadcc_dmamask,
  993. .coherent_dma_mask = DMA_BIT_MASK(32),
  994. .platform_data = &tsadcc_data,
  995. },
  996. .resource = tsadcc_resources,
  997. .num_resources = ARRAY_SIZE(tsadcc_resources),
  998. };
  999. void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
  1000. {
  1001. if (!data)
  1002. return;
  1003. at91_set_gpio_input(AT91_PIN_PD20, 0); /* AD0_XR */
  1004. at91_set_gpio_input(AT91_PIN_PD21, 0); /* AD1_XL */
  1005. at91_set_gpio_input(AT91_PIN_PD22, 0); /* AD2_YT */
  1006. at91_set_gpio_input(AT91_PIN_PD23, 0); /* AD3_TB */
  1007. tsadcc_data = *data;
  1008. platform_device_register(&at91sam9g45_tsadcc_device);
  1009. }
  1010. #else
  1011. void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
  1012. #endif
  1013. /* --------------------------------------------------------------------
  1014. * RTT
  1015. * -------------------------------------------------------------------- */
  1016. static struct resource rtt_resources[] = {
  1017. {
  1018. .start = AT91SAM9G45_BASE_RTT,
  1019. .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1,
  1020. .flags = IORESOURCE_MEM,
  1021. }, {
  1022. .flags = IORESOURCE_MEM,
  1023. }
  1024. };
  1025. static struct platform_device at91sam9g45_rtt_device = {
  1026. .name = "at91_rtt",
  1027. .id = 0,
  1028. .resource = rtt_resources,
  1029. };
  1030. #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
  1031. static void __init at91_add_device_rtt_rtc(void)
  1032. {
  1033. at91sam9g45_rtt_device.name = "rtc-at91sam9";
  1034. /*
  1035. * The second resource is needed:
  1036. * GPBR will serve as the storage for RTC time offset
  1037. */
  1038. at91sam9g45_rtt_device.num_resources = 2;
  1039. rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
  1040. 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
  1041. rtt_resources[1].end = rtt_resources[1].start + 3;
  1042. }
  1043. #else
  1044. static void __init at91_add_device_rtt_rtc(void)
  1045. {
  1046. /* Only one resource is needed: RTT not used as RTC */
  1047. at91sam9g45_rtt_device.num_resources = 1;
  1048. }
  1049. #endif
  1050. static void __init at91_add_device_rtt(void)
  1051. {
  1052. at91_add_device_rtt_rtc();
  1053. platform_device_register(&at91sam9g45_rtt_device);
  1054. }
  1055. /* --------------------------------------------------------------------
  1056. * TRNG
  1057. * -------------------------------------------------------------------- */
  1058. #if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE)
  1059. static struct resource trng_resources[] = {
  1060. {
  1061. .start = AT91SAM9G45_BASE_TRNG,
  1062. .end = AT91SAM9G45_BASE_TRNG + SZ_16K - 1,
  1063. .flags = IORESOURCE_MEM,
  1064. },
  1065. };
  1066. static struct platform_device at91sam9g45_trng_device = {
  1067. .name = "atmel-trng",
  1068. .id = -1,
  1069. .resource = trng_resources,
  1070. .num_resources = ARRAY_SIZE(trng_resources),
  1071. };
  1072. static void __init at91_add_device_trng(void)
  1073. {
  1074. platform_device_register(&at91sam9g45_trng_device);
  1075. }
  1076. #else
  1077. static void __init at91_add_device_trng(void) {}
  1078. #endif
  1079. /* --------------------------------------------------------------------
  1080. * Watchdog
  1081. * -------------------------------------------------------------------- */
  1082. #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
  1083. static struct resource wdt_resources[] = {
  1084. {
  1085. .start = AT91SAM9G45_BASE_WDT,
  1086. .end = AT91SAM9G45_BASE_WDT + SZ_16 - 1,
  1087. .flags = IORESOURCE_MEM,
  1088. }
  1089. };
  1090. static struct platform_device at91sam9g45_wdt_device = {
  1091. .name = "at91_wdt",
  1092. .id = -1,
  1093. .resource = wdt_resources,
  1094. .num_resources = ARRAY_SIZE(wdt_resources),
  1095. };
  1096. static void __init at91_add_device_watchdog(void)
  1097. {
  1098. platform_device_register(&at91sam9g45_wdt_device);
  1099. }
  1100. #else
  1101. static void __init at91_add_device_watchdog(void) {}
  1102. #endif
  1103. /* --------------------------------------------------------------------
  1104. * PWM
  1105. * --------------------------------------------------------------------*/
  1106. #if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE)
  1107. static u32 pwm_mask;
  1108. static struct resource pwm_resources[] = {
  1109. [0] = {
  1110. .start = AT91SAM9G45_BASE_PWMC,
  1111. .end = AT91SAM9G45_BASE_PWMC + SZ_16K - 1,
  1112. .flags = IORESOURCE_MEM,
  1113. },
  1114. [1] = {
  1115. .start = AT91SAM9G45_ID_PWMC,
  1116. .end = AT91SAM9G45_ID_PWMC,
  1117. .flags = IORESOURCE_IRQ,
  1118. },
  1119. };
  1120. static struct platform_device at91sam9g45_pwm0_device = {
  1121. .name = "atmel_pwm",
  1122. .id = -1,
  1123. .dev = {
  1124. .platform_data = &pwm_mask,
  1125. },
  1126. .resource = pwm_resources,
  1127. .num_resources = ARRAY_SIZE(pwm_resources),
  1128. };
  1129. void __init at91_add_device_pwm(u32 mask)
  1130. {
  1131. if (mask & (1 << AT91_PWM0))
  1132. at91_set_B_periph(AT91_PIN_PD24, 1); /* enable PWM0 */
  1133. if (mask & (1 << AT91_PWM1))
  1134. at91_set_B_periph(AT91_PIN_PD31, 1); /* enable PWM1 */
  1135. if (mask & (1 << AT91_PWM2))
  1136. at91_set_B_periph(AT91_PIN_PD26, 1); /* enable PWM2 */
  1137. if (mask & (1 << AT91_PWM3))
  1138. at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */
  1139. pwm_mask = mask;
  1140. platform_device_register(&at91sam9g45_pwm0_device);
  1141. }
  1142. #else
  1143. void __init at91_add_device_pwm(u32 mask) {}
  1144. #endif
  1145. /* --------------------------------------------------------------------
  1146. * SSC -- Synchronous Serial Controller
  1147. * -------------------------------------------------------------------- */
  1148. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  1149. static u64 ssc0_dmamask = DMA_BIT_MASK(32);
  1150. static struct resource ssc0_resources[] = {
  1151. [0] = {
  1152. .start = AT91SAM9G45_BASE_SSC0,
  1153. .end = AT91SAM9G45_BASE_SSC0 + SZ_16K - 1,
  1154. .flags = IORESOURCE_MEM,
  1155. },
  1156. [1] = {
  1157. .start = AT91SAM9G45_ID_SSC0,
  1158. .end = AT91SAM9G45_ID_SSC0,
  1159. .flags = IORESOURCE_IRQ,
  1160. },
  1161. };
  1162. static struct platform_device at91sam9g45_ssc0_device = {
  1163. .name = "ssc",
  1164. .id = 0,
  1165. .dev = {
  1166. .dma_mask = &ssc0_dmamask,
  1167. .coherent_dma_mask = DMA_BIT_MASK(32),
  1168. },
  1169. .resource = ssc0_resources,
  1170. .num_resources = ARRAY_SIZE(ssc0_resources),
  1171. };
  1172. static inline void configure_ssc0_pins(unsigned pins)
  1173. {
  1174. if (pins & ATMEL_SSC_TF)
  1175. at91_set_A_periph(AT91_PIN_PD1, 1);
  1176. if (pins & ATMEL_SSC_TK)
  1177. at91_set_A_periph(AT91_PIN_PD0, 1);
  1178. if (pins & ATMEL_SSC_TD)
  1179. at91_set_A_periph(AT91_PIN_PD2, 1);
  1180. if (pins & ATMEL_SSC_RD)
  1181. at91_set_A_periph(AT91_PIN_PD3, 1);
  1182. if (pins & ATMEL_SSC_RK)
  1183. at91_set_A_periph(AT91_PIN_PD4, 1);
  1184. if (pins & ATMEL_SSC_RF)
  1185. at91_set_A_periph(AT91_PIN_PD5, 1);
  1186. }
  1187. static u64 ssc1_dmamask = DMA_BIT_MASK(32);
  1188. static struct resource ssc1_resources[] = {
  1189. [0] = {
  1190. .start = AT91SAM9G45_BASE_SSC1,
  1191. .end = AT91SAM9G45_BASE_SSC1 + SZ_16K - 1,
  1192. .flags = IORESOURCE_MEM,
  1193. },
  1194. [1] = {
  1195. .start = AT91SAM9G45_ID_SSC1,
  1196. .end = AT91SAM9G45_ID_SSC1,
  1197. .flags = IORESOURCE_IRQ,
  1198. },
  1199. };
  1200. static struct platform_device at91sam9g45_ssc1_device = {
  1201. .name = "ssc",
  1202. .id = 1,
  1203. .dev = {
  1204. .dma_mask = &ssc1_dmamask,
  1205. .coherent_dma_mask = DMA_BIT_MASK(32),
  1206. },
  1207. .resource = ssc1_resources,
  1208. .num_resources = ARRAY_SIZE(ssc1_resources),
  1209. };
  1210. static inline void configure_ssc1_pins(unsigned pins)
  1211. {
  1212. if (pins & ATMEL_SSC_TF)
  1213. at91_set_A_periph(AT91_PIN_PD14, 1);
  1214. if (pins & ATMEL_SSC_TK)
  1215. at91_set_A_periph(AT91_PIN_PD12, 1);
  1216. if (pins & ATMEL_SSC_TD)
  1217. at91_set_A_periph(AT91_PIN_PD10, 1);
  1218. if (pins & ATMEL_SSC_RD)
  1219. at91_set_A_periph(AT91_PIN_PD11, 1);
  1220. if (pins & ATMEL_SSC_RK)
  1221. at91_set_A_periph(AT91_PIN_PD13, 1);
  1222. if (pins & ATMEL_SSC_RF)
  1223. at91_set_A_periph(AT91_PIN_PD15, 1);
  1224. }
  1225. /*
  1226. * SSC controllers are accessed through library code, instead of any
  1227. * kind of all-singing/all-dancing driver. For example one could be
  1228. * used by a particular I2S audio codec's driver, while another one
  1229. * on the same system might be used by a custom data capture driver.
  1230. */
  1231. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  1232. {
  1233. struct platform_device *pdev;
  1234. /*
  1235. * NOTE: caller is responsible for passing information matching
  1236. * "pins" to whatever will be using each particular controller.
  1237. */
  1238. switch (id) {
  1239. case AT91SAM9G45_ID_SSC0:
  1240. pdev = &at91sam9g45_ssc0_device;
  1241. configure_ssc0_pins(pins);
  1242. break;
  1243. case AT91SAM9G45_ID_SSC1:
  1244. pdev = &at91sam9g45_ssc1_device;
  1245. configure_ssc1_pins(pins);
  1246. break;
  1247. default:
  1248. return;
  1249. }
  1250. platform_device_register(pdev);
  1251. }
  1252. #else
  1253. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  1254. #endif
  1255. /* --------------------------------------------------------------------
  1256. * UART
  1257. * -------------------------------------------------------------------- */
  1258. #if defined(CONFIG_SERIAL_ATMEL)
  1259. static struct resource dbgu_resources[] = {
  1260. [0] = {
  1261. .start = AT91SAM9G45_BASE_DBGU,
  1262. .end = AT91SAM9G45_BASE_DBGU + SZ_512 - 1,
  1263. .flags = IORESOURCE_MEM,
  1264. },
  1265. [1] = {
  1266. .start = AT91_ID_SYS,
  1267. .end = AT91_ID_SYS,
  1268. .flags = IORESOURCE_IRQ,
  1269. },
  1270. };
  1271. static struct atmel_uart_data dbgu_data = {
  1272. .use_dma_tx = 0,
  1273. .use_dma_rx = 0,
  1274. };
  1275. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  1276. static struct platform_device at91sam9g45_dbgu_device = {
  1277. .name = "atmel_usart",
  1278. .id = 0,
  1279. .dev = {
  1280. .dma_mask = &dbgu_dmamask,
  1281. .coherent_dma_mask = DMA_BIT_MASK(32),
  1282. .platform_data = &dbgu_data,
  1283. },
  1284. .resource = dbgu_resources,
  1285. .num_resources = ARRAY_SIZE(dbgu_resources),
  1286. };
  1287. static inline void configure_dbgu_pins(void)
  1288. {
  1289. at91_set_A_periph(AT91_PIN_PB12, 0); /* DRXD */
  1290. at91_set_A_periph(AT91_PIN_PB13, 1); /* DTXD */
  1291. }
  1292. static struct resource uart0_resources[] = {
  1293. [0] = {
  1294. .start = AT91SAM9G45_BASE_US0,
  1295. .end = AT91SAM9G45_BASE_US0 + SZ_16K - 1,
  1296. .flags = IORESOURCE_MEM,
  1297. },
  1298. [1] = {
  1299. .start = AT91SAM9G45_ID_US0,
  1300. .end = AT91SAM9G45_ID_US0,
  1301. .flags = IORESOURCE_IRQ,
  1302. },
  1303. };
  1304. static struct atmel_uart_data uart0_data = {
  1305. .use_dma_tx = 1,
  1306. .use_dma_rx = 1,
  1307. };
  1308. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  1309. static struct platform_device at91sam9g45_uart0_device = {
  1310. .name = "atmel_usart",
  1311. .id = 1,
  1312. .dev = {
  1313. .dma_mask = &uart0_dmamask,
  1314. .coherent_dma_mask = DMA_BIT_MASK(32),
  1315. .platform_data = &uart0_data,
  1316. },
  1317. .resource = uart0_resources,
  1318. .num_resources = ARRAY_SIZE(uart0_resources),
  1319. };
  1320. static inline void configure_usart0_pins(unsigned pins)
  1321. {
  1322. at91_set_A_periph(AT91_PIN_PB19, 1); /* TXD0 */
  1323. at91_set_A_periph(AT91_PIN_PB18, 0); /* RXD0 */
  1324. if (pins & ATMEL_UART_RTS)
  1325. at91_set_B_periph(AT91_PIN_PB17, 0); /* RTS0 */
  1326. if (pins & ATMEL_UART_CTS)
  1327. at91_set_B_periph(AT91_PIN_PB15, 0); /* CTS0 */
  1328. }
  1329. static struct resource uart1_resources[] = {
  1330. [0] = {
  1331. .start = AT91SAM9G45_BASE_US1,
  1332. .end = AT91SAM9G45_BASE_US1 + SZ_16K - 1,
  1333. .flags = IORESOURCE_MEM,
  1334. },
  1335. [1] = {
  1336. .start = AT91SAM9G45_ID_US1,
  1337. .end = AT91SAM9G45_ID_US1,
  1338. .flags = IORESOURCE_IRQ,
  1339. },
  1340. };
  1341. static struct atmel_uart_data uart1_data = {
  1342. .use_dma_tx = 1,
  1343. .use_dma_rx = 1,
  1344. };
  1345. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  1346. static struct platform_device at91sam9g45_uart1_device = {
  1347. .name = "atmel_usart",
  1348. .id = 2,
  1349. .dev = {
  1350. .dma_mask = &uart1_dmamask,
  1351. .coherent_dma_mask = DMA_BIT_MASK(32),
  1352. .platform_data = &uart1_data,
  1353. },
  1354. .resource = uart1_resources,
  1355. .num_resources = ARRAY_SIZE(uart1_resources),
  1356. };
  1357. static inline void configure_usart1_pins(unsigned pins)
  1358. {
  1359. at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD1 */
  1360. at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD1 */
  1361. if (pins & ATMEL_UART_RTS)
  1362. at91_set_A_periph(AT91_PIN_PD16, 0); /* RTS1 */
  1363. if (pins & ATMEL_UART_CTS)
  1364. at91_set_A_periph(AT91_PIN_PD17, 0); /* CTS1 */
  1365. }
  1366. static struct resource uart2_resources[] = {
  1367. [0] = {
  1368. .start = AT91SAM9G45_BASE_US2,
  1369. .end = AT91SAM9G45_BASE_US2 + SZ_16K - 1,
  1370. .flags = IORESOURCE_MEM,
  1371. },
  1372. [1] = {
  1373. .start = AT91SAM9G45_ID_US2,
  1374. .end = AT91SAM9G45_ID_US2,
  1375. .flags = IORESOURCE_IRQ,
  1376. },
  1377. };
  1378. static struct atmel_uart_data uart2_data = {
  1379. .use_dma_tx = 1,
  1380. .use_dma_rx = 1,
  1381. };
  1382. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  1383. static struct platform_device at91sam9g45_uart2_device = {
  1384. .name = "atmel_usart",
  1385. .id = 3,
  1386. .dev = {
  1387. .dma_mask = &uart2_dmamask,
  1388. .coherent_dma_mask = DMA_BIT_MASK(32),
  1389. .platform_data = &uart2_data,
  1390. },
  1391. .resource = uart2_resources,
  1392. .num_resources = ARRAY_SIZE(uart2_resources),
  1393. };
  1394. static inline void configure_usart2_pins(unsigned pins)
  1395. {
  1396. at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD2 */
  1397. at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD2 */
  1398. if (pins & ATMEL_UART_RTS)
  1399. at91_set_B_periph(AT91_PIN_PC9, 0); /* RTS2 */
  1400. if (pins & ATMEL_UART_CTS)
  1401. at91_set_B_periph(AT91_PIN_PC11, 0); /* CTS2 */
  1402. }
  1403. static struct resource uart3_resources[] = {
  1404. [0] = {
  1405. .start = AT91SAM9G45_BASE_US3,
  1406. .end = AT91SAM9G45_BASE_US3 + SZ_16K - 1,
  1407. .flags = IORESOURCE_MEM,
  1408. },
  1409. [1] = {
  1410. .start = AT91SAM9G45_ID_US3,
  1411. .end = AT91SAM9G45_ID_US3,
  1412. .flags = IORESOURCE_IRQ,
  1413. },
  1414. };
  1415. static struct atmel_uart_data uart3_data = {
  1416. .use_dma_tx = 1,
  1417. .use_dma_rx = 1,
  1418. };
  1419. static u64 uart3_dmamask = DMA_BIT_MASK(32);
  1420. static struct platform_device at91sam9g45_uart3_device = {
  1421. .name = "atmel_usart",
  1422. .id = 4,
  1423. .dev = {
  1424. .dma_mask = &uart3_dmamask,
  1425. .coherent_dma_mask = DMA_BIT_MASK(32),
  1426. .platform_data = &uart3_data,
  1427. },
  1428. .resource = uart3_resources,
  1429. .num_resources = ARRAY_SIZE(uart3_resources),
  1430. };
  1431. static inline void configure_usart3_pins(unsigned pins)
  1432. {
  1433. at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD3 */
  1434. at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD3 */
  1435. if (pins & ATMEL_UART_RTS)
  1436. at91_set_B_periph(AT91_PIN_PA23, 0); /* RTS3 */
  1437. if (pins & ATMEL_UART_CTS)
  1438. at91_set_B_periph(AT91_PIN_PA24, 0); /* CTS3 */
  1439. }
  1440. static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  1441. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  1442. {
  1443. struct platform_device *pdev;
  1444. struct atmel_uart_data *pdata;
  1445. switch (id) {
  1446. case 0: /* DBGU */
  1447. pdev = &at91sam9g45_dbgu_device;
  1448. configure_dbgu_pins();
  1449. break;
  1450. case AT91SAM9G45_ID_US0:
  1451. pdev = &at91sam9g45_uart0_device;
  1452. configure_usart0_pins(pins);
  1453. break;
  1454. case AT91SAM9G45_ID_US1:
  1455. pdev = &at91sam9g45_uart1_device;
  1456. configure_usart1_pins(pins);
  1457. break;
  1458. case AT91SAM9G45_ID_US2:
  1459. pdev = &at91sam9g45_uart2_device;
  1460. configure_usart2_pins(pins);
  1461. break;
  1462. case AT91SAM9G45_ID_US3:
  1463. pdev = &at91sam9g45_uart3_device;
  1464. configure_usart3_pins(pins);
  1465. break;
  1466. default:
  1467. return;
  1468. }
  1469. pdata = pdev->dev.platform_data;
  1470. pdata->num = portnr; /* update to mapped ID */
  1471. if (portnr < ATMEL_MAX_UART)
  1472. at91_uarts[portnr] = pdev;
  1473. }
  1474. void __init at91_set_serial_console(unsigned portnr)
  1475. {
  1476. if (portnr < ATMEL_MAX_UART) {
  1477. atmel_default_console_device = at91_uarts[portnr];
  1478. at91sam9g45_set_console_clock(at91_uarts[portnr]->id);
  1479. }
  1480. }
  1481. void __init at91_add_device_serial(void)
  1482. {
  1483. int i;
  1484. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1485. if (at91_uarts[i])
  1486. platform_device_register(at91_uarts[i]);
  1487. }
  1488. if (!atmel_default_console_device)
  1489. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1490. }
  1491. #else
  1492. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1493. void __init at91_set_serial_console(unsigned portnr) {}
  1494. void __init at91_add_device_serial(void) {}
  1495. #endif
  1496. /* -------------------------------------------------------------------- */
  1497. /*
  1498. * These devices are always present and don't need any board-specific
  1499. * setup.
  1500. */
  1501. static int __init at91_add_standard_devices(void)
  1502. {
  1503. at91_add_device_hdmac();
  1504. at91_add_device_rtc();
  1505. at91_add_device_rtt();
  1506. at91_add_device_trng();
  1507. at91_add_device_watchdog();
  1508. at91_add_device_tc();
  1509. return 0;
  1510. }
  1511. arch_initcall(at91_add_standard_devices);