]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
usb: host: xhci: plat: add support for otg_set_host() call
authorManish Narani <manish.narani@xilinx.com>
Fri, 27 Jan 2017 10:06:13 +0000 (15:36 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 30 Jan 2017 10:09:08 +0000 (11:09 +0100)
This patch will add support for OTG host initialization. This will
help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/usb/host/xhci-plat.c

index ed56bf9ed885fbb3766b6a30c9ac786023d351ec..1ced58089161f99b2341a26fdb6e14f2fa0520ee 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/usb/phy.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/usb/otg.h>
 
 #include "xhci.h"
 #include "xhci-plat.h"
@@ -135,6 +136,34 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static int usb_otg_set_host(struct device *dev, struct usb_hcd *hcd, bool yes)
+{
+       int ret = 0;
+
+       hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
+       if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
+               if (yes) {
+                       if (otg_set_host(hcd->usb_phy->otg, &hcd->self)) {
+                               usb_put_phy(hcd->usb_phy);
+                               goto disable_phy;
+                       }
+               } else {
+                       ret = otg_set_host(hcd->usb_phy->otg, NULL);
+                       usb_put_phy(hcd->usb_phy);
+                       goto disable_phy;
+               }
+
+       } else
+               goto disable_phy;
+
+       return 0;
+
+disable_phy:
+       hcd->usb_phy = NULL;
+
+       return ret;
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)
 {
        const struct of_device_id *match;
@@ -246,6 +275,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
        if (ret)
                goto dealloc_usb2_hcd;
 
+       ret = usb_otg_set_host(&pdev->dev, hcd, 1);
+       if (ret)
+               goto dealloc_usb2_hcd;
+
        return 0;
 
 
@@ -274,6 +307,8 @@ static int xhci_plat_remove(struct platform_device *dev)
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
        struct clk *clk = xhci->clk;
 
+       usb_otg_set_host(&dev->dev, hcd, 0);
+
        usb_remove_hcd(xhci->shared_hcd);
        usb_phy_shutdown(hcd->usb_phy);