On 8/22/26 11:20 AM, Bruno Banelli wrote:
Since commit 4fcba5d556b4 ("regulator: implement basic reference
counter") regulator_set_enable() returns -EALREADY when a fixed or
GPIO regulator has already been enabled. On boards whose VBUS
regulator carries regulator-always-on or regulator-boot-on -
armada-8040-mcbin.dts is one - regulator_autoset() enables it during
the regulator's own probe, so the subsequent enable in xhci_usb_probe()
fails and the controller is never registered:

   starting USB...
   Failed to turn ON the VBUS regulator
   Bus usb3@500000: probe failed, error -114
   No USB controllers found

Use regulator_set_enable_if_allowed(), which tolerates -EALREADY, in
the same way as commit 0830333c4743 ("usb: ehci-generic: Use
regulator_set_enable_if_allowed") and the other drivers converted
after the reference counter was introduced. Also tolerate -ENOSYS,
which include/power/regulator.h returns unconditionally from its
!DM_REGULATOR stub, matching the check ehci-generic.c already makes.

Tested on a SolidRun MACCHIATObin (Armada 8040), where USB mass
storage now enumerates.

Fixes: 4fcba5d556b4 ("regulator: implement basic reference counter")
Signed-off-by: Bruno Banelli <[email protected]>
---
  drivers/usb/host/xhci-mvebu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index c294a56b3c..f932acf848 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -51,8 +51,8 @@ static int xhci_usb_probe(struct udevice *dev)
ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
        if (!ret) {
-               ret = regulator_set_enable(regulator, true);
-               if (ret) {
+               ret = regulator_set_enable_if_allowed(regulator, true);
+               if (ret && ret != -ENOSYS) {
                        printf("Failed to turn ON the VBUS regulator\n");
You could also turn this printf() into dev_err() in a separate patch.

This one is:

Reviewed-by: Marek Vasut <[email protected]>

Thanks !

Reply via email to