at91sam9260_devices.c 32 KB

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