Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Birger Koblitz
Dear Martin and Enrico,

thanks for your comments.

On 11.08.19 13:38, Martin Blumenstingl wrote:
> On Sun, Aug 11, 2019 at 1:00 PM Birger Koblitz  wrote:
>> I'll go through the patches and remove anything that sounds like it
>> might need user space configuration (i.e. not power the USB bus or the
>> like).
> upstream GPIO maintainers prefer dedicated properties instead of a GPIO hog.
>
> some USB controller drivers support a "vbus-supply" property, which
> can be used together with a GPIO regulator
> in case of the VBUS supply it means the GPIO will be turned off if the
> USB port is "disabled" (for example by unloading the kernel USB
> controller driver).
>
> I'm not saying that you have to switch over to something other than GPIO hogs.
> switching to an upstream solution is a good starting point!
> just be aware that this may not be the final solution

this is understood. gpio-hog is only the second best solution, where
gpio-export is only the third best solution for the general case but in
some cases at the moment the only reasonable one.


>
>> Is anyone working on converting the use-cases which require user space
>> switching to libgpiod or any other solution?
> how do you identify the "use-cases which require use space switching"?

I believe this discussion has happened already, e.g. here:

https://github.com/openwrt/openwrt/pull/1366

and I don't think you need a final answer to this question in order to
start migrating to gpio_hog where it is easily possible.

@Enrico: It is clear that in some cases definitely we need to have a
possibility to manipulate gpios from user-space.


Cheers

   Birger



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Enrico Mioso
Fully agree. And BTW, AT commands may not be a viable option in some cases. We 
need to be able to manipulate gpios from user space sometime.
Thanks,
Enrico
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Martin Blumenstingl via openwrt-devel
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.--- Begin Message ---
On Sun, Aug 11, 2019 at 1:00 PM Birger Koblitz  wrote:
> I'll go through the patches and remove anything that sounds like it
> might need user space configuration (i.e. not power the USB bus or the
> like).
upstream GPIO maintainers prefer dedicated properties instead of a GPIO hog.

some USB controller drivers support a "vbus-supply" property, which
can be used together with a GPIO regulator
in case of the VBUS supply it means the GPIO will be turned off if the
USB port is "disabled" (for example by unloading the kernel USB
controller driver).

I'm not saying that you have to switch over to something other than GPIO hogs.
switching to an upstream solution is a good starting point!
just be aware that this may not be the final solution

> Is anyone working on converting the use-cases which require user space
> switching to libgpiod or any other solution?
how do you identify the "use-cases which require use space switching"?


Martin

--- End Message ---
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Birger Koblitz
Dear Mathias and Piotr,

thank you for your comments. I had incorrectly assumed that a gpio_hog
could still be switched on/off from user space and that the only thing
not possible was changing the direction.

I'll go through the patches and remove anything that sounds like it
might need user space configuration (i.e. not power the USB bus or the
like).

Is anyone working on converting the use-cases which require user space
switching to libgpiod or any other solution?

Cheers,

  Birger


