diff mbox series

[OpenWrt-Devel] lantiq: use gpio_hog instead of gpio-export

Message ID 1399e68b-a5f7-c949-3bc9-cae951176f69@birger-koblitz.de
State Rejected
Delegated to: Mathias Kresin
Headers show
Series [OpenWrt-Devel] lantiq: use gpio_hog instead of gpio-export | expand

Commit Message

Birger Koblitz Aug. 2, 2019, 9:57 a.m. UTC
lantiq: use gpio_hog instead of gpio-export

The `gpio-export` functionality is a hack for
missing kernel functionality, which was rejected in upstream kernel long
time
ago, for details see this email
http://lists.infradead.org/pipermail/openwrt-devel/2019-February/015772.html,
discussion in PR#1366 or
https://github.com/openwrt/openwrt/pull/1814#issuecomment-462942022.

This patch converts all remaining lantiq .dts(i) files which were
using export-gpio and not making use of the change-direction functionality
to using gpio_hog instead

Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>

---

Comments

Hauke Mehrtens Aug. 2, 2019, 2:08 p.m. UTC | #1
On 8/2/19 11:57 AM, Birger Koblitz wrote:
> lantiq: use gpio_hog instead of gpio-export
> 
> The `gpio-export` functionality is a hack for
> missing kernel functionality, which was rejected in upstream kernel long
> time
> ago, for details see this email
> http://lists.infradead.org/pipermail/openwrt-devel/2019-February/015772.html,
> discussion in PR#1366 or
> https://github.com/openwrt/openwrt/pull/1814#issuecomment-462942022.
> 
> This patch converts all remaining lantiq .dts(i) files which were
> using export-gpio and not making use of the change-direction functionality
> to using gpio_hog instead
> 
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>

Reviewed-by: Hauke Mehrtens <hauke@haukem.de>

I only reviewed this, it would be nice if someone could test this at
least on one of the affected devices.

Hauke
Mathias Kresin Aug. 11, 2019, 9:26 a.m. UTC | #2
02/08/2019 11:57, Birger Koblitz:
> lantiq: use gpio_hog instead of gpio-export
> 
> The `gpio-export` functionality is a hack for
> missing kernel functionality, which was rejected in upstream kernel long
> time
> ago, for details see this email
> http://lists.infradead.org/pipermail/openwrt-devel/2019-February/015772.html,
> discussion in PR#1366 or
> https://github.com/openwrt/openwrt/pull/1814#issuecomment-462942022.
> 
> This patch converts all remaining lantiq .dts(i) files which were
> using export-gpio and not making use of the change-direction functionality
> to using gpio_hog instead
> 
> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
> 
> ---

...

> diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
> b/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
> index 4796123c20..0b21b67504 100644
> --- a/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
> +++ b/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
> @@ -37,22 +37,6 @@
>           };
>       };
>   
> -    gpio_export {
> -        compatible = "gpio-export";
> -        #size-cells = <0>;
> -
> -        annexa {
> -            gpio-export,name = "annexa";
> -            gpio-export,output = <0>;
> -            gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
> -        };
> -        annexb {
> -            gpio-export,name = "annexb";
> -            gpio-export,output = <0>;
> -            gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
> -        };
> -    };
> -
>       leds {
>           compatible = "gpio-leds";
>   
> @@ -85,6 +69,24 @@
>       };
>   };
>   
> +&gpio {
> +    status = "okay";
> +
> +    annexa {
> +        gpio-hog;
> +        line-name = "annexa";
> +        gpios = <12 GPIO_ACTIVE_HIGH>;
> +        output-low;
> +    };
> +
> +    annexb {
> +        gpio-hog;
> +        line-name = "annexb";
> +        gpios = <15 GPIO_ACTIVE_HIGH>;
> +        output-low;
> +    };
> +};
> +
>   &eth0 {
>       lantiq,phys = <&gphy1>;
>   

NAK on this change. Here w've an example where we can't hog gpios.

These gpios are used to switch the xDSL Frontend to either Annex A or 
Annex B mode. It's a configuration which has to be done from userspace, 
based on the user selectable ADSL mode. Have a look at commit 
08cd5b769deb4833b7a20208fa15674f52023fea for reference.

If we hog the gpios, they can't be controlled from userspace any more.

Before we drop these exports, we need to find another solution for this 
use case.

Regards
Mathias
diff mbox series

Patch

diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/ARV7519PW.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/ARV7519PW.dts
index e9c418e482..c597febeeb 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/ARV7519PW.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/ARV7519PW.dts
@@ -110,15 +110,16 @@ 
     };
 
     /* is there another way to "reserve" the GPIO? */
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
+};
 
-        switch {
-            gpio-export,name = "switch";
-            gpio-export,output = <1>;
-            gpios = <&gpio 19 GPIO_ACTIVE_HIGH>;
-        };
+&gpio {
+    status = "okay";
+
+    switch {
+        gpio-hog;
+        line-name = "switch";
+        gpios = <19 GPIO_ACTIVE_HIGH>;
+        output-high;
     };
 };
 
diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/ASL56026.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/ASL56026.dts
index 1c7f03c355..5d801d14ec 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/ASL56026.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/ASL56026.dts
@@ -58,16 +58,16 @@ 
             gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
         };
     };
+};
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
+&gpio {
+    status = "okay";
 
-        power_led_blink {
-            gpio-export,name = "power_led_blink";
-            gpio-export,output = <0>;
-            gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
-        };
+    power_led_blink {
+        gpio-hog;
+        line-name = "power_led_blink";
+        gpios = <16 GPIO_ACTIVE_LOW>;
+        output-low;
     };
 };
 
diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
index 4796123c20..0b21b67504 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/DM200.dts
@@ -37,22 +37,6 @@ 
         };
     };
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        annexa {
-            gpio-export,name = "annexa";
-            gpio-export,output = <0>;
-            gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
-        };
-        annexb {
-            gpio-export,name = "annexb";
-            gpio-export,output = <0>;
-            gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
-        };
-    };
-
     leds {
         compatible = "gpio-leds";
 
@@ -85,6 +69,24 @@ 
     };
 };
 
+&gpio {
+    status = "okay";
+
+    annexa {
+        gpio-hog;
+        line-name = "annexa";
+        gpios = <12 GPIO_ACTIVE_HIGH>;
+        output-low;
+    };
+
+    annexb {
+        gpio-hog;
+        line-name = "annexb";
+        gpios = <15 GPIO_ACTIVE_HIGH>;
+        output-low;
+    };
+};
+
 &eth0 {
     lantiq,phys = <&gphy1>;
 
diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/GIGASX76X.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/GIGASX76X.dts
index a9a5cbae2f..6b4ab7f918 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/GIGASX76X.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/GIGASX76X.dts
@@ -28,17 +28,6 @@ 
         };
     };
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        switch {
-            gpio-export,name = "switch";
-            gpio-export,output = <1>;
-            gpios = <&gpio 19 GPIO_ACTIVE_HIGH>;
-        };
-    };
-
     usb_vbus: regulator-usb-vbus {
         compatible = "regulator-fixed";
 
@@ -52,6 +41,17 @@ 
     };
 };
 
+&gpio {
+    status = "okay";
+
+    switch {
+        gpio-hog;
+        line-name = "switch";
+        gpios = <19 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
+};
+
 &gpio {
     pinctrl-names = "default";
     pinctrl-0 = <&state_default>;
@@ -64,10 +64,6 @@ 
     };
 };
 
-&gpios {
-    status = "okay";
-};
-
 &gsw {
     phy-mode = "rmii";
 };
diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/H201L.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/H201L.dts
index 9b640e0327..fe0e5af0c1 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/H201L.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/H201L.dts
@@ -84,27 +84,6 @@ 
         };
     };
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        switch {
-            gpio-export,name = "switch";
-            gpio-export,output = <1>;
-            gpios = <&gpio 38 GPIO_ACTIVE_HIGH>;
-        };
-        usb {
-            gpio-export,name = "usb";
-            gpio-export,output = <1>;
-            gpios = <&gpio 28 GPIO_ACTIVE_HIGH>;
-        };
-        wifi {
-            gpio-export,name = "wifi";
-            gpio-export,output = <1>;
-            gpios = <&gpio 7 GPIO_ACTIVE_HIGH>;
-        };
-    };
-
     usb_vbus: regulator-usb-vbus {
         compatible = "regulator-fixed";
 
@@ -118,6 +97,31 @@ 
     };
 };
 
+&gpio {
+    status = "okay";
+
+    switch {
+        gpio-hog;
+        line-name = "switch";
+        gpios = <38 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
+
+    usb {
+        gpio-hog;
+        line-name = "usb";
+        gpios = <28 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
+
+    wifi {
+        gpio-hog;
+        line-name = "wifi";
+        gpios = <7 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
+};
+
 &gpio {
     pinctrl-names = "default";
     pinctrl-0 = <&state_default>;
@@ -165,7 +169,6 @@ 
     status = "okay";
 };
 
-
 &usb0 {
     status = "okay";
     vbus-supply = <&usb_vbus>;
diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/P2601HNFX.dts
b/target/linux/lantiq/files/arch/mips/boot/dts/P2601HNFX.dts
index 62e5e70169..9abc5745e4 100644
--- a/target/linux/lantiq/files/arch/mips/boot/dts/P2601HNFX.dts
+++ b/target/linux/lantiq/files/arch/mips/boot/dts/P2601HNFX.dts
@@ -85,16 +85,16 @@ 
             gpios = <&stp 10 GPIO_ACTIVE_LOW>;
         };
     };
+};
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
+&gpio {
+    status = "okay";
 
-        switch {
-            gpio-export,name = "switch";
-            gpio-export,output = <1>;
-            gpios = <&gpio 50 GPIO_ACTIVE_HIGH>;
-        };
+    switch {
+        gpio-hog;
+        line-name = "switch";
+        gpios = <50 GPIO_ACTIVE_HIGH>;
+        output-high;
     };
 };