From: Linus Walleij <linus.walleij@linaro.org>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Rob Herring <robh+dt@kernel.org>,
"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>,
Maxime Ripard <mripard@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>
Subject: Re: [RFC 2/2] gpiolib: Support for (output only) shared GPIO line
Date: Fri, 22 Nov 2019 13:22:23 +0100 [thread overview]
Message-ID: <CACRpkdYt5P=GNc3EgHb-ry9fxMbXfpZd4FC=tuLqonNJKUM2wg@mail.gmail.com> (raw)
In-Reply-To: <20191120133409.9217-3-peter.ujfalusi@ti.com>
On Wed, Nov 20, 2019 at 2:34 PM Peter Ujfalusi <peter.ujfalusi@ti.com> wrote:
> This patch adds basic support for handling shared GPIO lines in the core.
> The line must be configured with a child node in DT.
> Based on the configuration the core will use different strategy to manage
> the shared line:
> refcounted low: Keep the line low as long as there is at least one low
> request is registered
> refcounted high: Keep the line high as long as there is at least one high
> request is registered
> pass through: all requests are allowed to go through without refcounting.
>
> The pass through mode is equivalent to how currently the
> GPIOD_FLAGS_BIT_NONEXCLUSIVE is handled.
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
This is a good start! Some ideas on how I'd like this to develop.
> drivers/gpio/gpiolib-of.c | 28 ++++++--
> drivers/gpio/gpiolib.c | 132 +++++++++++++++++++++++++++++++++++---
Please put this API under its own Kconfig option
and in its own file in
drivers/gpio/gpiolib-refcounted.c
local header in
drivers/gpio/gpiolib-refcounted.h
only built in if the appropriate Kconfig is selected.
Consumer header in
include/linux/gpio/reference-counted.h
And add external driver API to this last file.
> --- a/drivers/gpio/gpiolib-of.c
No commenting on this because as pointed out in the binding
patch I want this done by simply detecting the same GPIO
being referenced by several <&gpio N> phandles.
> diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
> index ca9bc1e4803c..0eec0857e3a8 100644
> --- a/drivers/gpio/gpiolib.h
> +++ b/drivers/gpio/gpiolib.h
> @@ -111,11 +111,18 @@ struct gpio_desc {
> #define FLAG_PULL_UP 13 /* GPIO has pull up enabled */
> #define FLAG_PULL_DOWN 14 /* GPIO has pull down enabled */
> #define FLAG_BIAS_DISABLE 15 /* GPIO has pull disabled */
> +#define FLAG_IS_SHARED 16 /* GPIO is shared */
This is a good way of flagging that this is a refcounted GPIO
I would call it FLAG_IS_REFERENCE_COUNTED as it is
more precise to what it means.
> +#define FLAG_REFCOUNT_LOW 17 /* Shared GPIO is refcounted for raw low */
> +#define FLAG_REFCOUNT_HIGH 18 /* Shared GPIO is refcounted for raw high */
Do not put this here, keep it in the local refcounted GPIO
struct gpio_refcount_desc.
> /* Connection label */
> const char *label;
> /* Name of the GPIO */
> const char *name;
> + /* Number of users of a shared GPIO */
> + int shared_users;
> + /* Reference counter for shared GPIO (low or high level) */
> + int level_refcount;
We can't expand this struct for everyone on the planet like this.
In the local header
drivers/gpio/gpiolib-refcount.h create something like:
struct gpio_refcount_desc {
struct gpio_desc *gd;
int shared_users;
int level_refcount;
};
This should be the opaque cookie returned to consumers of this new
refcounted API.
It defines the reference counted API as separate and optional from
the non-reference counted API, also using its own API.
The only effect on the core
gpiolib will be the single flag in struct gpio_desc; and some
calls into the shared code with stubs if the support for systems
that do not enable the reference counting API.
Yours,
Linus Walleij
next prev parent reply other threads:[~2019-11-22 12:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 13:34 [RFC 0/2] gpiolib: Initial, basic support for shared GPIO lines Peter Ujfalusi
2019-11-20 13:34 ` [RFC 1/2] dt-bindings: gpio: Document shared GPIO line usage Peter Ujfalusi
2019-11-22 12:10 ` Linus Walleij
2019-11-22 13:36 ` Peter Ujfalusi
2019-11-28 10:06 ` Linus Walleij
2019-12-02 21:31 ` Peter Ujfalusi
2019-12-11 0:06 ` Linus Walleij
2019-12-03 23:51 ` Rob Herring
2019-12-10 23:54 ` Linus Walleij
2019-11-20 13:34 ` [RFC 2/2] gpiolib: Support for (output only) shared GPIO line Peter Ujfalusi
2019-11-22 12:22 ` Linus Walleij [this message]
2019-11-22 15:14 ` Peter Ujfalusi
2019-11-20 13:49 ` [RFC 0/2] gpiolib: Initial, basic support for shared GPIO lines 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='CACRpkdYt5P=GNc3EgHb-ry9fxMbXfpZd4FC=tuLqonNJKUM2wg@mail.gmail.com' \
--to=linus.walleij@linaro.org \
--cc=bgolaszewski@baylibre.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=peter.ujfalusi@ti.com \
--cc=robh+dt@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 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).