On 11.08.19 12:06, Piotr Dymacz wrote:
> Hi Mathias, Birger,
>
> On 11.08.2019 11:36, Mathias Kresin wrote:
>> 02/08/2019 11:58, Birger Koblitz:
>>> ramips: 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 ramips .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 
>>>
>>> ---
>>>
>>> diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
>>> b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
>>> index 4097dc6140..ea0d9801c1 100644
>>> --- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
>>> +++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
>>> @@ -21,39 +21,6 @@
>>>       bootargs = "console=ttyS0,115200";
>>>   };
>>>   -    gpio-export {
>>> -        compatible = "gpio-export";
>>> -        #size-cells = <0>;
>>> -
>>> -        modem-enable {
>>> -            gpio-export,name = "modem-enable";
>>> -            gpio-export,output = <1>;
>>> -            gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
>>> -        };
>>> -
>>> -        modem-rf-enable {
>>> -            gpio-export,name = "modem-rf-enable";
>>> -            gpio-export,output = <1>;
>>> -            gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
>>> -        };
>>> -
>>> -        sim-select {
>>> -            gpio-export,name = "sim-select";
>>> -            gpio-export,output = <0>;
>>> -            gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
>>> -        };
>>> -
>>> -        sim1-detect {
>>> -            gpio-export,name = "sim1-detect";
>>> -            gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
>>> -        };
>>> -
>>> -        sim2-detect {
>>> -            gpio-export,name = "sim2-detect";
>>> -            gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
>>> -        };
>>> -    };
>>> -
>>
>> Hey Birger,
>>
>> similar to my comment for the lantiq version, this doesn't work as well.
>>
>> AFAIR, the Tube e4g has two sim card slots and the "sim-select" gpio is
>> supposed to be used from the userspace, to select which sim card slot
>> should be used.
>>
>> If we hog the gpio, it can't be manipulated from the userspace anymore.
>>
>> I haven't had a closer look at the patch. There might be similar issues
>> for other boards.
>>
>> @Piotr can confirm what I might to remember?
>
> Yes, you're correct.
>
> Also, the "modem-enable" should be available in user space as in case
> of some modems (without "SIM power down" feature support), only this
> approach works when changing SIM cards/slots:
>
> put the modem in reset -> switch SIM slot -> enable modem
>
> (still, there is a way to perform modem reset using AT command but
> IMHO it's not as convenient as toggling PERST# pin)
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Piotr Dymacz

Hi Mathias, Birger,

On 11.08.2019 11:36, Mathias Kresin wrote:

02/08/2019 11:58, Birger Koblitz:

ramips: 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 ramips .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 

---

diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
index 4097dc6140..ea0d9801c1 100644
--- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
+++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
@@ -21,39 +21,6 @@
      bootargs = "console=ttyS0,115200";
  };
  
