From: Rosen Penev <rosenp@gmail.com>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] usb: fsl-mph-dr-of: add regulator support
Date: Tue, 30 Jun 2026 12:51:44 -0700 [thread overview]
Message-ID: <20260630195144.88122-1-rosenp@gmail.com> (raw)
Some devices have a GPIO that controls power to the USB bus. Add
support for a vbus regulator to have the kernel control it automatically
instead of having to rely on userspace.
Acquire the regulator in the common probe path so that it works for
all fsl-usb2-dr compatible controllers, not just MPC5121.
Tested on a TP-LINK WDR4900v1 by adding roughly the following
reg_power_usb: regulator {
compatible = "regulator-fixed";
regulator-name = "power_usb";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
enable-active-high;
regulator-boot-on;
};
uhubctl and rmmod both turn USB power off.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/usb/host/fsl-mph-dr-of.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 852649156b16..85b08f2f162d 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -14,6 +14,7 @@
#include <linux/clk.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
+#include <linux/regulator/consumer.h>
struct fsl_usb2_dev_data {
char *dr_mode; /* controller mode */
@@ -182,7 +183,7 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
const struct fsl_usb2_platform_data *match_data;
const unsigned char *prop;
static unsigned int idx;
- int i;
+ int i, err;
if (!of_device_is_available(np))
return -ENODEV;
@@ -242,6 +243,10 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
}
}
+ err = devm_regulator_get_enable_optional(&ofdev->dev, "vbus");
+ if (err)
+ return dev_err_probe(&ofdev->dev, err, "failed to get vbus regulator\n");
+
for (i = 0; i < ARRAY_SIZE(dev_data->drivers); i++) {
if (!dev_data->drivers[i])
continue;
--
2.55.0
reply other threads:[~2026-06-30 19:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260630195144.88122-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox