usb-ehci.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. * linux/arch/arm/mach-omap2/usb-ehci.c
  3. *
  4. * This file will contain the board specific details for the
  5. * Synopsys EHCI host controller on OMAP3430
  6. *
  7. * Copyright (C) 2007 Texas Instruments
  8. * Author: Vikram Pandita <vikram.pandita@ti.com>
  9. *
  10. * Generalization by:
  11. * Felipe Balbi <felipe.balbi@nokia.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. */
  17. #include <linux/types.h>
  18. #include <linux/errno.h>
  19. #include <linux/delay.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/clk.h>
  22. #include <linux/dma-mapping.h>
  23. #include <asm/io.h>
  24. #include <plat/mux.h>
  25. #include <mach/hardware.h>
  26. #include <mach/irqs.h>
  27. #include <plat/usb.h>
  28. #include "mux.h"
  29. #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
  30. static struct resource ehci_resources[] = {
  31. {
  32. .start = OMAP34XX_EHCI_BASE,
  33. .end = OMAP34XX_EHCI_BASE + SZ_1K - 1,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. {
  37. .start = OMAP34XX_UHH_CONFIG_BASE,
  38. .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1,
  39. .flags = IORESOURCE_MEM,
  40. },
  41. {
  42. .start = OMAP34XX_USBTLL_BASE,
  43. .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. { /* general IRQ */
  47. .start = INT_34XX_EHCI_IRQ,
  48. .flags = IORESOURCE_IRQ,
  49. }
  50. };
  51. static u64 ehci_dmamask = ~(u32)0;
  52. static struct platform_device ehci_device = {
  53. .name = "ehci-omap",
  54. .id = 0,
  55. .dev = {
  56. .dma_mask = &ehci_dmamask,
  57. .coherent_dma_mask = 0xffffffff,
  58. .platform_data = NULL,
  59. },
  60. .num_resources = ARRAY_SIZE(ehci_resources),
  61. .resource = ehci_resources,
  62. };
  63. /* MUX settings for EHCI pins */
  64. /*
  65. * setup_ehci_io_mux - initialize IO pad mux for USBHOST
  66. */
  67. static void setup_ehci_io_mux(const enum ehci_hcd_omap_mode *port_mode)
  68. {
  69. switch (port_mode[0]) {
  70. case EHCI_HCD_OMAP_MODE_PHY:
  71. omap_mux_init_signal("hsusb1_stp", OMAP_PIN_OUTPUT);
  72. omap_mux_init_signal("hsusb1_clk", OMAP_PIN_OUTPUT);
  73. omap_mux_init_signal("hsusb1_dir", OMAP_PIN_INPUT_PULLDOWN);
  74. omap_mux_init_signal("hsusb1_nxt", OMAP_PIN_INPUT_PULLDOWN);
  75. omap_mux_init_signal("hsusb1_data0", OMAP_PIN_INPUT_PULLDOWN);
  76. omap_mux_init_signal("hsusb1_data1", OMAP_PIN_INPUT_PULLDOWN);
  77. omap_mux_init_signal("hsusb1_data2", OMAP_PIN_INPUT_PULLDOWN);
  78. omap_mux_init_signal("hsusb1_data3", OMAP_PIN_INPUT_PULLDOWN);
  79. omap_mux_init_signal("hsusb1_data4", OMAP_PIN_INPUT_PULLDOWN);
  80. omap_mux_init_signal("hsusb1_data5", OMAP_PIN_INPUT_PULLDOWN);
  81. omap_mux_init_signal("hsusb1_data6", OMAP_PIN_INPUT_PULLDOWN);
  82. omap_mux_init_signal("hsusb1_data7", OMAP_PIN_INPUT_PULLDOWN);
  83. break;
  84. case EHCI_HCD_OMAP_MODE_TLL:
  85. omap_mux_init_signal("hsusb1_tll_stp",
  86. OMAP_PIN_INPUT_PULLUP);
  87. omap_mux_init_signal("hsusb1_tll_clk",
  88. OMAP_PIN_INPUT_PULLDOWN);
  89. omap_mux_init_signal("hsusb1_tll_dir",
  90. OMAP_PIN_INPUT_PULLDOWN);
  91. omap_mux_init_signal("hsusb1_tll_nxt",
  92. OMAP_PIN_INPUT_PULLDOWN);
  93. omap_mux_init_signal("hsusb1_tll_data0",
  94. OMAP_PIN_INPUT_PULLDOWN);
  95. omap_mux_init_signal("hsusb1_tll_data1",
  96. OMAP_PIN_INPUT_PULLDOWN);
  97. omap_mux_init_signal("hsusb1_tll_data2",
  98. OMAP_PIN_INPUT_PULLDOWN);
  99. omap_mux_init_signal("hsusb1_tll_data3",
  100. OMAP_PIN_INPUT_PULLDOWN);
  101. omap_mux_init_signal("hsusb1_tll_data4",
  102. OMAP_PIN_INPUT_PULLDOWN);
  103. omap_mux_init_signal("hsusb1_tll_data5",
  104. OMAP_PIN_INPUT_PULLDOWN);
  105. omap_mux_init_signal("hsusb1_tll_data6",
  106. OMAP_PIN_INPUT_PULLDOWN);
  107. omap_mux_init_signal("hsusb1_tll_data7",
  108. OMAP_PIN_INPUT_PULLDOWN);
  109. break;
  110. case EHCI_HCD_OMAP_MODE_UNKNOWN:
  111. /* FALLTHROUGH */
  112. default:
  113. break;
  114. }
  115. switch (port_mode[1]) {
  116. case EHCI_HCD_OMAP_MODE_PHY:
  117. omap_mux_init_signal("hsusb2_stp", OMAP_PIN_OUTPUT);
  118. omap_mux_init_signal("hsusb2_clk", OMAP_PIN_OUTPUT);
  119. omap_mux_init_signal("hsusb2_dir", OMAP_PIN_INPUT_PULLDOWN);
  120. omap_mux_init_signal("hsusb2_nxt", OMAP_PIN_INPUT_PULLDOWN);
  121. omap_mux_init_signal("hsusb2_data0",
  122. OMAP_PIN_INPUT_PULLDOWN);
  123. omap_mux_init_signal("hsusb2_data1",
  124. OMAP_PIN_INPUT_PULLDOWN);
  125. omap_mux_init_signal("hsusb2_data2",
  126. OMAP_PIN_INPUT_PULLDOWN);
  127. omap_mux_init_signal("hsusb2_data3",
  128. OMAP_PIN_INPUT_PULLDOWN);
  129. omap_mux_init_signal("hsusb2_data4",
  130. OMAP_PIN_INPUT_PULLDOWN);
  131. omap_mux_init_signal("hsusb2_data5",
  132. OMAP_PIN_INPUT_PULLDOWN);
  133. omap_mux_init_signal("hsusb2_data6",
  134. OMAP_PIN_INPUT_PULLDOWN);
  135. omap_mux_init_signal("hsusb2_data7",
  136. OMAP_PIN_INPUT_PULLDOWN);
  137. break;
  138. case EHCI_HCD_OMAP_MODE_TLL:
  139. omap_mux_init_signal("hsusb2_tll_stp",
  140. OMAP_PIN_INPUT_PULLUP);
  141. omap_mux_init_signal("hsusb2_tll_clk",
  142. OMAP_PIN_INPUT_PULLDOWN);
  143. omap_mux_init_signal("hsusb2_tll_dir",
  144. OMAP_PIN_INPUT_PULLDOWN);
  145. omap_mux_init_signal("hsusb2_tll_nxt",
  146. OMAP_PIN_INPUT_PULLDOWN);
  147. omap_mux_init_signal("hsusb2_tll_data0",
  148. OMAP_PIN_INPUT_PULLDOWN);
  149. omap_mux_init_signal("hsusb2_tll_data1",
  150. OMAP_PIN_INPUT_PULLDOWN);
  151. omap_mux_init_signal("hsusb2_tll_data2",
  152. OMAP_PIN_INPUT_PULLDOWN);
  153. omap_mux_init_signal("hsusb2_tll_data3",
  154. OMAP_PIN_INPUT_PULLDOWN);
  155. omap_mux_init_signal("hsusb2_tll_data4",
  156. OMAP_PIN_INPUT_PULLDOWN);
  157. omap_mux_init_signal("hsusb2_tll_data5",
  158. OMAP_PIN_INPUT_PULLDOWN);
  159. omap_mux_init_signal("hsusb2_tll_data6",
  160. OMAP_PIN_INPUT_PULLDOWN);
  161. omap_mux_init_signal("hsusb2_tll_data7",
  162. OMAP_PIN_INPUT_PULLDOWN);
  163. break;
  164. case EHCI_HCD_OMAP_MODE_UNKNOWN:
  165. /* FALLTHROUGH */
  166. default:
  167. break;
  168. }
  169. switch (port_mode[2]) {
  170. case EHCI_HCD_OMAP_MODE_PHY:
  171. printk(KERN_WARNING "Port3 can't be used in PHY mode\n");
  172. break;
  173. case EHCI_HCD_OMAP_MODE_TLL:
  174. omap_mux_init_signal("hsusb3_tll_stp",
  175. OMAP_PIN_INPUT_PULLUP);
  176. omap_mux_init_signal("hsusb3_tll_clk",
  177. OMAP_PIN_INPUT_PULLDOWN);
  178. omap_mux_init_signal("hsusb3_tll_dir",
  179. OMAP_PIN_INPUT_PULLDOWN);
  180. omap_mux_init_signal("hsusb3_tll_nxt",
  181. OMAP_PIN_INPUT_PULLDOWN);
  182. omap_mux_init_signal("hsusb3_tll_data0",
  183. OMAP_PIN_INPUT_PULLDOWN);
  184. omap_mux_init_signal("hsusb3_tll_data1",
  185. OMAP_PIN_INPUT_PULLDOWN);
  186. omap_mux_init_signal("hsusb3_tll_data2",
  187. OMAP_PIN_INPUT_PULLDOWN);
  188. omap_mux_init_signal("hsusb3_tll_data3",
  189. OMAP_PIN_INPUT_PULLDOWN);
  190. omap_mux_init_signal("hsusb3_tll_data4",
  191. OMAP_PIN_INPUT_PULLDOWN);
  192. omap_mux_init_signal("hsusb3_tll_data5",
  193. OMAP_PIN_INPUT_PULLDOWN);
  194. omap_mux_init_signal("hsusb3_tll_data6",
  195. OMAP_PIN_INPUT_PULLDOWN);
  196. omap_mux_init_signal("hsusb3_tll_data7",
  197. OMAP_PIN_INPUT_PULLDOWN);
  198. break;
  199. case EHCI_HCD_OMAP_MODE_UNKNOWN:
  200. /* FALLTHROUGH */
  201. default:
  202. break;
  203. }
  204. return;
  205. }
  206. void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata)
  207. {
  208. platform_device_add_data(&ehci_device, pdata, sizeof(*pdata));
  209. /* Setup Pin IO MUX for EHCI */
  210. if (cpu_is_omap34xx())
  211. setup_ehci_io_mux(pdata->port_mode);
  212. if (platform_device_register(&ehci_device) < 0) {
  213. printk(KERN_ERR "Unable to register HS-USB (EHCI) device\n");
  214. return;
  215. }
  216. }
  217. #else
  218. void __init usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata)
  219. {
  220. }
  221. #endif /* CONFIG_USB_EHCI_HCD */
  222. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  223. static struct resource ohci_resources[] = {
  224. {
  225. .start = OMAP34XX_OHCI_BASE,
  226. .end = OMAP34XX_OHCI_BASE + SZ_1K - 1,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. {
  230. .start = OMAP34XX_UHH_CONFIG_BASE,
  231. .end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1,
  232. .flags = IORESOURCE_MEM,
  233. },
  234. {
  235. .start = OMAP34XX_USBTLL_BASE,
  236. .end = OMAP34XX_USBTLL_BASE + SZ_4K - 1,
  237. .flags = IORESOURCE_MEM,
  238. },
  239. { /* general IRQ */
  240. .start = INT_34XX_OHCI_IRQ,
  241. .flags = IORESOURCE_IRQ,
  242. }
  243. };
  244. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  245. static struct platform_device ohci_device = {
  246. .name = "ohci-omap3",
  247. .id = 0,
  248. .dev = {
  249. .dma_mask = &ohci_dmamask,
  250. .coherent_dma_mask = 0xffffffff,
  251. },
  252. .num_resources = ARRAY_SIZE(ohci_resources),
  253. .resource = ohci_resources,
  254. };
  255. static void setup_ohci_io_mux(const enum ohci_omap3_port_mode *port_mode)
  256. {
  257. switch (port_mode[0]) {
  258. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  259. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  260. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  261. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  262. omap_mux_init_signal("mm1_rxdp",
  263. OMAP_PIN_INPUT_PULLDOWN);
  264. omap_mux_init_signal("mm1_rxdm",
  265. OMAP_PIN_INPUT_PULLDOWN);
  266. /* FALLTHROUGH */
  267. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  268. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  269. omap_mux_init_signal("mm1_rxrcv",
  270. OMAP_PIN_INPUT_PULLDOWN);
  271. /* FALLTHROUGH */
  272. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  273. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  274. omap_mux_init_signal("mm1_txen_n", OMAP_PIN_OUTPUT);
  275. /* FALLTHROUGH */
  276. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  277. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  278. omap_mux_init_signal("mm1_txse0",
  279. OMAP_PIN_INPUT_PULLDOWN);
  280. omap_mux_init_signal("mm1_txdat",
  281. OMAP_PIN_INPUT_PULLDOWN);
  282. break;
  283. case OMAP_OHCI_PORT_MODE_UNUSED:
  284. /* FALLTHROUGH */
  285. default:
  286. break;
  287. }
  288. switch (port_mode[1]) {
  289. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  290. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  291. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  292. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  293. omap_mux_init_signal("mm2_rxdp",
  294. OMAP_PIN_INPUT_PULLDOWN);
  295. omap_mux_init_signal("mm2_rxdm",
  296. OMAP_PIN_INPUT_PULLDOWN);
  297. /* FALLTHROUGH */
  298. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  299. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  300. omap_mux_init_signal("mm2_rxrcv",
  301. OMAP_PIN_INPUT_PULLDOWN);
  302. /* FALLTHROUGH */
  303. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  304. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  305. omap_mux_init_signal("mm2_txen_n", OMAP_PIN_OUTPUT);
  306. /* FALLTHROUGH */
  307. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  308. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  309. omap_mux_init_signal("mm2_txse0",
  310. OMAP_PIN_INPUT_PULLDOWN);
  311. omap_mux_init_signal("mm2_txdat",
  312. OMAP_PIN_INPUT_PULLDOWN);
  313. break;
  314. case OMAP_OHCI_PORT_MODE_UNUSED:
  315. /* FALLTHROUGH */
  316. default:
  317. break;
  318. }
  319. switch (port_mode[2]) {
  320. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  321. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  322. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  323. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  324. omap_mux_init_signal("mm3_rxdp",
  325. OMAP_PIN_INPUT_PULLDOWN);
  326. omap_mux_init_signal("mm3_rxdm",
  327. OMAP_PIN_INPUT_PULLDOWN);
  328. /* FALLTHROUGH */
  329. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  330. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  331. omap_mux_init_signal("mm3_rxrcv",
  332. OMAP_PIN_INPUT_PULLDOWN);
  333. /* FALLTHROUGH */
  334. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  335. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  336. omap_mux_init_signal("mm3_txen_n", OMAP_PIN_OUTPUT);
  337. /* FALLTHROUGH */
  338. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  339. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  340. omap_mux_init_signal("mm3_txse0",
  341. OMAP_PIN_INPUT_PULLDOWN);
  342. omap_mux_init_signal("mm3_txdat",
  343. OMAP_PIN_INPUT_PULLDOWN);
  344. break;
  345. case OMAP_OHCI_PORT_MODE_UNUSED:
  346. /* FALLTHROUGH */
  347. default:
  348. break;
  349. }
  350. }
  351. void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata)
  352. {
  353. platform_device_add_data(&ohci_device, pdata, sizeof(*pdata));
  354. /* Setup Pin IO MUX for OHCI */
  355. if (cpu_is_omap34xx())
  356. setup_ohci_io_mux(pdata->port_mode);
  357. if (platform_device_register(&ohci_device) < 0) {
  358. pr_err("Unable to register FS-USB (OHCI) device\n");
  359. return;
  360. }
  361. }
  362. #else
  363. void __init usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata)
  364. {
  365. }
  366. #endif /* CONFIG_USB_OHCI_HCD */