-    gpio-export {

-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        modem-enable {
-            gpio-export,name = "modem-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        modem-rf-enable {
-            gpio-export,name = "modem-rf-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim-select {
-            gpio-export,name = "sim-select";
-            gpio-export,output = <0>;
-            gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim1-detect {
-            gpio-export,name = "sim1-detect";
-            gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim2-detect {
-            gpio-export,name = "sim2-detect";
-            gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
-        };
-    };
-


Hey Birger,

similar to my comment for the lantiq version, this doesn't work as well.

AFAIR, the Tube e4g has two sim card slots and the "sim-select" gpio is
supposed to be used from the userspace, to select which sim card slot
should be used.

If we hog the gpio, it can't be manipulated from the userspace anymore.

I haven't had a closer look at the patch. There might be similar issues
for other boards.

@Piotr can confirm what I might to remember?


Yes, you're correct.

Also, the "modem-enable" should be available in user space as in case of 
some modems (without "SIM power down" feature support), only this 
approach works when changing SIM cards/slots:


put the modem in reset -> switch SIM slot -> enable modem

(still, there is a way to perform modem reset using AT command but IMHO 
it's not as convenient as toggling PERST# pin)


--
Cheers,
Piotr

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: use gpio_hog instead of gpio-export

2019-08-11 Thread Mathias Kresin

02/08/2019 11:58, Birger Koblitz:

ramips: 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 ramips .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 

---

diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
index 4097dc6140..ea0d9801c1 100644
--- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
+++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
@@ -21,39 +21,6 @@
      bootargs = "console=ttyS0,115200";
  };
  
-    gpio-export {

-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        modem-enable {
-            gpio-export,name = "modem-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        modem-rf-enable {
-            gpio-export,name = "modem-rf-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim-select {
-            gpio-export,name = "sim-select";
-            gpio-export,output = <0>;
-            gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim1-detect {
-            gpio-export,name = "sim1-detect";
-            gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim2-detect {
-            gpio-export,name = "sim2-detect";
-            gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
-        };
-    };
-


Hey Birger,

similar to my comment for the lantiq version, this doesn't work as well.

AFAIR, the Tube e4g has two sim card slots and the "sim-select" gpio is 
supposed to be used from the userspace, to select which sim card slot 
should be used.


If we hog the gpio, it can't be manipulated from the userspace anymore.

I haven't had a closer look at the patch. There might be similar issues 
for other boards.


@Piotr can confirm what I might to remember?

Regards
Mathias

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


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

2019-08-02 Thread Birger Koblitz
ramips: 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 ramips .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 

---

diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
index 4097dc6140..ea0d9801c1 100644
--- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
+++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
@@ -21,39 +21,6 @@
     bootargs = "console=ttyS0,115200";
 };
 
-    gpio-export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        modem-enable {
-            gpio-export,name = "modem-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        modem-rf-enable {
-            gpio-export,name = "modem-rf-enable";
-            gpio-export,output = <1>;
-            gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim-select {
-            gpio-export,name = "sim-select";
-            gpio-export,output = <0>;
-            gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim1-detect {
-            gpio-export,name = "sim1-detect";
-            gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
-        };
-
-        sim2-detect {
-            gpio-export,name = "sim2-detect";
-            gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
-        };
-    };
-
 keys {
     compatible = "gpio-keys";
 
@@ -98,26 +65,61 @@
 };
 };
 
-&ehci {
+&gpio1 {
 status = "okay";
-};
 
-ðernet {
-    mtd-mac-address = <&factory 0x28>;
+    modem-enable {
+        gpio-hog;
+        line-name = "modem-enable";
+        gpios = <12 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
 };
 
 &gpio0 {
 status = "okay";
+
+    modem-rf-enable {
+        gpio-hog;
+        line-name = "modem-rf-enable";
+        gpios = <12 GPIO_ACTIVE_HIGH>;
+        output-high;
+    };
+
+    sim-select {
+        gpio-hog;
+        line-name = "sim-select";
+        gpios = <13 GPIO_ACTIVE_HIGH>;
+        output-low;
+    };
+
+    sim1-detect {
+        gpio-hog;
+        line-name = "sim1-detect";
+        gpios = <9 GPIO_ACTIVE_HIGH>;
+        input;
+    };
 };
 
-&gpio1 {
+&gpio2 {
 status = "okay";
+
+    sim2-detect {
+        gpio-hog;
+        line-name = "sim2-detect";
+        gpios = <1 GPIO_ACTIVE_HIGH>;
+        input;
+    };
 };
 
-&gpio2 {
+&ehci {
 status = "okay";
 };
 
+ðernet {
+    mtd-mac-address = <&factory 0x28>;
+};
+
 &gsw {
 mediatek,port4 = "ephy";
 };
diff --git a/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts
b/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts
index 3e54ffdad2..c573b38284 100644
--- a/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts
+++ b/target/linux/ramips/dts/mt7620a_asus_rt-ac51u.dts
@@ -53,16 +53,16 @@
         linux,code = ;
     };
 };
+};
 
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
+&gpio0 {
+    status = "okay";
 
-        enable-leds {
-            gpio-export,name = "enable-leds";
-            gpio-export,output = <1>;
-            gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
-        };
+    enable-leds {
+        gpio-hog;
+        line-name = "enable-leds";
+        gpios = <10 GPIO_ACTIVE_HIGH>;
+        output-high;
 };
 };
 
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
index 707bc1c3d3..7af90c6908 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
@@ -63,21 +63,17 @@
         linux,default-trigger = "usbport";
     };
 };
-
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;
-
-        usb {
-            gpio-export,name = "usb";
-            gpio-export,output = <0>;
-            gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
-        };
-    };
 };
 
 &gpio1 {
 status = "okay";
+
+    usb {
+        gpio-hog;
+        line-name = "usb";
+        gpios = <14 GPIO_ACTIVE_LOW>;
+        output-low;
+    };
 };
 
 &gpio2 {
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
index 26b23aa6d1..17ec47b9d5 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
@@ -61,21 +61,17 @@
         linux,default-trigger = "usbport";
     };
 };
-
-    gpio_export {
-        compatible = "gpio-export";
-        #size-cells = <0>;