All of lore.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <drew@beagleboard.org>
To: Rodolfo Giometti <giometti@enneenne.com>
Cc: linux-gpio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [RFC] GPIO User I/O
Date: Mon, 6 Jul 2020 15:35:19 +0200	[thread overview]
Message-ID: <20200706133519.GA1046717@x1> (raw)
In-Reply-To: <01afcac0-bd34-3fd0-b991-a8b40d4b4561@enneenne.com>

On Mon, Jul 06, 2020 at 02:19:49PM +0200, Rodolfo Giometti wrote:
> 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

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


  reply	other threads:[~2020-07-06 13:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 12:19 [RFC] GPIO User I/O Rodolfo Giometti
2020-07-06 13:35 ` Drew Fustini [this message]
2020-07-06 18:19   ` Rodolfo Giometti
2020-07-06 13:43 ` Linus Walleij
2020-07-06 15:33   ` Rodolfo Giometti
2020-07-06 20:38     ` Linus Walleij
2020-07-06 21:00       ` Geert Uytterhoeven
2020-07-07  7:17         ` Rodolfo Giometti
2020-07-07  7:41           ` Geert Uytterhoeven
2020-07-07  9:56             ` Rodolfo Giometti
2020-07-09 14:11               ` [RFC] GPIO lines [was: GPIO User I/O] Rodolfo Giometti
2020-07-11 15:21                 ` Linus Walleij
2020-07-13 14:20                   ` Rodolfo Giometti
2020-07-13 21:26                     ` Linus Walleij
2020-07-14 14:01                       ` [RFC v2 " Rodolfo Giometti
2020-07-16 13:38                         ` Linus Walleij
2020-07-16 15:15                           ` Rodolfo Giometti
2020-07-19 18:35                             ` Andy Shevchenko
2020-07-20  7:38                               ` Rodolfo Giometti
2020-07-20  8:17                               ` Linus Walleij
2021-04-26  8:44                                 ` Rodolfo Giometti
2021-04-26  8:48                                   ` Andy Shevchenko
2021-04-26  9:16                                     ` Rodolfo Giometti
2021-04-26  9:31                                   ` Linus Walleij
2021-04-26  9:43                                     ` Rodolfo Giometti
2021-04-26 10:12                                       ` Linus Walleij
2021-04-26 11:20                                         ` Rodolfo Giometti
     [not found]           ` <CAEf4M_C5ztHoiu4uGiiqxLF7uW6wbyxdg43cs=YgArszMfbXcw@mail.gmail.com>
2020-07-07  8:47             ` [RFC] GPIO User I/O Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706133519.GA1046717@x1 \
    --to=drew@beagleboard.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=giometti@enneenne.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.