19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/types.h>
22 #include <linux/slab.h>
32 #define USBHS_DRIVER_NAME "usbhs_omap"
33 #define OMAP_EHCI_DEVICE "ehci-omap"
34 #define OMAP_OHCI_DEVICE "ohci-omap3"
39 #define OMAP_UHH_REVISION (0x00)
40 #define OMAP_UHH_SYSCONFIG (0x10)
41 #define OMAP_UHH_SYSCONFIG_MIDLEMODE (1 << 12)
42 #define OMAP_UHH_SYSCONFIG_CACTIVITY (1 << 8)
43 #define OMAP_UHH_SYSCONFIG_SIDLEMODE (1 << 3)
44 #define OMAP_UHH_SYSCONFIG_ENAWAKEUP (1 << 2)
45 #define OMAP_UHH_SYSCONFIG_SOFTRESET (1 << 1)
46 #define OMAP_UHH_SYSCONFIG_AUTOIDLE (1 << 0)
48 #define OMAP_UHH_SYSSTATUS (0x14)
49 #define OMAP_UHH_HOSTCONFIG (0x40)
50 #define OMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1 << 0)
51 #define OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS (1 << 0)
52 #define OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS (1 << 11)
53 #define OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS (1 << 12)
54 #define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
55 #define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
56 #define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN (1 << 4)
57 #define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
58 #define OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS (1 << 8)
59 #define OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS (1 << 9)
60 #define OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS (1 << 10)
61 #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1 << 31)
64 #define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3 << 2)
65 #define OMAP4_UHH_SYSCONFIG_NOIDLE (1 << 2)
66 #define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR (3 << 4)
67 #define OMAP4_UHH_SYSCONFIG_NOSTDBY (1 << 4)
68 #define OMAP4_UHH_SYSCONFIG_SOFTRESET (1 << 0)
70 #define OMAP4_P1_MODE_CLEAR (3 << 16)
71 #define OMAP4_P1_MODE_TLL (1 << 16)
72 #define OMAP4_P1_MODE_HSIC (3 << 16)
73 #define OMAP4_P2_MODE_CLEAR (3 << 18)
74 #define OMAP4_P2_MODE_TLL (1 << 18)
75 #define OMAP4_P2_MODE_HSIC (3 << 18)
77 #define OMAP_UHH_DEBUG_CSR (0x44)
80 #define OMAP_USBHS_REV1 0x00000010
81 #define OMAP_USBHS_REV2 0x50700100
83 #define is_omap_usbhs_rev1(x) (x->usbhs_rev == OMAP_USBHS_REV1)
84 #define is_omap_usbhs_rev2(x) (x->usbhs_rev == OMAP_USBHS_REV2)
86 #define is_ehci_phy_mode(x) (x == OMAP_EHCI_PORT_MODE_PHY)
87 #define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL)
88 #define is_ehci_hsic_mode(x) (x == OMAP_EHCI_PORT_MODE_HSIC)
147 dev_err(dev,
"platform_device_alloc %s failed\n", name);
153 dev_err(dev,
"platform_device_add_resources failed\n");
159 dev_err(dev,
"platform_device_add_data failed\n");
163 child->
dev.dma_mask = &usbhs_dmamask;
169 dev_err(dev,
"platform_device_add failed\n");
186 struct ehci_hcd_omap_platform_data *ehci_data;
187 struct ohci_hcd_omap_platform_data *ohci_data;
194 omap = platform_get_drvdata(pdev);
195 ehci_data = omap->
platdata.ehci_data;
196 ohci_data = omap->
platdata.ohci_data;
200 dev_err(dev,
"EHCI get resource IORESOURCE_MEM failed\n");
208 dev_err(dev,
" EHCI get resource IORESOURCE_IRQ failed\n");
215 sizeof(*ehci_data), dev);
218 dev_err(dev,
"omap_usbhs_alloc_child failed\n");
225 dev_err(dev,
"OHCI get resource IORESOURCE_MEM failed\n");
233 dev_err(dev,
"OHCI get resource IORESOURCE_IRQ failed\n");
240 sizeof(*ohci_data), dev);
242 dev_err(dev,
"omap_usbhs_alloc_child failed\n");
276 static int usbhs_runtime_resume(
struct device *dev)
279 struct usbhs_omap_platform_data *pdata = &omap->
platdata;
282 dev_dbg(dev,
"usbhs_runtime_resume\n");
285 dev_dbg(dev,
"missing platform_data\n");
303 spin_unlock_irqrestore(&omap->
lock, flags);
308 static int usbhs_runtime_suspend(
struct device *dev)
311 struct usbhs_omap_platform_data *pdata = &omap->
platdata;
314 dev_dbg(dev,
"usbhs_runtime_suspend\n");
317 dev_dbg(dev,
"missing platform_data\n");
334 spin_unlock_irqrestore(&omap->
lock, flags);
340 static void omap_usbhs_init(
struct device *dev)
343 struct usbhs_omap_platform_data *pdata = &omap->
platdata;
347 dev_dbg(dev,
"starting TI HSUSB Controller\n");
349 if (pdata->ehci_data->phy_reset) {
350 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
354 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
362 pm_runtime_get_sync(dev);
385 dev_dbg(dev,
"OMAP3 ES version <= ES2.1\n");
393 dev_dbg(dev,
"OMAP3 ES version > ES2.1\n");
413 (is_ohci_port(pdata->port_mode[0])))
419 (is_ohci_port(pdata->port_mode[1])))
426 dev_dbg(dev,
"UHH setup done, uhh_hostconfig=%x\n", reg);
428 spin_unlock_irqrestore(&omap->
lock, flags);
430 pm_runtime_put_sync(dev);
431 if (pdata->ehci_data->phy_reset) {
437 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
439 (pdata->ehci_data->reset_gpio_port[0], 1);
441 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
443 (pdata->ehci_data->reset_gpio_port[1], 1);
447 static void omap_usbhs_deinit(
struct device *dev)
450 struct usbhs_omap_platform_data *pdata = &omap->
platdata;
452 if (pdata->ehci_data->phy_reset) {
453 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
454 gpio_free(pdata->ehci_data->reset_gpio_port[0]);
456 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
457 gpio_free(pdata->ehci_data->reset_gpio_port[1]);
477 dev_err(dev,
"Missing platform data\n");
484 dev_err(dev,
"Memory allocation failed\n");
492 omap->
platdata.port_mode[i] = pdata->port_mode[i];
494 omap->
platdata.ehci_data = pdata->ehci_data;
495 omap->
platdata.ohci_data = pdata->ohci_data;
506 dev_warn(dev,
"ehci_logic_fck failed:%d\n",
515 dev_err(dev,
"utmi_p1_gfclk failed error:%d\n", ret);
522 dev_err(dev,
"xclk60mhsp1_ck failed error:%d\n", ret);
523 goto err_utmi_p1_fck;
529 dev_err(dev,
"utmi_p2_gfclk failed error:%d\n", ret);
530 goto err_xclk60mhsp1_ck;
536 dev_err(dev,
"xclk60mhsp2_ck failed error:%d\n", ret);
537 goto err_utmi_p2_fck;
543 dev_err(dev,
"usbhost_p1_fck failed error:%d\n", ret);
544 goto err_xclk60mhsp2_ck;
550 dev_err(dev,
"usbhost_p2_fck failed error:%d\n", ret);
551 goto err_usbhost_p1_fck;
557 dev_err(dev,
"init_60m_fclk failed error:%d\n", ret);
558 goto err_usbhost_p2_fck;
566 dev_err(dev,
"xclk60mhsp1_ck set parent"
567 "failed error:%d\n", ret);
572 dev_err(dev,
"init_60m_fclk set parent"
573 "failed error:%d\n", ret);
580 dev_err(dev,
"xclk60mhsp2_ck set parent"
581 "failed error:%d\n", ret);
586 dev_err(dev,
"init_60m_fclk set parent"
587 "failed error:%d\n", ret);
592 dev_err(dev,
"UHH EHCI get resource failed\n");
594 goto err_init_60m_fclk;
599 dev_err(dev,
"UHH ioremap failed\n");
601 goto err_init_60m_fclk;
604 platform_set_drvdata(pdev, omap);
606 omap_usbhs_init(dev);
607 ret = omap_usbhs_alloc_children(pdev);
609 dev_err(dev,
"omap_usbhs_alloc_children failed\n");
616 omap_usbhs_deinit(&pdev->
dev);
642 pm_runtime_disable(dev);
659 omap_usbhs_deinit(&pdev->
dev);
669 pm_runtime_disable(&pdev->
dev);
675 static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
676 .runtime_suspend = usbhs_runtime_suspend,
677 .runtime_resume = usbhs_runtime_resume,
684 .
pm = &usbhsomap_dev_pm_ops,
686 .
remove =
__exit_p(usbhs_omap_remove),
694 static int __init omap_usbhs_drvinit(
void)
708 static void __exit omap_usbhs_drvexit(
void)