[PATCH v2 1/1] usb: dwc3: Add optional VBUS regulator support to SpacemiT K1
Chukun Pan
amadeus at jmu.edu.cn
Fri Mar 20 03:01:20 PDT 2026
Some SpacemiT K1 boards (like OrangePi R2S) provide USB VBUS
through a controllable regulator. Add support for the optional
vbus-supply property so the regulator can be properly managed
in host mode instead of left always-on. Note that this doesn't
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>
---
drivers/usb/dwc3/dwc3-generic-plat.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/dwc3-generic-plat.c b/drivers/usb/dwc3/dwc3-generic-plat.c
index e846844e0023..bd281fde5ce0 100644
--- a/drivers/usb/dwc3/dwc3-generic-plat.c
+++ b/drivers/usb/dwc3/dwc3-generic-plat.c
@@ -12,6 +12,8 @@
#include <linux/reset.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>
+#include <linux/regulator/consumer.h>
+#include <linux/usb/otg.h>
#include "glue.h"
#define EIC7700_HSP_BUS_FILTER_EN BIT(0)
@@ -69,6 +71,20 @@ static int dwc3_eic7700_init(struct dwc3_generic *dwc3g)
return 0;
}
+static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g)
+{
+ struct device *dev = dwc3g->dev;
+
+ if (usb_get_dr_mode(dev) == USB_DR_MODE_HOST) {
+ int ret = devm_regulator_get_enable_optional(dev, "vbus");
+
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable VBUS\n");
+ }
+
+ return 0;
+}
+
static int dwc3_generic_probe(struct platform_device *pdev)
{
const struct dwc3_generic_config *plat_config;
@@ -210,10 +226,14 @@ static const struct dwc3_generic_config eic7700_dwc3 = {
.properties = DWC3_DEFAULT_PROPERTIES,
};
+static const struct dwc3_generic_config spacemit_k1_dwc3 = {
+ .init = dwc3_spacemit_k1_init,
+};
+
static const struct of_device_id dwc3_generic_of_match[] = {
- { .compatible = "spacemit,k1-dwc3", },
{ .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3},
{ .compatible = "eswin,eic7700-dwc3", &eic7700_dwc3},
+ { .compatible = "spacemit,k1-dwc3", &spacemit_k1_dwc3},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, dwc3_generic_of_match);
--
2.34.1
More information about the linux-riscv
mailing list