at91sam9g45_devices.c 44 KB

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