devices.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. /*
  2. * arch/arm/mach-at91rm9200/devices.c
  3. *
  4. * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
  5. * Copyright (C) 2005 David Brownell
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. */
  13. #include <asm/mach/arch.h>
  14. #include <asm/mach/map.h>
  15. #include <linux/config.h>
  16. #include <linux/platform_device.h>
  17. #include <asm/arch/board.h>
  18. #include <asm/arch/pio.h>
  19. /* --------------------------------------------------------------------
  20. * USB Host
  21. * -------------------------------------------------------------------- */
  22. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  23. static u64 ohci_dmamask = 0xffffffffUL;
  24. static struct at91_usbh_data usbh_data;
  25. static struct resource at91_usbh_resource[] = {
  26. [0] = {
  27. .start = AT91_UHP_BASE,
  28. .end = AT91_UHP_BASE + SZ_1M - 1,
  29. .flags = IORESOURCE_MEM,
  30. },
  31. [1] = {
  32. .start = AT91_ID_UHP,
  33. .end = AT91_ID_UHP,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. };
  37. static struct platform_device at91rm9200_usbh_device = {
  38. .name = "at91rm9200-ohci",
  39. .id = -1,
  40. .dev = {
  41. .dma_mask = &ohci_dmamask,
  42. .coherent_dma_mask = 0xffffffff,
  43. .platform_data = &usbh_data,
  44. },
  45. .resource = at91_usbh_resource,
  46. .num_resources = ARRAY_SIZE(at91_usbh_resource),
  47. };
  48. void __init at91_add_device_usbh(struct at91_usbh_data *data)
  49. {
  50. if (!data)
  51. return;
  52. usbh_data = *data;
  53. platform_device_register(&at91rm9200_usbh_device);
  54. }
  55. #else
  56. void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
  57. #endif
  58. /* --------------------------------------------------------------------
  59. * USB Device (Gadget)
  60. * -------------------------------------------------------------------- */
  61. #ifdef CONFIG_USB_GADGET_AT91
  62. static struct at91_udc_data udc_data;
  63. static struct resource at91_udc_resources[] = {
  64. {
  65. .start = AT91_BASE_UDP,
  66. .end = AT91_BASE_UDP + SZ_16K - 1,
  67. .flags = IORESOURCE_MEM,
  68. }
  69. };
  70. static struct platform_device at91rm9200_udc_device = {
  71. .name = "at91_udc",
  72. .id = -1,
  73. .dev = {
  74. .platform_data = &udc_data,
  75. },
  76. .resource = at91_udc_resources,
  77. .num_resources = ARRAY_SIZE(at91_udc_resources),
  78. };
  79. void __init at91_add_device_udc(struct at91_udc_data *data)
  80. {
  81. if (!data)
  82. return;
  83. if (data->vbus_pin) {
  84. at91_set_gpio_input(data->vbus_pin, 0);
  85. at91_set_deglitch(data->vbus_pin, 1);
  86. }
  87. if (data->pullup_pin) {
  88. at91_set_gpio_output(data->pullup_pin, 0);
  89. at91_set_multi_drive(data->pullup_pin, 1);
  90. }
  91. udc_data = *data;
  92. platform_device_register(&at91rm9200_udc_device);
  93. }
  94. #else
  95. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  96. #endif
  97. /* --------------------------------------------------------------------
  98. * Ethernet
  99. * -------------------------------------------------------------------- */
  100. #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
  101. static u64 eth_dmamask = 0xffffffffUL;
  102. static struct at91_eth_data eth_data;
  103. static struct resource at91_eth_resources[] = {
  104. [0] = {
  105. .start = AT91_BASE_EMAC,
  106. .end = AT91_BASE_EMAC + SZ_16K - 1,
  107. .flags = IORESOURCE_MEM,
  108. },
  109. [1] = {
  110. .start = AT91_ID_EMAC,
  111. .end = AT91_ID_EMAC,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct platform_device at91rm9200_eth_device = {
  116. .name = "at91_ether",
  117. .id = -1,
  118. .dev = {
  119. .dma_mask = &eth_dmamask,
  120. .coherent_dma_mask = 0xffffffff,
  121. .platform_data = &eth_data,
  122. },
  123. .resource = at91_eth_resources,
  124. .num_resources = ARRAY_SIZE(at91_eth_resources),
  125. };
  126. void __init at91_add_device_eth(struct at91_eth_data *data)
  127. {
  128. if (!data)
  129. return;
  130. if (data->phy_irq_pin) {
  131. at91_set_gpio_input(data->phy_irq_pin, 0);
  132. at91_set_deglitch(data->phy_irq_pin, 1);
  133. }
  134. /* Pins used for MII and RMII */
  135. at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
  136. at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
  137. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
  138. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  139. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  140. at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
  141. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
  142. at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
  143. at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
  144. at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
  145. if (!data->is_rmii) {
  146. at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
  147. at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
  148. at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
  149. at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
  150. at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
  151. at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
  152. at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
  153. at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
  154. }
  155. eth_data = *data;
  156. platform_device_register(&at91rm9200_eth_device);
  157. }
  158. #else
  159. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  160. #endif
  161. /* --------------------------------------------------------------------
  162. * Compact Flash / PCMCIA
  163. * -------------------------------------------------------------------- */
  164. #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  165. static struct at91_cf_data cf_data;
  166. static struct resource at91_cf_resources[] = {
  167. [0] = {
  168. .start = AT91_CF_BASE,
  169. /* ties up CS4, CS5, and CS6 */
  170. .end = AT91_CF_BASE + (0x30000000 - 1),
  171. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  172. },
  173. };
  174. static struct platform_device at91rm9200_cf_device = {
  175. .name = "at91_cf",
  176. .id = -1,
  177. .dev = {
  178. .platform_data = &cf_data,
  179. },
  180. .resource = at91_cf_resources,
  181. .num_resources = ARRAY_SIZE(at91_cf_resources),
  182. };
  183. void __init at91_add_device_cf(struct at91_cf_data *data)
  184. {
  185. if (!data)
  186. return;
  187. /* input/irq */
  188. if (data->irq_pin) {
  189. at91_set_gpio_input(data->irq_pin, 1);
  190. at91_set_deglitch(data->irq_pin, 1);
  191. }
  192. at91_set_gpio_input(data->det_pin, 1);
  193. at91_set_deglitch(data->det_pin, 1);
  194. /* outputs, initially off */
  195. if (data->vcc_pin)
  196. at91_set_gpio_output(data->vcc_pin, 0);
  197. at91_set_gpio_output(data->rst_pin, 0);
  198. cf_data = *data;
  199. platform_device_register(&at91rm9200_cf_device);
  200. }
  201. #else
  202. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  203. #endif
  204. /* --------------------------------------------------------------------
  205. * MMC / SD
  206. * -------------------------------------------------------------------- */
  207. #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
  208. static u64 mmc_dmamask = 0xffffffffUL;
  209. static struct at91_mmc_data mmc_data;
  210. static struct resource at91_mmc_resources[] = {
  211. [0] = {
  212. .start = AT91_BASE_MCI,
  213. .end = AT91_BASE_MCI + SZ_16K - 1,
  214. .flags = IORESOURCE_MEM,
  215. },
  216. [1] = {
  217. .start = AT91_ID_MCI,
  218. .end = AT91_ID_MCI,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device at91rm9200_mmc_device = {
  223. .name = "at91_mci",
  224. .id = -1,
  225. .dev = {
  226. .dma_mask = &mmc_dmamask,
  227. .coherent_dma_mask = 0xffffffff,
  228. .platform_data = &mmc_data,
  229. },
  230. .resource = at91_mmc_resources,
  231. .num_resources = ARRAY_SIZE(at91_mmc_resources),
  232. };
  233. void __init at91_add_device_mmc(struct at91_mmc_data *data)
  234. {
  235. if (!data)
  236. return;
  237. /* input/irq */
  238. if (data->det_pin) {
  239. at91_set_gpio_input(data->det_pin, 1);
  240. at91_set_deglitch(data->det_pin, 1);
  241. }
  242. if (data->wp_pin)
  243. at91_set_gpio_input(data->wp_pin, 1);
  244. /* CLK */
  245. at91_set_A_periph(AT91_PIN_PA27, 0);
  246. if (data->is_b) {
  247. /* CMD */
  248. at91_set_B_periph(AT91_PIN_PA8, 0);
  249. /* DAT0, maybe DAT1..DAT3 */
  250. at91_set_B_periph(AT91_PIN_PA9, 0);
  251. if (data->wire4) {
  252. at91_set_B_periph(AT91_PIN_PA10, 0);
  253. at91_set_B_periph(AT91_PIN_PA11, 0);
  254. at91_set_B_periph(AT91_PIN_PA12, 0);
  255. }
  256. } else {
  257. /* CMD */
  258. at91_set_A_periph(AT91_PIN_PA28, 0);
  259. /* DAT0, maybe DAT1..DAT3 */
  260. at91_set_A_periph(AT91_PIN_PA29, 0);
  261. if (data->wire4) {
  262. at91_set_B_periph(AT91_PIN_PB3, 0);
  263. at91_set_B_periph(AT91_PIN_PB4, 0);
  264. at91_set_B_periph(AT91_PIN_PB5, 0);
  265. }
  266. }
  267. mmc_data = *data;
  268. platform_device_register(&at91rm9200_mmc_device);
  269. }
  270. #else
  271. void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
  272. #endif
  273. /* --------------------------------------------------------------------
  274. * NAND / SmartMedia
  275. * -------------------------------------------------------------------- */
  276. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  277. static struct at91_nand_data nand_data;
  278. static struct resource at91_nand_resources[] = {
  279. {
  280. .start = AT91_SMARTMEDIA_BASE,
  281. .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1,
  282. .flags = IORESOURCE_MEM,
  283. }
  284. };
  285. static struct platform_device at91_nand_device = {
  286. .name = "at91_nand",
  287. .id = -1,
  288. .dev = {
  289. .platform_data = &nand_data,
  290. },
  291. .resource = at91_nand_resources,
  292. .num_resources = ARRAY_SIZE(at91_nand_resources),
  293. };
  294. void __init at91_add_device_nand(struct at91_nand_data *data)
  295. {
  296. if (!data)
  297. return;
  298. /* enable pin */
  299. if (data->enable_pin)
  300. at91_set_gpio_output(data->enable_pin, 1);
  301. /* ready/busy pin */
  302. if (data->rdy_pin)
  303. at91_set_gpio_input(data->rdy_pin, 1);
  304. /* card detect pin */
  305. if (data->det_pin)
  306. at91_set_gpio_input(data->det_pin, 1);
  307. at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
  308. at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
  309. nand_data = *data;
  310. platform_device_register(&at91_nand_device);
  311. }
  312. #else
  313. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  314. #endif
  315. /* --------------------------------------------------------------------
  316. * TWI (i2c)
  317. * -------------------------------------------------------------------- */
  318. #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  319. static struct platform_device at91rm9200_twi_device = {
  320. .name = "at91_i2c",
  321. .id = -1,
  322. .num_resources = 0,
  323. };
  324. void __init at91_add_device_i2c(void)
  325. {
  326. /* pins used for TWI interface */
  327. at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
  328. at91_set_multi_drive(AT91_PIN_PA25, 1);
  329. at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
  330. at91_set_multi_drive(AT91_PIN_PA26, 1);
  331. platform_device_register(&at91rm9200_twi_device);
  332. }
  333. #else
  334. void __init at91_add_device_i2c(void) {}
  335. #endif
  336. /* --------------------------------------------------------------------
  337. * RTC
  338. * -------------------------------------------------------------------- */
  339. #if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE)
  340. static struct platform_device at91rm9200_rtc_device = {
  341. .name = "at91_rtc",
  342. .id = -1,
  343. .num_resources = 0,
  344. };
  345. void __init at91_add_device_rtc(void)
  346. {
  347. platform_device_register(&at91rm9200_rtc_device);
  348. }
  349. #else
  350. void __init at91_add_device_rtc(void) {}
  351. #endif
  352. /* --------------------------------------------------------------------
  353. * LEDs
  354. * -------------------------------------------------------------------- */
  355. #if defined(CONFIG_LEDS)
  356. u8 at91_leds_cpu;
  357. u8 at91_leds_timer;
  358. void __init at91_init_leds(u8 cpu_led, u8 timer_led)
  359. {
  360. at91_leds_cpu = cpu_led;
  361. at91_leds_timer = timer_led;
  362. }
  363. #else
  364. void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
  365. #endif
  366. /* -------------------------------------------------------------------- */