[PATCH 1/1] usb: dwc3: dwc3-generic-plat: Add optional VBUS regulator support
Ze Huang
huang.ze at linux.dev
Mon Mar 16 21:15:02 PDT 2026
On Mon Mar 16, 2026 at 4:00 PM CST, Chukun Pan wrote:
> Some boards provide USB VBUS through a controllable regulator. Add
> support for the optional vbus-supply property so the regulator can
> be properly managed instead of left always-on. Note that this does
> not apply to USB Hub downstream ports with different VBUS supplies.
>
> The enabled and disabled actions of the regulator are handled
> automatically by devm_regulator_get_enable_optional().
>
> Signed-off-by: Chukun Pan <amadeus at jmu.edu.cn>
> ---
> The vbus-supply property has been declared in spacemit,k1-dwc3.yaml
> https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/usb/spacemit%2Ck1-dwc3.yaml#L71
> ---
> drivers/usb/dwc3/dwc3-generic-plat.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
> index e846844e0023..83b4e4d69ba9 100644
> --- a/drivers/usb/dwc3/dwc3-generic-plat.c
> +++ b/drivers/usb/dwc3/dwc3-generic-plat.c
> @@ -12,6 +12,7 @@
> #include <linux/reset.h>
> #include <linux/regmap.h>
> #include <linux/mfd/syscon.h>
> +#include <linux/regulator/consumer.h>
> #include "glue.h"
>
> #define EIC7700_HSP_BUS_FILTER_EN BIT(0)
> @@ -113,6 +114,10 @@ static int dwc3_generic_probe(struct platform_device *pdev)
> if (ret < 0)
> return dev_err_probe(dev, ret, "failed to get clocks\n");
>
> + ret = devm_regulator_get_enable_optional(dev, "vbus");
> + if (ret && ret != -ENODEV)
> + return dev_err_probe(dev, ret, "failed to enable VBUS\n");
> +
> dwc3g->num_clocks = ret;
> dwc3g->dwc.dev = dev;
> probe_data.dwc = &dwc3g->dwc;
This could be useful for boards with direct-attached VBUS.
Just to clarify, the vbus-supply binding is for potential direct-attached
designs. For current boards (like K1 BPI-F3 and Jupiter) with the VL817 hub,
we'll use onboard_usb_dev instead.
More information about the linux-riscv
mailing list