devices.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 at91rm9200_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 = at91rm9200_usbh_resource,
  46. .num_resources = ARRAY_SIZE(at91rm9200_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. udc_data = *data;
  90. platform_device_register(&at91rm9200_udc_device);
  91. }
  92. #else
  93. void __init at91_add_device_udc(struct at91_udc_data *data) {}
  94. #endif
  95. /* --------------------------------------------------------------------
  96. * Ethernet
  97. * -------------------------------------------------------------------- */
  98. #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
  99. static u64 eth_dmamask = 0xffffffffUL;
  100. static struct at91_eth_data eth_data;
  101. static struct platform_device at91rm9200_eth_device = {
  102. .name = "at91_ether",
  103. .id = -1,
  104. .dev = {
  105. .dma_mask = &eth_dmamask,
  106. .coherent_dma_mask = 0xffffffff,
  107. .platform_data = &eth_data,
  108. },
  109. .num_resources = 0,
  110. };
  111. void __init at91_add_device_eth(struct at91_eth_data *data)
  112. {
  113. if (!data)
  114. return;
  115. if (data->phy_irq_pin) {
  116. at91_set_gpio_input(data->phy_irq_pin, 0);
  117. at91_set_deglitch(data->phy_irq_pin, 1);
  118. }
  119. /* Pins used for MII and RMII */
  120. at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */
  121. at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */
  122. at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */
  123. at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
  124. at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
  125. at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */
  126. at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */
  127. at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */
  128. at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */
  129. at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */
  130. if (!data->is_rmii) {
  131. at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */
  132. at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */
  133. at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */
  134. at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */
  135. at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */
  136. at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */
  137. at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */
  138. at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */
  139. }
  140. eth_data = *data;
  141. platform_device_register(&at91rm9200_eth_device);
  142. }
  143. #else
  144. void __init at91_add_device_eth(struct at91_eth_data *data) {}
  145. #endif
  146. /* --------------------------------------------------------------------
  147. * Compact Flash / PCMCIA
  148. * -------------------------------------------------------------------- */
  149. #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
  150. static struct at91_cf_data cf_data;
  151. static struct platform_device at91rm9200_cf_device = {
  152. .name = "at91_cf",
  153. .id = -1,
  154. .dev = {
  155. .platform_data = &cf_data,
  156. },
  157. .num_resources = 0,
  158. };
  159. void __init at91_add_device_cf(struct at91_cf_data *data)
  160. {
  161. if (!data)
  162. return;
  163. /* input/irq */
  164. if (data->irq_pin) {
  165. at91_set_gpio_input(data->irq_pin, 1);
  166. at91_set_deglitch(data->irq_pin, 1);
  167. }
  168. at91_set_gpio_input(data->det_pin, 1);
  169. at91_set_deglitch(data->det_pin, 1);
  170. /* outputs, initially off */
  171. if (data->vcc_pin)
  172. at91_set_gpio_output(data->vcc_pin, 0);
  173. at91_set_gpio_output(data->rst_pin, 0);
  174. cf_data = *data;
  175. platform_device_register(&at91rm9200_cf_device);
  176. }
  177. #else
  178. void __init at91_add_device_cf(struct at91_cf_data *data) {}
  179. #endif
  180. /* --------------------------------------------------------------------
  181. * MMC / SD
  182. * -------------------------------------------------------------------- */
  183. #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE)
  184. static u64 mmc_dmamask = 0xffffffffUL;
  185. static struct at91_mmc_data mmc_data;
  186. static struct resource at91_mmc_resources[] = {
  187. {
  188. .start = AT91_BASE_MCI,
  189. .end = AT91_BASE_MCI + SZ_16K - 1,
  190. .flags = IORESOURCE_MEM,
  191. }
  192. };
  193. static struct platform_device at91rm9200_mmc_device = {
  194. .name = "at91rm9200_mci",
  195. .id = -1,
  196. .dev = {
  197. .dma_mask = &mmc_dmamask,
  198. .coherent_dma_mask = 0xffffffff,
  199. .platform_data = &mmc_data,
  200. },
  201. .resource = at91_mmc_resources,
  202. .num_resources = ARRAY_SIZE(at91_mmc_resources),
  203. };
  204. void __init at91_add_device_mmc(struct at91_mmc_data *data)
  205. {
  206. if (!data)
  207. return;
  208. /* input/irq */
  209. if (data->det_pin) {
  210. at91_set_gpio_input(data->det_pin, 1);
  211. at91_set_deglitch(data->det_pin, 1);
  212. }
  213. if (data->wp_pin)
  214. at91_set_gpio_input(data->wp_pin, 1);
  215. /* CLK */
  216. at91_set_A_periph(AT91_PIN_PA27, 0);
  217. if (data->is_b) {
  218. /* CMD */
  219. at91_set_B_periph(AT91_PIN_PA8, 0);
  220. /* DAT0, maybe DAT1..DAT3 */
  221. at91_set_B_periph(AT91_PIN_PA9, 0);
  222. if (data->wire4) {
  223. at91_set_B_periph(AT91_PIN_PA10, 0);
  224. at91_set_B_periph(AT91_PIN_PA11, 0);
  225. at91_set_B_periph(AT91_PIN_PA12, 0);
  226. }
  227. } else {
  228. /* CMD */
  229. at91_set_A_periph(AT91_PIN_PA28, 0);
  230. /* DAT0, maybe DAT1..DAT3 */
  231. at91_set_A_periph(AT91_PIN_PA29, 0);
  232. if (data->wire4) {
  233. at91_set_B_periph(AT91_PIN_PB3, 0);
  234. at91_set_B_periph(AT91_PIN_PB4, 0);
  235. at91_set_B_periph(AT91_PIN_PB5, 0);
  236. }
  237. }
  238. mmc_data = *data;
  239. platform_device_register(&at91rm9200_mmc_device);
  240. }
  241. #else
  242. void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
  243. #endif
  244. /* -------------------------------------------------------------------- */