linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC/RFT 0/2] gpio: allow auto population of request/free
@ 2015-10-11 15:48 Jonas Gorski
  2015-10-11 15:48 ` [PATCH RFC/RFT 1/2] gpio: allow atomic registration of gpio chip with pin ranges Jonas Gorski
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jonas Gorski @ 2015-10-11 15:48 UTC (permalink / raw)
  To: linux-gpio
  Cc: Linus Walleij, Alexandre Courbot, Florian Fainelli, Ray Jui,
	Scott Branden

Many pinctrl/gpio combinations are fine with the generic gpio
request/free implementations, and some only have a subset of the
gpios actually support muxed.

The common occurrence is

a) populate request/free of gpiochip
b) if only some gcs have pinmux, store for the chip if it does
   and call pinctrl_request/free conditionally
c) register gpiochip
d) add ranges to chip

To reduce the amount of work for the drivers, introduce a
gpiochip_add_with_ranges(), that allows doing c and d at the same time.

Since gpiochip_add_with_ranges then has the information at hand whether
the chip ties into the pinctrl subsystem, we can then also automatically
populate the gpiochip's request/free in case ranges were passed or a
gpio range property is present on the of node of the chip. This handles
a) and b) for most known drivers.

This patchset is a proof-of-concept, with the pinctrl-cygnus-gpio driver
as the example conversion to it. It registers a total of 51 gpio ranges,
which I thought as an ideal maximum reduction example.

This patchset depends on "gpiochip: add and use generic request/free".

As last time only build tested, not run tested due to lacking hardware.

A few points of disscussion:

So far I have just reused the struct pinctrl_gpio_range, but ignore most
fields, which might bloat the kernel a bit. OTOH 0's should compress
fine.

Also currently the code assumes all ranges are handled by the same
pinctrl device. Currently this could be trivially fixed as
pinctrl_gpio_range has a field for the pinctrl device name.

So far I have assumed there are no actual platorms with such a setup.


Jonas Gorski (2):
  gpio: allow atomic registration of gpio chip with pin ranges
  pinctrl-cygnus-gpio: convert to use gpiochip_add_with_ranges

 drivers/gpio/gpiolib-of.c                 |   5 ++
 drivers/gpio/gpiolib.c                    |  43 ++++++++--
 drivers/gpio/gpiolib.h                    |   9 +++
 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 126 +++++++-----------------------
 include/linux/gpio/driver.h               |  10 ++-
 5 files changed, 85 insertions(+), 108 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-16 21:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-11 15:48 [PATCH RFC/RFT 0/2] gpio: allow auto population of request/free Jonas Gorski
2015-10-11 15:48 ` [PATCH RFC/RFT 1/2] gpio: allow atomic registration of gpio chip with pin ranges Jonas Gorski
2015-10-13 20:32   ` Ray Jui
2015-10-16 21:10   ` Linus Walleij
2015-10-11 15:48 ` [PATCH RFC/RFT 2/2] pinctrl-cygnus-gpio: convert to use gpiochip_add_with_ranges Jonas Gorski
2015-10-13 20:34   ` Ray Jui
2015-10-13 20:31 ` [PATCH RFC/RFT 0/2] gpio: allow auto population of request/free Ray Jui
2015-10-16 21:04   ` Linus Walleij
2015-10-16 21:10     ` Ray Jui

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).