Skip to content

RFC gpiolib: Initial, basic support for shared GPIO lines

Peter Ujfalusi linux-devicetree linux-gpio lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dt-bindings: gpio: Document shared GPIO line usageDocumentation/devicetree/bindings/gpio/gpio.txt+66 -07 replies
2/2gpiolib: Support for (output only) shared GPIO linedrivers/gpio/gpiolib-of.c drivers/gpio/gpiolib.c drivers/gpio/gpiolib.h+157 -132 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/2] gpiolib: Initial, basic support for shared GPIO lines

Hi,

The initial support can replace all use of GPIOD_FLAGS_BIT_NONEXCLUSIVE if the shared GPIO is configured to follow pass through 'strategy' for the shared GPIO pin.

I have only implemented DT support.

With the shared gpio support one can choose between three different strategy for managing the shared gpio:
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.

Few shortcomings as of now:
- can not handle different GPIO_ACTIVE_ on the user side, both the root GPIO (which is shared) and clients must have the same GPIO_ACTIVE_ mode. We are using common gpio_desc.
Like with GPIOD_FLAGS_BIT_NONEXCLUSIVE
- refcounting counts _all_ 1/0 requests coming from the users of the shared GPIO. This could cause issues if clients are using the gpiod API in unbalanced way.
We would need to have separate tracking for each of the clients and agregate the level they are asking for at any moment. Basically a new gpio-chip on top of the real gpio pin can solve this.

Regards,
Peter
---
Peter Ujfalusi (2):
dt-bindings: gpio: Document shared GPIO line usage
gpiolib: Support for (output only) shared GPIO line

 .../devicetree/bindings/gpio/gpio.txt         |  66 +++++++++
 drivers/gpio/gpiolib-of.c                     |  28 +++-
 drivers/gpio/gpiolib.c                        | 132 ++++++++++++++++--
 drivers/gpio/gpiolib.h                        |  10 ++
 4 files changed, 223 insertions(+), 13 deletions(-)
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki