diff mbox series

[U-Boot,RESEND,4/5] usb: host: dwc2: add usb33d supply support for stm32mp1

Message ID 20191014080025.11245-5-patrick.delaunay@st.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series usb: host: dwc2: use driver model for PHY and CLOCK | expand

Commit Message

Patrick DELAUNAY Oct. 14, 2019, 8 a.m. UTC
Enable the usb33d-supply on STM32MP1 SoCs (with "st,stm32mp1-hsotg"
compatible), it is the external VBUS and ID sensing comparators supply
needed to perform OTG operation.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/usb/host/dwc2.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Marek Vasut Oct. 14, 2019, 11:31 p.m. UTC | #1
On 10/14/19 10:00 AM, Patrick Delaunay wrote:
> Enable the usb33d-supply on STM32MP1 SoCs (with "st,stm32mp1-hsotg"
> compatible), it is the external VBUS and ID sensing comparators supply
> needed to perform OTG operation.

I suspect we might need some dwc2-stm32p1.c SoC-specific driver here.
Adding SoC-specific stuff into common driver doesn't sound right.
Patrick DELAUNAY Nov. 6, 2019, 6:42 p.m. UTC | #2
Hi,

> 
> On 10/14/19 10:00 AM, Patrick Delaunay wrote:
> > Enable the usb33d-supply on STM32MP1 SoCs (with "st,stm32mp1-hsotg"
> > compatible), it is the external VBUS and ID sensing comparators supply
> > needed to perform OTG operation.
> 
> I suspect we might need some dwc2-stm32p1.c SoC-specific driver here.
> Adding SoC-specific stuff into common driver doesn't sound right.

Yes, you are right... I perhaps  need to rework this patch.

Today I will drop this part in the V2 patchset.
I will resubmit a other patch later for this part because I need to cross-checks with Linux driver....

This stm32mp1 specific part also exist in our dwc2 kernel driver but I need to check if it can be upstreamed (modification in binding dwc2 is acceptable).

Patrick
diff mbox series

Patch

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 3086411fc4..5b499abded 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -1414,6 +1414,24 @@  static int dwc2_usb_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	if (CONFIG_IS_ENABLED(ARCH_STM32MP) &&
+	    device_is_compatible(dev, "st,stm32mp1-hsotg")) {
+		struct udevice *usb33d_supply;
+
+		ret = device_get_supply_regulator(dev, "usb33d-supply",
+						  &usb33d_supply);
+		if (ret) {
+			dev_err(dev,
+				"can't get voltage level detector supply\n");
+		} else {
+			ret = regulator_set_enable(usb33d_supply, true);
+			if (ret) {
+				dev_err(dev,
+					"can't enable voltage level detector supply\n");
+			}
+		}
+	}
+
 	return dwc2_init_common(dev, priv);
 }