at91sam9g45_devices.c 44 KB

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