ath79: Fix glinet ar300m usb not working
authorLuo Chongjun <luochongjun@gl-inet.com>
Thu, 15 Dec 2022 09:25:15 +0000 (17:25 +0800)
committerRISCi_ATOM <bob@bobcall.me>
Mon, 15 May 2023 15:17:39 +0000 (11:17 -0400)
glinet forum users reported the problem at
https://forum.gl-inet.com/t/gl-ar300m16-openwrt-22-03-0-rc5-usb-port-power-off-by-default/23199

The current code uses the regulator framework to control the USB power
supply. Although usb0 described in DTS refers to the regulator by
vbus-supply, but there is no code related to regulator implemented
in the USB driver of QCA953X, so the USB of the device cannot work.

Under the regulator framework, adding the regulator-always-on attribute
fixes this problem, but it means that USB power will not be able to be
turned off. Since we need to control the USB power supply in user space,
I didn't find any other better way under the regulator framework of Linux,
so I directly export gpio.

Signed-off-by: Luo Chongjun <luochongjun@gl-inet.com>
(cherry picked from commit b352124cd2115fec648a00956a848660df9477d3)

target/linux/ath79/dts/qca9531_glinet_gl-ar300m-lite.dts
target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi

index a34abb1dd2d87fbad9cb5f9724e2720990eefc91..c712236114cc3d0637f0c4fbc6318fd610f409ac 100644 (file)
@@ -7,7 +7,6 @@
        model = "GL.iNet GL-AR300M-Lite";
 };
 
-/delete-node/ &reg_usb_vbus;
 
 /delete-node/ &nand_flash;
 
@@ -30,6 +29,3 @@
        label = "green:wlan";
 };
 
-&usb0 {
-       /delete-property/ vbus-supply;
-};
index d64ffa7115d2616e508d6d16e6d1273ce0fd213e..b6ea1080a4a6c67a09061ae86b491156bf6f29bf 100644 (file)
                };
        };
 
-       reg_usb_vbus: reg_usb_vbus {
-               compatible = "regulator-fixed";
-
-               regulator-name = "usb_vbus";
-               regulator-min-microvolt = <5000000>;
-               regulator-max-microvolt = <5000000>;
-               gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
-               enable-active-high;
+       gpio-export {
+               compatible = "gpio-export";
+
+               gpio_usb_power {
+                       gpio-export,name = "usb_power";
+                       gpio-export,output = <1>;
+                       gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+               };
        };
 
        leds {
 &usb0 {
        #address-cells = <1>;
        #size-cells = <0>;
-       vbus-supply = <&reg_usb_vbus>;
        status = "okay";
 };