summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2021-03-31 12:19:27 +0200
committerMarek Vasut <marex@denx.de>2021-04-18 04:29:36 +0200
commit7e1f1e16fe75b0a5a2ef8dcbba5b6a543d6ec442 (patch)
treea850f4b4842c7a2875317cceec05f414bc576a35 /drivers/usb
parentf174a0dbce0b787053bf921eee3a635aef304957 (diff)
downloadu-boot-7e1f1e16fe75b0a5a2ef8dcbba5b6a543d6ec442.tar.gz
u-boot-7e1f1e16fe75b0a5a2ef8dcbba5b6a543d6ec442.tar.bz2
u-boot-7e1f1e16fe75b0a5a2ef8dcbba5b6a543d6ec442.zip
usb: ehci-mx6: Turn off Vbus on probe failure
The driver turns on Vbus regulator in probe, but fails to turn it back off in case of probe failure. Add the missing code. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Ye Li <ye.li@nxp.com> Cc: uboot-imx <uboot-imx@nxp.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/ehci-mx6.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index aeea539999..7b538b6dcb 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -640,7 +640,32 @@ static int ehci_usb_probe(struct udevice *dev)
hcor = (struct ehci_hcor *)((uint32_t)hccr +
HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
- return ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type);
+ ret = ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type);
+ if (ret)
+ goto err_regulator;
+
+ return ret;
+
+err_regulator:
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+ if (priv->vbus_supply)
+ regulator_set_enable(priv->vbus_supply, false);
+#endif
+ return ret;
+}
+
+int ehci_usb_remove(struct udevice *dev)
+{
+ struct ehci_mx6_priv_data *priv __maybe_unused = dev_get_priv(dev);
+
+ ehci_deregister(dev);
+
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+ if (priv->vbus_supply)
+ regulator_set_enable(priv->vbus_supply, false);
+#endif
+
+ return 0;
}
static const struct udevice_id mx6_usb_ids[] = {
@@ -655,7 +680,7 @@ U_BOOT_DRIVER(usb_mx6) = {
.of_to_plat = ehci_usb_of_to_plat,
.bind = ehci_usb_bind,
.probe = ehci_usb_probe,
- .remove = ehci_deregister,
+ .remove = ehci_usb_remove,
.ops = &ehci_usb_ops,
.plat_auto = sizeof(struct usb_plat),
.priv_auto = sizeof(struct ehci_mx6_priv_data),