devices.c 7.3 KB

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