public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init()
@ 2016-04-27 13:24 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
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Marek Vasut @ 2016-04-27 13:24 UTC (permalink / raw)
  To: u-boot

Pass the whole bulk of private data instead of just the regs,
since the private data will soon contain important configuration
flags.

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index b2f4bc6..637b6c0 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -252,8 +252,9 @@ static void dwc_otg_core_host_init(struct dwc2_core_regs *regs)
  *
  * @param regs Programming view of the DWC_otg controller
  */
-static void dwc_otg_core_init(struct dwc2_core_regs *regs)
+static void dwc_otg_core_init(struct dwc2_priv *priv)
 {
+	struct dwc2_core_regs *regs = priv->regs;
 	uint32_t ahbcfg = 0;
 	uint32_t usbcfg = 0;
 	uint8_t brst_sz = CONFIG_DWC2_DMA_BURST_SIZE;
@@ -1056,7 +1057,7 @@ static int dwc2_init_common(struct dwc2_priv *priv)
 		return -ENODEV;
 	}
 
-	dwc_otg_core_init(regs);
+	dwc_otg_core_init(priv);
 	dwc_otg_core_host_init(regs);
 
 	clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/4] usb: dwc2: Pull Ext VBUS macro from dwc_otg_core_init()
  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 ` Marek Vasut
  2016-04-28  6:17   ` Stefan Roese
  2016-04-27 13:24 ` [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable Marek Vasut
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2016-04-27 13:24 UTC (permalink / raw)
  To: u-boot

Introduce a boolean flag in the dwc2 controller private data and set
it according to the macro (for now) instead of having this macro
directly in the dwc_otg_core_init(). This will let us configure the
flag from DT or such later on, if needed.

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 | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 637b6c0..5673220 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -39,6 +39,7 @@ struct dwc2_priv {
 	u8 out_data_toggle[MAX_DEVICE][MAX_ENDPOINT];
 	struct dwc2_core_regs *regs;
 	int root_hub_devnum;
+	bool ext_vbus;
 };
 
 #ifndef CONFIG_DM_USB
@@ -263,13 +264,13 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)
 	usbcfg = readl(&regs->gusbcfg);
 
 	/* Program the ULPI External VBUS bit if needed */
-#ifdef CONFIG_DWC2_PHY_ULPI_EXT_VBUS
-	usbcfg |= (DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV |
-		   DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR |
-		   DWC2_GUSBCFG_INDICATOR_PASSTHROUGH);
-#else
-	usbcfg &= ~DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
-#endif
+	if (priv->ext_vbus) {
+		usbcfg |= (DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV |
+			   DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR |
+			   DWC2_GUSBCFG_INDICATOR_PASSTHROUGH);
+	} else {
+		usbcfg &= ~DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
+	}
 
 	/* Set external TS Dline pulsing */
 #ifdef CONFIG_DWC2_TS_DLINE
@@ -1057,6 +1058,12 @@ static int dwc2_init_common(struct dwc2_priv *priv)
 		return -ENODEV;
 	}
 
+#ifdef CONFIG_DWC2_PHY_ULPI_EXT_VBUS
+	priv->ext_vbus = 1;
+#else
+	priv->ext_vbus = 0;
+#endif
+
 	dwc_otg_core_init(priv);
 	dwc_otg_core_host_init(regs);
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable
  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-27 13:24 ` Marek Vasut
  2016-04-28  6:17   ` 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:16 ` [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init() Stefan Roese
  3 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2016-04-27 13:24 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 4/4] ARM: socfpga: Disable USB OC protection on SoCrates
  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-27 13:24 ` [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable Marek Vasut
@ 2016-04-27 13:24 ` 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
  3 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2016-04-27 13:24 UTC (permalink / raw)
  To: u-boot

This is mandatory, otherwise the USB does not work.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
---
 arch/arm/dts/socfpga_cyclone5_socrates.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/socfpga_cyclone5_socrates.dts b/arch/arm/dts/socfpga_cyclone5_socrates.dts
index d2ab3b3..bdd9324 100644
--- a/arch/arm/dts/socfpga_cyclone5_socrates.dts
+++ b/arch/arm/dts/socfpga_cyclone5_socrates.dts
@@ -83,5 +83,6 @@
 };
 
 &usb1 {
+	disable-over-current;
 	status = "okay";
 };
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init()
  2016-04-27 13:24 [U-Boot] [PATCH 1/4] usb: dwc2: Pass private data into dwc_otg_core_init() Marek Vasut
                   ` (2 preceding siblings ...)
  2016-04-27 13:24 ` [U-Boot] [PATCH 4/4] ARM: socfpga: Disable USB OC protection on SoCrates Marek Vasut
@ 2016-04-28  6:16 ` Stefan Roese
  3 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2016-04-28  6:16 UTC (permalink / raw)
  To: u-boot

On 27.04.2016 15:24, Marek Vasut wrote:
> Pass the whole bulk of private data instead of just the regs,
> since the private data will soon contain important configuration
> flags.
>
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/4] usb: dwc2: Pull Ext VBUS macro from dwc_otg_core_init()
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2016-04-28  6:17 UTC (permalink / raw)
  To: u-boot

On 27.04.2016 15:24, Marek Vasut wrote:
> Introduce a boolean flag in the dwc2 controller private data and set
> it according to the macro (for now) instead of having this macro
> directly in the dwc_otg_core_init(). This will let us configure the
> flag from DT or such later on, if needed.
>
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable
  2016-04-27 13:24 ` [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable Marek Vasut
@ 2016-04-28  6:17   ` Stefan Roese
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2016-04-28  6:17 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 4/4] ARM: socfpga: Disable USB OC protection on SoCrates
  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
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2016-04-28  6:17 UTC (permalink / raw)
  To: u-boot

On 27.04.2016 15:24, Marek Vasut wrote:
> This is mandatory, otherwise the USB does not work.
>
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-28  6:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [U-Boot] [PATCH 3/4] usb: dwc2: Make OC protection configurable Marek Vasut
2016-04-28  6:17   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox