From: Mehmet Fide <mehmet.fide@gmail.com>
To: Marek Vasut <marek.vasut+usb@mailbox.org>
Cc: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Fabio Estevam <festevam@gmail.com>,
Stefan Agner <stefan@agner.ch>,
Francesco Dolcini <francesco@dolcini.it>,
u-boot@lists.u-boot-project.org, mehmet.fide@screeningeagle.com
Subject: [PATCH v7 9/9] usb: ehci-vf: enable the vbus supply of the port
Date: Tue, 20 Oct 2026 12:16:08 +0200 [thread overview]
Message-ID: <20261020101608.2818265-10-mehmet.fide@gmail.com> (raw)
In-Reply-To: <20261020101608.2818265-1-mehmet.fide@gmail.com>
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
The driver never enables the vbus-supply of its port, so on boards that
switch VBUS through a regulator, such as the Colibri VF50 and VF61
carriers, the port stays unpowered and no device is found.
Do what ehci-mx6 does: look the regulator up in probe, enable it in
host mode, disable it in device mode, and turn it off on remove. A
missing vbus-supply or a build without DM_REGULATOR is fine; any other
lookup error fails the probe instead of leaving the port dead.
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
Notes:
Changes in v7:
- the Reviewed-by of Marek and Simon on v6 is dropped: the VBUS code is
unchanged, but the remove hook now comes from patch 7 and this patch
adds its VBUS line to it
Changes in v6:
- dev_err() and dev_dbg() for the two messages; the reset hook reaches
the device through the private data
Changes in v5:
- none
Changes in v4:
- enable VBUS in the reset hook only, as ehci-mx6 does: enabling it in
the shared init as well counted two enables per probe, so "usb stop"
never switched it off
- the dm core patch it needed is dropped, next claims the regulator
GPIO at probe time
- reworded the commit message
drivers/usb/host/ehci-vf.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index e67eae834b0..ca2023cf7f5 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -20,7 +20,9 @@
#include <asm/mach-imx/regs-usbphy.h>
#include <linux/delay.h>
#include <usb/ehci-ci.h>
+#include <power/regulator.h>
#include <linux/usb/otg.h>
+#include <dm/device_compat.h>
#include "ehci.h"
@@ -42,6 +44,8 @@ struct ehci_vf_priv_data {
struct anadig_reg __iomem *anatop_addr;
void __iomem *phy_addr;
void __iomem *misc_addr;
+ struct udevice *vbus_supply;
+ struct udevice *dev;
u32 portnr;
};
@@ -221,9 +225,9 @@ static int vf_usb_of_to_plat(struct udevice *dev)
return 0;
}
-static int vf_init_after_reset(struct ehci_ctrl *dev)
+static int vf_init_after_reset(struct ehci_ctrl *ctrl)
{
- struct ehci_vf_priv_data *priv = dev->priv;
+ struct ehci_vf_priv_data *priv = ctrl->priv;
enum usb_init_type type = priv->init_type;
struct usb_ehci *ehci = priv->ehci;
int ret;
@@ -232,6 +236,13 @@ static int vf_init_after_reset(struct ehci_ctrl *dev)
if (ret)
return ret;
+ ret = regulator_set_enable_if_allowed(priv->vbus_supply,
+ type != USB_INIT_DEVICE);
+ if (ret && ret != -ENOSYS) {
+ dev_err(priv->dev, "cannot enable the VBUS supply: %d\n", ret);
+ return ret;
+ }
+
if (type == USB_INIT_DEVICE)
return 0;
@@ -257,6 +268,16 @@ static int ehci_usb_probe(struct udevice *dev)
struct ehci_hcor *hcor;
int ret;
+ priv->dev = dev;
+ ret = device_get_supply_regulator(dev, "vbus-supply",
+ &priv->vbus_supply);
+ if (ret == -ENOENT || ret == -ENOSYS) {
+ dev_dbg(dev, "no VBUS supply\n");
+ } else if (ret) {
+ dev_err(dev, "cannot get the VBUS supply: %d\n", ret);
+ return ret;
+ }
+
if (priv->dr_mode == USB_DR_MODE_OTG) {
ret = gpio_request_by_name(dev, "fsl,cdet-gpio", 0,
&priv->cdet_gpio, GPIOD_IS_IN);
@@ -313,6 +334,8 @@ static int ehci_usb_remove(struct udevice *dev)
{
struct ehci_vf_priv_data *priv = dev_get_priv(dev);
+ regulator_set_enable_if_allowed(priv->vbus_supply, false);
+
if (dm_gpio_is_valid(&priv->cdet_gpio))
dm_gpio_free(dev, &priv->cdet_gpio);
--
2.55.0
next prev parent reply other threads:[~2026-10-20 10:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 10:15 [PATCH v7 0/9] usb: ehci-vf: make the USB host port usable Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 1/9] fdtdec: match an alias to its stem only when the number follows it Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 2/9] usb: ehci-vf: take the controller index from the device tree Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 3/9] usb: ehci-vf: remove the code path for a build without DM_USB Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 4/9] usb: ehci-vf: drop the empty bind hook Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 5/9] dm: core: add ofnode_get_alias_seq() Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 6/9] usb: ehci-vf: use usb_get_dr_mode() Mehmet Fide
2026-10-21 0:09 ` Marek Vasut
2026-10-21 11:59 ` Mehmet Fide
2026-10-21 12:07 ` Marek Vasut
2026-10-21 12:21 ` Mehmet Fide
2026-10-21 13:17 ` Marek Vasut
2026-10-21 18:41 ` Mehmet Fide
2026-10-21 18:56 ` Marek Vasut
2026-10-20 10:16 ` [PATCH v7 7/9] usb: ehci-vf: request the ID detect gpio through the device Mehmet Fide
2026-10-21 0:10 ` Marek Vasut
2026-10-20 10:16 ` [PATCH v7 8/9] usb: ehci-vf: take the register bases from the device tree Mehmet Fide
2026-10-21 0:13 ` Marek Vasut
2026-10-20 10:16 ` Mehmet Fide [this message]
2026-10-21 0:13 ` [PATCH v7 9/9] usb: ehci-vf: enable the vbus supply of the port Marek Vasut
2026-10-21 11:59 ` Mehmet Fide
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020101608.2818265-10-mehmet.fide@gmail.com \
--to=mehmet.fide@gmail.com \
--cc=festevam@gmail.com \
--cc=francesco@dolcini.it \
--cc=marek.vasut+usb@mailbox.org \
--cc=mehmet.fide@screeningeagle.com \
--cc=sjg@chromium.org \
--cc=stefan@agner.ch \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.