usb: ehci: add rockchip relinquishing port quirk support
authorFrank Wang <frank.wang@rock-chips.com>
Wed, 29 Mar 2017 10:26:34 +0000 (18:26 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Mar 2017 11:59:44 +0000 (19:59 +0800)
Add a quirk to support rockchip relinquishing port from abnormal ohci
to ehci when FS/LS devices plug in.

To support this function, the rockchip-relinquish-port property must be
specified in ehci node of dt.

Change-Id: I91b58905132282ef2a836d54a1c7ace1e334d119
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
drivers/usb/host/ehci-platform.c

index 6f69798e3452589c328f98db986d58d675a04a02..7866008c4350e4d9808753ca132ac329034df59f 100644 (file)
@@ -51,6 +51,18 @@ struct ehci_platform_priv {
 
 static const char hcd_name[] = "ehci-platform";
 
+static void ehci_rockchip_relinquish_port(struct usb_hcd *hcd, int portnum)
+{
+       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+       u32 __iomem *status_reg = &ehci->regs->port_status[--portnum];
+       u32 portsc;
+
+       portsc = ehci_readl(ehci, status_reg);
+       portsc &= ~(PORT_OWNER | PORT_RWC_BITS);
+
+       ehci_writel(ehci, portsc, status_reg);
+}
+
 static int ehci_platform_reset(struct usb_hcd *hcd)
 {
        struct platform_device *pdev = to_platform_device(hcd->self.controller);
@@ -202,6 +214,11 @@ static int ehci_platform_probe(struct platform_device *dev)
                                          "has-transaction-translator"))
                        hcd->has_tt = 1;
 
+               if (of_property_read_bool(dev->dev.of_node,
+                                         "rockchip-relinquish-port"))
+                       ehci_platform_hc_driver.relinquish_port =
+                                         ehci_rockchip_relinquish_port;
+
                priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
                                "phys", "#phy-cells");