GPIO User I/O
RFC 1/1 GPIO User I/O
Hello,
at the moment if a developer wishes to use a GPIO as output or input with a well defined name from userspace via the sysfs interface he/she can use, respectively, the gpio-leds or gpio-uinput devices. However, IMHO, this is not the best nor a proper way to do it, that's why I'm here to propose this really simple interface named GPIO_UIO.
That's why I wrote the attached patch (for kernel 4.19) which it's just a proposal, and the purpose of this message is to collect feedback about this solution. Of course I'll be happy to port it for latest kernel release and complete it with all requested documentation and needed modifications, but I'll do it only if this patch has some changes to be accepted by GPIO subsystem's maintainers. :)
For the moment here is how it works:
1) The patch is activated by the configuration entry CONFIG_GPIO_UIO.
2) In the device-tree the developer defines all board's GPIO lines with their names and mode of functioning:
+ gpio_uio {
+ compatible = "gpio-uio";
+
+ bypass0 {
+ gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>;
+ mode = "out-low";
+ };
+
+ bypass1 {
+ gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>; + mode = "out-low"; + label = "bypass-1";
+ };
+ };
Property "mode" can be "asis", "input", "out-low", etc. and the property label can be used in case the GPIO line's name should be different from the node's name.
3) At boot the GPIO lines are added:
[ 2.398902] gpio-uio bypass0: line added [ 2.423558] gpio-uio bypass-1: line added
4) Then users will find a new class with entries, one for each new line:
# ls /sys/class/gpio-uio/ bypass-1 bypass0
5) By using the attribute "line" the users can get or set the line status
# cat /sys/class/gpio-uio/bypass-1/line 0 # echo 1 > /sys/class/gpio-uio/bypass-1/line # cat /sys/class/gpio-uio/bypass-1/line 1
6) Developers can monitor the GPIO lines via debugfs as for kernel modules:
# cat /sys/kernel/debug/gpio gpiochip1: GPIOs 446-475, parent: platform/d0018800.pinctrl, GPIO2: gpio-457 ( |bypass-1 ) out lo
gpiochip0: GPIOs 476-511, parent: platform/d0013800.pinctrl, GPIO1:
gpio-479 ( |cd ) in hi IRQ gpio-480 ( |vcc_sd1 ) out lo gpio-486 ( |bypass0 ) out lo
The End. :)
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
drivers/gpio/Kconfig +10 -0
@@ -73,6 +73,16 @@ config GPIO_SYSFS Kernel drivers may also request that a particular GPIO be exported to userspace; this can be useful when debugging. +config GPIO_UIO + bool "/sys/class/gpio-uio/... (sysfs user I/O interface)" + depends on SYSFS + help + Say Y here to add a sysfs interface for I/O activities from userspace. + + Instead of the GPIO_SYSFS support, by using this support, you'll be + able to use GPIOs from userspace as stated in the device-tree + for well defined pourposes and by using proper names. + config GPIO_GENERIC depends on HAS_IOMEM # Only for IOMEM drivers tristate
drivers/gpio/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o obj-$(CONFIG_OF_GPIO) += gpiolib-of.o obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o +obj-$(CONFIG_GPIO_UIO) += gpiolib-uio.o obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically
drivers/gpio/gpiolib-uio.c new file +256 -0
256 lines not on this page · raw message
Quoted 60 lines · Rodolfo Giometti
Hello,
at the moment if a developer wishes to use a GPIO as output or input with a well defined name from userspace via the sysfs interface he/she can use, respectively, the gpio-leds or gpio-uinput devices. However, IMHO, this is not the best nor a proper way to do it, that's why I'm here to propose this really simple interface named
GPIO_UIO.That's why I wrote the attached patch (for kernel 4.19) which it's just a proposal, and the purpose of this message is to collect feedback about this solution. Of course I'll be happy to port it for latest kernel release and complete it with all requested documentation and needed modifications, but I'll do it only if this patch has some changes to be accepted by GPIO subsystem's maintainers. :)
For the moment here is how it works:
1) The patch is activated by the configuration entry
CONFIG_GPIO_UIO.2) In the device-tree the developer defines all board's GPIO lines with their names and mode of functioning:
(quoted diff) +14
-0+ gpio_uio { + compatible = "gpio-uio"; + + bypass0 { + gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>; + mode = "out-low"; + }; + + bypass1 { + gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>; + mode = "out-low"; + label = "bypass-1"; + }; + };Property "mode" can be "asis", "input", "out-low", etc. and the property label can be used in case the GPIO line's name should be different from the node's name.
3) At boot the GPIO lines are added:
[ 2.398902] gpio-uio bypass0: line added [ 2.423558] gpio-uio bypass-1: line added4) Then users will find a new class with entries, one for each new line:
# ls /sys/class/gpio-uio/ bypass-1 bypass05) By using the attribute "line" the users can get or set the line status
# cat /sys/class/gpio-uio/bypass-1/line 0 # echo 1 > /sys/class/gpio-uio/bypass-1/line # cat /sys/class/gpio-uio/bypass-1/line 16) Developers can monitor the GPIO lines via debugfs as for kernel modules:
Quoted 8 lines
# cat /sys/kernel/debug/gpio gpiochip1: GPIOs 446-475, parent: platform/d0018800.pinctrl, GPIO2: gpio-457 ( |bypass-1 ) out logpiochip0: GPIOs 476-511, parent: platform/d0013800.pinctrl, GPIO1:
gpio-479 ( |cd ) in hi IRQ gpio-480 ( |vcc_sd1 ) out lo gpio-486 ( |bypass0 ) out lo
This is similar to an out-of-tree driver we use in the kernel build for our BeagleBoard.org Debian images called gpio-of-helper [0].
It is a DT based driver created by Pantelis Antoniou back in 2013. It allows our downstream BeagleBoard.org dts files to describe the gpio lines that will be controlled from userspace. We failed to get the driver upstream back then, and it has remained out-of-tree since.
Currently, I am trying to shrink our out-of-tree patches [1] so we can eventually get our BeagleBoard.org kernel builds on to mainline. Thus coming up with a mainline solution for this is important to me. I was to chat virtually last week with Bart [2], Geert and Linus and it does seem like the new GPIO aggregator [3] could address this use case. I need to do some experimentation to understand how that would work.
Regards,
Drew
[0] https://github.com/beagleboard/linux/blob/5.4/drivers/gpio/gpio-of-helper.c
[1] https://github.com/RobertCNelson/ti-linux-kernel-dev/tree/ti-linux-5.4.y/patches
[2] https://static.sched.com/hosted_files/ossna2020/67/Linux%20GPIO-Evolution%20and%20Current%20State%20of%20the%20User%20API.pdf
[3] https://www.kernel.org/doc/html/latest/admin-guide/gpio/gpio-aggregator.html
Quoted 7 lines · Drew Fustini
This is similar to an out-of-tree driver we use in the kernel build for our BeagleBoard.org Debian images called gpio-of-helper [0].
It is a DT based driver created by Pantelis Antoniou back in 2013. It allows our downstream BeagleBoard.org dts files to describe the gpio lines that will be controlled from userspace. We failed to get the driver upstream back then, and it has remained out-of-tree since.
I see.
However my support is not designed for a general purpose board where GPIOs usage may vary, but for final products where GPIO lines are well-defined (even if the patch can be easily modified in order to support unregister() operations).
Quoted 6 lines
Currently, I am trying to shrink our out-of-tree patches [1] so we can eventually get our BeagleBoard.org kernel builds on to mainline. Thus coming up with a mainline solution for this is important to me. I was to chat virtually last week with Bart [2], Geert and Linus and it does seem like the new GPIO aggregator [3] could address this use case. I need to do some experimentation to understand how that would work.
As already stated in my last e-mail to Linus GPIO aggregator doesn't allow board manufacturer to define meaningful GPIO lines within the device tree without additional patches or by forcing users to define them by additional commands after boot.
Why a LED should be easily and completely managed within the device-tree and a relè, a photo-diode or any other input/output digital line should not? :-/
The driver by Pantelis Antoniou and my support does this jobs without interfere with other GPIOs mechanisms.
I think the maintainers should seriously consider it.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Hi Rodolfo!
thanks for your mail.
Quoted 5 lines · Rodolfo Giometti
4) Then users will find a new class with entries, one for each new line:
# ls /sys/class/gpio-uio/ bypass-1 bypass0
Quoted 7 lines
5) By using the attribute "line" the users can get or set the line status
# cat /sys/class/gpio-uio/bypass-1/line 0 # echo 1 > /sys/class/gpio-uio/bypass-1/line # cat /sys/class/gpio-uio/bypass-1/line 1
This interface is problematic because it extends the sysfs ABI which is obsolete. This is why the documentation of this ABI has been moved to Documentation/ABI/obsolete/sysfs-gpio for many years.
The sysfs approach has several problems which are summarized like this in the commit where it was introduced:
commit 3c702e9987e261042a07e43460a8148be254412e
Author: Linus Walleij <[email protected]> Date: Wed Oct 21 15:29:53 2015 +0200
gpio: add a userspace chardev ABI for GPIOs
A new chardev that is to be used for userspace GPIO access is added in this patch. It is intended to gradually replace the horribly broken sysfs ABI.
Using a chardev has many upsides:
- All operations are per-gpiochip, which is the actual device underlying the GPIOs, making us tie in to the kernel device model properly.
- Hotpluggable GPIO controllers can come and go, as this kind of problem has been know to userspace for character devices since ages, and if a gpiochip handle is held in userspace we know we will break something, whereas the sysfs is stateless.
- The one-value-per-file rule of sysfs is really hard to maintain when you want to twist more than one knob at a time, for example have in-kernel APIs to switch several GPIO lines at the same time, and this will be possible to do with a single ioctl() from userspace, saving a lot of context switching.
(...)
Another thing that is not mentioned here is that when a character device is opened it is automatically closed if a process crashes, which means that kernelspace can do clean-ups and reference counting and making the lines available to other consumers (like if you restart the program).
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Yours,
Linus Walleij
Quoted 1 line · Linus Walleij
Hi Rodolfo!
Hi. :)
Quoted 17 lines
thanks for your mail.
Quoted 5 lines · Rodolfo Giometti
4) Then users will find a new class with entries, one for each new line:
# ls /sys/class/gpio-uio/ bypass-1 bypass0Quoted 7 lines
5) By using the attribute "line" the users can get or set the line status
# cat /sys/class/gpio-uio/bypass-1/line 0 # echo 1 > /sys/class/gpio-uio/bypass-1/line # cat /sys/class/gpio-uio/bypass-1/line 1
Quoted 3 lines
This interface is problematic because it extends the sysfs ABI which is obsolete. This is why the documentation of this ABI has been moved to
Documentation/ABI/obsolete/sysfs-gpiofor many years.
This support is not part of CONFIG_GPIO_SYSFS; it just uses the sysfs to work.
Quoted 2 lines
The sysfs approach has several problems which are summarized like this in the commit where it was introduced:
I see, but my solution is just for having an easy-to-use way to get access to meaningful GPIOs the board manufacturer defined for some specific usage during the board design. It's not generic as gpio-sysfs.
Quoted 5 lines
Another thing that is not mentioned here is that when a character device is opened it is automatically closed if a process crashes, which means that kernelspace can do clean-ups and reference counting and making the lines available to other consumers (like if you restart the program).
In this case there is nothing to release nor clean up since each line has a fixed name, usage and it can be used as input or output without modifications.
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...
By using my solution each board manufacturer can specify meaningful GPIO lines directly within the device-tree, then users can use it via the "line" property or just use the new chrdev interface for better performances.
Also my solution allows developers to manage these lines without any external programs but just using cat&echo. This is _very_ useful when your embedded system has a very tiny rootfs!
My two cents. :)
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...
I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
But Geert can speak of that.
Yours,
Linus Walleij
Quoted 16 lines · Linus Walleij
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...
Quoted 5 lines
I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
But Geert can speak of that.
The idea is to describe the real device in DT, and add it's compatible value to gpio_aggregator_dt_ids[], or enable support for it dynamically using driver_override.
The former indeed requires modifying the driver.
Note that if you ever want to write a pure kernelspace driver, you do need a proper compatible value anyway.
I do agree that it's annoying to have "gpio-leds", but not "gpio-motors" or "gpio-relays". However, you can always propose bindings for the latter, and, when they have been accepted, add those compatible values to upstream gpio_aggregator_dt_ids[].
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Linus Walleij
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
Quoted 6 lines
Quoted 1 line
But Geert can speak of that.
The idea is to describe the real device in DT, and add it's compatible value to gpio_aggregator_dt_ids[], or enable support for it dynamically using
driver_override.
The former indeed requires modifying the driver.
I see.
Quoted 2 lines
Note that if you ever want to write a pure kernelspace driver, you do need a proper compatible value anyway.
OK, but for our purposes we need just one compatible value.
Quoted 4 lines
I do agree that it's annoying to have "gpio-leds", but not "gpio-motors" or "gpio-relays". However, you can always propose bindings for the latter, and, when they have been accepted, add those compatible values to upstream gpio_aggregator_dt_ids[].
Having gpio-uio with proper names within it as motor0, motor1, relay0, etc. as in my solution would be suffice. However, after these discussions, are there any chances my patch (with needed modifications and documentation) may be accepted? :)
Thanks for your time and answers.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Hi Rodolfo,
CC devicetree
Quoted 41 lines · Rodolfo Giometti
Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Linus Walleij
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
Quoted 6 lines
Quoted 1 line
But Geert can speak of that.
The idea is to describe the real device in DT, and add it's compatible value to gpio_aggregator_dt_ids[], or enable support for it dynamically using
driver_override.
The former indeed requires modifying the driver.I see.
Quoted 2 lines
Note that if you ever want to write a pure kernelspace driver, you do need a proper compatible value anyway.
OK, but for our purposes we need just one compatible value.
Quoted 4 lines
I do agree that it's annoying to have "gpio-leds", but not "gpio-motors" or "gpio-relays". However, you can always propose bindings for the latter, and, when they have been accepted, add those compatible values to upstream gpio_aggregator_dt_ids[].
Quoted 5 lines
Having gpio-uio with proper names within it as motor0, motor1, relay0, etc. as in my solution would be suffice. However, after these discussions, are there any chances my patch (with needed modifications and documentation) may be accepted? :)
Thanks for your time and answers.
Let's ask the DT people...
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 46 lines · Geert Uytterhoeven
Hi Rodolfo,
CC devicetree
Quoted 41 lines · Rodolfo Giometti
Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Linus Walleij
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
Quoted 6 lines
Quoted 1 line
But Geert can speak of that.
The idea is to describe the real device in DT, and add it's compatible value to gpio_aggregator_dt_ids[], or enable support for it dynamically using
driver_override.
The former indeed requires modifying the driver.I see.
Quoted 2 lines
Note that if you ever want to write a pure kernelspace driver, you do need a proper compatible value anyway.
OK, but for our purposes we need just one compatible value.
Quoted 4 lines
I do agree that it's annoying to have "gpio-leds", but not "gpio-motors" or "gpio-relays". However, you can always propose bindings for the latter, and, when they have been accepted, add those compatible values to upstream gpio_aggregator_dt_ids[].
Quoted 7 lines
Quoted 5 lines
Having gpio-uio with proper names within it as motor0, motor1, relay0, etc. as in my solution would be suffice. However, after these discussions, are there any chances my patch (with needed modifications and documentation) may be accepted? :)
Thanks for your time and answers.
Let's ask the DT people...
I think I need an OK from GPIO SUBSYSTEM's maintainers first...
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
RFC 1/1 GPIO lines [was: GPIO User I/O]
Hello,
I reworked a bit my proposal due to the fact that the name "GPIO User I/O" is not so clear as I supposed to be... so I renamed it as "GPIO lines". :)
Since this support is intended to allow boards developers to easily define their GPIO lines for a well defined purpose from the userspace I thing this last name is more appropriate.
Within the device tree we have to specify each line:
gpio_lines {
compatible = "gpio-line";
bypass0 {
gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>;
mode = "out-low";
};
bypass1 {
gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>;
mode = "out-low";
};
key {
gpios = <&gpionb 4 GPIO_ACTIVE_HIGH>;
mode = "input";
};
motor {
gpios = <&gpionb 8 GPIO_ACTIVE_HIGH>;
mode = "out-high-open-drain";
};
};Then we enable the configuration settings CONFIG_GPIO_LINE so at boot we have:
[ 2.377401] line bypass0: added [ 2.411496] line bypass1: added [ 2.416141] line key: added [ 2.419758] line motor: added
Then, when the boot is finished, we have the following entries in the new "line" class:
# ls /sys/class/line/ bypass0 bypass1 key motor
Now each line can be read and written by using the "state" attribute:
# cat /sys/class/line/bypass0/state 0 # echo 1 > /sys/class/line/bypass0/state # cat /sys/class/line/bypass0/state 1
Hope it could be more acceptable now.
Please, let me know if should I propose a proper patch for inclusion or something must be changed/added/fixed.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
drivers/gpio/Kconfig +10 -0
@@ -73,6 +73,16 @@ config GPIO_SYSFS Kernel drivers may also request that a particular GPIO be exported to userspace; this can be useful when debugging. +config GPIO_LINE + bool "/sys/class/line/... (GPIO lines interface)" + depends on SYSFS + help + Say Y here to add a sysfs interface to manage system's GPIO lines. + + Instead of the GPIO_SYSFS support, by using this support, you'll be + able to use GPIOs from userspace as stated in the device-tree + for well defined pourposes and by using proper names. + config GPIO_GENERIC depends on HAS_IOMEM # Only for IOMEM drivers tristate
drivers/gpio/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o obj-$(CONFIG_OF_GPIO) += gpiolib-of.o obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o +obj-$(CONFIG_GPIO_LINE) += gpiolib-line.o obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically
drivers/gpio/gpiolib-line.c new file +256 -0
256 lines not on this page · raw message
Re: [RFC] GPIO lines [was: GPIO User I/O]
Quoted 14 lines · Rodolfo Giometti
gpio_lines {
compatible = "gpio-line";
bypass0 {
gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>;
mode = "out-low";
};
bypass1 {
gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>;
mode = "out-low";
};
key {Quoted 8 lines
gpios = <&gpionb 4 GPIO_ACTIVE_HIGH>;
mode = "input";
};
motor {
gpios = <&gpionb 8 GPIO_ACTIVE_HIGH>;
mode = "out-high-open-drain";
};These mode = ... strings are really just a big confusion for me since they reinvent several of the flags you can already give to the gpios, see include/dt-bindings/gpio/gpio.h:
/* Bit 0 express polarity */
#define GPIO_ACTIVE_HIGH 0
#define GPIO_ACTIVE_LOW 1
/* Bit 1 express single-endedness */
#define GPIO_PUSH_PULL 0
#define GPIO_SINGLE_ENDED 2
/* Bit 2 express Open drain or open source */
#define GPIO_LINE_OPEN_SOURCE 0
#define GPIO_LINE_OPEN_DRAIN 4
/*
* Open Drain/Collector is the combination of single-ended open drain interface.
* Open Source/Emitter is the combination of single-ended open source interface. */
#define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_DRAIN) #define GPIO_OPEN_SOURCE (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_SOURCE)
Yours,
Linus Walleij
Re: [RFC] GPIO lines [was: GPIO User I/O]
Quoted 41 lines · Linus Walleij
Quoted 14 lines · Rodolfo Giometti
gpio_lines { compatible = "gpio-line"; bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>; mode = "out-low"; }; bypass1 { gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>; mode = "out-low"; }; key {Quoted 8 lines
gpios = <&gpionb 4 GPIO_ACTIVE_HIGH>; mode = "input"; }; motor { gpios = <&gpionb 8 GPIO_ACTIVE_HIGH>; mode = "out-high-open-drain"; };These mode = ... strings are really just a big confusion for me since they reinvent several of the flags you can already give to the gpios, see
include/dt-bindings/gpio/gpio.h:/* Bit 0 express polarity */
#defineGPIO_ACTIVE_HIGH0
#defineGPIO_ACTIVE_LOW1/* Bit 1 express single-endedness */
#defineGPIO_PUSH_PULL0
#defineGPIO_SINGLE_ENDED2/* Bit 2 express Open drain or open source */
#defineGPIO_LINE_OPEN_SOURCE0
#defineGPIO_LINE_OPEN_DRAIN4
Quoted 6 lines
/*
* Open Drain/Collector is the combination of single-ended open drain interface.
* Open Source/Emitter is the combination of single-ended open source interface. */
#defineGPIO_OPEN_DRAIN(GPIO_SINGLE_ENDED|GPIO_LINE_OPEN_DRAIN) #defineGPIO_OPEN_SOURCE(GPIO_SINGLE_ENDED|GPIO_LINE_OPEN_SOURCE)
These modes came from include/linux/gpio/consumer.h:
/**
* Optional flags that can be passed to one of gpiod_* to configure direction
* and output value. These values cannot be OR'd.
*/
enum gpiod_flags {
GPIOD_ASIS = 0,
GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET,
GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT,
GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT | GPIOD_FLAGS_BIT_DIR_VAL,
GPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN, GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN,
};
So a setting like the following should set at boot gpio10 as output to 0:
bypass0 {
gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>;
mode = "out-low";
};While the next one should set gpio10 as output to 1:
bypass0 {
gpios = <&gpionb 10 GPIO_ACTIVE_LOW>;
mode = "out-low";
};Maybe I can do something similar to hog-gpio as below, if you prefer...
bypass0 {
gpios = <&gpionb 10 GPIO_ACTIVE_LOW>;
output-low;
};Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC] GPIO lines [was: GPIO User I/O]
Quoted 4 lines · Rodolfo Giometti
Quoted 4 lines
Quoted 4 lines
motor { gpios = <&gpionb 8 GPIO_ACTIVE_HIGH>; mode = "out-high-open-drain"; };
(...)
Quoted 3 lines
Quoted 3 lines
/* Bit 2 express Open drain or open source */
#defineGPIO_LINE_OPEN_SOURCE0
#defineGPIO_LINE_OPEN_DRAIN4
(...)
Quoted 1 line
These modes came from
include/linux/gpio/consumer.h:
OK I was a bit unclear. Mainly open drain should be a flag on the line, not a mode.
Quoted 5 lines
Maybe I can do something similar to hog-gpio as below, if you prefer...
bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_LOW>; output-low;
Yes this is better, just boolean flags is not natural than strings for this.
However it addresses in a way an issue we have had popping up from time to time which is assignment of default values to lines before they are used overall.
I think that would be a bit of thing that should be proper to solve as part of this.
The discussion has often stopped short due to different opinions on the device tree bindings for that.
Yours,
Linus Walleij
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 9 lines · Linus Walleij
Quoted 5 lines · Rodolfo Giometti
Maybe I can do something similar to hog-gpio as below, if you prefer...
bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_LOW>; output-low;Yes this is better, just boolean flags is not natural than strings for this.
OK, changed.
Quoted 9 lines
However it addresses in a way an issue we have had popping up from time to time which is assignment of default values to lines before they are used overall.
I think that would be a bit of thing that should be proper to solve as part of this.
The discussion has often stopped short due to different opinions on the device tree bindings for that.
I see... however attached is a new version of my proposal patch with the following changelog:
- GPIO line modes are now decoded as boolean properties (as for gpio-hogs). Allowed values are" "input", "output-low" and "output-high". If nothing is specified defaults to "as-is";
- At boot a more descriptive message for each line is displayed as below:
[ 1.834901] line bypass0: GPIO486 added as output-low
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
drivers/gpio/Kconfig +10 -0
@@ -73,6 +73,16 @@ config GPIO_SYSFS Kernel drivers may also request that a particular GPIO be exported to userspace; this can be useful when debugging. +config GPIO_LINE + bool "/sys/class/line/... (GPIO lines interface)" + depends on SYSFS + help + Say Y here to add a sysfs interface to manage system's GPIO lines. + + Instead of the GPIO_SYSFS support, by using this support, you'll be + able to use GPIOs from userspace as stated in the device-tree + for well defined pourposes and by using proper names. + config GPIO_GENERIC depends on HAS_IOMEM # Only for IOMEM drivers tristate
drivers/gpio/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o obj-$(CONFIG_OF_GPIO) += gpiolib-of.o obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o +obj-$(CONFIG_GPIO_LINE) += gpiolib-line.o obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically
drivers/gpio/gpiolib-line.c new file +251 -0
251 lines not on this page · raw message
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 1 line · Rodolfo Giometti
I see... however attached is a new version of my proposal patch
I looked a bit at this!
IIUC the idea is a "new" sysfs interface that does not require the exporting etc used by the current "old" sysfs interface. Instead of poking around in sysfs to export lines we do that from the device tree.
It also does not use any global GPIO numbers which would be my other main concern.
I must admit that it has some elegance to it. Especially when it comes to scripting.
The problem I see is that lines are left in whatever state they were in if a script crashes, so there is no "return to the initial value" that was there when the GPIOs were picked from the device tree. This makes this a bit fragile.
Also users regularly need to listen to events. This interface can and should never support that, for this one must use the character device, which will of course not work in parallel with using this sysfs ABI. And the day someone wants that we simply have to say no. There is no way to hold states for event handling in a stateless ABI.
Well of course they can poll for a line to change, but that is not proper event handling that reacts to an interrupt.
So while this is much more elegant the old sysfs ABI, and certainly better for scripting, it still suffers from some conflicts with the character device, and there is a risk to make users dissatisfied when they want to e.g. script event handlers.
What are your thoughts on this?
Yours,
Linus Walleij
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 9 lines · Linus Walleij
Quoted 1 line · Rodolfo Giometti
I see... however attached is a new version of my proposal patch
I looked a bit at this!
IIUC the idea is a "new" sysfs interface that does not require the exporting etc used by the current "old" sysfs interface. Instead of poking around in sysfs to export lines we do that from the device tree.
Yes.
Quoted 2 lines
It also does not use any global GPIO numbers which would be my other main concern.
Exactly, the idea is to have "names" that describe the IO lines to the userspace and a way to fix their usage in each board in the device tree. If a board has a relay line is a non-sense allow users in the userland to use it as an input line.
Quoted 2 lines
I must admit that it has some elegance to it. Especially when it comes to scripting.
:)
Quoted 4 lines
The problem I see is that lines are left in whatever state they were in if a script crashes, so there is no "return to the initial value" that was there when the GPIOs were picked from the device tree. This makes this a bit fragile.
I see but this interface is not designed for such complex usage nor to compete with the current character interface! It is designed to allow boards manufactures to "describe" some I/O lines that are not used by any driver in the device tree, and that users may desire to manage in a very simple manner. Let's thing about relay lines, or just a locked/unlocked input line which can be easily polled.
Quoted 8 lines
Also users regularly need to listen to events. This interface can and should never support that, for this one must use the character device, which will of course not work in parallel with using this sysfs ABI. And the day someone wants that we simply have to say no. There is no way to hold states for event handling in a stateless ABI.
Well of course they can poll for a line to change, but that is not proper event handling that reacts to an interrupt.
Again, the basic idea is not to compete with the current character interface nor to manage interrupts lines, but just to have a really simple way to describe those I/O lines which at the moment has no name nor references within the device tree.
Quoted 6 lines
So while this is much more elegant the old sysfs ABI, and certainly better for scripting, it still suffers from some conflicts with the character device, and there is a risk to make users dissatisfied when they want to e.g. script event handlers.
What are your thoughts on this?
Regarding the event handlers we can add irq supports... however I prefer to keep this interface really simple just to not be confused with the character interface.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 1 line · Rodolfo Giometti
On 16/07/2020 15:38, Linus Walleij wrote:
...
Quoted 4 lines
I see but this interface is not designed for such complex usage nor to compete with the current character interface! It is designed to allow boards manufactures to "describe" some I/O lines that are not used by any driver in the device tree,
Why are they not in firmware tables? Platform is a set of hardware that makes it so.
If something is not in DT, then there is no possible way to know what is that line?
Or in other words how does the OS know that the certain line is connected to a relay?
Quoted 3 lines
and that users may desire to manage in a very simple manner. Let's thing about relay lines, or just a locked/unlocked input line which can be easily polled.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 10 lines · Andy Shevchenko
Quoted 1 line · Rodolfo Giometti
On 16/07/2020 15:38, Linus Walleij wrote:
...
Quoted 4 lines
I see but this interface is not designed for such complex usage nor to compete with the current character interface! It is designed to allow boards manufactures to "describe" some I/O lines that are not used by any driver in the device tree,
Quoted 7 lines
Why are they not in firmware tables? Platform is a set of hardware that makes it so.
If something is not in DT, then there is no possible way to know what is that line?Or in other words how does the OS know that the certain line is connected to a relay?
I'm sorry but I'm not sure to understand you.
I think that within the DT the board developer should describe his/her hardware in the most detailed manner for drivers and, as last step, for the userspace. The OS should only knows such IO lines whose are driver related while other ones (such as a relay or a generic digital input such as a lock/unlock signal) should be described for the userspace.
At the moment the only way to "describe" a digital output/input not related to any driver is by using the led or uinput interface that are not designed for such purposes! My suggestion is to give a proper/dedicated description of such IO lines.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
In reply to Andy ShevchenkoQuoted 8 lines · Andy Shevchenko
Quoted 6 lines · Rodolfo Giometti
On 16/07/2020 15:38, Linus Walleij wrote:
I see but this interface is not designed for such complex usage nor to compete with the current character interface! It is designed to allow boards manufactures to "describe" some I/O lines that are not used by any driver in the device tree,
Quoted 7 lines
Why are they not in firmware tables? Platform is a set of hardware that makes it so.
If something is not in DT, then there is no possible way to know what is that line?Or in other words how does the OS know that the certain line is connected to a relay?
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Yours,
Linus Walleij
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 8 lines · Linus Walleij
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Quoted 5 lines
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Hello Linus,
I'm currently using my solution for GPIOs management as input or output lines described in the DT on several systems.
Are you re-thinking about this topic? Can we go further for inclusion or should I continue doing out-of-tree? :(
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 10 lines · Rodolfo Giometti
Quoted 8 lines · Linus Walleij
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Quoted 5 lines
Quoted 5 lines
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Not only neutral but be software'isms free!
It's only about hardware.
What I understand here is that we have missed the intermediate layer (let's call it 'platform abstraction') where it's related to the platform and neither strictly speaking hardware, nor software per se.
Quoted 5 lines
I'm currently using my solution for GPIOs management as input or output lines described in the DT on several systems.
Are you re-thinking about this topic? Can we go further for inclusion or should I continue doing out-of-tree? :(
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 17 lines · Andy Shevchenko
Quoted 10 lines · Rodolfo Giometti
Quoted 8 lines · Linus Walleij
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Quoted 5 lines
Quoted 5 lines
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Quoted 6 lines
Not only neutral but be software'isms free!
It's only about hardware.What I understand here is that we have missed the intermediate layer (let's call it 'platform abstraction') where it's related to the platform and neither strictly speaking hardware, nor software per se.
Maybe I don't well understand the-problem(TM), but why people are currently using led and uinput layers to describes their output or input lines?
Why don't providing a dedicated layer for this special scope?
My two cents,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
In reply to Rodolfo GiomettiQuoted 16 lines · Rodolfo Giometti
Quoted 8 lines · Linus Walleij
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Quoted 5 lines
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Quoted 7 lines
Hello Linus,
I'm currently using my solution for GPIOs management as input or output lines described in the DT on several systems.
Are you re-thinking about this topic? Can we go further for inclusion or should I continue doing out-of-tree? :(
It is a system description question, and I think you will need to discuss it on the [email protected] mailing list.
The people there are working with things like the system device tree which is intended to describe aspects of a system apart from what Linux or any operating system is doing with the hardware.
I would send an RFC of the proposed DT bindings there.
They have been Cced in the past but not addressed directly.
Yours,
Linus Walleij
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 25 lines · Linus Walleij
Quoted 16 lines · Rodolfo Giometti
Quoted 8 lines · Linus Walleij
IIUC Rodolfo's idea is to provide this with a DT compatible. The use case will be industrial automation-ish tasks from userspace.
Currently the only mechanism we have in the device tree to assign a use for a line is the "gpio-line-names" property, which creates a name that is reported upward to the character device.
Quoted 5 lines
Rodolfo's patch is for scripting use cases, assigning some lines for some cases to be handled by scripts, not the character device.
What I am a bit worried about is if this would be a Linuxism, as DT should be OS neutral.
Quoted 7 lines
Hello Linus,
I'm currently using my solution for GPIOs management as input or output lines described in the DT on several systems.
Are you re-thinking about this topic? Can we go further for inclusion or should I continue doing out-of-tree? :(
Quoted 6 lines
It is a system description question, and I think you will need to discuss it on the [email protected] mailing list.
The people there are working with things like the system device tree which is intended to describe aspects of a system apart from what Linux or any operating system is doing with the hardware.
That sounds great to me! :-)
Quoted 1 line
I would send an RFC of the proposed DT bindings there.
I agree. Please, let me know if you need some help.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 6 lines · Rodolfo Giometti
Quoted 3 lines · Linus Walleij
On Mon, Apr 26, 2021 at 10:44 AM Rodolfo Giometti <[email protected]> wrote:
I would send an RFC of the proposed DT bindings there.
I agree. Please, let me know if you need some help.
I [general tense] would, implied [if I were you].
What I mean is that whoever wants to drive this should send proposed DT bindings there.
I am not volunteering to drive the project. It needs to be driven by those who have the need and can verify that it is fulfils the needs they have.
Yours,
Linus Walleij
Re: [RFC v2 GPIO lines [was: GPIO User I/O]
Quoted 4 lines · Linus Walleij
Quoted 2 lines · Rodolfo Giometti
Quoted 1 line · Linus Walleij
On Mon, Apr 26, 2021 at 10:44 AM Rodolfo Giometti <[email protected]> wrote:
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I would send an RFC of the proposed DT bindings there.
I agree. Please, let me know if you need some help.
I [general tense] would, implied [if I were you].
What I mean is that whoever wants to drive this should send proposed DT bindings there.
:)
Quoted 3 lines
I am not volunteering to drive the project. It needs to be driven by those who have the need and can verify that it is fulfils the needs they have.
OK, I'm going to re-propose my patch to the [email protected] mailing list putting you on Cc.
Thanks a lot for your suggestions.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti
A message that is not in the archive (sent off-list or not yet received): CAEf4M_C5ztHoiu4uGiiqxLF7uW6wbyxdg43cs=YgArszMfbXcw@mail.gmail.com
Hi Drew,
Quoted 42 lines · Drew Fustini
Quoted 41 lines · On Tue, Jul 7, 2020, 09:18 Rodolfo Giometti <[email protected]> wrote:
Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Linus Walleij
Quoted 6 lines · Rodolfo Giometti
Quoted 5 lines
With Geert's GPIO aggregator userspace and device tree can conjure special per-usecase gpio chips as pointed out by Drew: this is very useful when you want some kernel-managed yet usecase-specific GPIO lines in a special "container" chip. To me this is the best of two worlds. (Kernelspace and userspace.)
Quoted 8 lines
Maybe this is the "best of two worlds" as you say but the problem is that board manufactures need a way to well-define how a GPIO line must be used for within the device-tree and without the need of patches! In this point of view neither the "
driver_override" way nor adding a compatible value to gpio_aggregator_dt_ids[] can help (this last solution requires a patch for each board!). That's why at the moment they prefer not specify these GPIO lines at all or (improperly) use the gpio-leds and gpio-uinput interfaces to keep it simple...I think the idea is to add a very generic DT compatible to the gpio_aggregator_dt_ids[]. That way, any DT can use the aggregator to create a new chip with named lines etc.
Quoted 6 lines
Quoted 1 line
But Geert can speak of that.
The idea is to describe the real device in DT, and add it's compatible value to gpio_aggregator_dt_ids[], or enable support for it dynamically using
driver_override.
The former indeed requires modifying the driver.I see.
Quoted 2 lines
Note that if you ever want to write a pure kernelspace driver, you do need a proper compatible value anyway.
OK, but for our purposes we need just one compatible value.
Quoted 4 lines
I do agree that it's annoying to have "gpio-leds", but not "gpio-motors" or "gpio-relays". However, you can always propose bindings for the latter, and, when they have been accepted, add those compatible values to upstream gpio_aggregator_dt_ids[].
Quoted 8 lines
Quoted 3 lines
Having gpio-uio with proper names within it as motor0, motor1, relay0, etc. as in my solution would be suffice. However, after these discussions, are there any chances my patch (with needed modifications and documentation) may be accepted? :)
Hi, I would like to clarify my understanding of what gpio-uio.
Is there something in mainline that already uses that binding?
No there isn't.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds