at91sam9g45_devices.c 44 KB

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