usb: bcma: control VBUS via a regulator
Subsystems (3)
v3 cover usb: bcma: control VBUS via a regulator
bcma-hcd currently drives the USB power line by grabbing the undocumented "vcc-gpio" property from the controller node and poking it through gpiolib. Besides relying on a non-standard binding, this cannot work on boards such as the NETGEAR R7000 and R8000 where one chipcommon GPIO powers both the USB2 and USB3 cores: the two controllers each request that GPIO exclusively, so the second one fails with -EBUSY and its port stays dead.
Instead, switch the driver to the standard regulator interface and express the power rails as regulator-fixed nodes bound to the chipcommon GPIOs. The regulator core reference-counts enable/disable requests, letting both controllers share one GPIO without conflicts.
v3: don't drop GPIO.
v2: fixup dts and keep GPIO working.
Rosen Penev (2):
usb: bcma: add regulator support
ARM: dts: broadcom: model USB VBUS power with regulator-fixed
.../broadcom/bcm4708-buffalo-wxr-1750dhp.dts | 12 +++- .../bcm4708-buffalo-wzr-1166dhp-common.dtsi | 23 +++++++- .../broadcom/bcm4708-buffalo-wzr-1750dhp.dts | 23 +++++++- .../broadcom/bcm4708-linksys-ea6300-v1.dts | 12 +++- .../broadcom/bcm4708-linksys-ea6500-v2.dts | 12 +++- .../dts/broadcom/bcm4708-netgear-r6250.dts | 12 +++- .../dts/broadcom/bcm4708-netgear-r6300-v2.dts | 12 +++- .../dts/broadcom/bcm47081-luxul-xwr-1200.dts | 12 +++- .../broadcom/bcm47081-tplink-archer-c5-v2.dts | 12 +++- .../dts/broadcom/bcm4709-asus-rt-ac3200.dts | 12 +++- .../broadcom/bcm4709-buffalo-wxr-1900dhp.dts | 13 ++++- .../dts/broadcom/bcm4709-linksys-ea9200.dts | 24 +++++++- .../dts/broadcom/bcm4709-netgear-r7000.dts | 14 ++++- .../dts/broadcom/bcm4709-netgear-r8000.dts | 14 ++++- .../broadcom/bcm4709-tplink-archer-c9-v1.dts | 24 +++++++- .../dts/broadcom/bcm47094-asus-rt-ac3100.dtsi | 12 +++- .../dts/broadcom/bcm47094-asus-rt-ac5300.dts | 12 +++- .../dts/broadcom/bcm47094-dlink-dir-885l.dts | 12 +++- .../dts/broadcom/bcm47094-dlink-dir-890l.dts | 24 +++++++- .../broadcom/bcm47094-linksys-panamera.dts | 24 +++++++- .../dts/broadcom/bcm47094-luxul-abr-4500.dts | 12 +++- .../dts/broadcom/bcm47094-luxul-xbr-4500.dts | 12 +++- .../dts/broadcom/bcm47094-luxul-xwr-3100.dts | 12 +++- .../broadcom/bcm47094-luxul-xwr-3150-v1.dts | 12 +++- .../arm/boot/dts/broadcom/bcm947189acdbmr.dts | 12 +++- drivers/usb/host/bcma-hcd.c | 55 +++++++++++++++---- 26 files changed, 384 insertions(+), 46 deletions(-)
Signature · 1 line
2.55.0
PATCH v3 1/2 usb: bcma: add regulator support
bcma-hcd drives the USB power line by grabbing the undocumented "vcc-gpio" from the controller node and poking it through gpiolib. Besides relying on a non-standard binding, this cannot work on boards such as the NETGEAR R7000 and R8000 where one chipcommon GPIO powers both the USB2 and USB3 cores: the two controllers each request that GPIO exclusively, so the second one fails with -EBUSY and its port stays dead.
Add support for the standard regulator interface. Each core obtains its (shared) VBUS supply through devm_regulator_get() and the regulator core reference-counts the enable/disable requests, allowing both controllers to drive one GPIO without conflicts.
--- drivers/usb/host/bcma-hcd.c | 55 +++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 12 deletions(-)
drivers/usb/host/bcma-hcd.c +43 -12
@@ -26,6 +26,7 @@#include <linux/slab.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/regulator/consumer.h> #include <linux/usb/ehci_pdriver.h> #include <linux/usb/ohci_pdriver.h>
@@ -41,6 +42,7 @@ struct bcma_hcd_device {struct platform_device *ehci_dev;struct platform_device *ohci_dev;struct gpio_desc *gpio_desc; +struct regulator *regulator; };/* Wait for bitmask in a register to get set or cleared.
@@ -280,14 +282,23 @@ static int bcma_hcd_usb20_ns_init(struct bcma_hcd_device *bcma_hcd)return 0 ; } -static void bcma_hci_platform_power_gpio (struct bcma_device *dev,bool val) +static int bcma_hci_platform_power (struct bcma_device *dev,bool on) {struct bcma_hcd_device *usb_dev =bcma_get_drvdata (dev); +int err; + +if (usb_dev->gpio_desc) +return gpiod_set_value (usb_dev->gpio_desc, on); -if (!usb_dev->gpio_desc) -return ; +if (!usb_dev->regulator) +return 0 ; -gpiod_set_value (usb_dev->gpio_desc, val); +if (on) + err =regulator_enable (usb_dev->regulator); +else + err =regulator_disable (usb_dev->regulator); + +return err; }static const struct usb_ehci_pdata ehci_pdata = {
@@ -395,12 +406,12 @@ static int bcma_hcd_usb30_init(struct bcma_hcd_device *bcma_hcd)static int bcma_hcd_probe (struct bcma_device *core) {int err; +struct device *dev = &core->dev;struct bcma_hcd_device *usb_dev;/* TODO: Probably need checks here; is the core connected? */ - usb_dev =devm_kzalloc (&core->dev,sizeof (struct bcma_hcd_device ), -GFP_KERNEL ); + usb_dev =devm_kzalloc (dev,sizeof (*usb_dev),GFP_KERNEL );if (!usb_dev)return -ENOMEM ; usb_dev->core = core;
@@ -409,7 +420,15 @@ static int bcma_hcd_probe(struct bcma_device *core) GPIOD_OUT_HIGH);if (IS_ERR (usb_dev->gpio_desc))return dev_err_probe (&core->dev,PTR_ERR (usb_dev->gpio_desc), -"error obtaining VCC GPIO" ); +"error obtaining VBUS GPIO" ); + + usb_dev->regulator =devm_regulator_get (dev,"vbus" ); +if (IS_ERR (usb_dev->regulator)) +return dev_err_probe (dev,PTR_ERR (usb_dev->regulator),"error obtaining VBUS regulator" ); + + err =regulator_enable (usb_dev->regulator); +if (err) +return dev_err_probe (dev, err,"error enabling VBUS regulator" );switch (core->id.id) {case BCMA_CORE_USB20_HOST :
@@ -427,13 +446,16 @@ static int bcma_hcd_probe(struct bcma_device *core) err =bcma_hcd_usb30_init (usb_dev);break ;default : -return -ENODEV ; + err = -ENODEV ; }if (err) -return err; + goto error;bcma_set_drvdata (core, usb_dev);return 0 ; +error: +regulator_disable (usb_dev->regulator); +return err; }static void bcma_hcd_remove (struct bcma_device *dev)
@@ -447,12 +469,13 @@ static void bcma_hcd_remove(struct bcma_device *dev)if (ehci_dev)platform_device_unregister (ehci_dev); +regulator_disable (usb_dev->regulator);bcma_core_disable (dev,0 ); }static void bcma_hcd_shutdown (struct bcma_device *dev) { -bcma_hci_platform_power_gpio (dev, false); +bcma_hci_platform_power (dev, false);bcma_core_disable (dev,0 ); }
@@ -460,7 +483,11 @@ static void bcma_hcd_shutdown(struct bcma_device *dev)static int bcma_hcd_suspend (struct bcma_device *dev) { -bcma_hci_platform_power_gpio (dev, false); +int err; + + err =bcma_hci_platform_power (dev, false); +if (err) +return err;bcma_core_disable (dev,0 );return 0 ;
@@ -468,7 +495,11 @@ static int bcma_hcd_suspend(struct bcma_device *dev)static int bcma_hcd_resume (struct bcma_device *dev) { -bcma_hci_platform_power_gpio (dev, true); +int err; + + err =bcma_hci_platform_power (dev, true); +if (err) +return err;bcma_core_enable (dev,0 );return 0 ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCHv3 1/2] usb: bcma: add regulator support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] usb: bcma: redundant NULL check for regulator pointer --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] usb: bcma: redundant NULL check for regulator pointer
--
commit 3c80ddac8dba5090761a99f4b7fdd330945bd836
Author: Rosen Penev <[email protected]>
usb: bcma: add regulator support
This commit adds standard regulator interface support to the bcma-hcd driver, replacing the non-standard exclusive GPIO manipulation for VBUS power. It allows the regulator core to reference-count enable and disable requests so that shared GPIOs do not cause conflicts between USB2 and USB3 controllers.
Quoted 4 lines
drivers/usb/host/bcma-hcd.c +0
-0
[ ... ]
Quoted 7 lines
drivers/usb/host/bcma-hcd.c +1
-1@@ -280,14 +282,23 @@ static int bcma_hcd_usb20_ns_init(struct bcma_hcd_device *bcma_hcd)return 0 ; } -static void bcma_hci_platform_power_gpio (struct bcma_device *dev,bool val) +static int bcma_hci_platform_power (struct bcma_device *dev,bool on) {
drivers/usb/host/bcma-hcd.c static int bcma_hcd_usb20_ns_init(struct bcma_hcd_device *bcma_hcd) · line 294
Quoted 10 lines
drivers/usb/host/bcma-hcd.c +6
-2struct bcma_hcd_device *usb_dev =bcma_get_drvdata (dev); +int err; + +if (usb_dev->gpio_desc) +return gpiod_set_value (usb_dev->gpio_desc, on); -if (!usb_dev->gpio_desc) -return ; +if (!usb_dev->regulator) +return 0 ;
[Severity: Low]
Since devm_regulator_get() returns either an ERR_PTR or a valid pointer, and returns NULL only if CONFIG_REGULATOR is disabled, is this NULL check necessary? The regulator stubs safely accept NULL pointers and return 0, and the probe function already aborts if IS_ERR() is true.
Quoted 8 lines
drivers/usb/host/bcma-hcd.c +7
-0+ +if (on) + err =regulator_enable (usb_dev->regulator); +else + err =regulator_disable (usb_dev->regulator); + +return err; }
[ ... ]
Quoted 3 lines
drivers/usb/host/bcma-hcd.c +0
-0@@ -395,12 +406,12 @@ static int bcma_hcd_usb30_init(struct bcma_hcd_device *bcma_hcd)static int bcma_hcd_probe (struct bcma_device *core) {
[ ... ]
drivers/usb/host/bcma-hcd.c static int bcma_hcd_probe(struct bcma_device *core) · line 427
Quoted 10 lines
drivers/usb/host/bcma-hcd.c +5
-1usb_dev->gpio_desc =devm_gpiod_get_optional (&core->dev,"vcc" ,GPIOD_OUT_HIGH );if (IS_ERR (usb_dev->gpio_desc))return dev_err_probe (&core->dev,PTR_ERR (usb_dev->gpio_desc), -"error obtaining VCC GPIO" ); +"error obtaining VBUS GPIO" ); + + usb_dev->regulator =devm_regulator_get (dev,"vbus" ); +if (IS_ERR (usb_dev->regulator)) +return dev_err_probe (dev,PTR_ERR (usb_dev->regulator),"error obtaining VBUS regulator" );
[Severity: Low]
This is a pre-existing issue, but if probe fails here and returns directly, will the physical GPIO pin remain driven high indefinitely? The earlier call to devm_gpiod_get_optional() uses GPIOD_OUT_HIGH, and while devres will free the software descriptor, gpiod_put() intentionally does not revert the physical pin state.
drivers/usb/host/bcma-hcd.c static int bcma_hcd_probe(struct bcma_device *core) · line 431
Quoted 4 lines
drivers/usb/host/bcma-hcd.c +4
-0+ + err =regulator_enable (usb_dev->regulator); +if (err) +return dev_err_probe (dev, err,"error enabling VBUS regulator" );
[Severity: Low]
This is a pre-existing issue, but similar to the above, does this direct return skip reverting the GPIO state?
Quoted 3 lines
drivers/usb/host/bcma-hcd.c +0
-0switch (core->id.id) {case BCMA_CORE_USB20_HOST :
[ ... ]
drivers/usb/host/bcma-hcd.c static int bcma_hcd_probe(struct bcma_device *core) · line 453
Quoted 10 lines
drivers/usb/host/bcma-hcd.c +4
-1@@ -427,13 +446,16 @@ static int bcma_hcd_probe(struct bcma_device *core)if (err) -return err; + goto error;bcma_set_drvdata (core, usb_dev);return 0 ; +error: +regulator_disable (usb_dev->regulator); +return err;
[Severity: Low]
This is a pre-existing issue, but while this common error path correctly handles disabling the newly added regulator, does it also need to drive the pre-existing GPIO back low so the peripheral isn't left powered indefinitely on failure?
Quoted 1 line
drivers/usb/host/bcma-hcd.c +0
-0}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v3 2/2 ARM: dts: broadcom: model USB VBUS power with regulator-fixed
In reply to Rosen PenevReplace the undocumented "vcc-gpio" property on the usb2/usb3 controller nodes with the standard vbus-supply/regulator-fixed model. Boards now declare a regulator bound to the chipcommon GPIO that bcma-hcd used to poke directly, one per power rail.
Polarity is preserved: rails that used a GPIO_ACTIVE_HIGH are marked enable-active-high, while the Buffalo usb3 rails keep GPIO_ACTIVE_LOW and rely on the binding's active-low default. regulator-boot-on mirrors the rail being left enabled by CFE so the power line is never toggled during probe.
--- .../broadcom/bcm4708-buffalo-wxr-1750dhp.dts | 12 +++++++++- .../bcm4708-buffalo-wzr-1166dhp-common.dtsi | 23 ++++++++++++++++-- .../broadcom/bcm4708-buffalo-wzr-1750dhp.dts | 23 ++++++++++++++++-- .../broadcom/bcm4708-linksys-ea6300-v1.dts | 12 +++++++++- .../broadcom/bcm4708-linksys-ea6500-v2.dts | 12 +++++++++- .../dts/broadcom/bcm4708-netgear-r6250.dts | 12 +++++++++- .../dts/broadcom/bcm4708-netgear-r6300-v2.dts | 12 +++++++++- .../dts/broadcom/bcm47081-luxul-xwr-1200.dts | 12 +++++++++- .../broadcom/bcm47081-tplink-archer-c5-v2.dts | 12 +++++++++- .../dts/broadcom/bcm4709-asus-rt-ac3200.dts | 12 +++++++++- .../broadcom/bcm4709-buffalo-wxr-1900dhp.dts | 13 ++++++++-- .../dts/broadcom/bcm4709-linksys-ea9200.dts | 24 +++++++++++++++++-- .../dts/broadcom/bcm4709-netgear-r7000.dts | 14 +++++++++-- .../dts/broadcom/bcm4709-netgear-r8000.dts | 14 +++++++++-- .../broadcom/bcm4709-tplink-archer-c9-v1.dts | 24 +++++++++++++++++-- .../dts/broadcom/bcm47094-asus-rt-ac3100.dtsi | 12 +++++++++- .../dts/broadcom/bcm47094-asus-rt-ac5300.dts | 12 +++++++++- .../dts/broadcom/bcm47094-dlink-dir-885l.dts | 12 +++++++++- .../dts/broadcom/bcm47094-dlink-dir-890l.dts | 24 +++++++++++++++++-- .../broadcom/bcm47094-linksys-panamera.dts | 24 +++++++++++++++++-- .../dts/broadcom/bcm47094-luxul-abr-4500.dts | 12 +++++++++- .../dts/broadcom/bcm47094-luxul-xbr-4500.dts | 12 +++++++++- .../dts/broadcom/bcm47094-luxul-xwr-3100.dts | 12 +++++++++- .../broadcom/bcm47094-luxul-xwr-3150-v1.dts | 12 +++++++++- .../arm/boot/dts/broadcom/bcm947189acdbmr.dts | 12 +++++++++- 25 files changed, 341 insertions(+), 34 deletions(-)
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts +11 -1
@@ -101,6 +101,16 @@ led-usb { trigger-sources = <&xhci_port1 &ehci_port1 &ohci_port1>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &srab {
@@ -130,7 +140,7 @@ port@4 { }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wzr-1166dhp-common.dtsi +21 -2
@@ -136,14 +136,33 @@ button-eject { gpios = <&chipcommon 15 GPIO_ACTIVE_LOW>; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_LOW>; + }; }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_LOW>; + vbus-supply = <&usb3_power>; }; &spi_nor {
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wzr-1750dhp.dts +21 -2
@@ -132,14 +132,33 @@ button-eject { gpios = <&chipcommon 15 GPIO_ACTIVE_LOW>; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_LOW>; + }; }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_LOW>; + vbus-supply = <&usb3_power>; }; &spi_nor {
arch/arm/boot/dts/broadcom/bcm4708-linksys-ea6300-v1.dts +11 -1
@@ -41,6 +41,16 @@ button-restart { gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3_phy {
@@ -48,5 +58,5 @@ &usb3_phy { }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; };
arch/arm/boot/dts/broadcom/bcm4708-linksys-ea6500-v2.dts +11 -1
@@ -38,6 +38,16 @@ button-restart { gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3_phy {
@@ -45,5 +55,5 @@ &usb3_phy { }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; };
arch/arm/boot/dts/broadcom/bcm4708-netgear-r6250.dts +11 -1
@@ -81,10 +81,20 @@ button-restart { gpios = <&chipcommon 6 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &spi_nor {
arch/arm/boot/dts/broadcom/bcm4708-netgear-r6300-v2.dts +11 -1
@@ -77,6 +77,16 @@ button-restart { gpios = <&chipcommon 6 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &spi_nor {
@@ -88,5 +98,5 @@ &usb3_phy { }; &usb3 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; };
arch/arm/boot/dts/broadcom/bcm47081-luxul-xwr-1200.dts +11 -1
@@ -104,10 +104,20 @@ button-restart { gpios = <&chipcommon 11 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &gmac0 {
arch/arm/boot/dts/broadcom/bcm47081-tplink-archer-c5-v2.dts +11 -1
@@ -89,6 +89,16 @@ button-restart { gpios = <&chipcommon 7 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &spi_nor {
@@ -109,5 +119,5 @@ partition-file-system { }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; };
arch/arm/boot/dts/broadcom/bcm4709-asus-rt-ac3200.dts +11 -1
@@ -73,6 +73,16 @@ led-wps { gpios = <&chipcommon 14 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &gmac0 {
@@ -142,7 +152,7 @@ port@4 { }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm4709-buffalo-wxr-1900dhp.dts +11 -2
@@ -116,11 +116,20 @@ button-eject { gpios = <&chipcommon 20 GPIO_ACTIVE_LOW>; }; }; -}; + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; +}; &usb2 { - vcc-gpio = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &spi_nor {
arch/arm/boot/dts/broadcom/bcm4709-linksys-ea9200.dts +22 -2
@@ -91,6 +91,26 @@ led-3 { linux,default-trigger = "default-on"; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 14 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &pcie_bridge0 {
@@ -155,11 +175,11 @@ &usb3_phy { }; &usb2 { - vcc-gpios = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpios = <&chipcommon 14 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb3_power>; }; &gmac2 {
arch/arm/boot/dts/broadcom/bcm4709-netgear-r7000.dts +12 -2
@@ -91,14 +91,24 @@ button-restart { gpios = <&chipcommon 6 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb2 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm4709-netgear-r8000.dts +12 -2
@@ -184,14 +184,24 @@ wifi@0,0 { }; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb2 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3 { - vcc-gpio = <&chipcommon 0 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm4709-tplink-archer-c9-v1.dts +22 -2
@@ -90,14 +90,34 @@ button-restart { gpios = <&chipcommon 3 GPIO_ACTIVE_LOW>; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 12 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb2 { - vcc-gpio = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpio = <&chipcommon 12 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb3_power>; }; &spi_nor {
arch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac3100.dtsi +11 -1
@@ -98,6 +98,16 @@ led-wps { gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &nandcs {
@@ -167,7 +177,7 @@ port@8 { }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac5300.dts +11 -1
@@ -79,6 +79,16 @@ led-wps { gpios = <&chipcommon 19 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &gmac0 {
@@ -151,7 +161,7 @@ port@4 { }; &usb2 { - vcc-gpio = <&chipcommon 9 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm47094-dlink-dir-885l.dts +11 -1
@@ -115,10 +115,20 @@ button-restart { gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3 { - vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &gmac0 {
arch/arm/boot/dts/broadcom/bcm47094-dlink-dir-890l.dts +22 -2
@@ -117,6 +117,26 @@ et0macaddr: et0macaddr { #nvmem-cell-cells = <1>; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 21 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &gmac2 {
@@ -158,11 +178,11 @@ firmware@0 { }; &usb2 { - vcc-gpios = <&chipcommon 21 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb3_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm47094-linksys-panamera.dts +22 -2
@@ -195,14 +195,34 @@ fixed-link { }; }; }; + + usb2_power: regulator-usb2 { + compatible = "regulator-fixed"; + regulator-name = "usb2-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + usb3_power: regulator-usb3 { + compatible = "regulator-fixed"; + regulator-name = "usb3-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 14 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb2 { - vcc-gpio = <&chipcommon 13 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb2_power>; }; &usb3 { - vcc-gpio = <&chipcommon 14 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb3_power>; }; &srab {
arch/arm/boot/dts/broadcom/bcm47094-luxul-abr-4500.dts +11 -1
@@ -59,10 +59,20 @@ button-restart { gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3 { - vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &gmac0 {
arch/arm/boot/dts/broadcom/bcm47094-luxul-xbr-4500.dts +11 -1
@@ -59,10 +59,20 @@ button-restart { gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3 { - vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &gmac0 {
arch/arm/boot/dts/broadcom/bcm47094-luxul-xwr-3100.dts +11 -1
@@ -99,10 +99,20 @@ button-restart { gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &usb3 { - vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &gmac0 {
arch/arm/boot/dts/broadcom/bcm47094-luxul-xwr-3150-v1.dts +11 -1
@@ -74,6 +74,16 @@ button-restart { gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>; }; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &gmac0 {
@@ -98,7 +108,7 @@ wifi@0,0 { }; &usb3 { - vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; }; &usb3_phy {
arch/arm/boot/dts/broadcom/bcm947189acdbmr.dts +11 -1
@@ -69,6 +69,16 @@ spi { /* External BCM6802 MoCA chip is connected */ }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 8 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; }; &pcie0 {
@@ -92,5 +102,5 @@ wifi@0,1,0 { }; &usb2 { - vcc-gpio = <&chipcommon 8 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>; };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCHv3 2/2] ARM: dts: broadcom: model USB VBUS power with regulator-fixed
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] usb: bcma: unclaimed vbus-supply regulator disables USB power after 30s - [Medium] usb: bcma…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] usb: bcma: unclaimed vbus-supply regulator disables USB power after 30s
- [Medium] usb: bcma: silent power management failure due to missing vcc GPIO --
commit 5639b159d14f6b05d776251fb2e51af77ccdaf1b
Author: Rosen Penev <[email protected]>
Subject: ARM: dts: broadcom: model USB VBUS power with regulator-fixed
This commit replaces the undocumented vcc-gpio property on usb2/usb3 controller nodes with the standard vbus-supply and regulator-fixed model. Boards now declare a regulator bound to the chipcommon GPIO, preserving polarity and using regulator-boot-on to mirror the CFE state.
Quoted 6 lines
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts +0
-0@@ -101,6 +101,16 @@ led-usb { trigger-sources = <&xhci_port1 &ehci_port1 &ohci_port1>;
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts led-usb { · line 111
Quoted 10 lines
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts +8
-0}; }; + + usb_power: regulator-usb { + compatible = "regulator-fixed"; + regulator-name = "usb-vcc"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + gpios = <&chipcommon 10 GPIO_ACTIVE_HIGH>;
[Severity: High]
Does this regulator definition need regulator-always-on?
The bcma-hcd driver in drivers/usb/host/bcma-hcd.c:bcma_hcd_probe() attempts to fetch a raw "vcc" GPIO rather than claiming this vbus-supply regulator. As a result, the new regulator remains unclaimed with a zero use count, and the regulator core will automatically disable USB power 30 seconds after boot when it disables unclaimed non-always-on regulators.
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts port@4 { · line 143
Quoted 11 lines
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts +3
-1+ enable-active-high; + }; }; &srab {@@ -130,7 +140,7 @@ port@4 { }; &usb3 { - vcc-gpio = <&chipcommon 10 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_power>;
[Severity: Medium]
Will replacing the vcc-gpio property with vbus-supply break power management for this device?
When bcma_hcd_probe() fails to fetch the vcc GPIO descriptor, the usb_dev gpio_desc remains NULL. Later power management calls, such as during suspend in bcma_hcd_suspend() which calls bcma_hci_platform_power_gpio(), will simply return early upon seeing a NULL descriptor. This silently skips all hardware power control operations on state transitions.
Quoted 3 lines
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wxr-1750dhp.dts +0
-0}; &usb3_phy {
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 8 lines · Rosen Penev
bcma-hcd currently drives the USB power line by grabbing the undocumented "vcc-gpio" property from the controller node and poking it through gpiolib. Besides relying on a non-standard binding, this cannot work on boards such as the NETGEAR R7000 and R8000 where one chipcommon GPIO powers both the USB2 and USB3 cores: the two controllers each request that GPIO exclusively, so the second one fails with
-EBUSYand its port stays dead.
Quoted 4 lines
Instead, switch the driver to the standard regulator interface and express the power rails as regulator-fixed nodes bound to the chipcommon GPIOs. The regulator core reference-counts enable/disable requests, letting both controllers share one GPIO without conflicts.
Please use standard email subjects, so with the PATCH keyword in the title. git format-patch -vX helps here to create proper versioned patches. Another useful tool is b4. Skipping the PATCH keyword makes filtering of emails more difficult thus making the review process less convenient.
Almost all your patches for months now do everything to escape my filters.
Best regards,
Krzysztof
Quoted 15 lines · Krzysztof Kozlowski
Quoted 8 lines · Rosen Penev
bcma-hcd currently drives the USB power line by grabbing the undocumented "vcc-gpio" property from the controller node and poking it through gpiolib. Besides relying on a non-standard binding, this cannot work on boards such as the NETGEAR R7000 and R8000 where one chipcommon GPIO powers both the USB2 and USB3 cores: the two controllers each request that GPIO exclusively, so the second one fails with
-EBUSYand its port stays dead.Quoted 4 lines
Instead, switch the driver to the standard regulator interface and express the power rails as regulator-fixed nodes bound to the chipcommon GPIOs. The regulator core reference-counts enable/disable requests, letting both controllers share one GPIO without conflicts.
Quoted 5 lines
Please use standard email subjects, so with the PATCH keyword in the title.
git format-patch -vXhelps here to create proper versioned patches. Another useful tool is b4. Skipping the PATCH keyword makes filtering of emails more difficult thus making the review process less convenient.
I will make this change going forward.
Quoted 2 lines
Almost all your patches for months now do everything to escape my filters.
That explains a lot.
Quoted 3 lines
Best regards,
Krzysztof