lkml.org 
[lkml]   [2022]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 0/2] gpio: gpio-sim: read property 'gpio-base' from dtb
On Wed, Jun 22, 2022 at 5:54 PM Menglong Wu <menglongwoo@aliyun.com> wrote:
>
> The first GPIO number of the gpio-sim module is dynamic.
>
> gpio_chip.base = -1.
>
> ```
> gpio-sim {
> compatible = "gpio-simulator";
> bank0 {
> gpio-controller;
> #gpio-cells = <2>;
> ngpios = <16>;
> gpio-sim,label = "dt-bank0";
> gpio-line-names = "", "sim-foo", "", "sim-bar";
> };
> };
> ```
>
> If I want to export GPIO from user space. I have to confirm the number
> from the debugfs filesystem. The 16 GPIO be map to 2032-2047.
>

I find it ironic that you're trying to use sysfs to play with the
module whose sole purpose is to facilitate the move away from it. I'd
like to hear a very good reason to add this option because otherwise
you're exposing information that should very much be hidden from
user-space.

Bart

>
> ```
> [root@QEMU-ARM ~]# cat /sys/kernel/debug/gpio
> gpiochip0: GPIOs 2032-2047, parent: platform/gpio-sim, dt-bank0:
>
> gpio-2033 (sim-foo )
> gpio-2035 (sim-bar )
> ```
>
> Change
>
> Then add the property 'gpio-base' to fix the base number.
> Although the method is be DEPRECATED (include/linux/gpio/driver.h)
>
> ```
> gpio-sim {
> compatible = "gpio-simulator";
> bank0 {
> gpio-controller;
> #gpio-cells = <2>;
> gpio-base = <300>;
> ngpios = <16>;
> gpio-sim,label = "dt-bank0";
> gpio-line-names = "", "sim-foo", "", "sim-bar";
> };
> };
> ```
>
> This base number is always 300.
>
> ```
> [root@QEMU-ARM ~]# cat /sys/kernel/debug/gpio
> gpiochip0: GPIOs 300-315, parent: platform/gpio-sim, dt-bank0:
> gpio-301 (sim-foo )
> gpio-303 (sim-bar )
> [root@QEMU-ARM ~]# echo 300 > /sys/class/gpio/export
> ```
>
>
>
>
> Menglong Wu (2):
> gpio: gpio-sim: initialize gpio_chip->base from dtb
> docs: gpio-sim device-tree example with gpio-base
>
> Documentation/admin-guide/gpio/gpio-sim.rst | 3 +++
> drivers/gpio/gpio-sim.c | 7 ++++++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> --
> 2.30.2
>

\
 
 \ /
  Last update: 2022-06-23 17:00    [W:0.029 / U:0.948 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site