mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
usb: fsl-mph-dr-of: add regulator support
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>
Link: https://patch.msgid.link/20260630195144.88122-1-rosenp@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
97cee53a94
commit
babf965320
|
|
@ -15,6 +15,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 */
|
||||
|
|
@ -183,7 +184,7 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
|
|||
const struct of_device_id *match;
|
||||
const unsigned char *prop;
|
||||
static unsigned int idx;
|
||||
int i;
|
||||
int i, err;
|
||||
|
||||
if (!of_device_is_available(np))
|
||||
return -ENODEV;
|
||||
|
|
@ -246,6 +247,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user