]> git.sur5r.net Git - u-boot/commitdiff
usb: dwc2: force to host mode if not support HNP/SRP
authorMeng Dongyang <daniel.meng@rock-chips.com>
Thu, 8 Jun 2017 07:34:20 +0000 (15:34 +0800)
committerMarek Vasut <marex@denx.de>
Sat, 17 Jun 2017 15:59:03 +0000 (17:59 +0200)
In current code, after running the command of "usb start", the controller
will keep in otg mode and can't switch to host mode if not support
SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS
to config the contrller work in force mode of host.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
drivers/usb/host/dwc2.c

index bbaefd23341e418966a2c2245f7b96c5b1e0087e..841e596700c47c78a07dde638ffb09ae60e44b00 100644 (file)
@@ -43,6 +43,7 @@ struct dwc2_priv {
        struct dwc2_core_regs *regs;
        int root_hub_devnum;
        bool ext_vbus;
+       bool hnp_srp_disable;
        bool oc_disable;
 };
 
@@ -394,6 +395,9 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
                usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M;
        }
 #endif
+       if (priv->hnp_srp_disable)
+               usbcfg |= DWC2_GUSBCFG_FORCEHOSTMODE;
+
        writel(usbcfg, &regs->gusbcfg);
 
        /* Program the GAHBCFG Register. */
@@ -422,12 +426,16 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 
        writel(ahbcfg, &regs->gahbcfg);
 
-       /* Program the GUSBCFG register for HNP/SRP. */
-       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP);
+       /* Program the capabilities in GUSBCFG Register */
+       usbcfg = 0;
 
+       if (!priv->hnp_srp_disable)
+               usbcfg |= DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP;
 #ifdef CONFIG_DWC2_IC_USB_CAP
-       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_IC_USB_CAP);
+       usbcfg |= DWC2_GUSBCFG_IC_USB_CAP;
 #endif
+
+       setbits_le32(&regs->gusbcfg, usbcfg);
 }
 
 /*
@@ -1244,6 +1252,11 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
        if (prop)
                priv->oc_disable = true;
 
+       prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
+                          "hnp-srp-disable", NULL);
+       if (prop)
+               priv->hnp_srp_disable = true;
+
        return 0;
 }