usb-host.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. * usb-host.c - OMAP USB Host
  3. *
  4. * This file will contain the board specific details for the
  5. * Synopsys EHCI/OHCI host controller on OMAP3430 and onwards
  6. *
  7. * Copyright (C) 2007-2011 Texas Instruments
  8. * Author: Vikram Pandita <vikram.pandita@ti.com>
  9. * Author: Keshava Munegowda <keshava_mgowda@ti.com>
  10. *
  11. * Generalization by:
  12. * Felipe Balbi <balbi@ti.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/types.h>
  19. #include <linux/errno.h>
  20. #include <linux/delay.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/slab.h>
  23. #include <linux/dma-mapping.h>
  24. #include <asm/io.h>
  25. #include <mach/hardware.h>
  26. #include <mach/irqs.h>
  27. #include <plat/usb.h>
  28. #include <plat/omap_device.h>
  29. #include "mux.h"
  30. #ifdef CONFIG_MFD_OMAP_USB_HOST
  31. #define OMAP_USBHS_DEVICE "usbhs_omap"
  32. #define USBHS_UHH_HWMODNAME "usb_host_hs"
  33. #define USBHS_TLL_HWMODNAME "usb_tll_hs"
  34. static struct usbhs_omap_platform_data usbhs_data;
  35. static struct ehci_hcd_omap_platform_data ehci_data;
  36. static struct ohci_hcd_omap_platform_data ohci_data;
  37. static struct omap_device_pm_latency omap_uhhtll_latency[] = {
  38. {
  39. .deactivate_func = omap_device_idle_hwmods,
  40. .activate_func = omap_device_enable_hwmods,
  41. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  42. },
  43. };
  44. /* MUX settings for EHCI pins */
  45. /*
  46. * setup_ehci_io_mux - initialize IO pad mux for USBHOST
  47. */
  48. static void __init setup_ehci_io_mux(const enum usbhs_omap_port_mode *port_mode)
  49. {
  50. switch (port_mode[0]) {
  51. case OMAP_EHCI_PORT_MODE_PHY:
  52. omap_mux_init_signal("hsusb1_stp", OMAP_PIN_OUTPUT);
  53. omap_mux_init_signal("hsusb1_clk", OMAP_PIN_OUTPUT);
  54. omap_mux_init_signal("hsusb1_dir", OMAP_PIN_INPUT_PULLDOWN);
  55. omap_mux_init_signal("hsusb1_nxt", OMAP_PIN_INPUT_PULLDOWN);
  56. omap_mux_init_signal("hsusb1_data0", OMAP_PIN_INPUT_PULLDOWN);
  57. omap_mux_init_signal("hsusb1_data1", OMAP_PIN_INPUT_PULLDOWN);
  58. omap_mux_init_signal("hsusb1_data2", OMAP_PIN_INPUT_PULLDOWN);
  59. omap_mux_init_signal("hsusb1_data3", OMAP_PIN_INPUT_PULLDOWN);
  60. omap_mux_init_signal("hsusb1_data4", OMAP_PIN_INPUT_PULLDOWN);
  61. omap_mux_init_signal("hsusb1_data5", OMAP_PIN_INPUT_PULLDOWN);
  62. omap_mux_init_signal("hsusb1_data6", OMAP_PIN_INPUT_PULLDOWN);
  63. omap_mux_init_signal("hsusb1_data7", OMAP_PIN_INPUT_PULLDOWN);
  64. break;
  65. case OMAP_EHCI_PORT_MODE_TLL:
  66. omap_mux_init_signal("hsusb1_tll_stp",
  67. OMAP_PIN_INPUT_PULLUP);
  68. omap_mux_init_signal("hsusb1_tll_clk",
  69. OMAP_PIN_INPUT_PULLDOWN);
  70. omap_mux_init_signal("hsusb1_tll_dir",
  71. OMAP_PIN_INPUT_PULLDOWN);
  72. omap_mux_init_signal("hsusb1_tll_nxt",
  73. OMAP_PIN_INPUT_PULLDOWN);
  74. omap_mux_init_signal("hsusb1_tll_data0",
  75. OMAP_PIN_INPUT_PULLDOWN);
  76. omap_mux_init_signal("hsusb1_tll_data1",
  77. OMAP_PIN_INPUT_PULLDOWN);
  78. omap_mux_init_signal("hsusb1_tll_data2",
  79. OMAP_PIN_INPUT_PULLDOWN);
  80. omap_mux_init_signal("hsusb1_tll_data3",
  81. OMAP_PIN_INPUT_PULLDOWN);
  82. omap_mux_init_signal("hsusb1_tll_data4",
  83. OMAP_PIN_INPUT_PULLDOWN);
  84. omap_mux_init_signal("hsusb1_tll_data5",
  85. OMAP_PIN_INPUT_PULLDOWN);
  86. omap_mux_init_signal("hsusb1_tll_data6",
  87. OMAP_PIN_INPUT_PULLDOWN);
  88. omap_mux_init_signal("hsusb1_tll_data7",
  89. OMAP_PIN_INPUT_PULLDOWN);
  90. break;
  91. case OMAP_USBHS_PORT_MODE_UNUSED:
  92. /* FALLTHROUGH */
  93. default:
  94. break;
  95. }
  96. switch (port_mode[1]) {
  97. case OMAP_EHCI_PORT_MODE_PHY:
  98. omap_mux_init_signal("hsusb2_stp", OMAP_PIN_OUTPUT);
  99. omap_mux_init_signal("hsusb2_clk", OMAP_PIN_OUTPUT);
  100. omap_mux_init_signal("hsusb2_dir", OMAP_PIN_INPUT_PULLDOWN);
  101. omap_mux_init_signal("hsusb2_nxt", OMAP_PIN_INPUT_PULLDOWN);
  102. omap_mux_init_signal("hsusb2_data0",
  103. OMAP_PIN_INPUT_PULLDOWN);
  104. omap_mux_init_signal("hsusb2_data1",
  105. OMAP_PIN_INPUT_PULLDOWN);
  106. omap_mux_init_signal("hsusb2_data2",
  107. OMAP_PIN_INPUT_PULLDOWN);
  108. omap_mux_init_signal("hsusb2_data3",
  109. OMAP_PIN_INPUT_PULLDOWN);
  110. omap_mux_init_signal("hsusb2_data4",
  111. OMAP_PIN_INPUT_PULLDOWN);
  112. omap_mux_init_signal("hsusb2_data5",
  113. OMAP_PIN_INPUT_PULLDOWN);
  114. omap_mux_init_signal("hsusb2_data6",
  115. OMAP_PIN_INPUT_PULLDOWN);
  116. omap_mux_init_signal("hsusb2_data7",
  117. OMAP_PIN_INPUT_PULLDOWN);
  118. break;
  119. case OMAP_EHCI_PORT_MODE_TLL:
  120. omap_mux_init_signal("hsusb2_tll_stp",
  121. OMAP_PIN_INPUT_PULLUP);
  122. omap_mux_init_signal("hsusb2_tll_clk",
  123. OMAP_PIN_INPUT_PULLDOWN);
  124. omap_mux_init_signal("hsusb2_tll_dir",
  125. OMAP_PIN_INPUT_PULLDOWN);
  126. omap_mux_init_signal("hsusb2_tll_nxt",
  127. OMAP_PIN_INPUT_PULLDOWN);
  128. omap_mux_init_signal("hsusb2_tll_data0",
  129. OMAP_PIN_INPUT_PULLDOWN);
  130. omap_mux_init_signal("hsusb2_tll_data1",
  131. OMAP_PIN_INPUT_PULLDOWN);
  132. omap_mux_init_signal("hsusb2_tll_data2",
  133. OMAP_PIN_INPUT_PULLDOWN);
  134. omap_mux_init_signal("hsusb2_tll_data3",
  135. OMAP_PIN_INPUT_PULLDOWN);
  136. omap_mux_init_signal("hsusb2_tll_data4",
  137. OMAP_PIN_INPUT_PULLDOWN);
  138. omap_mux_init_signal("hsusb2_tll_data5",
  139. OMAP_PIN_INPUT_PULLDOWN);
  140. omap_mux_init_signal("hsusb2_tll_data6",
  141. OMAP_PIN_INPUT_PULLDOWN);
  142. omap_mux_init_signal("hsusb2_tll_data7",
  143. OMAP_PIN_INPUT_PULLDOWN);
  144. break;
  145. case OMAP_USBHS_PORT_MODE_UNUSED:
  146. /* FALLTHROUGH */
  147. default:
  148. break;
  149. }
  150. switch (port_mode[2]) {
  151. case OMAP_EHCI_PORT_MODE_PHY:
  152. printk(KERN_WARNING "Port3 can't be used in PHY mode\n");
  153. break;
  154. case OMAP_EHCI_PORT_MODE_TLL:
  155. omap_mux_init_signal("hsusb3_tll_stp",
  156. OMAP_PIN_INPUT_PULLUP);
  157. omap_mux_init_signal("hsusb3_tll_clk",
  158. OMAP_PIN_INPUT_PULLDOWN);
  159. omap_mux_init_signal("hsusb3_tll_dir",
  160. OMAP_PIN_INPUT_PULLDOWN);
  161. omap_mux_init_signal("hsusb3_tll_nxt",
  162. OMAP_PIN_INPUT_PULLDOWN);
  163. omap_mux_init_signal("hsusb3_tll_data0",
  164. OMAP_PIN_INPUT_PULLDOWN);
  165. omap_mux_init_signal("hsusb3_tll_data1",
  166. OMAP_PIN_INPUT_PULLDOWN);
  167. omap_mux_init_signal("hsusb3_tll_data2",
  168. OMAP_PIN_INPUT_PULLDOWN);
  169. omap_mux_init_signal("hsusb3_tll_data3",
  170. OMAP_PIN_INPUT_PULLDOWN);
  171. omap_mux_init_signal("hsusb3_tll_data4",
  172. OMAP_PIN_INPUT_PULLDOWN);
  173. omap_mux_init_signal("hsusb3_tll_data5",
  174. OMAP_PIN_INPUT_PULLDOWN);
  175. omap_mux_init_signal("hsusb3_tll_data6",
  176. OMAP_PIN_INPUT_PULLDOWN);
  177. omap_mux_init_signal("hsusb3_tll_data7",
  178. OMAP_PIN_INPUT_PULLDOWN);
  179. break;
  180. case OMAP_USBHS_PORT_MODE_UNUSED:
  181. /* FALLTHROUGH */
  182. default:
  183. break;
  184. }
  185. return;
  186. }
  187. static
  188. void __init setup_4430ehci_io_mux(const enum usbhs_omap_port_mode *port_mode)
  189. {
  190. switch (port_mode[0]) {
  191. case OMAP_EHCI_PORT_MODE_PHY:
  192. omap_mux_init_signal("usbb1_ulpiphy_stp",
  193. OMAP_PIN_OUTPUT);
  194. omap_mux_init_signal("usbb1_ulpiphy_clk",
  195. OMAP_PIN_INPUT_PULLDOWN);
  196. omap_mux_init_signal("usbb1_ulpiphy_dir",
  197. OMAP_PIN_INPUT_PULLDOWN);
  198. omap_mux_init_signal("usbb1_ulpiphy_nxt",
  199. OMAP_PIN_INPUT_PULLDOWN);
  200. omap_mux_init_signal("usbb1_ulpiphy_dat0",
  201. OMAP_PIN_INPUT_PULLDOWN);
  202. omap_mux_init_signal("usbb1_ulpiphy_dat1",
  203. OMAP_PIN_INPUT_PULLDOWN);
  204. omap_mux_init_signal("usbb1_ulpiphy_dat2",
  205. OMAP_PIN_INPUT_PULLDOWN);
  206. omap_mux_init_signal("usbb1_ulpiphy_dat3",
  207. OMAP_PIN_INPUT_PULLDOWN);
  208. omap_mux_init_signal("usbb1_ulpiphy_dat4",
  209. OMAP_PIN_INPUT_PULLDOWN);
  210. omap_mux_init_signal("usbb1_ulpiphy_dat5",
  211. OMAP_PIN_INPUT_PULLDOWN);
  212. omap_mux_init_signal("usbb1_ulpiphy_dat6",
  213. OMAP_PIN_INPUT_PULLDOWN);
  214. omap_mux_init_signal("usbb1_ulpiphy_dat7",
  215. OMAP_PIN_INPUT_PULLDOWN);
  216. break;
  217. case OMAP_EHCI_PORT_MODE_TLL:
  218. omap_mux_init_signal("usbb1_ulpitll_stp",
  219. OMAP_PIN_INPUT_PULLUP);
  220. omap_mux_init_signal("usbb1_ulpitll_clk",
  221. OMAP_PIN_INPUT_PULLDOWN);
  222. omap_mux_init_signal("usbb1_ulpitll_dir",
  223. OMAP_PIN_INPUT_PULLDOWN);
  224. omap_mux_init_signal("usbb1_ulpitll_nxt",
  225. OMAP_PIN_INPUT_PULLDOWN);
  226. omap_mux_init_signal("usbb1_ulpitll_dat0",
  227. OMAP_PIN_INPUT_PULLDOWN);
  228. omap_mux_init_signal("usbb1_ulpitll_dat1",
  229. OMAP_PIN_INPUT_PULLDOWN);
  230. omap_mux_init_signal("usbb1_ulpitll_dat2",
  231. OMAP_PIN_INPUT_PULLDOWN);
  232. omap_mux_init_signal("usbb1_ulpitll_dat3",
  233. OMAP_PIN_INPUT_PULLDOWN);
  234. omap_mux_init_signal("usbb1_ulpitll_dat4",
  235. OMAP_PIN_INPUT_PULLDOWN);
  236. omap_mux_init_signal("usbb1_ulpitll_dat5",
  237. OMAP_PIN_INPUT_PULLDOWN);
  238. omap_mux_init_signal("usbb1_ulpitll_dat6",
  239. OMAP_PIN_INPUT_PULLDOWN);
  240. omap_mux_init_signal("usbb1_ulpitll_dat7",
  241. OMAP_PIN_INPUT_PULLDOWN);
  242. break;
  243. case OMAP_USBHS_PORT_MODE_UNUSED:
  244. default:
  245. break;
  246. }
  247. switch (port_mode[1]) {
  248. case OMAP_EHCI_PORT_MODE_PHY:
  249. omap_mux_init_signal("usbb2_ulpiphy_stp",
  250. OMAP_PIN_OUTPUT);
  251. omap_mux_init_signal("usbb2_ulpiphy_clk",
  252. OMAP_PIN_INPUT_PULLDOWN);
  253. omap_mux_init_signal("usbb2_ulpiphy_dir",
  254. OMAP_PIN_INPUT_PULLDOWN);
  255. omap_mux_init_signal("usbb2_ulpiphy_nxt",
  256. OMAP_PIN_INPUT_PULLDOWN);
  257. omap_mux_init_signal("usbb2_ulpiphy_dat0",
  258. OMAP_PIN_INPUT_PULLDOWN);
  259. omap_mux_init_signal("usbb2_ulpiphy_dat1",
  260. OMAP_PIN_INPUT_PULLDOWN);
  261. omap_mux_init_signal("usbb2_ulpiphy_dat2",
  262. OMAP_PIN_INPUT_PULLDOWN);
  263. omap_mux_init_signal("usbb2_ulpiphy_dat3",
  264. OMAP_PIN_INPUT_PULLDOWN);
  265. omap_mux_init_signal("usbb2_ulpiphy_dat4",
  266. OMAP_PIN_INPUT_PULLDOWN);
  267. omap_mux_init_signal("usbb2_ulpiphy_dat5",
  268. OMAP_PIN_INPUT_PULLDOWN);
  269. omap_mux_init_signal("usbb2_ulpiphy_dat6",
  270. OMAP_PIN_INPUT_PULLDOWN);
  271. omap_mux_init_signal("usbb2_ulpiphy_dat7",
  272. OMAP_PIN_INPUT_PULLDOWN);
  273. break;
  274. case OMAP_EHCI_PORT_MODE_TLL:
  275. omap_mux_init_signal("usbb2_ulpitll_stp",
  276. OMAP_PIN_INPUT_PULLUP);
  277. omap_mux_init_signal("usbb2_ulpitll_clk",
  278. OMAP_PIN_INPUT_PULLDOWN);
  279. omap_mux_init_signal("usbb2_ulpitll_dir",
  280. OMAP_PIN_INPUT_PULLDOWN);
  281. omap_mux_init_signal("usbb2_ulpitll_nxt",
  282. OMAP_PIN_INPUT_PULLDOWN);
  283. omap_mux_init_signal("usbb2_ulpitll_dat0",
  284. OMAP_PIN_INPUT_PULLDOWN);
  285. omap_mux_init_signal("usbb2_ulpitll_dat1",
  286. OMAP_PIN_INPUT_PULLDOWN);
  287. omap_mux_init_signal("usbb2_ulpitll_dat2",
  288. OMAP_PIN_INPUT_PULLDOWN);
  289. omap_mux_init_signal("usbb2_ulpitll_dat3",
  290. OMAP_PIN_INPUT_PULLDOWN);
  291. omap_mux_init_signal("usbb2_ulpitll_dat4",
  292. OMAP_PIN_INPUT_PULLDOWN);
  293. omap_mux_init_signal("usbb2_ulpitll_dat5",
  294. OMAP_PIN_INPUT_PULLDOWN);
  295. omap_mux_init_signal("usbb2_ulpitll_dat6",
  296. OMAP_PIN_INPUT_PULLDOWN);
  297. omap_mux_init_signal("usbb2_ulpitll_dat7",
  298. OMAP_PIN_INPUT_PULLDOWN);
  299. break;
  300. case OMAP_USBHS_PORT_MODE_UNUSED:
  301. default:
  302. break;
  303. }
  304. }
  305. static void __init setup_ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
  306. {
  307. switch (port_mode[0]) {
  308. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  309. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  310. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  311. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  312. omap_mux_init_signal("mm1_rxdp",
  313. OMAP_PIN_INPUT_PULLDOWN);
  314. omap_mux_init_signal("mm1_rxdm",
  315. OMAP_PIN_INPUT_PULLDOWN);
  316. /* FALLTHROUGH */
  317. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  318. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  319. omap_mux_init_signal("mm1_rxrcv",
  320. OMAP_PIN_INPUT_PULLDOWN);
  321. /* FALLTHROUGH */
  322. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  323. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  324. omap_mux_init_signal("mm1_txen_n", OMAP_PIN_OUTPUT);
  325. /* FALLTHROUGH */
  326. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  327. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  328. omap_mux_init_signal("mm1_txse0",
  329. OMAP_PIN_INPUT_PULLDOWN);
  330. omap_mux_init_signal("mm1_txdat",
  331. OMAP_PIN_INPUT_PULLDOWN);
  332. break;
  333. case OMAP_USBHS_PORT_MODE_UNUSED:
  334. /* FALLTHROUGH */
  335. default:
  336. break;
  337. }
  338. switch (port_mode[1]) {
  339. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  340. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  341. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  342. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  343. omap_mux_init_signal("mm2_rxdp",
  344. OMAP_PIN_INPUT_PULLDOWN);
  345. omap_mux_init_signal("mm2_rxdm",
  346. OMAP_PIN_INPUT_PULLDOWN);
  347. /* FALLTHROUGH */
  348. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  349. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  350. omap_mux_init_signal("mm2_rxrcv",
  351. OMAP_PIN_INPUT_PULLDOWN);
  352. /* FALLTHROUGH */
  353. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  354. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  355. omap_mux_init_signal("mm2_txen_n", OMAP_PIN_OUTPUT);
  356. /* FALLTHROUGH */
  357. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  358. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  359. omap_mux_init_signal("mm2_txse0",
  360. OMAP_PIN_INPUT_PULLDOWN);
  361. omap_mux_init_signal("mm2_txdat",
  362. OMAP_PIN_INPUT_PULLDOWN);
  363. break;
  364. case OMAP_USBHS_PORT_MODE_UNUSED:
  365. /* FALLTHROUGH */
  366. default:
  367. break;
  368. }
  369. switch (port_mode[2]) {
  370. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  371. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  372. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  373. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  374. omap_mux_init_signal("mm3_rxdp",
  375. OMAP_PIN_INPUT_PULLDOWN);
  376. omap_mux_init_signal("mm3_rxdm",
  377. OMAP_PIN_INPUT_PULLDOWN);
  378. /* FALLTHROUGH */
  379. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  380. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  381. omap_mux_init_signal("mm3_rxrcv",
  382. OMAP_PIN_INPUT_PULLDOWN);
  383. /* FALLTHROUGH */
  384. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  385. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  386. omap_mux_init_signal("mm3_txen_n", OMAP_PIN_OUTPUT);
  387. /* FALLTHROUGH */
  388. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  389. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  390. omap_mux_init_signal("mm3_txse0",
  391. OMAP_PIN_INPUT_PULLDOWN);
  392. omap_mux_init_signal("mm3_txdat",
  393. OMAP_PIN_INPUT_PULLDOWN);
  394. break;
  395. case OMAP_USBHS_PORT_MODE_UNUSED:
  396. /* FALLTHROUGH */
  397. default:
  398. break;
  399. }
  400. }
  401. static
  402. void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
  403. {
  404. switch (port_mode[0]) {
  405. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  406. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  407. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  408. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  409. omap_mux_init_signal("usbb1_mm_rxdp",
  410. OMAP_PIN_INPUT_PULLDOWN);
  411. omap_mux_init_signal("usbb1_mm_rxdm",
  412. OMAP_PIN_INPUT_PULLDOWN);
  413. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  414. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  415. omap_mux_init_signal("usbb1_mm_rxrcv",
  416. OMAP_PIN_INPUT_PULLDOWN);
  417. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  418. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  419. omap_mux_init_signal("usbb1_mm_txen",
  420. OMAP_PIN_INPUT_PULLDOWN);
  421. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  422. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  423. omap_mux_init_signal("usbb1_mm_txdat",
  424. OMAP_PIN_INPUT_PULLDOWN);
  425. omap_mux_init_signal("usbb1_mm_txse0",
  426. OMAP_PIN_INPUT_PULLDOWN);
  427. break;
  428. case OMAP_USBHS_PORT_MODE_UNUSED:
  429. default:
  430. break;
  431. }
  432. switch (port_mode[1]) {
  433. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  434. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  435. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  436. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  437. omap_mux_init_signal("usbb2_mm_rxdp",
  438. OMAP_PIN_INPUT_PULLDOWN);
  439. omap_mux_init_signal("usbb2_mm_rxdm",
  440. OMAP_PIN_INPUT_PULLDOWN);
  441. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  442. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  443. omap_mux_init_signal("usbb2_mm_rxrcv",
  444. OMAP_PIN_INPUT_PULLDOWN);
  445. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  446. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  447. omap_mux_init_signal("usbb2_mm_txen",
  448. OMAP_PIN_INPUT_PULLDOWN);
  449. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  450. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  451. omap_mux_init_signal("usbb2_mm_txdat",
  452. OMAP_PIN_INPUT_PULLDOWN);
  453. omap_mux_init_signal("usbb2_mm_txse0",
  454. OMAP_PIN_INPUT_PULLDOWN);
  455. break;
  456. case OMAP_USBHS_PORT_MODE_UNUSED:
  457. default:
  458. break;
  459. }
  460. }
  461. void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
  462. {
  463. struct omap_hwmod *oh[2];
  464. struct platform_device *pdev;
  465. int bus_id = -1;
  466. int i;
  467. for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
  468. usbhs_data.port_mode[i] = pdata->port_mode[i];
  469. ohci_data.port_mode[i] = pdata->port_mode[i];
  470. ehci_data.port_mode[i] = pdata->port_mode[i];
  471. ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i];
  472. ehci_data.regulator[i] = pdata->regulator[i];
  473. }
  474. ehci_data.phy_reset = pdata->phy_reset;
  475. ohci_data.es2_compatibility = pdata->es2_compatibility;
  476. usbhs_data.ehci_data = &ehci_data;
  477. usbhs_data.ohci_data = &ohci_data;
  478. if (cpu_is_omap34xx()) {
  479. setup_ehci_io_mux(pdata->port_mode);
  480. setup_ohci_io_mux(pdata->port_mode);
  481. } else if (cpu_is_omap44xx()) {
  482. setup_4430ehci_io_mux(pdata->port_mode);
  483. setup_4430ohci_io_mux(pdata->port_mode);
  484. }
  485. oh[0] = omap_hwmod_lookup(USBHS_UHH_HWMODNAME);
  486. if (!oh[0]) {
  487. pr_err("Could not look up %s\n", USBHS_UHH_HWMODNAME);
  488. return;
  489. }
  490. oh[1] = omap_hwmod_lookup(USBHS_TLL_HWMODNAME);
  491. if (!oh[1]) {
  492. pr_err("Could not look up %s\n", USBHS_TLL_HWMODNAME);
  493. return;
  494. }
  495. pdev = omap_device_build_ss(OMAP_USBHS_DEVICE, bus_id, oh, 2,
  496. (void *)&usbhs_data, sizeof(usbhs_data),
  497. omap_uhhtll_latency,
  498. ARRAY_SIZE(omap_uhhtll_latency), false);
  499. if (IS_ERR(pdev)) {
  500. pr_err("Could not build hwmod devices %s,%s\n",
  501. USBHS_UHH_HWMODNAME, USBHS_TLL_HWMODNAME);
  502. return;
  503. }
  504. }
  505. #else
  506. void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
  507. {
  508. }
  509. #endif