public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable
Date: Wed, 27 Apr 2016 15:24:05 +0200	[thread overview]
Message-ID: <1461763446-6763-3-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1461763446-6763-1-git-send-email-marex@denx.de>

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(-)

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;
 }
 
-- 
2.7.0

  parent reply	other threads:[~2016-04-27 13:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 13:24 [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init() Marek Vasut
2016-04-27 13:24 ` [U-Boot] [PATCH 2/4] usb: dwc2: Pull Ext VBUS macro from dwc_otg_core_init() Marek Vasut
2016-04-28  6:17   ` Stefan Roese
2016-04-27 13:24 ` Marek Vasut [this message]
2016-04-28  6:17   ` [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable Stefan Roese
2016-04-27 13:24 ` [U-Boot] [PATCH 4/4] ARM: socfpga: Disable USB OC protection on SoCrates Marek Vasut
2016-04-28  6:17   ` Stefan Roese
2016-04-28  6:16 ` [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init() Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461763446-6763-3-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox