From: Philipp Zabel <p.zabel@pengutronix.de>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>, Rob Herring <robh+dt@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Mark Brown <broonie@kernel.org>, Tero Kristo <t-kristo@ti.com>,
Maxime Ripard <mripard@kernel.org>,
devicetree@vger.kernel.org
Subject: Re: [RFC v2 0/2] gpio: Support for shared GPIO lines on boards
Date: Wed, 30 Oct 2019 14:51:35 +0100 [thread overview]
Message-ID: <116e2d1eb1333c322450f20a5f591b7038586865.camel@pengutronix.de> (raw)
In-Reply-To: <5bca4eb6-6379-394f-c95e-5bbbba5308f1@ti.com>
On Wed, 2019-10-30 at 15:32 +0200, Peter Ujfalusi wrote:
>
> On 30/10/2019 15.12, Rob Herring wrote:
> > On Wed, Oct 30, 2019 at 7:03 AM Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:
> > > Hi,
> > >
> > > The shared GPIO line for external components tends to be a common issue and
> > > there is no 'clean' way of handling it.
> > >
> > > I'm aware of the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag, which must be provided when
> > > a driver tries to request a GPIO which is already in use.
> > > However the driver must know that the component is going to be used in such a
> > > way, which can be said to any external components with GPIO line, so in theory
> > > all drivers must set this flag when requesting the GPIO...
> > >
> > > But with the GPIOD_FLAGS_BIT_NONEXCLUSIVE all clients have full control of the
> > > GPIO line. For example any device using the same GPIO as reset/enable line can
> > > reset/enable other devices, which is not something the other device might like
> > > or can handle.
> > > For example a device needs to be configured after it is enabled, but some other
> > > driver would reset it while handling the same GPIO -> the device is not
> > > operational anymmore as it lost it's configuration.
> > >
> > > With the gpio-shared gpiochip we can overcome this by giving the gpio-shared
> > > the role of making sure that the GPIO line only changes state when it will not
> > > disturb any of the clients sharing the same GPIO line.
> >
> > Why can't we just add a shared flag like we have for interrupts?
> > Effectively, we have that for resets too, it's just hardcoded in the
> > the drivers.
>
> This would be kind of the same thing what the
> GPIOD_FLAGS_BIT_NONEXCLUSIVE does, which was a quick workaround for
> fixed-regulators afaik.
>
> But let's say that a board design will pick two components (C1 and C2)
> and use the same GPIO line to enable them. We already have the drivers
> for them and they are used in boards already.
>
> Both needs the GPIO line to be high for normal operation.
> One or both of them needs register writes after they are enabled.
>
> During boot both requests the GPIO (OUTPUT_LOW) and sets it high, then
> run the register setup.
>
> C1 request GPIO (LOW)
> C1 gpio_set(1)
> C1 register writes
> C2 requests GPIO (LOW)
> C1 placed to reset and looses the configuration
> C2 gpio_set(1)
> C1 also enabled
> C2 register writes
>
> At this point C2 is operational, C1 is not.
>
> In shared GPIO case the GPIO should be handled like a regulator with a
> twist that the 'sticky' state of the GPIO might be low or high depending
> on the needs of the components it is connected to.
>
> The shared GPIO line is a board design quirk and basically any device
> which have reset/enable GPIO must be able to work in a situation when
> they are sharing that line with other components and the driver should
> not know much about this small detail.
What about components that require a register write right after being
enabled, for example to put the device into a low power state, to
silence it on a bus, or to mask some initially enabled interrupts?
regards
Philipp
next prev parent reply other threads:[~2019-10-30 13:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 12:04 [RFC v2 0/2] gpio: Support for shared GPIO lines on boards Peter Ujfalusi
2019-10-30 12:04 ` [RFC v2 1/2] dt-bindings: gpio: Add binding document for shared GPIO Peter Ujfalusi
2019-10-30 12:04 ` [RFC v2 2/2] gpio: Add new driver for handling 'shared' gpio lines on boards Peter Ujfalusi
2019-10-30 13:12 ` [RFC v2 0/2] gpio: Support for shared GPIO " Rob Herring
2019-10-30 13:32 ` Peter Ujfalusi
2019-10-30 13:51 ` Philipp Zabel [this message]
2019-10-30 14:03 ` Peter Ujfalusi
2019-10-30 14:17 ` Mark Brown
2019-10-30 14:31 ` Peter Ujfalusi
2019-10-30 18:49 ` Rob Herring
2019-10-31 8:01 ` Peter Ujfalusi
2019-11-01 13:46 ` Rob Herring
2019-11-01 15:21 ` Peter Ujfalusi
2019-11-04 19:11 ` Rob Herring
2019-11-05 9:58 ` Linus Walleij
2019-11-05 11:15 ` Peter Ujfalusi
2019-11-05 12:15 ` Grygorii Strashko
2019-11-05 12:32 ` Peter Ujfalusi
2019-11-05 18:07 ` Grygorii Strashko
2019-11-06 9:23 ` Peter Ujfalusi
2019-11-06 10:00 ` Philipp Zabel
2019-11-05 12:17 ` Peter Ujfalusi
2019-11-18 12:15 ` Enrico Weigelt, metux IT consult
2019-11-18 13:38 ` Philipp Zabel
2019-11-18 14:00 ` Peter Ujfalusi
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=116e2d1eb1333c322450f20a5f591b7038586865.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=bgolaszewski@baylibre.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mripard@kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=robh+dt@kernel.org \
--cc=t-kristo@ti.com \
/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).