diff mbox

[U-Boot,3/4] usb: dwc2: Make OC protection configurable

Message ID 1461763446-6763-3-git-send-email-marex@denx.de
State Accepted
Commit b4fbd089e4b7ead53d4a27148f6df9c18572b1ce
Delegated to: Marek Vasut
Headers show

Commit Message

Marek Vasut April 27, 2016, 1:24 p.m. UTC
Introduce a new flag in the controller private data, which allows selectively
disabling the OC protection. Use the standard 'disable-over-current' OF prop
to set this flag. This OC protection must be disabled on EBV SoCrates rev 1.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
---
 drivers/usb/host/dwc2.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Stefan Roese April 28, 2016, 6:17 a.m. UTC | #1
On 27.04.2016 15:24, Marek Vasut wrote:
> Introduce a new flag in the controller private data, which allows selectively
> disabling the OC protection. Use the standard 'disable-over-current' OF prop
> to set this flag. This OC protection must be disabled on EBV SoCrates rev 1.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Dinh Nguyen <dinguyen@kernel.org>

Tested-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
diff mbox

Patch

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 5673220..0c4adaf 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -18,6 +18,8 @@ 
 
 #include "dwc2.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Use only HC channel 0. */
 #define DWC2_HC_CHANNEL			0
 
@@ -40,6 +42,7 @@  struct dwc2_priv {
 	struct dwc2_core_regs *regs;
 	int root_hub_devnum;
 	bool ext_vbus;
+	bool oc_disable;
 };
 
 #ifndef CONFIG_DM_USB
@@ -265,9 +268,11 @@  static void dwc_otg_core_init(struct dwc2_priv *priv)
 
 	/* Program the ULPI External VBUS bit if needed */
 	if (priv->ext_vbus) {
-		usbcfg |= (DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV |
-			   DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR |
-			   DWC2_GUSBCFG_INDICATOR_PASSTHROUGH);
+		usbcfg |= DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
+		if (!priv->oc_disable) {
+			usbcfg |= DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR |
+				  DWC2_GUSBCFG_INDICATOR_PASSTHROUGH;
+		}
 	} else {
 		usbcfg &= ~DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
 	}
@@ -1177,6 +1182,7 @@  static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev,
 static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_priv *priv = dev_get_priv(dev);
+	const void *prop;
 	fdt_addr_t addr;
 
 	addr = dev_get_addr(dev);
@@ -1184,6 +1190,11 @@  static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	priv->regs = (struct dwc2_core_regs *)addr;
 
+	prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "disable-over-current",
+			   NULL);
+	if (prop)
+		priv->oc_disable = true;
+
 	return 0;
 }