[PATCH] usb: dwc3-generic: fix support without DM_REGULATOR

Robert Marko robert.marko at sartura.hr
Mon Apr 15 12:53:06 CEST 2024


Recent addition of vbus-supply support has broke platform which dont use
controllable regulators for USB.

Issue is that even withou DM_REGULATOR being enabled regulator related
functions will still build as there is a stub in regulator.h but they will
simply return -ENOSYS which will then make dwc3_generic_host_probe()
return the same error thus breaking probe.

Fixes: de451d5d5b6f ("usb: dwc3-generic: support external vbus regulator")
Signed-off-by: Robert Marko <robert.marko at sartura.hr>
---
 drivers/usb/dwc3/dwc3-generic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 7a00529a2a..784d3ec2ed 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -242,6 +242,7 @@ static int dwc3_generic_host_probe(struct udevice *dev)
 	if (rc)
 		return rc;
 
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
 	rc = device_get_supply_regulator(dev, "vbus-supply", &priv->vbus_supply);
 	if (rc)
 		debug("%s: No vbus regulator found: %d\n", dev->name, rc);
@@ -250,14 +251,17 @@ static int dwc3_generic_host_probe(struct udevice *dev)
 	rc = regulator_set_enable_if_allowed(priv->vbus_supply, true);
 	if (rc)
 		return rc;
+#endif
 
 	hccr = (struct xhci_hccr *)priv->gen_priv.base;
 	hcor = (struct xhci_hcor *)(priv->gen_priv.base +
 			HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
 
 	rc = xhci_register(dev, hccr, hcor);
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (rc)
 		regulator_set_enable_if_allowed(priv->vbus_supply, false);
+#endif
 
 	return rc;
 }
@@ -265,14 +269,18 @@ static int dwc3_generic_host_probe(struct udevice *dev)
 static int dwc3_generic_host_remove(struct udevice *dev)
 {
 	struct dwc3_generic_host_priv *priv = dev_get_priv(dev);
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
 	int rc;
+#endif
 
 	/* This function always returns 0 */
 	xhci_deregister(dev);
 
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
 	rc = regulator_set_enable_if_allowed(priv->vbus_supply, false);
 	if (rc)
 		debug("%s: Failed to disable vbus regulator: %d\n", dev->name, rc);
+#endif
 
 	return dwc3_generic_remove(dev, &priv->gen_priv);
 }
-- 
2.44.0



More information about the U-Boot mailing list