at91sam9260_devices.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. /*
  2. * arch/arm/mach-at91/at91sam9260_devices.c
  3. *
  4. * Copyright (C) 2006 Atmel
  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/platform_device.h>
  16. #include <linux/i2c-gpio.h>
  17. #include <mach/board.h>
  18. #include <mach/gpio.h>
  19. #include <mach/cpu.h>
  20. #include <mach/at91sam9260.h>
  21. #include <mach/at91sam9260_matrix.h>
  22. #include <mach/at91sam9_smc.h>
  23. #include "generic.h"
  24. /* --------------------------------------------------------------------
  25. * USB Host
  26. * -------------------------------------------------------------------- */
  27. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  28. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  29. static struct at91_usbh_data usbh_data;
  30. static struct resource usbh_resources[] = {
  31. [0] = {
  32. .start = AT91SAM9260_UHP_BASE,
  33. .end = AT91SAM9260_UHP_BASE + SZ_1M - 1,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. [1] = {
  37. .start = AT91SAM9260_ID_UHP,
  38. .end = AT91SAM9260_ID_UHP,
  39. .flags = IORESOURCE_IRQ,
  40. },
  41. };
  42. static struct platform_device at91_usbh_device = {
  43. .name = "at91_ohci",
  44. .id = -1,
  45. .dev = {
  46. .dma_mask = &ohci_dmamask,
  47. .coherent_dma_mask = DMA_BIT_MASK(32),
  48. .platform_data = &usbh_data,
  49. },
  50. .resource = usbh_resources,
  51. .num_resources = ARRAY_SIZE(usbh_resources),
  52. };
  53. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  54. {
  55. if (!data)
  56. return;
  57. usbh_data = *data;
  58. platform_device_register(&at91_usbh_device);
  59. }
  60. #else
  61. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  62. #endif
  63. /* --------------------------------------------------------------------
  64. * USB Device (Gadget)
  65. * -------------------------------------------------------------------- */
  66. #ifdef CONFIG_USB_GADGET_AT91
  67. static struct at91_udc_data udc_data;
  68. static struct resource udc_resources[] = {
  69. [0] = {
  70. .start = AT91SAM9260_BASE_UDP,
  71. .end = AT91SAM9260_BASE_UDP + SZ_16K - 1,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. [1] = {
  75. .start = AT91SAM9260_ID_UDP,
  76. .end = AT91SAM9260_ID_UDP,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct platform_device at91_udc_device = {
  81. .name = "at91_udc",
  82. .id = -1,
  83. .dev = {
  84. .platform_data = &udc_data,
  85. },
  86. .resource = udc_resources,
  87. .num_resources = ARRAY_SIZE(udc_resources),
  88. };
  89. void __init at91_add_device_udc(struct at91_udc_data *data)
  90. {
  91. if (!data)
  92. return;
  93. if (data->vbus_pin) {
  94. at91_set_gpio_input(data->vbus_pin, 0);
  95. at91_set_deglitch(data->vbus_pin, 1);
  96. }
  97. /* Pullup pin is handled internally by USB device peripheral */
  98. udc_data = *data;
  99. platform_device_register(&at91_udc_device);
  100. }
  101. #else
  102. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  103. #endif
  104. /* --------------------------------------------------------------------
  105. * Ethernet
  106. * -------------------------------------------------------------------- */
  107. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
  108. static u64 eth_dmamask = DMA_BIT_MASK(32);
  109. static struct at91_eth_data eth_data;
  110. static struct resource eth_resources[] = {
  111. [0] = {
  112. .start = AT91SAM9260_BASE_EMAC,
  113. .end = AT91SAM9260_BASE_EMAC + SZ_16K - 1,
  114. .flags = IORESOURCE_MEM,
  115. },
  116. [1] = {
  117. .start = AT91SAM9260_ID_EMAC,
  118. .end = AT91SAM9260_ID_EMAC,
  119. .flags = IORESOURCE_IRQ,
  120. },
  121. };
  122. static struct platform_device at91sam9260_eth_device = {
  123. .name = "macb",
  124. .id = -1,
  125. .dev = {
  126. .dma_mask = &eth_dmamask,
  127. .coherent_dma_mask = DMA_BIT_MASK(32),
  128. .platform_data = &eth_data,
  129. },
  130. .resource = eth_resources,
  131. .num_resources = ARRAY_SIZE(eth_resources),
  132. };
  133. void __init at91_add_device_eth(struct at91_eth_data *data)
  134. {
  135. if (!data)
  136. return;
  137. if (data->phy_irq_pin) {
  138. at91_set_gpio_input(data->phy_irq_pin, 0);
  139. at91_set_deglitch(data->phy_irq_pin, 1);
  140. }
  141. /* Pins used for MII and RMII */
  142. at91_set_A_periph(AT91_PIN_PA19, 0); /* ETXCK_EREFCK */
  143. at91_set_A_periph(AT91_PIN_PA17, 0); /* ERXDV */
  144. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERX0 */
  145. at91_set_A_periph(AT91_PIN_PA15, 0); /* ERX1 */
  146. at91_set_A_periph(AT91_PIN_PA18, 0); /* ERXER */
  147. at91_set_A_periph(AT91_PIN_PA16, 0); /* ETXEN */
  148. at91_set_A_periph(AT91_PIN_PA12, 0); /* ETX0 */
  149. at91_set_A_periph(AT91_PIN_PA13, 0); /* ETX1 */
  150. at91_set_A_periph(AT91_PIN_PA21, 0); /* EMDIO */
  151. at91_set_A_periph(AT91_PIN_PA20, 0); /* EMDC */
  152. if (!data->is_rmii) {
  153. at91_set_B_periph(AT91_PIN_PA28, 0); /* ECRS */
  154. at91_set_B_periph(AT91_PIN_PA29, 0); /* ECOL */
  155. at91_set_B_periph(AT91_PIN_PA25, 0); /* ERX2 */
  156. at91_set_B_periph(AT91_PIN_PA26, 0); /* ERX3 */
  157. at91_set_B_periph(AT91_PIN_PA27, 0); /* ERXCK */
  158. at91_set_B_periph(AT91_PIN_PA23, 0); /* ETX2 */
  159. at91_set_B_periph(AT91_PIN_PA24, 0); /* ETX3 */
  160. at91_set_B_periph(AT91_PIN_PA22, 0); /* ETXER */
  161. }
  162. eth_data = *data;
  163. platform_device_register(&at91sam9260_eth_device);
  164. }
  165. #else
  166. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  167. #endif
  168. /* --------------------------------------------------------------------
  169. * MMC / SD
  170. * -------------------------------------------------------------------- */
  171. #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
  172. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  173. static struct at91_mmc_data mmc_data;
  174. static struct resource mmc_resources[] = {
  175. [0] = {
  176. .start = AT91SAM9260_BASE_MCI,
  177. .end = AT91SAM9260_BASE_MCI + SZ_16K - 1,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. [1] = {
  181. .start = AT91SAM9260_ID_MCI,
  182. .end = AT91SAM9260_ID_MCI,
  183. .flags = IORESOURCE_IRQ,
  184. },
  185. };
  186. static struct platform_device at91sam9260_mmc_device = {
  187. .name = "at91_mci",
  188. .id = -1,
  189. .dev = {
  190. .dma_mask = &mmc_dmamask,
  191. .coherent_dma_mask = DMA_BIT_MASK(32),
  192. .platform_data = &mmc_data,
  193. },
  194. .resource = mmc_resources,
  195. .num_resources = ARRAY_SIZE(mmc_resources),
  196. };
  197. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
  198. {
  199. if (!data)
  200. return;
  201. /* input/irq */
  202. if (data->det_pin) {
  203. at91_set_gpio_input(data->det_pin, 1);
  204. at91_set_deglitch(data->det_pin, 1);
  205. }
  206. if (data->wp_pin)
  207. at91_set_gpio_input(data->wp_pin, 1);
  208. if (data->vcc_pin)
  209. at91_set_gpio_output(data->vcc_pin, 0);
  210. /* CLK */
  211. at91_set_A_periph(AT91_PIN_PA8, 0);
  212. if (data->slot_b) {
  213. /* CMD */
  214. at91_set_B_periph(AT91_PIN_PA1, 1);
  215. /* DAT0, maybe DAT1..DAT3 */
  216. at91_set_B_periph(AT91_PIN_PA0, 1);
  217. if (data->wire4) {
  218. at91_set_B_periph(AT91_PIN_PA5, 1);
  219. at91_set_B_periph(AT91_PIN_PA4, 1);
  220. at91_set_B_periph(AT91_PIN_PA3, 1);
  221. }
  222. } else {
  223. /* CMD */
  224. at91_set_A_periph(AT91_PIN_PA7, 1);
  225. /* DAT0, maybe DAT1..DAT3 */
  226. at91_set_A_periph(AT91_PIN_PA6, 1);
  227. if (data->wire4) {
  228. at91_set_A_periph(AT91_PIN_PA9, 1);
  229. at91_set_A_periph(AT91_PIN_PA10, 1);
  230. at91_set_A_periph(AT91_PIN_PA11, 1);
  231. }
  232. }
  233. mmc_data = *data;
  234. platform_device_register(&at91sam9260_mmc_device);
  235. }
  236. #else
  237. void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
  238. #endif
  239. /* --------------------------------------------------------------------
  240. * MMC / SD Slot for Atmel MCI Driver
  241. * -------------------------------------------------------------------- */
  242. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  243. static u64 mmc_dmamask = DMA_BIT_MASK(32);
  244. static struct mci_platform_data mmc_data;
  245. static struct resource mmc_resources[] = {
  246. [0] = {
  247. .start = AT91SAM9260_BASE_MCI,
  248. .end = AT91SAM9260_BASE_MCI + SZ_16K - 1,
  249. .flags = IORESOURCE_MEM,
  250. },
  251. [1] = {
  252. .start = AT91SAM9260_ID_MCI,
  253. .end = AT91SAM9260_ID_MCI,
  254. .flags = IORESOURCE_IRQ,
  255. },
  256. };
  257. static struct platform_device at91sam9260_mmc_device = {
  258. .name = "atmel_mci",
  259. .id = -1,
  260. .dev = {
  261. .dma_mask = &mmc_dmamask,
  262. .coherent_dma_mask = DMA_BIT_MASK(32),
  263. .platform_data = &mmc_data,
  264. },
  265. .resource = mmc_resources,
  266. .num_resources = ARRAY_SIZE(mmc_resources),
  267. };
  268. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
  269. {
  270. unsigned int i;
  271. unsigned int slot_count = 0;
  272. if (!data)
  273. return;
  274. for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) {
  275. if (data->slot[i].bus_width) {
  276. /* input/irq */
  277. if (data->slot[i].detect_pin) {
  278. at91_set_gpio_input(data->slot[i].detect_pin, 1);
  279. at91_set_deglitch(data->slot[i].detect_pin, 1);
  280. }
  281. if (data->slot[i].wp_pin)
  282. at91_set_gpio_input(data->slot[i].wp_pin, 1);
  283. switch (i) {
  284. case 0:
  285. /* CMD */
  286. at91_set_A_periph(AT91_PIN_PA7, 1);
  287. /* DAT0, maybe DAT1..DAT3 */
  288. at91_set_A_periph(AT91_PIN_PA6, 1);
  289. if (data->slot[i].bus_width == 4) {
  290. at91_set_A_periph(AT91_PIN_PA9, 1);
  291. at91_set_A_periph(AT91_PIN_PA10, 1);
  292. at91_set_A_periph(AT91_PIN_PA11, 1);
  293. }
  294. slot_count++;
  295. break;
  296. case 1:
  297. /* CMD */
  298. at91_set_B_periph(AT91_PIN_PA1, 1);
  299. /* DAT0, maybe DAT1..DAT3 */
  300. at91_set_B_periph(AT91_PIN_PA0, 1);
  301. if (data->slot[i].bus_width == 4) {
  302. at91_set_B_periph(AT91_PIN_PA5, 1);
  303. at91_set_B_periph(AT91_PIN_PA4, 1);
  304. at91_set_B_periph(AT91_PIN_PA3, 1);
  305. }
  306. slot_count++;
  307. break;
  308. default:
  309. printk(KERN_ERR
  310. "AT91: SD/MMC slot %d not available\n", i);
  311. break;
  312. }
  313. }
  314. }
  315. if (slot_count) {
  316. /* CLK */
  317. at91_set_A_periph(AT91_PIN_PA8, 0);
  318. mmc_data = *data;
  319. platform_device_register(&at91sam9260_mmc_device);
  320. }
  321. }
  322. #else
  323. void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
  324. #endif
  325. /* --------------------------------------------------------------------
  326. * NAND / SmartMedia
  327. * -------------------------------------------------------------------- */
  328. #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
  329. static struct atmel_nand_data nand_data;
  330. #define NAND_BASE AT91_CHIPSELECT_3
  331. static struct resource nand_resources[] = {
  332. [0] = {
  333. .start = NAND_BASE,
  334. .end = NAND_BASE + SZ_256M - 1,
  335. .flags = IORESOURCE_MEM,
  336. },
  337. [1] = {
  338. .start = AT91_BASE_SYS + AT91_ECC,
  339. .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
  340. .flags = IORESOURCE_MEM,
  341. }
  342. };
  343. static struct platform_device at91sam9260_nand_device = {
  344. .name = "atmel_nand",
  345. .id = -1,
  346. .dev = {
  347. .platform_data = &nand_data,
  348. },
  349. .resource = nand_resources,
  350. .num_resources = ARRAY_SIZE(nand_resources),
  351. };
  352. void __init at91_add_device_nand(struct atmel_nand_data *data)
  353. {
  354. unsigned long csa;
  355. if (!data)
  356. return;
  357. csa = at91_sys_read(AT91_MATRIX_EBICSA);
  358. at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
  359. /* enable pin */
  360. if (data->enable_pin)
  361. at91_set_gpio_output(data->enable_pin, 1);
  362. /* ready/busy pin */
  363. if (data->rdy_pin)
  364. at91_set_gpio_input(data->rdy_pin, 1);
  365. /* card detect pin */
  366. if (data->det_pin)
  367. at91_set_gpio_input(data->det_pin, 1);
  368. nand_data = *data;
  369. platform_device_register(&at91sam9260_nand_device);
  370. }
  371. #else
  372. void __init at91_add_device_nand(struct atmel_nand_data *data) {}
  373. #endif
  374. /* --------------------------------------------------------------------
  375. * TWI (i2c)
  376. * -------------------------------------------------------------------- */
  377. /*
  378. * Prefer the GPIO code since the TWI controller isn't robust
  379. * (gets overruns and underruns under load) and can only issue
  380. * repeated STARTs in one scenario (the driver doesn't yet handle them).
  381. */
  382. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  383. static struct i2c_gpio_platform_data pdata = {
  384. .sda_pin = AT91_PIN_PA23,
  385. .sda_is_open_drain = 1,
  386. .scl_pin = AT91_PIN_PA24,
  387. .scl_is_open_drain = 1,
  388. .udelay = 2, /* ~100 kHz */
  389. };
  390. static struct platform_device at91sam9260_twi_device = {
  391. .name = "i2c-gpio",
  392. .id = -1,
  393. .dev.platform_data = &pdata,
  394. };
  395. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  396. {
  397. at91_set_GPIO_periph(AT91_PIN_PA23, 1); /* TWD (SDA) */
  398. at91_set_multi_drive(AT91_PIN_PA23, 1);
  399. at91_set_GPIO_periph(AT91_PIN_PA24, 1); /* TWCK (SCL) */
  400. at91_set_multi_drive(AT91_PIN_PA24, 1);
  401. i2c_register_board_info(0, devices, nr_devices);
  402. platform_device_register(&at91sam9260_twi_device);
  403. }
  404. #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  405. static struct resource twi_resources[] = {
  406. [0] = {
  407. .start = AT91SAM9260_BASE_TWI,
  408. .end = AT91SAM9260_BASE_TWI + SZ_16K - 1,
  409. .flags = IORESOURCE_MEM,
  410. },
  411. [1] = {
  412. .start = AT91SAM9260_ID_TWI,
  413. .end = AT91SAM9260_ID_TWI,
  414. .flags = IORESOURCE_IRQ,
  415. },
  416. };
  417. static struct platform_device at91sam9260_twi_device = {
  418. .name = "at91_i2c",
  419. .id = -1,
  420. .resource = twi_resources,
  421. .num_resources = ARRAY_SIZE(twi_resources),
  422. };
  423. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
  424. {
  425. /* pins used for TWI interface */
  426. at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */
  427. at91_set_multi_drive(AT91_PIN_PA23, 1);
  428. at91_set_A_periph(AT91_PIN_PA24, 0); /* TWCK */
  429. at91_set_multi_drive(AT91_PIN_PA24, 1);
  430. i2c_register_board_info(0, devices, nr_devices);
  431. platform_device_register(&at91sam9260_twi_device);
  432. }
  433. #else
  434. void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
  435. #endif
  436. /* --------------------------------------------------------------------
  437. * SPI
  438. * -------------------------------------------------------------------- */
  439. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  440. static u64 spi_dmamask = DMA_BIT_MASK(32);
  441. static struct resource spi0_resources[] = {
  442. [0] = {
  443. .start = AT91SAM9260_BASE_SPI0,
  444. .end = AT91SAM9260_BASE_SPI0 + SZ_16K - 1,
  445. .flags = IORESOURCE_MEM,
  446. },
  447. [1] = {
  448. .start = AT91SAM9260_ID_SPI0,
  449. .end = AT91SAM9260_ID_SPI0,
  450. .flags = IORESOURCE_IRQ,
  451. },
  452. };
  453. static struct platform_device at91sam9260_spi0_device = {
  454. .name = "atmel_spi",
  455. .id = 0,
  456. .dev = {
  457. .dma_mask = &spi_dmamask,
  458. .coherent_dma_mask = DMA_BIT_MASK(32),
  459. },
  460. .resource = spi0_resources,
  461. .num_resources = ARRAY_SIZE(spi0_resources),
  462. };
  463. static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PC11, AT91_PIN_PC16, AT91_PIN_PC17 };
  464. static struct resource spi1_resources[] = {
  465. [0] = {
  466. .start = AT91SAM9260_BASE_SPI1,
  467. .end = AT91SAM9260_BASE_SPI1 + SZ_16K - 1,
  468. .flags = IORESOURCE_MEM,
  469. },
  470. [1] = {
  471. .start = AT91SAM9260_ID_SPI1,
  472. .end = AT91SAM9260_ID_SPI1,
  473. .flags = IORESOURCE_IRQ,
  474. },
  475. };
  476. static struct platform_device at91sam9260_spi1_device = {
  477. .name = "atmel_spi",
  478. .id = 1,
  479. .dev = {
  480. .dma_mask = &spi_dmamask,
  481. .coherent_dma_mask = DMA_BIT_MASK(32),
  482. },
  483. .resource = spi1_resources,
  484. .num_resources = ARRAY_SIZE(spi1_resources),
  485. };
  486. static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PC5, AT91_PIN_PC4, AT91_PIN_PC3 };
  487. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  488. {
  489. int i;
  490. unsigned long cs_pin;
  491. short enable_spi0 = 0;
  492. short enable_spi1 = 0;
  493. /* Choose SPI chip-selects */
  494. for (i = 0; i < nr_devices; i++) {
  495. if (devices[i].controller_data)
  496. cs_pin = (unsigned long) devices[i].controller_data;
  497. else if (devices[i].bus_num == 0)
  498. cs_pin = spi0_standard_cs[devices[i].chip_select];
  499. else
  500. cs_pin = spi1_standard_cs[devices[i].chip_select];
  501. if (devices[i].bus_num == 0)
  502. enable_spi0 = 1;
  503. else
  504. enable_spi1 = 1;
  505. /* enable chip-select pin */
  506. at91_set_gpio_output(cs_pin, 1);
  507. /* pass chip-select pin to driver */
  508. devices[i].controller_data = (void *) cs_pin;
  509. }
  510. spi_register_board_info(devices, nr_devices);
  511. /* Configure SPI bus(es) */
  512. if (enable_spi0) {
  513. at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
  514. at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
  515. at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI1_SPCK */
  516. at91_clock_associate("spi0_clk", &at91sam9260_spi0_device.dev, "spi_clk");
  517. platform_device_register(&at91sam9260_spi0_device);
  518. }
  519. if (enable_spi1) {
  520. at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI1_MISO */
  521. at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI1_MOSI */
  522. at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI1_SPCK */
  523. at91_clock_associate("spi1_clk", &at91sam9260_spi1_device.dev, "spi_clk");
  524. platform_device_register(&at91sam9260_spi1_device);
  525. }
  526. }
  527. #else
  528. void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
  529. #endif
  530. /* --------------------------------------------------------------------
  531. * Timer/Counter blocks
  532. * -------------------------------------------------------------------- */
  533. #ifdef CONFIG_ATMEL_TCLIB
  534. static struct resource tcb0_resources[] = {
  535. [0] = {
  536. .start = AT91SAM9260_BASE_TCB0,
  537. .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1,
  538. .flags = IORESOURCE_MEM,
  539. },
  540. [1] = {
  541. .start = AT91SAM9260_ID_TC0,
  542. .end = AT91SAM9260_ID_TC0,
  543. .flags = IORESOURCE_IRQ,
  544. },
  545. [2] = {
  546. .start = AT91SAM9260_ID_TC1,
  547. .end = AT91SAM9260_ID_TC1,
  548. .flags = IORESOURCE_IRQ,
  549. },
  550. [3] = {
  551. .start = AT91SAM9260_ID_TC2,
  552. .end = AT91SAM9260_ID_TC2,
  553. .flags = IORESOURCE_IRQ,
  554. },
  555. };
  556. static struct platform_device at91sam9260_tcb0_device = {
  557. .name = "atmel_tcb",
  558. .id = 0,
  559. .resource = tcb0_resources,
  560. .num_resources = ARRAY_SIZE(tcb0_resources),
  561. };
  562. static struct resource tcb1_resources[] = {
  563. [0] = {
  564. .start = AT91SAM9260_BASE_TCB1,
  565. .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1,
  566. .flags = IORESOURCE_MEM,
  567. },
  568. [1] = {
  569. .start = AT91SAM9260_ID_TC3,
  570. .end = AT91SAM9260_ID_TC3,
  571. .flags = IORESOURCE_IRQ,
  572. },
  573. [2] = {
  574. .start = AT91SAM9260_ID_TC4,
  575. .end = AT91SAM9260_ID_TC4,
  576. .flags = IORESOURCE_IRQ,
  577. },
  578. [3] = {
  579. .start = AT91SAM9260_ID_TC5,
  580. .end = AT91SAM9260_ID_TC5,
  581. .flags = IORESOURCE_IRQ,
  582. },
  583. };
  584. static struct platform_device at91sam9260_tcb1_device = {
  585. .name = "atmel_tcb",
  586. .id = 1,
  587. .resource = tcb1_resources,
  588. .num_resources = ARRAY_SIZE(tcb1_resources),
  589. };
  590. static void __init at91_add_device_tc(void)
  591. {
  592. /* this chip has a separate clock and irq for each TC channel */
  593. at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk");
  594. at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk");
  595. at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");
  596. platform_device_register(&at91sam9260_tcb0_device);
  597. at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk");
  598. at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk");
  599. at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");
  600. platform_device_register(&at91sam9260_tcb1_device);
  601. }
  602. #else
  603. static void __init at91_add_device_tc(void) { }
  604. #endif
  605. /* --------------------------------------------------------------------
  606. * RTT
  607. * -------------------------------------------------------------------- */
  608. static struct resource rtt_resources[] = {
  609. {
  610. .start = AT91_BASE_SYS + AT91_RTT,
  611. .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
  612. .flags = IORESOURCE_MEM,
  613. }
  614. };
  615. static struct platform_device at91sam9260_rtt_device = {
  616. .name = "at91_rtt",
  617. .id = 0,
  618. .resource = rtt_resources,
  619. .num_resources = ARRAY_SIZE(rtt_resources),
  620. };
  621. static void __init at91_add_device_rtt(void)
  622. {
  623. platform_device_register(&at91sam9260_rtt_device);
  624. }
  625. /* --------------------------------------------------------------------
  626. * Watchdog
  627. * -------------------------------------------------------------------- */
  628. #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
  629. static struct platform_device at91sam9260_wdt_device = {
  630. .name = "at91_wdt",
  631. .id = -1,
  632. .num_resources = 0,
  633. };
  634. static void __init at91_add_device_watchdog(void)
  635. {
  636. platform_device_register(&at91sam9260_wdt_device);
  637. }
  638. #else
  639. static void __init at91_add_device_watchdog(void) {}
  640. #endif
  641. /* --------------------------------------------------------------------
  642. * SSC -- Synchronous Serial Controller
  643. * -------------------------------------------------------------------- */
  644. #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
  645. static u64 ssc_dmamask = DMA_BIT_MASK(32);
  646. static struct resource ssc_resources[] = {
  647. [0] = {
  648. .start = AT91SAM9260_BASE_SSC,
  649. .end = AT91SAM9260_BASE_SSC + SZ_16K - 1,
  650. .flags = IORESOURCE_MEM,
  651. },
  652. [1] = {
  653. .start = AT91SAM9260_ID_SSC,
  654. .end = AT91SAM9260_ID_SSC,
  655. .flags = IORESOURCE_IRQ,
  656. },
  657. };
  658. static struct platform_device at91sam9260_ssc_device = {
  659. .name = "ssc",
  660. .id = 0,
  661. .dev = {
  662. .dma_mask = &ssc_dmamask,
  663. .coherent_dma_mask = DMA_BIT_MASK(32),
  664. },
  665. .resource = ssc_resources,
  666. .num_resources = ARRAY_SIZE(ssc_resources),
  667. };
  668. static inline void configure_ssc_pins(unsigned pins)
  669. {
  670. if (pins & ATMEL_SSC_TF)
  671. at91_set_A_periph(AT91_PIN_PB17, 1);
  672. if (pins & ATMEL_SSC_TK)
  673. at91_set_A_periph(AT91_PIN_PB16, 1);
  674. if (pins & ATMEL_SSC_TD)
  675. at91_set_A_periph(AT91_PIN_PB18, 1);
  676. if (pins & ATMEL_SSC_RD)
  677. at91_set_A_periph(AT91_PIN_PB19, 1);
  678. if (pins & ATMEL_SSC_RK)
  679. at91_set_A_periph(AT91_PIN_PB20, 1);
  680. if (pins & ATMEL_SSC_RF)
  681. at91_set_A_periph(AT91_PIN_PB21, 1);
  682. }
  683. /*
  684. * SSC controllers are accessed through library code, instead of any
  685. * kind of all-singing/all-dancing driver. For example one could be
  686. * used by a particular I2S audio codec's driver, while another one
  687. * on the same system might be used by a custom data capture driver.
  688. */
  689. void __init at91_add_device_ssc(unsigned id, unsigned pins)
  690. {
  691. struct platform_device *pdev;
  692. /*
  693. * NOTE: caller is responsible for passing information matching
  694. * "pins" to whatever will be using each particular controller.
  695. */
  696. switch (id) {
  697. case AT91SAM9260_ID_SSC:
  698. pdev = &at91sam9260_ssc_device;
  699. configure_ssc_pins(pins);
  700. at91_clock_associate("ssc_clk", &pdev->dev, "pclk");
  701. break;
  702. default:
  703. return;
  704. }
  705. platform_device_register(pdev);
  706. }
  707. #else
  708. void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
  709. #endif
  710. /* --------------------------------------------------------------------
  711. * UART
  712. * -------------------------------------------------------------------- */
  713. #if defined(CONFIG_SERIAL_ATMEL)
  714. static struct resource dbgu_resources[] = {
  715. [0] = {
  716. .start = AT91_VA_BASE_SYS + AT91_DBGU,
  717. .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
  718. .flags = IORESOURCE_MEM,
  719. },
  720. [1] = {
  721. .start = AT91_ID_SYS,
  722. .end = AT91_ID_SYS,
  723. .flags = IORESOURCE_IRQ,
  724. },
  725. };
  726. static struct atmel_uart_data dbgu_data = {
  727. .use_dma_tx = 0,
  728. .use_dma_rx = 0, /* DBGU not capable of receive DMA */
  729. .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
  730. };
  731. static u64 dbgu_dmamask = DMA_BIT_MASK(32);
  732. static struct platform_device at91sam9260_dbgu_device = {
  733. .name = "atmel_usart",
  734. .id = 0,
  735. .dev = {
  736. .dma_mask = &dbgu_dmamask,
  737. .coherent_dma_mask = DMA_BIT_MASK(32),
  738. .platform_data = &dbgu_data,
  739. },
  740. .resource = dbgu_resources,
  741. .num_resources = ARRAY_SIZE(dbgu_resources),
  742. };
  743. static inline void configure_dbgu_pins(void)
  744. {
  745. at91_set_A_periph(AT91_PIN_PB14, 0); /* DRXD */
  746. at91_set_A_periph(AT91_PIN_PB15, 1); /* DTXD */
  747. }
  748. static struct resource uart0_resources[] = {
  749. [0] = {
  750. .start = AT91SAM9260_BASE_US0,
  751. .end = AT91SAM9260_BASE_US0 + SZ_16K - 1,
  752. .flags = IORESOURCE_MEM,
  753. },
  754. [1] = {
  755. .start = AT91SAM9260_ID_US0,
  756. .end = AT91SAM9260_ID_US0,
  757. .flags = IORESOURCE_IRQ,
  758. },
  759. };
  760. static struct atmel_uart_data uart0_data = {
  761. .use_dma_tx = 1,
  762. .use_dma_rx = 1,
  763. };
  764. static u64 uart0_dmamask = DMA_BIT_MASK(32);
  765. static struct platform_device at91sam9260_uart0_device = {
  766. .name = "atmel_usart",
  767. .id = 1,
  768. .dev = {
  769. .dma_mask = &uart0_dmamask,
  770. .coherent_dma_mask = DMA_BIT_MASK(32),
  771. .platform_data = &uart0_data,
  772. },
  773. .resource = uart0_resources,
  774. .num_resources = ARRAY_SIZE(uart0_resources),
  775. };
  776. static inline void configure_usart0_pins(unsigned pins)
  777. {
  778. at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */
  779. at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD0 */
  780. if (pins & ATMEL_UART_RTS)
  781. at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS0 */
  782. if (pins & ATMEL_UART_CTS)
  783. at91_set_A_periph(AT91_PIN_PB27, 0); /* CTS0 */
  784. if (pins & ATMEL_UART_DTR)
  785. at91_set_A_periph(AT91_PIN_PB24, 0); /* DTR0 */
  786. if (pins & ATMEL_UART_DSR)
  787. at91_set_A_periph(AT91_PIN_PB22, 0); /* DSR0 */
  788. if (pins & ATMEL_UART_DCD)
  789. at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD0 */
  790. if (pins & ATMEL_UART_RI)
  791. at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */
  792. }
  793. static struct resource uart1_resources[] = {
  794. [0] = {
  795. .start = AT91SAM9260_BASE_US1,
  796. .end = AT91SAM9260_BASE_US1 + SZ_16K - 1,
  797. .flags = IORESOURCE_MEM,
  798. },
  799. [1] = {
  800. .start = AT91SAM9260_ID_US1,
  801. .end = AT91SAM9260_ID_US1,
  802. .flags = IORESOURCE_IRQ,
  803. },
  804. };
  805. static struct atmel_uart_data uart1_data = {
  806. .use_dma_tx = 1,
  807. .use_dma_rx = 1,
  808. };
  809. static u64 uart1_dmamask = DMA_BIT_MASK(32);
  810. static struct platform_device at91sam9260_uart1_device = {
  811. .name = "atmel_usart",
  812. .id = 2,
  813. .dev = {
  814. .dma_mask = &uart1_dmamask,
  815. .coherent_dma_mask = DMA_BIT_MASK(32),
  816. .platform_data = &uart1_data,
  817. },
  818. .resource = uart1_resources,
  819. .num_resources = ARRAY_SIZE(uart1_resources),
  820. };
  821. static inline void configure_usart1_pins(unsigned pins)
  822. {
  823. at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */
  824. at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD1 */
  825. if (pins & ATMEL_UART_RTS)
  826. at91_set_A_periph(AT91_PIN_PB28, 0); /* RTS1 */
  827. if (pins & ATMEL_UART_CTS)
  828. at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */
  829. }
  830. static struct resource uart2_resources[] = {
  831. [0] = {
  832. .start = AT91SAM9260_BASE_US2,
  833. .end = AT91SAM9260_BASE_US2 + SZ_16K - 1,
  834. .flags = IORESOURCE_MEM,
  835. },
  836. [1] = {
  837. .start = AT91SAM9260_ID_US2,
  838. .end = AT91SAM9260_ID_US2,
  839. .flags = IORESOURCE_IRQ,
  840. },
  841. };
  842. static struct atmel_uart_data uart2_data = {
  843. .use_dma_tx = 1,
  844. .use_dma_rx = 1,
  845. };
  846. static u64 uart2_dmamask = DMA_BIT_MASK(32);
  847. static struct platform_device at91sam9260_uart2_device = {
  848. .name = "atmel_usart",
  849. .id = 3,
  850. .dev = {
  851. .dma_mask = &uart2_dmamask,
  852. .coherent_dma_mask = DMA_BIT_MASK(32),
  853. .platform_data = &uart2_data,
  854. },
  855. .resource = uart2_resources,
  856. .num_resources = ARRAY_SIZE(uart2_resources),
  857. };
  858. static inline void configure_usart2_pins(unsigned pins)
  859. {
  860. at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */
  861. at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD2 */
  862. if (pins & ATMEL_UART_RTS)
  863. at91_set_A_periph(AT91_PIN_PA4, 0); /* RTS2 */
  864. if (pins & ATMEL_UART_CTS)
  865. at91_set_A_periph(AT91_PIN_PA5, 0); /* CTS2 */
  866. }
  867. static struct resource uart3_resources[] = {
  868. [0] = {
  869. .start = AT91SAM9260_BASE_US3,
  870. .end = AT91SAM9260_BASE_US3 + SZ_16K - 1,
  871. .flags = IORESOURCE_MEM,
  872. },
  873. [1] = {
  874. .start = AT91SAM9260_ID_US3,
  875. .end = AT91SAM9260_ID_US3,
  876. .flags = IORESOURCE_IRQ,
  877. },
  878. };
  879. static struct atmel_uart_data uart3_data = {
  880. .use_dma_tx = 1,
  881. .use_dma_rx = 1,
  882. };
  883. static u64 uart3_dmamask = DMA_BIT_MASK(32);
  884. static struct platform_device at91sam9260_uart3_device = {
  885. .name = "atmel_usart",
  886. .id = 4,
  887. .dev = {
  888. .dma_mask = &uart3_dmamask,
  889. .coherent_dma_mask = DMA_BIT_MASK(32),
  890. .platform_data = &uart3_data,
  891. },
  892. .resource = uart3_resources,
  893. .num_resources = ARRAY_SIZE(uart3_resources),
  894. };
  895. static inline void configure_usart3_pins(unsigned pins)
  896. {
  897. at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */
  898. at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD3 */
  899. if (pins & ATMEL_UART_RTS)
  900. at91_set_B_periph(AT91_PIN_PC8, 0); /* RTS3 */
  901. if (pins & ATMEL_UART_CTS)
  902. at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS3 */
  903. }
  904. static struct resource uart4_resources[] = {
  905. [0] = {
  906. .start = AT91SAM9260_BASE_US4,
  907. .end = AT91SAM9260_BASE_US4 + SZ_16K - 1,
  908. .flags = IORESOURCE_MEM,
  909. },
  910. [1] = {
  911. .start = AT91SAM9260_ID_US4,
  912. .end = AT91SAM9260_ID_US4,
  913. .flags = IORESOURCE_IRQ,
  914. },
  915. };
  916. static struct atmel_uart_data uart4_data = {
  917. .use_dma_tx = 1,
  918. .use_dma_rx = 1,
  919. };
  920. static u64 uart4_dmamask = DMA_BIT_MASK(32);
  921. static struct platform_device at91sam9260_uart4_device = {
  922. .name = "atmel_usart",
  923. .id = 5,
  924. .dev = {
  925. .dma_mask = &uart4_dmamask,
  926. .coherent_dma_mask = DMA_BIT_MASK(32),
  927. .platform_data = &uart4_data,
  928. },
  929. .resource = uart4_resources,
  930. .num_resources = ARRAY_SIZE(uart4_resources),
  931. };
  932. static inline void configure_usart4_pins(void)
  933. {
  934. at91_set_B_periph(AT91_PIN_PA31, 1); /* TXD4 */
  935. at91_set_B_periph(AT91_PIN_PA30, 0); /* RXD4 */
  936. }
  937. static struct resource uart5_resources[] = {
  938. [0] = {
  939. .start = AT91SAM9260_BASE_US5,
  940. .end = AT91SAM9260_BASE_US5 + SZ_16K - 1,
  941. .flags = IORESOURCE_MEM,
  942. },
  943. [1] = {
  944. .start = AT91SAM9260_ID_US5,
  945. .end = AT91SAM9260_ID_US5,
  946. .flags = IORESOURCE_IRQ,
  947. },
  948. };
  949. static struct atmel_uart_data uart5_data = {
  950. .use_dma_tx = 1,
  951. .use_dma_rx = 1,
  952. };
  953. static u64 uart5_dmamask = DMA_BIT_MASK(32);
  954. static struct platform_device at91sam9260_uart5_device = {
  955. .name = "atmel_usart",
  956. .id = 6,
  957. .dev = {
  958. .dma_mask = &uart5_dmamask,
  959. .coherent_dma_mask = DMA_BIT_MASK(32),
  960. .platform_data = &uart5_data,
  961. },
  962. .resource = uart5_resources,
  963. .num_resources = ARRAY_SIZE(uart5_resources),
  964. };
  965. static inline void configure_usart5_pins(void)
  966. {
  967. at91_set_A_periph(AT91_PIN_PB12, 1); /* TXD5 */
  968. at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */
  969. }
  970. static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
  971. struct platform_device *atmel_default_console_device; /* the serial console device */
  972. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
  973. {
  974. struct platform_device *pdev;
  975. switch (id) {
  976. case 0: /* DBGU */
  977. pdev = &at91sam9260_dbgu_device;
  978. configure_dbgu_pins();
  979. at91_clock_associate("mck", &pdev->dev, "usart");
  980. break;
  981. case AT91SAM9260_ID_US0:
  982. pdev = &at91sam9260_uart0_device;
  983. configure_usart0_pins(pins);
  984. at91_clock_associate("usart0_clk", &pdev->dev, "usart");
  985. break;
  986. case AT91SAM9260_ID_US1:
  987. pdev = &at91sam9260_uart1_device;
  988. configure_usart1_pins(pins);
  989. at91_clock_associate("usart1_clk", &pdev->dev, "usart");
  990. break;
  991. case AT91SAM9260_ID_US2:
  992. pdev = &at91sam9260_uart2_device;
  993. configure_usart2_pins(pins);
  994. at91_clock_associate("usart2_clk", &pdev->dev, "usart");
  995. break;
  996. case AT91SAM9260_ID_US3:
  997. pdev = &at91sam9260_uart3_device;
  998. configure_usart3_pins(pins);
  999. at91_clock_associate("usart3_clk", &pdev->dev, "usart");
  1000. break;
  1001. case AT91SAM9260_ID_US4:
  1002. pdev = &at91sam9260_uart4_device;
  1003. configure_usart4_pins();
  1004. at91_clock_associate("usart4_clk", &pdev->dev, "usart");
  1005. break;
  1006. case AT91SAM9260_ID_US5:
  1007. pdev = &at91sam9260_uart5_device;
  1008. configure_usart5_pins();
  1009. at91_clock_associate("usart5_clk", &pdev->dev, "usart");
  1010. break;
  1011. default:
  1012. return;
  1013. }
  1014. pdev->id = portnr; /* update to mapped ID */
  1015. if (portnr < ATMEL_MAX_UART)
  1016. at91_uarts[portnr] = pdev;
  1017. }
  1018. void __init at91_set_serial_console(unsigned portnr)
  1019. {
  1020. if (portnr < ATMEL_MAX_UART)
  1021. atmel_default_console_device = at91_uarts[portnr];
  1022. }
  1023. void __init at91_add_device_serial(void)
  1024. {
  1025. int i;
  1026. for (i = 0; i < ATMEL_MAX_UART; i++) {
  1027. if (at91_uarts[i])
  1028. platform_device_register(at91_uarts[i]);
  1029. }
  1030. if (!atmel_default_console_device)
  1031. printk(KERN_INFO "AT91: No default serial console defined.\n");
  1032. }
  1033. #else
  1034. void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
  1035. void __init at91_set_serial_console(unsigned portnr) {}
  1036. void __init at91_add_device_serial(void) {}
  1037. #endif
  1038. /* --------------------------------------------------------------------
  1039. * CF/IDE
  1040. * -------------------------------------------------------------------- */
  1041. #if defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE) || \
  1042. defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
  1043. defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  1044. static struct at91_cf_data cf0_data;
  1045. static struct resource cf0_resources[] = {
  1046. [0] = {
  1047. .start = AT91_CHIPSELECT_4,
  1048. .end = AT91_CHIPSELECT_4 + SZ_256M - 1,
  1049. .flags = IORESOURCE_MEM,
  1050. }
  1051. };
  1052. static struct platform_device cf0_device = {
  1053. .id = 0,
  1054. .dev = {
  1055. .platform_data = &cf0_data,
  1056. },
  1057. .resource = cf0_resources,
  1058. .num_resources = ARRAY_SIZE(cf0_resources),
  1059. };
  1060. static struct at91_cf_data cf1_data;
  1061. static struct resource cf1_resources[] = {
  1062. [0] = {
  1063. .start = AT91_CHIPSELECT_5,
  1064. .end = AT91_CHIPSELECT_5 + SZ_256M - 1,
  1065. .flags = IORESOURCE_MEM,
  1066. }
  1067. };
  1068. static struct platform_device cf1_device = {
  1069. .id = 1,
  1070. .dev = {
  1071. .platform_data = &cf1_data,
  1072. },
  1073. .resource = cf1_resources,
  1074. .num_resources = ARRAY_SIZE(cf1_resources),
  1075. };
  1076. void __init at91_add_device_cf(struct at91_cf_data *data)
  1077. {
  1078. struct platform_device *pdev;
  1079. unsigned long csa;
  1080. if (!data)
  1081. return;
  1082. csa = at91_sys_read(AT91_MATRIX_EBICSA);
  1083. switch (data->chipselect) {
  1084. case 4:
  1085. at91_set_multi_drive(AT91_PIN_PC8, 0);
  1086. at91_set_A_periph(AT91_PIN_PC8, 0);
  1087. csa |= AT91_MATRIX_CS4A_SMC_CF1;
  1088. cf0_data = *data;
  1089. pdev = &cf0_device;
  1090. break;
  1091. case 5:
  1092. at91_set_multi_drive(AT91_PIN_PC9, 0);
  1093. at91_set_A_periph(AT91_PIN_PC9, 0);
  1094. csa |= AT91_MATRIX_CS5A_SMC_CF2;
  1095. cf1_data = *data;
  1096. pdev = &cf1_device;
  1097. break;
  1098. default:
  1099. printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
  1100. data->chipselect);
  1101. return;
  1102. }
  1103. at91_sys_write(AT91_MATRIX_EBICSA, csa);
  1104. if (data->rst_pin) {
  1105. at91_set_multi_drive(data->rst_pin, 0);
  1106. at91_set_gpio_output(data->rst_pin, 1);
  1107. }
  1108. if (data->irq_pin) {
  1109. at91_set_gpio_input(data->irq_pin, 0);
  1110. at91_set_deglitch(data->irq_pin, 1);
  1111. }
  1112. if (data->det_pin) {
  1113. at91_set_gpio_input(data->det_pin, 0);
  1114. at91_set_deglitch(data->det_pin, 1);
  1115. }
  1116. at91_set_B_periph(AT91_PIN_PC6, 0); /* CFCE1 */
  1117. at91_set_B_periph(AT91_PIN_PC7, 0); /* CFCE2 */
  1118. at91_set_A_periph(AT91_PIN_PC10, 0); /* CFRNW */
  1119. at91_set_A_periph(AT91_PIN_PC15, 1); /* NWAIT */
  1120. if (data->flags & AT91_CF_TRUE_IDE)
  1121. #if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE)
  1122. pdev->name = "pata_at91";
  1123. #elif defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
  1124. pdev->name = "at91_ide";
  1125. #else
  1126. #warning "board requires AT91_CF_TRUE_IDE: enable either at91_ide or pata_at91"
  1127. #endif
  1128. else
  1129. pdev->name = "at91_cf";
  1130. platform_device_register(pdev);
  1131. }
  1132. #else
  1133. void __init at91_add_device_cf(struct at91_cf_data * data) {}
  1134. #endif
  1135. /* -------------------------------------------------------------------- */
  1136. /*
  1137. * These devices are always present and don't need any board-specific
  1138. * setup.
  1139. */
  1140. static int __init at91_add_standard_devices(void)
  1141. {
  1142. at91_add_device_rtt();
  1143. at91_add_device_watchdog();
  1144. at91_add_device_tc();
  1145. return 0;
  1146. }
  1147. arch_initcall(at91_add_standard_devices);