omap-usb-host.c 29 KB

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