omap-usb-host.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. /**
  2. * omap-usb-host.c - The USBHS core driver for OMAP EHCI & OHCI
  3. *
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
  5. * Author: Keshava Munegowda <keshava_mgowda@ti.com>
  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 version 2 of
  9. * the License as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/types.h>
  21. #include <linux/slab.h>
  22. #include <linux/delay.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/clk.h>
  25. #include <linux/dma-mapping.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/gpio.h>
  28. #include <plat/usb.h>
  29. #define USBHS_DRIVER_NAME "usbhs-omap"
  30. #define OMAP_EHCI_DEVICE "ehci-omap"
  31. #define OMAP_OHCI_DEVICE "ohci-omap3"
  32. /* OMAP USBHOST Register addresses */
  33. /* TLL Register Set */
  34. #define OMAP_USBTLL_REVISION (0x00)
  35. #define OMAP_USBTLL_SYSCONFIG (0x10)
  36. #define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8)
  37. #define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
  38. #define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
  39. #define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
  40. #define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0)
  41. #define OMAP_USBTLL_SYSSTATUS (0x14)
  42. #define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
  43. #define OMAP_USBTLL_IRQSTATUS (0x18)
  44. #define OMAP_USBTLL_IRQENABLE (0x1C)
  45. #define OMAP_TLL_SHARED_CONF (0x30)
  46. #define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6)
  47. #define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5)
  48. #define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2)
  49. #define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1)
  50. #define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0)
  51. #define OMAP_TLL_CHANNEL_CONF(num) (0x040 + 0x004 * num)
  52. #define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT 24
  53. #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11)
  54. #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
  55. #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9)
  56. #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8)
  57. #define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS (1 << 1)
  58. #define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0)
  59. #define OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0 0x0
  60. #define OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM 0x1
  61. #define OMAP_TLL_FSLSMODE_3PIN_PHY 0x2
  62. #define OMAP_TLL_FSLSMODE_4PIN_PHY 0x3
  63. #define OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0 0x4
  64. #define OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM 0x5
  65. #define OMAP_TLL_FSLSMODE_3PIN_TLL 0x6
  66. #define OMAP_TLL_FSLSMODE_4PIN_TLL 0x7
  67. #define OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0 0xA
  68. #define OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM 0xB
  69. #define OMAP_TLL_ULPI_FUNCTION_CTRL(num) (0x804 + 0x100 * num)
  70. #define OMAP_TLL_ULPI_INTERFACE_CTRL(num) (0x807 + 0x100 * num)
  71. #define OMAP_TLL_ULPI_OTG_CTRL(num) (0x80A + 0x100 * num)
  72. #define OMAP_TLL_ULPI_INT_EN_RISE(num) (0x80D + 0x100 * num)
  73. #define OMAP_TLL_ULPI_INT_EN_FALL(num) (0x810 + 0x100 * num)
  74. #define OMAP_TLL_ULPI_INT_STATUS(num) (0x813 + 0x100 * num)
  75. #define OMAP_TLL_ULPI_INT_LATCH(num) (0x814 + 0x100 * num)
  76. #define OMAP_TLL_ULPI_DEBUG(num) (0x815 + 0x100 * num)
  77. #define OMAP_TLL_ULPI_SCRATCH_REGISTER(num) (0x816 + 0x100 * num)
  78. #define OMAP_TLL_CHANNEL_COUNT 3
  79. #define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 0)
  80. #define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 1)
  81. #define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 2)
  82. /* UHH Register Set */
  83. #define OMAP_UHH_REVISION (0x00)
  84. #define OMAP_UHH_SYSCONFIG (0x10)
  85. #define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
  86. #define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
  87. #define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
  88. #define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
  89. #define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
  90. #define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
  91. #define OMAP_UHH_SYSSTATUS (0x14)
  92. #define OMAP_UHH_HOSTCONFIG (0x40)
  93. #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
  94. #define OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS (1 << 0)
  95. #define OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS (1 << 11)
  96. #define OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS (1 << 12)
  97. #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
  98. #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
  99. #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
  100. #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
  101. #define OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS (1 << 8)
  102. #define OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS (1 << 9)
  103. #define OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS (1 << 10)
  104. #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1 << 31)
  105. /* OMAP4-specific defines */
  106. #define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3 << 2)
  107. #define OMAP4_UHH_SYSCONFIG_NOIDLE (1 << 2)
  108. #define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR (3 << 4)
  109. #define OMAP4_UHH_SYSCONFIG_NOSTDBY (1 << 4)
  110. #define OMAP4_UHH_SYSCONFIG_SOFTRESET (1 << 0)
  111. #define OMAP4_P1_MODE_CLEAR (3 << 16)
  112. #define OMAP4_P1_MODE_TLL (1 << 16)
  113. #define OMAP4_P1_MODE_HSIC (3 << 16)
  114. #define OMAP4_P2_MODE_CLEAR (3 << 18)
  115. #define OMAP4_P2_MODE_TLL (1 << 18)
  116. #define OMAP4_P2_MODE_HSIC (3 << 18)
  117. #define OMAP_REV2_TLL_CHANNEL_COUNT 2
  118. #define OMAP_UHH_DEBUG_CSR (0x44)
  119. /* Values of UHH_REVISION - Note: these are not given in the TRM */
  120. #define OMAP_USBHS_REV1 0x00000010 /* OMAP3 */
  121. #define OMAP_USBHS_REV2 0x50700100 /* OMAP4 */
  122. #define is_omap_usbhs_rev1(x) (x->usbhs_rev == OMAP_USBHS_REV1)
  123. #define is_omap_usbhs_rev2(x) (x->usbhs_rev == OMAP_USBHS_REV2)
  124. #define is_ehci_phy_mode(x) (x == OMAP_EHCI_PORT_MODE_PHY)
  125. #define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL)
  126. #define is_ehci_hsic_mode(x) (x == OMAP_EHCI_PORT_MODE_HSIC)
  127. struct usbhs_hcd_omap {
  128. struct clk *usbhost_ick;
  129. struct clk *usbhost_hs_fck;
  130. struct clk *usbhost_fs_fck;
  131. struct clk *xclk60mhsp1_ck;
  132. struct clk *xclk60mhsp2_ck;
  133. struct clk *utmi_p1_fck;
  134. struct clk *usbhost_p1_fck;
  135. struct clk *usbtll_p1_fck;
  136. struct clk *utmi_p2_fck;
  137. struct clk *usbhost_p2_fck;
  138. struct clk *usbtll_p2_fck;
  139. struct clk *init_60m_fclk;
  140. struct clk *usbtll_fck;
  141. struct clk *usbtll_ick;
  142. void __iomem *uhh_base;
  143. void __iomem *tll_base;
  144. struct usbhs_omap_platform_data platdata;
  145. u32 usbhs_rev;
  146. spinlock_t lock;
  147. int count;
  148. };
  149. /*-------------------------------------------------------------------------*/
  150. const char usbhs_driver_name[] = USBHS_DRIVER_NAME;
  151. static u64 usbhs_dmamask = ~(u32)0;
  152. /*-------------------------------------------------------------------------*/
  153. static inline void usbhs_write(void __iomem *base, u32 reg, u32 val)
  154. {
  155. __raw_writel(val, base + reg);
  156. }
  157. static inline u32 usbhs_read(void __iomem *base, u32 reg)
  158. {
  159. return __raw_readl(base + reg);
  160. }
  161. static inline void usbhs_writeb(void __iomem *base, u8 reg, u8 val)
  162. {
  163. __raw_writeb(val, base + reg);
  164. }
  165. static inline u8 usbhs_readb(void __iomem *base, u8 reg)
  166. {
  167. return __raw_readb(base + reg);
  168. }
  169. /*-------------------------------------------------------------------------*/
  170. static struct platform_device *omap_usbhs_alloc_child(const char *name,
  171. struct resource *res, int num_resources, void *pdata,
  172. size_t pdata_size, struct device *dev)
  173. {
  174. struct platform_device *child;
  175. int ret;
  176. child = platform_device_alloc(name, 0);
  177. if (!child) {
  178. dev_err(dev, "platform_device_alloc %s failed\n", name);
  179. goto err_end;
  180. }
  181. ret = platform_device_add_resources(child, res, num_resources);
  182. if (ret) {
  183. dev_err(dev, "platform_device_add_resources failed\n");
  184. goto err_alloc;
  185. }
  186. ret = platform_device_add_data(child, pdata, pdata_size);
  187. if (ret) {
  188. dev_err(dev, "platform_device_add_data failed\n");
  189. goto err_alloc;
  190. }
  191. child->dev.dma_mask = &usbhs_dmamask;
  192. child->dev.coherent_dma_mask = 0xffffffff;
  193. child->dev.parent = dev;
  194. ret = platform_device_add(child);
  195. if (ret) {
  196. dev_err(dev, "platform_device_add failed\n");
  197. goto err_alloc;
  198. }
  199. return child;
  200. err_alloc:
  201. platform_device_put(child);
  202. err_end:
  203. return NULL;
  204. }
  205. static int omap_usbhs_alloc_children(struct platform_device *pdev)
  206. {
  207. struct device *dev = &pdev->dev;
  208. struct usbhs_hcd_omap *omap;
  209. struct ehci_hcd_omap_platform_data *ehci_data;
  210. struct ohci_hcd_omap_platform_data *ohci_data;
  211. struct platform_device *ehci;
  212. struct platform_device *ohci;
  213. struct resource *res;
  214. struct resource resources[2];
  215. int ret;
  216. omap = platform_get_drvdata(pdev);
  217. ehci_data = omap->platdata.ehci_data;
  218. ohci_data = omap->platdata.ohci_data;
  219. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
  220. if (!res) {
  221. dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n");
  222. ret = -ENODEV;
  223. goto err_end;
  224. }
  225. resources[0] = *res;
  226. res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ehci-irq");
  227. if (!res) {
  228. dev_err(dev, " EHCI get resource IORESOURCE_IRQ failed\n");
  229. ret = -ENODEV;
  230. goto err_end;
  231. }
  232. resources[1] = *res;
  233. ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data,
  234. sizeof(*ehci_data), dev);
  235. if (!ehci) {
  236. dev_err(dev, "omap_usbhs_alloc_child failed\n");
  237. goto err_end;
  238. }
  239. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ohci");
  240. if (!res) {
  241. dev_err(dev, "OHCI get resource IORESOURCE_MEM failed\n");
  242. ret = -ENODEV;
  243. goto err_ehci;
  244. }
  245. resources[0] = *res;
  246. res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ohci-irq");
  247. if (!res) {
  248. dev_err(dev, "OHCI get resource IORESOURCE_IRQ failed\n");
  249. ret = -ENODEV;
  250. goto err_ehci;
  251. }
  252. resources[1] = *res;
  253. ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data,
  254. sizeof(*ohci_data), dev);
  255. if (!ohci) {
  256. dev_err(dev, "omap_usbhs_alloc_child failed\n");
  257. goto err_ehci;
  258. }
  259. return 0;
  260. err_ehci:
  261. platform_device_put(ehci);
  262. err_end:
  263. return ret;
  264. }
  265. /**
  266. * usbhs_omap_probe - initialize TI-based HCDs
  267. *
  268. * Allocates basic resources for this USB host controller.
  269. */
  270. static int __devinit usbhs_omap_probe(struct platform_device *pdev)
  271. {
  272. struct device *dev = &pdev->dev;
  273. struct usbhs_omap_platform_data *pdata = dev->platform_data;
  274. struct usbhs_hcd_omap *omap;
  275. struct resource *res;
  276. int ret = 0;
  277. int i;
  278. if (!pdata) {
  279. dev_err(dev, "Missing platform data\n");
  280. ret = -ENOMEM;
  281. goto end_probe;
  282. }
  283. omap = kzalloc(sizeof(*omap), GFP_KERNEL);
  284. if (!omap) {
  285. dev_err(dev, "Memory allocation failed\n");
  286. ret = -ENOMEM;
  287. goto end_probe;
  288. }
  289. spin_lock_init(&omap->lock);
  290. for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
  291. omap->platdata.port_mode[i] = pdata->port_mode[i];
  292. omap->platdata.ehci_data = pdata->ehci_data;
  293. omap->platdata.ohci_data = pdata->ohci_data;
  294. omap->usbhost_ick = clk_get(dev, "usbhost_ick");
  295. if (IS_ERR(omap->usbhost_ick)) {
  296. ret = PTR_ERR(omap->usbhost_ick);
  297. dev_err(dev, "usbhost_ick failed error:%d\n", ret);
  298. goto err_end;
  299. }
  300. omap->usbhost_hs_fck = clk_get(dev, "hs_fck");
  301. if (IS_ERR(omap->usbhost_hs_fck)) {
  302. ret = PTR_ERR(omap->usbhost_hs_fck);
  303. dev_err(dev, "usbhost_hs_fck failed error:%d\n", ret);
  304. goto err_usbhost_ick;
  305. }
  306. omap->usbhost_fs_fck = clk_get(dev, "fs_fck");
  307. if (IS_ERR(omap->usbhost_fs_fck)) {
  308. ret = PTR_ERR(omap->usbhost_fs_fck);
  309. dev_err(dev, "usbhost_fs_fck failed error:%d\n", ret);
  310. goto err_usbhost_hs_fck;
  311. }
  312. omap->usbtll_fck = clk_get(dev, "usbtll_fck");
  313. if (IS_ERR(omap->usbtll_fck)) {
  314. ret = PTR_ERR(omap->usbtll_fck);
  315. dev_err(dev, "usbtll_fck failed error:%d\n", ret);
  316. goto err_usbhost_fs_fck;
  317. }
  318. omap->usbtll_ick = clk_get(dev, "usbtll_ick");
  319. if (IS_ERR(omap->usbtll_ick)) {
  320. ret = PTR_ERR(omap->usbtll_ick);
  321. dev_err(dev, "usbtll_ick failed error:%d\n", ret);
  322. goto err_usbtll_fck;
  323. }
  324. omap->utmi_p1_fck = clk_get(dev, "utmi_p1_gfclk");
  325. if (IS_ERR(omap->utmi_p1_fck)) {
  326. ret = PTR_ERR(omap->utmi_p1_fck);
  327. dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret);
  328. goto err_usbtll_ick;
  329. }
  330. omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck");
  331. if (IS_ERR(omap->xclk60mhsp1_ck)) {
  332. ret = PTR_ERR(omap->xclk60mhsp1_ck);
  333. dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret);
  334. goto err_utmi_p1_fck;
  335. }
  336. omap->utmi_p2_fck = clk_get(dev, "utmi_p2_gfclk");
  337. if (IS_ERR(omap->utmi_p2_fck)) {
  338. ret = PTR_ERR(omap->utmi_p2_fck);
  339. dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret);
  340. goto err_xclk60mhsp1_ck;
  341. }
  342. omap->xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2_ck");
  343. if (IS_ERR(omap->xclk60mhsp2_ck)) {
  344. ret = PTR_ERR(omap->xclk60mhsp2_ck);
  345. dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret);
  346. goto err_utmi_p2_fck;
  347. }
  348. omap->usbhost_p1_fck = clk_get(dev, "usb_host_hs_utmi_p1_clk");
  349. if (IS_ERR(omap->usbhost_p1_fck)) {
  350. ret = PTR_ERR(omap->usbhost_p1_fck);
  351. dev_err(dev, "usbhost_p1_fck failed error:%d\n", ret);
  352. goto err_xclk60mhsp2_ck;
  353. }
  354. omap->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk");
  355. if (IS_ERR(omap->usbtll_p1_fck)) {
  356. ret = PTR_ERR(omap->usbtll_p1_fck);
  357. dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
  358. goto err_usbhost_p1_fck;
  359. }
  360. omap->usbhost_p2_fck = clk_get(dev, "usb_host_hs_utmi_p2_clk");
  361. if (IS_ERR(omap->usbhost_p2_fck)) {
  362. ret = PTR_ERR(omap->usbhost_p2_fck);
  363. dev_err(dev, "usbhost_p2_fck failed error:%d\n", ret);
  364. goto err_usbtll_p1_fck;
  365. }
  366. omap->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
  367. if (IS_ERR(omap->usbtll_p2_fck)) {
  368. ret = PTR_ERR(omap->usbtll_p2_fck);
  369. dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
  370. goto err_usbhost_p2_fck;
  371. }
  372. omap->init_60m_fclk = clk_get(dev, "init_60m_fclk");
  373. if (IS_ERR(omap->init_60m_fclk)) {
  374. ret = PTR_ERR(omap->init_60m_fclk);
  375. dev_err(dev, "init_60m_fclk failed error:%d\n", ret);
  376. goto err_usbtll_p2_fck;
  377. }
  378. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
  379. if (!res) {
  380. dev_err(dev, "UHH EHCI get resource failed\n");
  381. ret = -ENODEV;
  382. goto err_init_60m_fclk;
  383. }
  384. omap->uhh_base = ioremap(res->start, resource_size(res));
  385. if (!omap->uhh_base) {
  386. dev_err(dev, "UHH ioremap failed\n");
  387. ret = -ENOMEM;
  388. goto err_init_60m_fclk;
  389. }
  390. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tll");
  391. if (!res) {
  392. dev_err(dev, "UHH EHCI get resource failed\n");
  393. ret = -ENODEV;
  394. goto err_tll;
  395. }
  396. omap->tll_base = ioremap(res->start, resource_size(res));
  397. if (!omap->tll_base) {
  398. dev_err(dev, "TLL ioremap failed\n");
  399. ret = -ENOMEM;
  400. goto err_tll;
  401. }
  402. platform_set_drvdata(pdev, omap);
  403. ret = omap_usbhs_alloc_children(pdev);
  404. if (ret) {
  405. dev_err(dev, "omap_usbhs_alloc_children failed\n");
  406. goto err_alloc;
  407. }
  408. goto end_probe;
  409. err_alloc:
  410. iounmap(omap->tll_base);
  411. err_tll:
  412. iounmap(omap->uhh_base);
  413. err_init_60m_fclk:
  414. clk_put(omap->init_60m_fclk);
  415. err_usbtll_p2_fck:
  416. clk_put(omap->usbtll_p2_fck);
  417. err_usbhost_p2_fck:
  418. clk_put(omap->usbhost_p2_fck);
  419. err_usbtll_p1_fck:
  420. clk_put(omap->usbtll_p1_fck);
  421. err_usbhost_p1_fck:
  422. clk_put(omap->usbhost_p1_fck);
  423. err_xclk60mhsp2_ck:
  424. clk_put(omap->xclk60mhsp2_ck);
  425. err_utmi_p2_fck:
  426. clk_put(omap->utmi_p2_fck);
  427. err_xclk60mhsp1_ck:
  428. clk_put(omap->xclk60mhsp1_ck);
  429. err_utmi_p1_fck:
  430. clk_put(omap->utmi_p1_fck);
  431. err_usbtll_ick:
  432. clk_put(omap->usbtll_ick);
  433. err_usbtll_fck:
  434. clk_put(omap->usbtll_fck);
  435. err_usbhost_fs_fck:
  436. clk_put(omap->usbhost_fs_fck);
  437. err_usbhost_hs_fck:
  438. clk_put(omap->usbhost_hs_fck);
  439. err_usbhost_ick:
  440. clk_put(omap->usbhost_ick);
  441. err_end:
  442. kfree(omap);
  443. end_probe:
  444. return ret;
  445. }
  446. /**
  447. * usbhs_omap_remove - shutdown processing for UHH & TLL HCDs
  448. * @pdev: USB Host Controller being removed
  449. *
  450. * Reverses the effect of usbhs_omap_probe().
  451. */
  452. static int __devexit usbhs_omap_remove(struct platform_device *pdev)
  453. {
  454. struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
  455. if (omap->count != 0) {
  456. dev_err(&pdev->dev,
  457. "Either EHCI or OHCI is still using usbhs core\n");
  458. return -EBUSY;
  459. }
  460. iounmap(omap->tll_base);
  461. iounmap(omap->uhh_base);
  462. clk_put(omap->init_60m_fclk);
  463. clk_put(omap->usbtll_p2_fck);
  464. clk_put(omap->usbhost_p2_fck);
  465. clk_put(omap->usbtll_p1_fck);
  466. clk_put(omap->usbhost_p1_fck);
  467. clk_put(omap->xclk60mhsp2_ck);
  468. clk_put(omap->utmi_p2_fck);
  469. clk_put(omap->xclk60mhsp1_ck);
  470. clk_put(omap->utmi_p1_fck);
  471. clk_put(omap->usbtll_ick);
  472. clk_put(omap->usbtll_fck);
  473. clk_put(omap->usbhost_fs_fck);
  474. clk_put(omap->usbhost_hs_fck);
  475. clk_put(omap->usbhost_ick);
  476. kfree(omap);
  477. return 0;
  478. }
  479. static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
  480. {
  481. switch (pmode) {
  482. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  483. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  484. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  485. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  486. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  487. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  488. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  489. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  490. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  491. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  492. return true;
  493. default:
  494. return false;
  495. }
  496. }
  497. /*
  498. * convert the port-mode enum to a value we can use in the FSLSMODE
  499. * field of USBTLL_CHANNEL_CONF
  500. */
  501. static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode)
  502. {
  503. switch (mode) {
  504. case OMAP_USBHS_PORT_MODE_UNUSED:
  505. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:
  506. return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0;
  507. case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:
  508. return OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM;
  509. case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:
  510. return OMAP_TLL_FSLSMODE_3PIN_PHY;
  511. case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:
  512. return OMAP_TLL_FSLSMODE_4PIN_PHY;
  513. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:
  514. return OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0;
  515. case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:
  516. return OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM;
  517. case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:
  518. return OMAP_TLL_FSLSMODE_3PIN_TLL;
  519. case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:
  520. return OMAP_TLL_FSLSMODE_4PIN_TLL;
  521. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:
  522. return OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0;
  523. case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:
  524. return OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM;
  525. default:
  526. pr_warning("Invalid port mode, using default\n");
  527. return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0;
  528. }
  529. }
  530. static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count)
  531. {
  532. struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
  533. struct usbhs_omap_platform_data *pdata = dev->platform_data;
  534. unsigned reg;
  535. int i;
  536. /* Program Common TLL register */
  537. reg = usbhs_read(omap->tll_base, OMAP_TLL_SHARED_CONF);
  538. reg |= (OMAP_TLL_SHARED_CONF_FCLK_IS_ON
  539. | OMAP_TLL_SHARED_CONF_USB_DIVRATION);
  540. reg &= ~OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN;
  541. reg &= ~OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN;
  542. usbhs_write(omap->tll_base, OMAP_TLL_SHARED_CONF, reg);
  543. /* Enable channels now */
  544. for (i = 0; i < tll_channel_count; i++) {
  545. reg = usbhs_read(omap->tll_base,
  546. OMAP_TLL_CHANNEL_CONF(i));
  547. if (is_ohci_port(pdata->port_mode[i])) {
  548. reg |= ohci_omap3_fslsmode(pdata->port_mode[i])
  549. << OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT;
  550. reg |= OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS;
  551. } else if (pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_TLL) {
  552. /* Disable AutoIdle, BitStuffing and use SDR Mode */
  553. reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE
  554. | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
  555. | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
  556. reg |= (1 << (i + 1));
  557. } else
  558. continue;
  559. reg |= OMAP_TLL_CHANNEL_CONF_CHANEN;
  560. usbhs_write(omap->tll_base,
  561. OMAP_TLL_CHANNEL_CONF(i), reg);
  562. usbhs_writeb(omap->tll_base,
  563. OMAP_TLL_ULPI_SCRATCH_REGISTER(i), 0xbe);
  564. }
  565. }
  566. static int usbhs_enable(struct device *dev)
  567. {
  568. struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
  569. struct usbhs_omap_platform_data *pdata = &omap->platdata;
  570. unsigned long flags = 0;
  571. int ret = 0;
  572. unsigned long timeout;
  573. unsigned reg;
  574. dev_dbg(dev, "starting TI HSUSB Controller\n");
  575. if (!pdata) {
  576. dev_dbg(dev, "missing platform_data\n");
  577. return -ENODEV;
  578. }
  579. spin_lock_irqsave(&omap->lock, flags);
  580. if (omap->count > 0)
  581. goto end_count;
  582. clk_enable(omap->usbhost_ick);
  583. clk_enable(omap->usbhost_hs_fck);
  584. clk_enable(omap->usbhost_fs_fck);
  585. clk_enable(omap->usbtll_fck);
  586. clk_enable(omap->usbtll_ick);
  587. if (pdata->ehci_data->phy_reset) {
  588. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) {
  589. gpio_request(pdata->ehci_data->reset_gpio_port[0],
  590. "USB1 PHY reset");
  591. gpio_direction_output
  592. (pdata->ehci_data->reset_gpio_port[0], 0);
  593. }
  594. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) {
  595. gpio_request(pdata->ehci_data->reset_gpio_port[1],
  596. "USB2 PHY reset");
  597. gpio_direction_output
  598. (pdata->ehci_data->reset_gpio_port[1], 0);
  599. }
  600. /* Hold the PHY in RESET for enough time till DIR is high */
  601. udelay(10);
  602. }
  603. omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
  604. dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
  605. /* perform TLL soft reset, and wait until reset is complete */
  606. usbhs_write(omap->tll_base, OMAP_USBTLL_SYSCONFIG,
  607. OMAP_USBTLL_SYSCONFIG_SOFTRESET);
  608. /* Wait for TLL reset to complete */
  609. timeout = jiffies + msecs_to_jiffies(1000);
  610. while (!(usbhs_read(omap->tll_base, OMAP_USBTLL_SYSSTATUS)
  611. & OMAP_USBTLL_SYSSTATUS_RESETDONE)) {
  612. cpu_relax();
  613. if (time_after(jiffies, timeout)) {
  614. dev_dbg(dev, "operation timed out\n");
  615. ret = -EINVAL;
  616. goto err_tll;
  617. }
  618. }
  619. dev_dbg(dev, "TLL RESET DONE\n");
  620. /* (1<<3) = no idle mode only for initial debugging */
  621. usbhs_write(omap->tll_base, OMAP_USBTLL_SYSCONFIG,
  622. OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
  623. OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
  624. OMAP_USBTLL_SYSCONFIG_AUTOIDLE);
  625. /* Put UHH in NoIdle/NoStandby mode */
  626. reg = usbhs_read(omap->uhh_base, OMAP_UHH_SYSCONFIG);
  627. if (is_omap_usbhs_rev1(omap)) {
  628. reg |= (OMAP_UHH_SYSCONFIG_ENAWAKEUP
  629. | OMAP_UHH_SYSCONFIG_SIDLEMODE
  630. | OMAP_UHH_SYSCONFIG_CACTIVITY
  631. | OMAP_UHH_SYSCONFIG_MIDLEMODE);
  632. reg &= ~OMAP_UHH_SYSCONFIG_AUTOIDLE;
  633. } else if (is_omap_usbhs_rev2(omap)) {
  634. reg &= ~OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR;
  635. reg |= OMAP4_UHH_SYSCONFIG_NOIDLE;
  636. reg &= ~OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR;
  637. reg |= OMAP4_UHH_SYSCONFIG_NOSTDBY;
  638. }
  639. usbhs_write(omap->uhh_base, OMAP_UHH_SYSCONFIG, reg);
  640. reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
  641. /* setup ULPI bypass and burst configurations */
  642. reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
  643. | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
  644. | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN);
  645. reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK;
  646. reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
  647. if (is_omap_usbhs_rev1(omap)) {
  648. if (pdata->port_mode[0] == OMAP_USBHS_PORT_MODE_UNUSED)
  649. reg &= ~OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS;
  650. if (pdata->port_mode[1] == OMAP_USBHS_PORT_MODE_UNUSED)
  651. reg &= ~OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS;
  652. if (pdata->port_mode[2] == OMAP_USBHS_PORT_MODE_UNUSED)
  653. reg &= ~OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS;
  654. /* Bypass the TLL module for PHY mode operation */
  655. if (cpu_is_omap3430() && (omap_rev() <= OMAP3430_REV_ES2_1)) {
  656. dev_dbg(dev, "OMAP3 ES version <= ES2.1\n");
  657. if (is_ehci_phy_mode(pdata->port_mode[0]) ||
  658. is_ehci_phy_mode(pdata->port_mode[1]) ||
  659. is_ehci_phy_mode(pdata->port_mode[2]))
  660. reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
  661. else
  662. reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
  663. } else {
  664. dev_dbg(dev, "OMAP3 ES version > ES2.1\n");
  665. if (is_ehci_phy_mode(pdata->port_mode[0]))
  666. reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
  667. else
  668. reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
  669. if (is_ehci_phy_mode(pdata->port_mode[1]))
  670. reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;
  671. else
  672. reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS;
  673. if (is_ehci_phy_mode(pdata->port_mode[2]))
  674. reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;
  675. else
  676. reg |= OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS;
  677. }
  678. } else if (is_omap_usbhs_rev2(omap)) {
  679. /* Clear port mode fields for PHY mode*/
  680. reg &= ~OMAP4_P1_MODE_CLEAR;
  681. reg &= ~OMAP4_P2_MODE_CLEAR;
  682. if (is_ehci_phy_mode(pdata->port_mode[0])) {
  683. ret = clk_set_parent(omap->utmi_p1_fck,
  684. omap->xclk60mhsp1_ck);
  685. if (ret != 0) {
  686. dev_err(dev, "xclk60mhsp1_ck set parent"
  687. "failed error:%d\n", ret);
  688. goto err_tll;
  689. }
  690. } else if (is_ehci_tll_mode(pdata->port_mode[0])) {
  691. ret = clk_set_parent(omap->utmi_p1_fck,
  692. omap->init_60m_fclk);
  693. if (ret != 0) {
  694. dev_err(dev, "init_60m_fclk set parent"
  695. "failed error:%d\n", ret);
  696. goto err_tll;
  697. }
  698. clk_enable(omap->usbhost_p1_fck);
  699. clk_enable(omap->usbtll_p1_fck);
  700. }
  701. if (is_ehci_phy_mode(pdata->port_mode[1])) {
  702. ret = clk_set_parent(omap->utmi_p2_fck,
  703. omap->xclk60mhsp2_ck);
  704. if (ret != 0) {
  705. dev_err(dev, "xclk60mhsp1_ck set parent"
  706. "failed error:%d\n", ret);
  707. goto err_tll;
  708. }
  709. } else if (is_ehci_tll_mode(pdata->port_mode[1])) {
  710. ret = clk_set_parent(omap->utmi_p2_fck,
  711. omap->init_60m_fclk);
  712. if (ret != 0) {
  713. dev_err(dev, "init_60m_fclk set parent"
  714. "failed error:%d\n", ret);
  715. goto err_tll;
  716. }
  717. clk_enable(omap->usbhost_p2_fck);
  718. clk_enable(omap->usbtll_p2_fck);
  719. }
  720. clk_enable(omap->utmi_p1_fck);
  721. clk_enable(omap->utmi_p2_fck);
  722. if (is_ehci_tll_mode(pdata->port_mode[0]) ||
  723. (is_ohci_port(pdata->port_mode[0])))
  724. reg |= OMAP4_P1_MODE_TLL;
  725. else if (is_ehci_hsic_mode(pdata->port_mode[0]))
  726. reg |= OMAP4_P1_MODE_HSIC;
  727. if (is_ehci_tll_mode(pdata->port_mode[1]) ||
  728. (is_ohci_port(pdata->port_mode[1])))
  729. reg |= OMAP4_P2_MODE_TLL;
  730. else if (is_ehci_hsic_mode(pdata->port_mode[1]))
  731. reg |= OMAP4_P2_MODE_HSIC;
  732. }
  733. usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
  734. dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
  735. if (is_ehci_tll_mode(pdata->port_mode[0]) ||
  736. is_ehci_tll_mode(pdata->port_mode[1]) ||
  737. is_ehci_tll_mode(pdata->port_mode[2]) ||
  738. (is_ohci_port(pdata->port_mode[0])) ||
  739. (is_ohci_port(pdata->port_mode[1])) ||
  740. (is_ohci_port(pdata->port_mode[2]))) {
  741. /* Enable UTMI mode for required TLL channels */
  742. if (is_omap_usbhs_rev2(omap))
  743. usbhs_omap_tll_init(dev, OMAP_REV2_TLL_CHANNEL_COUNT);
  744. else
  745. usbhs_omap_tll_init(dev, OMAP_TLL_CHANNEL_COUNT);
  746. }
  747. if (pdata->ehci_data->phy_reset) {
  748. /* Hold the PHY in RESET for enough time till
  749. * PHY is settled and ready
  750. */
  751. udelay(10);
  752. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
  753. gpio_set_value
  754. (pdata->ehci_data->reset_gpio_port[0], 1);
  755. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
  756. gpio_set_value
  757. (pdata->ehci_data->reset_gpio_port[1], 1);
  758. }
  759. end_count:
  760. omap->count++;
  761. spin_unlock_irqrestore(&omap->lock, flags);
  762. return 0;
  763. err_tll:
  764. if (pdata->ehci_data->phy_reset) {
  765. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
  766. gpio_free(pdata->ehci_data->reset_gpio_port[0]);
  767. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
  768. gpio_free(pdata->ehci_data->reset_gpio_port[1]);
  769. }
  770. clk_disable(omap->usbtll_ick);
  771. clk_disable(omap->usbtll_fck);
  772. clk_disable(omap->usbhost_fs_fck);
  773. clk_disable(omap->usbhost_hs_fck);
  774. clk_disable(omap->usbhost_ick);
  775. spin_unlock_irqrestore(&omap->lock, flags);
  776. return ret;
  777. }
  778. static void usbhs_disable(struct device *dev)
  779. {
  780. struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
  781. struct usbhs_omap_platform_data *pdata = &omap->platdata;
  782. unsigned long flags = 0;
  783. unsigned long timeout;
  784. dev_dbg(dev, "stopping TI HSUSB Controller\n");
  785. spin_lock_irqsave(&omap->lock, flags);
  786. if (omap->count == 0)
  787. goto end_disble;
  788. omap->count--;
  789. if (omap->count != 0)
  790. goto end_disble;
  791. /* Reset OMAP modules for insmod/rmmod to work */
  792. usbhs_write(omap->uhh_base, OMAP_UHH_SYSCONFIG,
  793. is_omap_usbhs_rev2(omap) ?
  794. OMAP4_UHH_SYSCONFIG_SOFTRESET :
  795. OMAP_UHH_SYSCONFIG_SOFTRESET);
  796. timeout = jiffies + msecs_to_jiffies(100);
  797. while (!(usbhs_read(omap->uhh_base, OMAP_UHH_SYSSTATUS)
  798. & (1 << 0))) {
  799. cpu_relax();
  800. if (time_after(jiffies, timeout))
  801. dev_dbg(dev, "operation timed out\n");
  802. }
  803. while (!(usbhs_read(omap->uhh_base, OMAP_UHH_SYSSTATUS)
  804. & (1 << 1))) {
  805. cpu_relax();
  806. if (time_after(jiffies, timeout))
  807. dev_dbg(dev, "operation timed out\n");
  808. }
  809. while (!(usbhs_read(omap->uhh_base, OMAP_UHH_SYSSTATUS)
  810. & (1 << 2))) {
  811. cpu_relax();
  812. if (time_after(jiffies, timeout))
  813. dev_dbg(dev, "operation timed out\n");
  814. }
  815. usbhs_write(omap->tll_base, OMAP_USBTLL_SYSCONFIG, (1 << 1));
  816. while (!(usbhs_read(omap->tll_base, OMAP_USBTLL_SYSSTATUS)
  817. & (1 << 0))) {
  818. cpu_relax();
  819. if (time_after(jiffies, timeout))
  820. dev_dbg(dev, "operation timed out\n");
  821. }
  822. if (pdata->ehci_data->phy_reset) {
  823. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
  824. gpio_free(pdata->ehci_data->reset_gpio_port[0]);
  825. if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
  826. gpio_free(pdata->ehci_data->reset_gpio_port[1]);
  827. }
  828. clk_disable(omap->utmi_p2_fck);
  829. clk_disable(omap->utmi_p1_fck);
  830. clk_disable(omap->usbtll_ick);
  831. clk_disable(omap->usbtll_fck);
  832. clk_disable(omap->usbhost_fs_fck);
  833. clk_disable(omap->usbhost_hs_fck);
  834. clk_disable(omap->usbhost_ick);
  835. end_disble:
  836. spin_unlock_irqrestore(&omap->lock, flags);
  837. }
  838. int omap_usbhs_enable(struct device *dev)
  839. {
  840. return usbhs_enable(dev->parent);
  841. }
  842. EXPORT_SYMBOL_GPL(omap_usbhs_enable);
  843. void omap_usbhs_disable(struct device *dev)
  844. {
  845. usbhs_disable(dev->parent);
  846. }
  847. EXPORT_SYMBOL_GPL(omap_usbhs_disable);
  848. static struct platform_driver usbhs_omap_driver = {
  849. .driver = {
  850. .name = (char *)usbhs_driver_name,
  851. .owner = THIS_MODULE,
  852. },
  853. .remove = __exit_p(usbhs_omap_remove),
  854. };
  855. MODULE_AUTHOR("Keshava Munegowda <keshava_mgowda@ti.com>");
  856. MODULE_ALIAS("platform:" USBHS_DRIVER_NAME);
  857. MODULE_LICENSE("GPL v2");
  858. MODULE_DESCRIPTION("usb host common core driver for omap EHCI and OHCI");
  859. static int __init omap_usbhs_drvinit(void)
  860. {
  861. return platform_driver_probe(&usbhs_omap_driver, usbhs_omap_probe);
  862. }
  863. /*
  864. * init before ehci and ohci drivers;
  865. * The usbhs core driver should be initialized much before
  866. * the omap ehci and ohci probe functions are called.
  867. */
  868. fs_initcall(omap_usbhs_drvinit);
  869. static void __exit omap_usbhs_drvexit(void)
  870. {
  871. platform_driver_unregister(&usbhs_omap_driver);
  872. }
  873. module_exit(omap_usbhs_drvexit);