From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Rob Herring <robh@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
kernel@pengutronix.de, linux-gpio@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] gpio: document how to order GPIO controllers
Date: Tue, 5 Jul 2016 20:04:47 +0200 [thread overview]
Message-ID: <20160705180447.GP16643@pengutronix.de> (raw)
In-Reply-To: <20160705140546.GA10601@rob-hp-laptop>
On Tue, Jul 05, 2016 at 09:05:46AM -0500, Rob Herring wrote:
> On Fri, Jul 01, 2016 at 08:42:13AM +0200, Uwe Kleine-König wrote:
> > This uses the same approach that is already used for spi, i2c and
> > several other controllers to ensure a consistent numbering independent
> > of probe order. This is in use for several gpio drivers that already now
> > use of_alias_get_id(np, "gpio").
>
> Like SPI and I2C, I'm against further abuse of aliases for this purpose
> [1].
I considered spi and i2c the good examples here :-|
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > Hello,
> >
> > Linus requested such a patch as part of a change that introduces
> > this mechanism to the gpio-omap driver[1]. IMHO this is better done in a
> > separate patch, so here it comes.
> >
> > Best regards
> > Uwe
> >
> > [1] http://thread.gmane.org/gmane.linux.kernel.gpio/17399/focus=17629
> >
> > Documentation/devicetree/bindings/gpio/gpio.txt | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt
> > index 68d28f62a6f4..5dbacc8f094a 100644
> > --- a/Documentation/devicetree/bindings/gpio/gpio.txt
> > +++ b/Documentation/devicetree/bindings/gpio/gpio.txt
> > @@ -227,6 +227,24 @@ Example of two SOC GPIO banks defined as gpio-controller nodes:
> > #gpio-cells = <2>;
> > };
> >
> > +Usually the GPIO banks in SoCs are ordered, that is there is a dedicated "first
> > +gpio bank". To fix this ordering in the device tree use aliases starting at 0
> > +(even if the first bank is called "GPIO1" in the hardware reference).
> > +This is necessary/handy to ensure deterministical numbering of GPIOs and GPIO
> > +controllers.
>
> Why is deterministic numbering needed?
in my case (with a pre 4.8 kernel) it's to control GPIO48 with
/sys/class/gpio/gpio48. But also when using the gpio chardev device
(that will hit 4.8-rc1 AFAIK) there is one device file per gpio chip.
Now consider a user who wants to control/debug direction and value of
GPIO48 (or GPIO2.16 for the chardev case). The strait forward approach
is to use /sys/class/gpio/gpio48 (or /dev/dontknowthename2 with offset
16). I doubt there is a platform where it didn't work like this up to
now and I'd consider it a userspace breakage to force the user to know
that the 2nd gpio bank is located at address 0x53fd0000 and so to lookup
the gpio bank below /sys/bus/platform/devices/53fd0000.gpio/.
On an i.MX25 device I currently see:
root@hostname:/sys/bus/gpio/devices ls -l
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip0 -> ../../../devices/platform/soc/53f00000.aips/53f9c000.gpio/gpiochip0
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip1 -> ../../../devices/platform/soc/53f00000.aips/53fa4000.gpio/gpiochip1
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip2 -> ../../../devices/platform/soc/53f00000.aips/53fcc000.gpio/gpiochip2
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip3 -> ../../../devices/platform/soc/53f00000.aips/53fd0000.gpio/gpiochip3
That is we have:
Hardware name | software gpiochip
GPIO4 | gpiochip0
GPIO3 | gpiochip1
GPIO1 | gpiochip2
GPIO2 | gpiochip3
I bet that's the probe order because when sorted by address (and so
by order in the device tree) we have exactly this ordering. (Compare
with $(grep gpio@ arch/arm/boot/dts/imx25.dtsi).)
For a new interface this is OK, still I predict users will complain if
the numbers used don't match naturally the hardware names. And IMHO they
are right.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] gpio: document how to order GPIO controllers
Date: Tue, 5 Jul 2016 20:04:47 +0200 [thread overview]
Message-ID: <20160705180447.GP16643@pengutronix.de> (raw)
In-Reply-To: <20160705140546.GA10601@rob-hp-laptop>
On Tue, Jul 05, 2016 at 09:05:46AM -0500, Rob Herring wrote:
> On Fri, Jul 01, 2016 at 08:42:13AM +0200, Uwe Kleine-K?nig wrote:
> > This uses the same approach that is already used for spi, i2c and
> > several other controllers to ensure a consistent numbering independent
> > of probe order. This is in use for several gpio drivers that already now
> > use of_alias_get_id(np, "gpio").
>
> Like SPI and I2C, I'm against further abuse of aliases for this purpose
> [1].
I considered spi and i2c the good examples here :-|
> > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> > ---
> > Hello,
> >
> > Linus requested such a patch as part of a change that introduces
> > this mechanism to the gpio-omap driver[1]. IMHO this is better done in a
> > separate patch, so here it comes.
> >
> > Best regards
> > Uwe
> >
> > [1] http://thread.gmane.org/gmane.linux.kernel.gpio/17399/focus=17629
> >
> > Documentation/devicetree/bindings/gpio/gpio.txt | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt
> > index 68d28f62a6f4..5dbacc8f094a 100644
> > --- a/Documentation/devicetree/bindings/gpio/gpio.txt
> > +++ b/Documentation/devicetree/bindings/gpio/gpio.txt
> > @@ -227,6 +227,24 @@ Example of two SOC GPIO banks defined as gpio-controller nodes:
> > #gpio-cells = <2>;
> > };
> >
> > +Usually the GPIO banks in SoCs are ordered, that is there is a dedicated "first
> > +gpio bank". To fix this ordering in the device tree use aliases starting at 0
> > +(even if the first bank is called "GPIO1" in the hardware reference).
> > +This is necessary/handy to ensure deterministical numbering of GPIOs and GPIO
> > +controllers.
>
> Why is deterministic numbering needed?
in my case (with a pre 4.8 kernel) it's to control GPIO48 with
/sys/class/gpio/gpio48. But also when using the gpio chardev device
(that will hit 4.8-rc1 AFAIK) there is one device file per gpio chip.
Now consider a user who wants to control/debug direction and value of
GPIO48 (or GPIO2.16 for the chardev case). The strait forward approach
is to use /sys/class/gpio/gpio48 (or /dev/dontknowthename2 with offset
16). I doubt there is a platform where it didn't work like this up to
now and I'd consider it a userspace breakage to force the user to know
that the 2nd gpio bank is located at address 0x53fd0000 and so to lookup
the gpio bank below /sys/bus/platform/devices/53fd0000.gpio/.
On an i.MX25 device I currently see:
root at hostname:/sys/bus/gpio/devices ls -l
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip0 -> ../../../devices/platform/soc/53f00000.aips/53f9c000.gpio/gpiochip0
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip1 -> ../../../devices/platform/soc/53f00000.aips/53fa4000.gpio/gpiochip1
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip2 -> ../../../devices/platform/soc/53f00000.aips/53fcc000.gpio/gpiochip2
lrwxrwxrwx 1 root root 0 Jul 5 20:52 gpiochip3 -> ../../../devices/platform/soc/53f00000.aips/53fd0000.gpio/gpiochip3
That is we have:
Hardware name | software gpiochip
GPIO4 | gpiochip0
GPIO3 | gpiochip1
GPIO1 | gpiochip2
GPIO2 | gpiochip3
I bet that's the probe order because when sorted by address (and so
by order in the device tree) we have exactly this ordering. (Compare
with $(grep gpio@ arch/arm/boot/dts/imx25.dtsi).)
For a new interface this is OK, still I predict users will complain if
the numbers used don't match naturally the hardware names. And IMHO they
are right.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2016-07-05 18:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-01 6:42 [PATCH] gpio: document how to order GPIO controllers Uwe Kleine-König
2016-07-01 6:42 ` Uwe Kleine-König
2016-07-05 14:05 ` Rob Herring
2016-07-05 14:05 ` Rob Herring
2016-07-05 18:04 ` Uwe Kleine-König [this message]
2016-07-05 18:04 ` Uwe Kleine-König
2016-07-06 7:24 ` Lothar Waßmann
2016-07-06 7:24 ` Lothar Waßmann
2016-07-06 7:54 ` Alexander Stein
2016-07-06 7:54 ` Alexander Stein
2016-07-06 9:34 ` Linus Walleij
2016-07-06 9:34 ` Linus Walleij
2016-07-06 10:27 ` Johan Hovold
2016-07-06 10:27 ` Johan Hovold
2016-07-06 12:34 ` Linus Walleij
2016-07-06 12:34 ` Linus Walleij
2016-07-06 14:12 ` Permissions for GPIOs [Was: [PATCH] gpio: document how to order GPIO controllers] Jan Lübbe
2016-07-06 14:12 ` Jan Lübbe
[not found] ` <1467814334.2472.154.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-07-08 11:25 ` Linus Walleij
2016-07-08 11:25 ` Linus Walleij
2016-07-13 13:14 ` [PATCH] gpio: document how to order GPIO controllers Johan Hovold
2016-07-13 13:14 ` Johan Hovold
2016-07-22 14:34 ` Linus Walleij
2016-07-22 14:34 ` Linus Walleij
2016-07-17 22:03 ` Rob Herring
2016-07-17 22:03 ` Rob Herring
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=20160705180447.GP16643@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=devicetree@vger.kernel.org \
--cc=gnurou@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh@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.