From: Linus Walleij <linus.walleij@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Romain Izard <romain.izard.pro@gmail.com>,
Linux GPIO List <linux-gpio@vger.kernel.org>,
Ludovic Desroches <ludovic.desroches@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: GPIOs not correctly exported via sysfs on ATSAMA5D2
Date: Tue, 3 Mar 2020 14:10:35 +0100 [thread overview]
Message-ID: <CACRpkdYdwsLPEGnVLpYZsf70BLvxhOAbNbSD7LDCTp-FDYPCGA@mail.gmail.com> (raw)
In-Reply-To: <20200302213002.ajeujnuox6ioi2ua@pengutronix.de>
On Mon, Mar 2, 2020 at 10:30 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Mon, Mar 02, 2020 at 05:34:19PM +0100, Linus Walleij wrote:
> > That's especially annoying. I would consider adding a specific
> > consumer flag for GPIOs used this way, in additon to
> > GPIOD_ASIS, something like GPIOD_ASIS_NOMUX
> > (thinking of better names).
>
> This is not only relevant for GPIOD_ASIS. GPIOs for recovery are
> registered (in the case of i2c-imx) with:
>
> rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
> rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN);
>
> so we'd need a _NOMUX variant for each gpiod_flags value.
Oh we don't need a special variant for everything. In the end
it is just a bitfield, sorry if I was unclear. :(
#define GPIOD_FLAGS_BIT_NOMUX BIT(5)
rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN |
GPIOD_FLAGS_BIT_NOMUX);
or
GPIOD_OUT_HIGH_OPEN_DRAIN | GPIOD_FLAGS_BIT_NOMUX
is fine.
It is just convenient helpers after all.
> Also if a board makes use of i2c, the corresponding pins shouldn't be
> muxed to GPIO if userspace requests the GPIO via gpioctl or sysfs.
> (IMHO i2c isn't special here, this should apply to all used pins,
> shouldn't it?)
This is another reason why people tag their pin controllers
as strict, and in that case this works.
For those that are not strict, userspace can intercept
the same pins and wreac havoc. Using GPIO from userspace
is indeed in many cases a good gun to shoot oneself in
the foot with.
The solution is not perfect, improvements can be made.
> > Since the calling site knows about this usecase we can
> > open code the semantics for this specifically.
>
> Since the calling site doesn't know if the pin is used otherwise, it
> should default to _NOMUX?
Sorry I'm not following?
I was thinking that if the I2C driver knows it will be doing this
imperative I2C recovery by shaking the pins from the GPIO
side of things, it will request the pins with the flag
GPIOD_FLAGS_BIT_NOMUX and then the GPIO and
pin control subsystems knows: "aha they wanna use these
behind the back of pin control so let's not enforce stuff,
just give them a handle to the line and make sure nobody
else goes and use these lines".
Yours,
Linus Walleij
prev parent reply other threads:[~2020-03-03 13:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 10:58 GPIOs not correctly exported via sysfs on ATSAMA5D2 Romain Izard
2020-02-28 12:39 ` Ludovic Desroches
2020-02-28 12:46 ` Russell King - ARM Linux admin
2020-02-28 13:36 ` Linus Walleij
2020-03-02 8:47 ` Uwe Kleine-König
2020-03-02 8:39 ` Uwe Kleine-König
2020-03-02 9:36 ` Russell King - ARM Linux admin
2020-03-02 16:34 ` Linus Walleij
2020-03-02 16:44 ` Russell King - ARM Linux admin
2020-03-02 21:30 ` Uwe Kleine-König
2020-03-03 13:10 ` Linus Walleij [this message]
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=CACRpkdYdwsLPEGnVLpYZsf70BLvxhOAbNbSD7LDCTp-FDYPCGA@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=ludovic.desroches@microchip.com \
--cc=romain.izard.pro@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).