devices.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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 platform_device at91rm9200_cf_device = {
  167. .name = "at91_cf",
  168. .id = -1,
  169. .dev = {
  170. .platform_data = &cf_data,
  171. },
  172. .num_resources = 0,
  173. };
  174. void __init at91_add_device_cf(struct at91_cf_data *data)
  175. {
  176. if (!data)
  177. return;
  178. /* input/irq */
  179. if (data->irq_pin) {
  180. at91_set_gpio_input(data->irq_pin, 1);
  181. at91_set_deglitch(data->irq_pin, 1);
  182. }
  183. at91_set_gpio_input(data->det_pin, 1);
  184. at91_set_deglitch(data->det_pin, 1);
  185. /* outputs, initially off */
  186. if (data->vcc_pin)
  187. at91_set_gpio_output(data->vcc_pin, 0);
  188. at91_set_gpio_output(data->rst_pin, 0);
  189. cf_data = *data;
  190. platform_device_register(&at91rm9200_cf_device);
  191. }
  192. #else
  193. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  194. #endif
  195. /* --------------------------------------------------------------------
  196. * MMC / SD
  197. * -------------------------------------------------------------------- */
  198. #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
  199. static u64 mmc_dmamask = 0xffffffffUL;
  200. static struct at91_mmc_data mmc_data;
  201. static struct resource at91_mmc_resources[] = {
  202. [0] = {
  203. .start = AT91_BASE_MCI,
  204. .end = AT91_BASE_MCI + SZ_16K - 1,
  205. .flags = IORESOURCE_MEM,
  206. },
  207. [1] = {
  208. .start = AT91_ID_MCI,
  209. .end = AT91_ID_MCI,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. };
  213. static struct platform_device at91rm9200_mmc_device = {
  214. .name = "at91_mci",
  215. .id = -1,
  216. .dev = {
  217. .dma_mask = &mmc_dmamask,
  218. .coherent_dma_mask = 0xffffffff,
  219. .platform_data = &mmc_data,
  220. },
  221. .resource = at91_mmc_resources,
  222. .num_resources = ARRAY_SIZE(at91_mmc_resources),
  223. };
  224. void __init at91_add_device_mmc(struct at91_mmc_data *data)
  225. {
  226. if (!data)
  227. return;
  228. /* input/irq */
  229. if (data->det_pin) {
  230. at91_set_gpio_input(data->det_pin, 1);
  231. at91_set_deglitch(data->det_pin, 1);
  232. }
  233. if (data->wp_pin)
  234. at91_set_gpio_input(data->wp_pin, 1);
  235. /* CLK */
  236. at91_set_A_periph(AT91_PIN_PA27, 0);
  237. if (data->is_b) {
  238. /* CMD */
  239. at91_set_B_periph(AT91_PIN_PA8, 0);
  240. /* DAT0, maybe DAT1..DAT3 */
  241. at91_set_B_periph(AT91_PIN_PA9, 0);
  242. if (data->wire4) {
  243. at91_set_B_periph(AT91_PIN_PA10, 0);
  244. at91_set_B_periph(AT91_PIN_PA11, 0);
  245. at91_set_B_periph(AT91_PIN_PA12, 0);
  246. }
  247. } else {
  248. /* CMD */
  249. at91_set_A_periph(AT91_PIN_PA28, 0);
  250. /* DAT0, maybe DAT1..DAT3 */
  251. at91_set_A_periph(AT91_PIN_PA29, 0);
  252. if (data->wire4) {
  253. at91_set_B_periph(AT91_PIN_PB3, 0);
  254. at91_set_B_periph(AT91_PIN_PB4, 0);
  255. at91_set_B_periph(AT91_PIN_PB5, 0);
  256. }
  257. }
  258. mmc_data = *data;
  259. platform_device_register(&at91rm9200_mmc_device);
  260. }
  261. #else
  262. void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
  263. #endif
  264. /* --------------------------------------------------------------------
  265. * NAND / SmartMedia
  266. * -------------------------------------------------------------------- */
  267. #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
  268. static struct at91_nand_data nand_data;
  269. static struct resource at91_nand_resources[] = {
  270. {
  271. .start = AT91_SMARTMEDIA_BASE,
  272. .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1,
  273. .flags = IORESOURCE_MEM,
  274. }
  275. };
  276. static struct platform_device at91_nand_device = {
  277. .name = "at91_nand",
  278. .id = -1,
  279. .dev = {
  280. .platform_data = &nand_data,
  281. },
  282. .resource = at91_nand_resources,
  283. .num_resources = ARRAY_SIZE(at91_nand_resources),
  284. };
  285. void __init at91_add_device_nand(struct at91_nand_data *data)
  286. {
  287. if (!data)
  288. return;
  289. /* enable pin */
  290. if (data->enable_pin)
  291. at91_set_gpio_output(data->enable_pin, 1);
  292. /* ready/busy pin */
  293. if (data->rdy_pin)
  294. at91_set_gpio_input(data->rdy_pin, 1);
  295. /* card detect pin */
  296. if (data->det_pin)
  297. at91_set_gpio_input(data->det_pin, 1);
  298. at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
  299. at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */
  300. nand_data = *data;
  301. platform_device_register(&at91_nand_device);
  302. }
  303. #else
  304. void __init at91_add_device_nand(struct at91_nand_data *data) {}
  305. #endif
  306. /* --------------------------------------------------------------------
  307. * TWI (i2c)
  308. * -------------------------------------------------------------------- */
  309. #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
  310. static struct platform_device at91rm9200_twi_device = {
  311. .name = "at91_i2c",
  312. .id = -1,
  313. .num_resources = 0,
  314. };
  315. void __init at91_add_device_i2c(void)
  316. {
  317. /* pins used for TWI interface */
  318. at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */
  319. at91_set_multi_drive(AT91_PIN_PA25, 1);
  320. at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */
  321. at91_set_multi_drive(AT91_PIN_PA26, 1);
  322. platform_device_register(&at91rm9200_twi_device);
  323. }
  324. #else
  325. void __init at91_add_device_i2c(void) {}
  326. #endif
  327. /* --------------------------------------------------------------------
  328. * RTC
  329. * -------------------------------------------------------------------- */
  330. #if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE)
  331. static struct platform_device at91rm9200_rtc_device = {
  332. .name = "at91_rtc",
  333. .id = -1,
  334. .num_resources = 0,
  335. };
  336. void __init at91_add_device_rtc(void)
  337. {
  338. platform_device_register(&at91rm9200_rtc_device);
  339. }
  340. #else
  341. void __init at91_add_device_rtc(void) {}
  342. #endif
  343. /* --------------------------------------------------------------------
  344. * LEDs
  345. * -------------------------------------------------------------------- */
  346. #if defined(CONFIG_LEDS)
  347. u8 at91_leds_cpu;
  348. u8 at91_leds_timer;
  349. void __init at91_init_leds(u8 cpu_led, u8 timer_led)
  350. {
  351. at91_leds_cpu = cpu_led;
  352. at91_leds_timer = timer_led;
  353. }
  354. #else
  355. void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
  356. #endif
  357. /* -------------------------------------------------------------------- */