Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc3: Add optional VBUS regulator support to SpacemiT K1

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@jmu.edu.cn>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Reviewed-by: Anand Moon <linux.amoon@gmail.com>
Link: https://patch.msgid.link/20260326100010.3588454-2-amadeus@jmu.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chukun Pan and committed by
Greg Kroah-Hartman
764c2e6e c05cf9d2

+22 -1
+22 -1
drivers/usb/dwc3/dwc3-generic-plat.c
··· 12 12 #include <linux/reset.h> 13 13 #include <linux/regmap.h> 14 14 #include <linux/mfd/syscon.h> 15 + #include <linux/regulator/consumer.h> 16 + #include <linux/usb/otg.h> 15 17 #include "glue.h" 16 18 17 19 #define EIC7700_HSP_BUS_FILTER_EN BIT(0) ··· 68 66 69 67 regmap_write(regmap, hsp_usb_axi_lp, EIC7700_HSP_AXI_LP_XM_CSYSREQ | 70 68 EIC7700_HSP_AXI_LP_XS_CSYSREQ); 69 + return 0; 70 + } 71 + 72 + static int dwc3_spacemit_k1_init(struct dwc3_generic *dwc3g) 73 + { 74 + struct device *dev = dwc3g->dev; 75 + 76 + if (usb_get_dr_mode(dev) == USB_DR_MODE_HOST) { 77 + int ret = devm_regulator_get_enable_optional(dev, "vbus"); 78 + 79 + if (ret && ret != -ENODEV) 80 + return dev_err_probe(dev, ret, "failed to enable VBUS\n"); 81 + } 82 + 71 83 return 0; 72 84 } 73 85 ··· 217 201 dwc3_generic_runtime_idle) 218 202 }; 219 203 204 + static const struct dwc3_generic_config spacemit_k1_dwc3 = { 205 + .init = dwc3_spacemit_k1_init, 206 + .properties = DWC3_DEFAULT_PROPERTIES, 207 + }; 208 + 220 209 static const struct dwc3_generic_config fsl_ls1028_dwc3 = { 221 210 .properties.gsbuscfg0_reqinfo = 0x2222, 222 211 }; ··· 232 211 }; 233 212 234 213 static const struct of_device_id dwc3_generic_of_match[] = { 235 - { .compatible = "spacemit,k1-dwc3", }, 214 + { .compatible = "spacemit,k1-dwc3", &spacemit_k1_dwc3}, 236 215 { .compatible = "spacemit,k3-dwc3", }, 237 216 { .compatible = "fsl,ls1028a-dwc3", &fsl_ls1028_dwc3}, 238 217 { .compatible = "eswin,eic7700-dwc3", &eic7700_dwc3},