]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ramips: mt7621: use regulators for USB GPIO 16967/head
authorRosen Penev <rosenp@gmail.com>
Fri, 15 Nov 2024 23:22:42 +0000 (15:22 -0800)
committerRobert Marko <robimarko@gmail.com>
Tue, 3 Jun 2025 09:04:50 +0000 (11:04 +0200)
Regulators as implemented by the XHCI driver only accept one GPIO.
However, we can abuse the fact that the XHCI driver accepts two
regulators, one for 5V and the other for 3.3V, for USB 2 and 3 GPIOs.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16967
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/ramips/dts/mt7621_d-team_pbr-m1.dts
target/linux/ramips/dts/mt7621_dual-q_h721.dts
target/linux/ramips/dts/mt7621_lenovo_newifi-d1.dts
target/linux/ramips/dts/mt7621_xzwifi_creativebox-v1.dts

index ffa405133b5a2184dc8da999d872ab97d65f1441..a0f8a62106317c0edf6a0d3b7d3321102e20cb3f 100644 (file)
                };
        };
 
-       gpio_export {
-               compatible = "gpio-export";
+       reg_usb_vbus: regulator-usb {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 
-               power_usb2 {
-                       gpio-export,name = "power_usb2";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
-               };
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 
-               power_usb3 {
-                       gpio-export,name = "power_usb3";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
-               };
+       gpio_export {
+               compatible = "gpio-export";
 
                power_sata {
                        gpio-export,name = "power_sata";
        status = "okay";
 };
 
+&xhci {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_usb_vbus>;
+};
+
 &spi0 {
        status = "okay";
 
index 8b2df414173ec5719d970d7fe48ea96b5b90e43e..3499e14f950ed5e0904e9b1752d4805a2faf4fbd 100644 (file)
                bootargs = "console=ttyS0,115200";
        };
 
-       gpio-export {
-               compatible = "gpio-export";
-
-               usb-30-power {
-                       gpio-export,name = "usb-30-power";
-                       gpio-export,output = <0>;
-                       gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
-               };
-
-               usb-20-power {
-                       gpio-export,name = "usb-20-power";
-                       gpio-export,output = <0>;
-                       gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
-               };
-       };
-
        keys {
                compatible = "gpio-keys";
 
                        gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
                };
        };
+
+       reg_usb_vbus: regulator-usb {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
+       };
+};
+
+&xhci {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_usb_vbus>;
 };
 
 &spi0 {
index a4d55a5e870b8539266136da37f0c6020161dab9..c43ed152f653a4bd34d8e7674a3350254a5b4389 100644 (file)
                };
        };
 
-       gpio_export {
-               compatible = "gpio-export";
-
-               usb2power {
-                       gpio-export,name = "usb2power";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
-               };
+       reg_usb_vbus: regulator-usb {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 
-               usb3power {
-                       gpio-export,name = "usb3power";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
-               };
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
 };
 
        status = "okay";
 };
 
+&xhci {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_usb_vbus>;
+};
+
 &spi0 {
        status = "okay";
 
index 00e4171d93231ae929c87ab4d2e249bc1be4526d..8830320954bc162bc76aaafe7e4b5b1003f059ca 100644 (file)
        gpio_export {
                compatible = "gpio-export";
 
-               power_usb2 {
-                       gpio-export,name = "power_usb2";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
-               };
-
-               power_usb3 {
-                       gpio-export,name = "power_usb3";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
-               };
-
                power_sata {
                        gpio-export,name = "power_sata";
                        gpio-export,output = <1>;
                        gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
                };
        };
+
+       reg_usb_vbus: regulator-usb {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+};
+
+&xhci {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_usb_vbus>;
 };
 
 &spi0 {