platform/kernel/linux-rpi.git
6 years agogpiolib: Fix incorrect use of find_next_zero_bit()
Janusz Krzysztofik [Sat, 29 Sep 2018 12:20:22 +0000 (14:20 +0200)]
gpiolib: Fix incorrect use of find_next_zero_bit()

Commit b17566a6b08b ("gpiolib: Implement fast processing path in
get/set array"), already fixed to some extent with commit 5d581d7e8cdc
("gpiolib: Fix missing updates of bitmap index"), introduced a new mode
of processing bitmaps where bits applicable for fast bitmap processing
path are supposed to be skipped while iterating bits which don't apply.
Unfortunately, find_next_zero_bit() function supposed to skip over
those fast bits is always called with a 'start' argument equal to an
index of last zero bit found and returns that index value again an
again, causing an infinite loop.

Fix it by incrementing the index uncoditionally before
find_next_zero_bit() is optionally called.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: new driver to work with a 8x12 siox
Uwe Kleine-König [Thu, 27 Sep 2018 07:48:08 +0000 (09:48 +0200)]
gpio: new driver to work with a 8x12 siox

This driver controls a SIOX device that provides 20 I/O lines. The first
twelve are fixed inputs, the remaining eight are outputs.

Acked-by: Gavin Schenk <g.schenk@eckelmann.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agodt-bindings: gpio: rcar: Add r8a7744 (RZ/G1N) support
Biju Das [Fri, 21 Sep 2018 15:34:04 +0000 (16:34 +0100)]
dt-bindings: gpio: rcar: Add r8a7744 (RZ/G1N) support

Renesas RZ/G1N (R8A7744) SoC GPIO blocks are identical to the R-Car Gen2
family. Add support for its GPIO controllers.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: Add comments on single direction chips
Linus Walleij [Tue, 25 Sep 2018 07:54:14 +0000 (09:54 +0200)]
gpio: Add comments on single direction chips

A patch from Ricardo got me thinking about some gpio chip
semantics so let's drop in some comments to make things
more clear around that.

Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Fix gpio_direction_* for single direction GPIOs
Ricardo Ribalda Delgado [Fri, 21 Sep 2018 10:36:03 +0000 (12:36 +0200)]
gpiolib: Fix gpio_direction_* for single direction GPIOs

GPIOs with no programmable direction are not required to implement
direction_output nor direction_input.

If we try to set an output direction on an output-only GPIO or input
direction on an input-only GPIO simply return 0.

This allows this single direction GPIO to be used by libgpiod.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: Rename devres implementation file
Linus Walleij [Tue, 25 Sep 2018 07:11:50 +0000 (09:11 +0200)]
gpio: Rename devres implementation file

All the other core files are named "gpiolib-<something>" so
let's rename the devres as well so we have some logical
namespacing here.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: Use SPDX header for core library
Linus Walleij [Tue, 25 Sep 2018 07:08:48 +0000 (09:08 +0200)]
gpio: Use SPDX header for core library

Use the SPDX headers and cut down on boilerplate to indicate the
license in the core gpiolib implementation.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agoMerge branch 'ib-omap' into devel
Linus Walleij [Tue, 25 Sep 2018 06:49:07 +0000 (08:49 +0200)]
Merge branch 'ib-omap' into devel

6 years agogpio: omap: Get rid of pm_runtime_irq_safe()
Tony Lindgren [Thu, 20 Sep 2018 19:35:32 +0000 (12:35 -0700)]
gpio: omap: Get rid of pm_runtime_irq_safe()

If a gpio instance has any GPIO bits requested we do a pm_runtime_get()
on the device. Now with cpu_pm handling the deeper SoC idle state quirks,
let's just remove pm_runtime_irq_safe() call and add a warning in case we
ever happen to encounter it.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Ladislav Michl <ladis@linux-mips.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: omap: Remove custom PM calls and use cpu_pm instead
Tony Lindgren [Thu, 20 Sep 2018 19:35:31 +0000 (12:35 -0700)]
gpio: omap: Remove custom PM calls and use cpu_pm instead

For a long time the gpio-omap custom PM calls have been annoying me so
let's replace them with cpu_pm instead. This will enable GPIO PM for
deeper idle states on omap4. And we can handle GPIO PM for omap2/3/4
in the same way.

Note that with this patch we are also slightly changing GPIO PM to be
less aggressive for omap3 and only will idle GPIO when PER context
may be lost.

For omap2, we don't need to save context and don't want to remove any
triggering so let's add a quirk flag for that.

Let's do this all in a single patch to avoid a situation where old
custom calls still are used with new code.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Ladislav Michl <ladis@linux-mips.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: omap: Add level wakeup handling for omap4 based SoCs
Tony Lindgren [Thu, 20 Sep 2018 19:35:30 +0000 (12:35 -0700)]
gpio: omap: Add level wakeup handling for omap4 based SoCs

I noticed that unlike omap2 and 3 based SoCs, omap4 based SoCs keep
the GPIO clocks enabled for GPIO level interrupts with wakeup enabled.
This blocks deeper idle states as the whole domain will stay busy.

The GPIO functional clock seems to stay enabled if the wakeup register
is enabled and a level interrupt is triggered. In that case the only
way to have the GPIO module idle is to reset it. It is possible this
has gone unnoticed with OSWR (Open SWitch Retention) and off mode
during idle resetting GPIO context most GPIO instances in the earlier
Android trees for example.

Looks like the way to deal with this is to have omap4 based SoCs
only set wake for the duration of idle for level interrupts, and clear
level registers for the idle. With level interrupts we can do this as
the level interrupt from device will be still there on resume.

I've taken the long path to fixing this to avoid yet more hard to
read code. I've set up a quirks flag, and a struct for function
pointers so we can use these to clean up other quirk handling easier
in the later patches. The current level quirk handling is moved to
the new functions.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Ladislav Michl <ladis@linux-mips.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Fix array members of same chip processed separately
Janusz Krzysztofik [Sun, 23 Sep 2018 23:53:36 +0000 (01:53 +0200)]
gpiolib: Fix array members of same chip processed separately

New code introduced by commit bf9346f5d47b ("gpiolib: Identify arrays
matching GPIO hardware") forcibly tries to find an array member which
has its array index number equal to its hardware pin number and set
up an array info for possible fast bitmap processing of all arrray
pins belonging to that chip which also satisfy that numbering rule.

Depending on array content, it may happen that consecutive array
members which belong to the same chip but don't have array indexes
equal to their pin hardware numbers will be split into groups, some of
them processed together via the fast bitmap path, and rest of them
separetely.  However, applications may expect all those pins being
processed together with a single call to .set_multiple() chip callback,
like that was done before the change.

Limit applicability of fast bitmap processing path to cases where all
pins of consecutive array members starting from 0 which belong to the
same chip have their hardware numbers equal to their corresponding
array indexes.  That should still speed up processing of applications
using whole GPIO banks as I/O ports, while not breaking simultaneous
manipulation of consecutive pins of the same chip which don't follow
the equal numbering rule.

Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Fix missing updates of bitmap index
Janusz Krzysztofik [Sun, 23 Sep 2018 23:53:35 +0000 (01:53 +0200)]
gpiolib: Fix missing updates of bitmap index

In new code introduced by commit b17566a6b08b ("gpiolib: Implement fast
processing path in get/set array"), bitmap index is not updated with
next found zero bit position as it should while skipping over pins
already processed via fast bitmap path, possibly resulting in an
infinite loop.  Fix it.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: htc-egpio: Unique label per chip
Linus Walleij [Sun, 23 Sep 2018 14:07:07 +0000 (16:07 +0200)]
gpio: htc-egpio: Unique label per chip

Give the HTC EGPIO chips unique names, htc-egpio-0,
htc-egpio-1 etc, so that it gets possible to associate
machine descriptor tables with individual chips.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agoMerge branch 'ib-array-bitmaps' into devel
Linus Walleij [Thu, 20 Sep 2018 15:36:36 +0000 (08:36 -0700)]
Merge branch 'ib-array-bitmaps' into devel

6 years agogpio: OF: Remove bad practice examples
Linus Walleij [Thu, 13 Sep 2018 07:44:21 +0000 (09:44 +0200)]
gpio: OF: Remove bad practice examples

We remove the references to anything but two-cell GPIO specifiers
and just mention that controllers need to specify their bindings
and that we strongly recommend two-cell bindings.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: OF: Cut painful BNF experiments from bindings
Linus Walleij [Thu, 13 Sep 2018 07:28:13 +0000 (09:28 +0200)]
gpio: OF: Cut painful BNF experiments from bindings

In 2011 the commit bf859f84a19f
("gpio/dt: Refine GPIO device tree binding") introduced an
experimental BNF notation for defining a regular grammar for
the GPIO phandles used by different devices.

This was an interesting approach, and shows that we have long
nutured the idea to formally verify device tree files using
regular grammar.

Most if not all other bindings use natural language to define
the bindings, and the recent thinking for verifying device
tree files is to use JSON schemas in separate definitions.

Cut the BNF business and replace it with natural language
so that it becomes more human-readable for now.

Cc: devicetree@vger.kernel.org
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Kumar Gala <galak@kernel.crashing.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: davinci: Move driver local definitions to driver
Andrew F. Davis [Fri, 31 Aug 2018 19:13:26 +0000 (14:13 -0500)]
gpio: davinci: Move driver local definitions to driver

These defines, structs and inline functions are used only internally by
the driver, they do not belong in platform_data. Move them.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: davinci: Remove unneeded GPIO macro
Andrew F. Davis [Fri, 31 Aug 2018 19:13:25 +0000 (14:13 -0500)]
gpio: davinci: Remove unneeded GPIO macro

This macro does nothing and has only one user, remove it.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: davinci: Allocate the correct amount of memory for controller
Andrew F. Davis [Fri, 31 Aug 2018 19:13:24 +0000 (14:13 -0500)]
gpio: davinci: Allocate the correct amount of memory for controller

Previously we created a controller structure per bank of GPIO pins. This
has since been changed to one per controller, but the allocation size
was not changed. Fix this here.

This also leaves the variable 'nbank' unused, instead of removing it,
move it down and use it to clean up a loop. For loops with multiple
initializers and/or iteration expressions, especially ones that don't
use those loop counters are quite hard to follow, fix this.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: davinci: Use dev name for label and automatic base selection
Andrew F. Davis [Fri, 31 Aug 2018 19:13:23 +0000 (14:13 -0500)]
gpio: davinci: Use dev name for label and automatic base selection

Use dev_name to get a unique label and use -1 for a base to get our
selection automatically. We pull in all GPIOs per chip now so this
does not have the effect of out of order labels like before.

We do these both together so we can drop all the static data in one
patch. This also lets us normalize the return paths as we don't need
any cleanup after this change.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: davinci: Remove unused member of davinci_gpio_controller
Andrew F. Davis [Fri, 31 Aug 2018 19:13:22 +0000 (14:13 -0500)]
gpio: davinci: Remove unused member of davinci_gpio_controller

This was added as part of the patch in the fixes below, but was
not needed or used, remove this here.

Fixes: 8e11047b8f3c ("gpio: davinci: Add support for multiple GPIO controllers")
Tested-by: Keerthy <j-keerthy@ti.com>
Acked-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: Get rid of legacy header
Linus Walleij [Thu, 13 Sep 2018 12:05:26 +0000 (14:05 +0200)]
gpio: Get rid of legacy header

A bunch of core gpiolib files still include the <linux/gpio.h>
legacy API header for no good reason. After this only the
gpiolib-legacy.c file includes it, which is fine.

The sysfs ABI code has a pointless wrapper function around
gpio_to_desc() we can just loose.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: wm8xxx: Cut down on boilerplate
Linus Walleij [Thu, 13 Sep 2018 11:28:13 +0000 (13:28 +0200)]
gpio: wm8xxx: Cut down on boilerplate

Just use the SPDX license tag for these drivers.

Cc: patches@opensource.cirrus.com
Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: Mark Brown <broonie@kernel.org>
Acked-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: wm8xxx: Use the right header
Linus Walleij [Thu, 13 Sep 2018 11:25:58 +0000 (13:25 +0200)]
gpio: wm8xxx: Use the right header

These are GPIO drivers so just include <linux/gpio/driver.h>.

Cc: patches@opensource.cirrus.com
Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: Mark Brown <broonie@kernel.org>
Acked-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: xlp: Cut down on boilerplate
Linus Walleij [Wed, 12 Sep 2018 12:32:07 +0000 (14:32 +0200)]
gpio: xlp: Cut down on boilerplate

Just use the SPDX license tag for this file.

Cc: Kamlakant Patel <kamlakant.patel@cavium.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: xlp: Include the right header
Linus Walleij [Wed, 12 Sep 2018 12:30:59 +0000 (14:30 +0200)]
gpio: xlp: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Cc: Kamlakant Patel <kamlakant.patel@cavium.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vx855: Cut down on boilerplate
Linus Walleij [Wed, 12 Sep 2018 12:13:17 +0000 (14:13 +0200)]
gpio: vx855: Cut down on boilerplate

Just use the SPDX header for the license.

Cc: Daniel Drake <drake@endlessm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vx855: Include the right header
Linus Walleij [Wed, 12 Sep 2018 12:11:59 +0000 (14:11 +0200)]
gpio: vx855: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Cc: Daniel Drake <drake@endlessm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: viperboard: Cut down on boilerplate
Linus Walleij [Wed, 12 Sep 2018 11:49:13 +0000 (13:49 +0200)]
gpio: viperboard: Cut down on boilerplate

Just use the SPDX header for the license.

Cc: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: viperboard: Include the right header
Linus Walleij [Wed, 12 Sep 2018 11:47:35 +0000 (13:47 +0200)]
gpio: viperboard: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Cc: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: xtensa: Cut down on boilerplate
Linus Walleij [Wed, 12 Sep 2018 11:36:08 +0000 (13:36 +0200)]
gpio: xtensa: Cut down on boilerplate

Just use the SPDX header for the license.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: xtensa: Include the right header
Linus Walleij [Wed, 12 Sep 2018 11:34:40 +0000 (13:34 +0200)]
gpio: xtensa: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vr41xx: Delete vr41xx_gpio_pullupdown() callback
Linus Walleij [Wed, 12 Sep 2018 11:22:15 +0000 (13:22 +0200)]
gpio: vr41xx: Delete vr41xx_gpio_pullupdown() callback

This API is not used anywhere in the kernel and has remained
unused for years after being introduced.

Over time, we have developed a subsystem to deal with pin
control and this now managed pull up/down.

Delete the old and unused API. If this platform needs it,
we should implement a proper pin controller for it instead.

Cc: Yoichi Yuasa <yuasa@linux-mips.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vr41xx: Cut down on boilerplate
Linus Walleij [Wed, 12 Sep 2018 11:15:50 +0000 (13:15 +0200)]
gpio: vr41xx: Cut down on boilerplate

This switches this file to use the SPDX license tag.

Cc: Yoichi Yuasa <yuasa@linux-mips.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vr41xx: Include the right header
Linus Walleij [Wed, 12 Sep 2018 11:14:33 +0000 (13:14 +0200)]
gpio: vr41xx: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Cc: Yoichi Yuasa <yuasa@linux-mips.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: check if irqchip already has the irq hook replacements
Hans Verkuil [Fri, 14 Sep 2018 08:36:39 +0000 (10:36 +0200)]
gpiolib: check if irqchip already has the irq hook replacements

Some drivers use a single irqchip for multiple gpiochips. As a result the
irqchip hooks are overridden for the first gpiochip that was added, but
for the other gpiochip instances this should not happen again, otherwise
we would go into an infinite recursion.

Check for this, but also log a message that the driver should be fixed
since this is bad practice.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: use better errno if get_direction is not available
Wolfram Sang [Wed, 11 Jul 2018 16:33:19 +0000 (18:33 +0200)]
gpiolib: use better errno if get_direction is not available

EINVAL is very generic, use ENOTSUPP in case the gpiochip does not
provide this function. While removing the assignment from the 'status'
variable, use better indentation in the declaration block.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Implement fast processing path in get/set array
Janusz Krzysztofik [Wed, 5 Sep 2018 21:50:08 +0000 (23:50 +0200)]
gpiolib: Implement fast processing path in get/set array

Certain GPIO descriptor arrays returned by gpio_get_array() may contain
information on direct mapping of array members to pins of a single GPIO
chip in hardware order.  In such cases, bitmaps of values can be passed
directly from/to the chip's .get/set_multiple() callbacks without
wasting time on iterations.

Add respective code to gpiod_get/set_array_bitmap_complex() functions.
Pins not applicable for fast path are processed as before, skipping
over the 'fast' ones.

Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Pass array info to get/set array functions
Janusz Krzysztofik [Wed, 5 Sep 2018 21:50:07 +0000 (23:50 +0200)]
gpiolib: Pass array info to get/set array functions

In order to make use of array info obtained from gpiod_get_array() and
speed up processing of arrays matching single GPIO chip layout, that
information must be passed to get/set array functions.  Extend the
functions' API with that additional parameter and update all users.
Pass NULL if a user builds an array itself from single GPIOs.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Korsgaard <peter.korsgaard@barco.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rojhalat Ibrahim <imr@rtschenk.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Identify arrays matching GPIO hardware
Janusz Krzysztofik [Wed, 5 Sep 2018 21:50:06 +0000 (23:50 +0200)]
gpiolib: Identify arrays matching GPIO hardware

Certain GPIO array lookup results may map directly to GPIO pins of a
single GPIO chip in hardware order.  If that condition is recognized
and handled efficiently, significant performance gain of get/set array
functions may be possible.

While processing a request for an array of GPIO descriptors, identify
those which represent corresponding pins of a single GPIO chip.  Skip
over pins which require open source or open drain special processing.
Moreover, identify pins which require inversion.  Pass a pointer to
that information with the array to the caller so it can benefit from
enhanced performance as soon as get/set array functions can accept and
make efficient use of it.

Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Pass bitmaps, not integer arrays, to get/set array
Janusz Krzysztofik [Wed, 5 Sep 2018 21:50:05 +0000 (23:50 +0200)]
gpiolib: Pass bitmaps, not integer arrays, to get/set array

Most users of get/set array functions iterate consecutive bits of data,
usually a single integer, while processing array of results obtained
from, or building an array of values to be passed to those functions.
Save time wasted on those iterations by changing the functions' API to
accept bitmaps.

All current users are updated as well.

More benefits from the change are expected as soon as planned support
for accepting/passing those bitmaps directly from/to respective GPIO
chip callbacks if applicable is implemented.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Korsgaard <peter.korsgaard@barco.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rojhalat Ibrahim <imr@rtschenk.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: Don't support irq sharing for userspace
Uwe Kleine-König [Mon, 20 Aug 2018 06:32:53 +0000 (08:32 +0200)]
gpiolib: Don't support irq sharing for userspace

This concerns gpio edge detection for GPIO IRQs used from
userspace for GPIO event listeners.

Trying to work out the right event if it's not sure that the
examined gpio actually moved is impossible.

Consider two gpios "gpioA" and "gpioB" that share an interrupt.
gpioA's irq should trigger on any edge, gpioB's on a falling edge.
If now the common irq fires and both gpio lines are high, there
are several possibilities that could have happend:

 a) gpioA just had a low-to-high edge
 b) gpioB just had a high-to-low-to-high spike
 c) a combination of both a) and b)

While c) is unlikely (in most setups) a) and b) alone are bad
enough. Currently the code assumes case a) unconditionally and
doesn't report an event for gpioB. Note that even if there is no
irq sharing involved a spike for a gpio might not result in an
event if it's configured to trigger for a single edge only.

The only way to improve this is to drop support for interrupt
sharing. This way a spike results in an event for the right gpio
at least. Note that apart from dropping IRQF_SHARED this
effectively undoes commit df1e76f28ffe
("gpiolib: skip unwanted events, don't convert them to opposite edge").

This obviously breaks setups that rely on interrupt sharing,
but given that this cannot be reliable, this is probably an
acceptable trade-off.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[Assuming there are no users of interrupt sharing yet]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: uapi: Grammar s/array/array of/
Geert Uytterhoeven [Tue, 11 Sep 2018 14:32:43 +0000 (16:32 +0200)]
gpio: uapi: Grammar s/array/array of/

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vf610: Cut down on boilerplate
Linus Walleij [Fri, 7 Sep 2018 20:04:50 +0000 (22:04 +0200)]
gpio: vf610: Cut down on boilerplate

Just use the SPDX identifier for the license.

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: vf610: Include the right header
Linus Walleij [Fri, 7 Sep 2018 20:03:07 +0000 (22:03 +0200)]
gpio: vf610: Include the right header

This is a GPIO driver so only include <linux/gpio/driver.h>.

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: of: make example syntactically correct
Wolfram Sang [Sun, 21 Jan 2018 12:12:43 +0000 (13:12 +0100)]
gpio: of: make example syntactically correct

The ';' was missing. And cosmetic: there was a space too much.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: of: Handle SPI chipselect legacy bindings
Linus Walleij [Tue, 4 Sep 2018 09:01:58 +0000 (11:01 +0200)]
gpio: of: Handle SPI chipselect legacy bindings

The SPI chipselects are assumed to be active low in the current
binding, so when we want to use GPIO descriptors and handle
the active low/high semantics in gpiolib, we need a special
parsing quirk to deal with this.

We check for the property "spi-cs-high" and if that is
NOT present we assume the CS line is active low.

If the line is tagged as active low in the device tree and
has no "spi-cs-high" property all is fine, the device
tree and the SPI bindings are in agreement.

If the line is tagged as active high in the device tree with
the second cell flag and has no "spi-cs-high" property we
enforce active low semantics (as this is the exception we can
just tag on the flag).

If the line is tagged as active low with the second cell flag
AND tagged with "spi-cs-high" the SPI active high property
takes precedence and we print a warning.

Cc: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio-bcm-kona: use new req/relres and dis/enable_irq funcs
Hans Verkuil [Sat, 8 Sep 2018 09:23:19 +0000 (11:23 +0200)]
gpio-bcm-kona: use new req/relres and dis/enable_irq funcs

Since this driver does not use the gpiolib irqchip helpers it will have to
allocate the irq resources and irq_en/disable itself.

Use the new gpiochip_req/relres_irq helpers to request/release all the
resources.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Ray Jui <rjui@broadcom.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio/driver.rst: document gpiochip_disable/enable_irq()
Hans Verkuil [Sat, 8 Sep 2018 09:23:18 +0000 (11:23 +0200)]
gpio/driver.rst: document gpiochip_disable/enable_irq()

Document these new functions.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: override irq_enable/disable
Hans Verkuil [Sat, 8 Sep 2018 09:23:17 +0000 (11:23 +0200)]
gpiolib: override irq_enable/disable

When using the gpiolib irqchip helpers install irq_enable/disable
hooks for the irqchip to ensure that gpiolib knows when the irq
is enabled or disabled, allowing drivers to disable the irq and then
use it as an output pin, and later switch the direction to input and
re-enable the irq.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: add flag to indicate if the irq is disabled
Hans Verkuil [Sat, 8 Sep 2018 09:23:16 +0000 (11:23 +0200)]
gpiolib: add flag to indicate if the irq is disabled

GPIO drivers call gpiochip_(un)lock_as_irq whenever they want to use a gpio
as an interrupt. This is done when the irq is requested and it marks the
gpio as in use by an interrupt.

This is problematic for cases where a gpio pin is used as an interrupt
pin, then, after the irq is disabled, is used as a regular gpio pin.
Currently it is not possible to do this other than by first freeing
the interrupt so gpiochip_unlock_as_irq is called, since an attempt to
switch the gpio direction for output will fail since gpiolib believes
that the gpio is in use for an interrupt and it does not know that it
the irq is actually disabled.

There are currently two drivers that would like to be able to do this:
the tda998x_drv.c driver where a regular gpio pin needs to be temporarily
reconfigured as an interrupt pin during CEC calibration, and the cec-gpio
driver where you want to configure the gpio pin as an interrupt while
waiting for traffic over the CEC bus, or as a regular pin when receiving or
transmitting a CEC message.

The solution is to add a new flag that is set when the irq is enabled,
and have gpiod_direction_output check for that flag.

We also add functions that drivers that do not use GPIOLIB_IRQCHIP
can call when they enable/disable the irq.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogliolib: set hooks in gpiochip_set_irq_hooks()
Hans Verkuil [Sat, 8 Sep 2018 09:23:15 +0000 (11:23 +0200)]
gliolib: set hooks in gpiochip_set_irq_hooks()

Centralize setting the irq_request/release_resources callbacks
in one function since we'll be adding more callbacks to that.

Also fix the removal of the callback overrides: this should
only be done if we actually installed our own callback there.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpiolib: export gpiochip_irq_reqres/relres()
Hans Verkuil [Sat, 8 Sep 2018 09:23:14 +0000 (11:23 +0200)]
gpiolib: export gpiochip_irq_reqres/relres()

GPIO drivers that do not use GPIOLIB_IRQCHIP can hook these into
the irq_request_resource and irq_release_resource callbacks of the
irq_chip so they correctly 'get' the module and lock the gpio line
for IRQ use.

This will simplify driver code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: fix test for end of loop
Dan Carpenter [Thu, 6 Sep 2018 13:33:48 +0000 (16:33 +0300)]
gpio: ep93xx: fix test for end of loop

The problem is that if port == ARRAY_SIZE() and "gc == &epg->gc[port]"
then that should be treated as invalid.

Fixes: fd935fc421e7 ("gpio: ep93xx: Do not pingpong irq numbers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: fix incorrect array element size check
Colin Ian King [Thu, 6 Sep 2018 11:58:30 +0000 (12:58 +0100)]
gpio: ep93xx: fix incorrect array element size check

Currently the while loop checks for the end of the array using
the size of egp->gc rather that the number of elements in the array,
so fix this. Also, perform the array size check first as stylistically
it is always good to bounds check on an array first before referencing
the array (in this case, we're just computing the address of an
element in an array so this is a moot point).

Fixes: fd935fc421e7 ("gpio: ep93xx: Do not pingpong irq numbers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: fix kernel-doc notation warning for 'request_key'
Randy Dunlap [Mon, 3 Sep 2018 19:55:30 +0000 (12:55 -0700)]
gpio: fix kernel-doc notation warning for 'request_key'

Fix kernel-doc warning for missing struct member 'request_key':

../include/linux/gpio/driver.h:142: warning: Function parameter or member 'request_key' not described in 'gpio_irq_chip'

Fixes: 39c3fd58952d ("kernel/irq: Extend lockdep class for request mutex")

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl6040: Implement .get_direction()
Linus Walleij [Mon, 3 Sep 2018 08:04:01 +0000 (10:04 +0200)]
gpio: twl6040: Implement .get_direction()

The gpiolib cannot deduce the fact that every line is output
by itself, implement a .get_direction() callback so we can
inspect this.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl6040: Use bitops
Linus Walleij [Mon, 3 Sep 2018 07:59:57 +0000 (09:59 +0200)]
gpio: twl6040: Use bitops

It's nice to use BIT() macros rather than open coding the same.
It's good practice as sometimes people use BIT(31) and forget
that the constant must be cast unsigned long.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl6040: Cut down boilerplate
Linus Walleij [Mon, 3 Sep 2018 07:55:50 +0000 (09:55 +0200)]
gpio: twl6040: Cut down boilerplate

Use the SPDX header to indicate the license for this driver.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl6040: Include the right header
Linus Walleij [Mon, 3 Sep 2018 07:54:55 +0000 (09:54 +0200)]
gpio: twl6040: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl4030: Implement .get_direction()
Linus Walleij [Mon, 3 Sep 2018 07:52:10 +0000 (09:52 +0200)]
gpio: twl4030: Implement .get_direction()

It's nice to be able to read back the direction of the GPIO
line from the hardware so implement .get_direction() for
twl4030.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl4030: Cut down boilerplate
Linus Walleij [Mon, 3 Sep 2018 06:20:59 +0000 (08:20 +0200)]
gpio: twl4030: Cut down boilerplate

Use the SPDX header to indicate the license for this driver.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: twl4030: Include the right header
Linus Walleij [Mon, 3 Sep 2018 06:15:50 +0000 (08:15 +0200)]
gpio: twl4030: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: zevio: Include the right header
Linus Walleij [Sun, 2 Sep 2018 22:18:51 +0000 (00:18 +0200)]
gpio: zevio: Include the right header

This is a driver so include only <linux/gpio/driver.h>.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ts5500: Delete platform data handling
Linus Walleij [Wed, 29 Aug 2018 15:16:18 +0000 (17:16 +0200)]
gpio: ts5500: Delete platform data handling

The TS5500 GPIO driver apparently supports platform data
without making any use of it whatsoever. Delete this code,
last chance to speak up if you think it is needed.

Cc: kernel@savoirfairelinux.com
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ts5500: Use SPDX header
Linus Walleij [Wed, 29 Aug 2018 15:08:53 +0000 (17:08 +0200)]
gpio: ts5500: Use SPDX header

Cut some boilerplate, use the SPDX license identifier.

Cc: kernel@savoirfairelinux.com
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ts5500: Include the right header
Linus Walleij [Wed, 29 Aug 2018 15:07:29 +0000 (17:07 +0200)]
gpio: ts5500: Include the right header

This is a GPIO driver so include only <linux/gpio/driver.h>.

Cc: kernel@savoirfairelinux.com
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: mxs: Get rid of external API call
Linus Walleij [Wed, 29 Aug 2018 15:02:16 +0000 (17:02 +0200)]
gpio: mxs: Get rid of external API call

The MXS driver was calling back into the GPIO API from
its irqchip. This is not very elegant, as we are a driver,
let's just shortcut back into the gpio_chip .get() function
instead.

This is a tricky case since the .get() callback is not in
this file, instead assigned by bgpio_init(). Calling the
function direcly in the gpio_chip is however the lesser
evil.

Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: tps65xxx: Use SPDX license tag
Linus Walleij [Wed, 29 Aug 2018 14:49:14 +0000 (16:49 +0200)]
gpio: tps65xxx: Use SPDX license tag

I'm tired of boilerplate, use the SPDX tag.

Acked-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: tpx65xxx: Include the right header
Linus Walleij [Wed, 29 Aug 2018 14:45:30 +0000 (16:45 +0200)]
gpio: tpx65xxx: Include the right header

These are drivers so include only <linux/gpio/driver.h>.

Acked-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agoMAINTAINERS: Add myself as designated reviewer of Intel PMIC GPIO
Andy Shevchenko [Thu, 30 Aug 2018 16:49:35 +0000 (19:49 +0300)]
MAINTAINERS: Add myself as designated reviewer of Intel PMIC GPIO

There are few Intel PMIC GPIO device drivers which I would like
to review.

Note, Intel MSIC is old system controller that based mostly on PMIC
integrated in it. Thus, I included it as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: brcmstb: allow 0 width GPIO banks
Justin Chen [Fri, 17 Aug 2018 23:47:39 +0000 (16:47 -0700)]
gpio: brcmstb: allow 0 width GPIO banks

Sometimes we have empty banks within the GPIO block. This commit allows
proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by
incrementing the bank and number of GPIOs, but not initializing them.
This will mean a call into the non-existent GPIOs will return an error.

Also remove "GPIO registered" dev print. This information is misleading
since the incremented banks and gpio_base do not reflect the actual GPIOs
that get initialized. We leave this information out since it is already
printed with dev_dbg.

Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ftgpio: Support debounce timer
Linus Walleij [Mon, 27 Aug 2018 20:15:51 +0000 (22:15 +0200)]
gpio: ftgpio: Support debounce timer

The FTGPIO010 has a debounce timer or rather prescaler that
will affect interrupts fireing off the block. We can support
this to get proper debounce on e.g. keypresses.

Since the same prescaler is used across all GPIO lines of
the silicon block, we need to bail out if the prescaler is
already set and in use by another line.

If the prescaler is already set to what we need, fine, we
reuse it. This happens more often than not when the same
debounce time is set for several GPIO keys, so we support
that usecase easily with this code.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ftgpio: Support optional silicon clock
Linus Walleij [Mon, 27 Aug 2018 20:15:40 +0000 (22:15 +0200)]
gpio: ftgpio: Support optional silicon clock

The GPIO silicon is clocked with a PCLK (peripheral clock)
on all systems, however not all platforms model it and include
it in e.g. the device tree, so add clock handling but make it
optional so we bail out safely if it is e.g. always on.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agoMerge branch 'ib-ingenic' of ../linux-pinctrl into devel
Linus Walleij [Wed, 29 Aug 2018 12:10:57 +0000 (14:10 +0200)]
Merge branch 'ib-ingenic' of ../linux-pinctrl into devel

6 years agogpio: Convert to using %pOFn instead of device_node.name
Rob Herring [Tue, 28 Aug 2018 01:52:19 +0000 (20:52 -0500)]
gpio: Convert to using %pOFn instead of device_node.name

In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: pxa: handle corner case of unprobed device
Robert Jarzmik [Sat, 25 Aug 2018 08:44:17 +0000 (10:44 +0200)]
gpio: pxa: handle corner case of unprobed device

In the corner case where the gpio driver probe fails, for whatever
reason, the suspend and resume handlers will still be called as they
have to be registered as syscore operations. This applies as well when
no probe was called while the driver has been built in the kernel.

Nicolas tracked this in :
https://bugzilla.kernel.org/show_bug.cgi?id=200905

Therefore, add a failsafe in these function, and test if a proper probe
succeeded and the driver is functional.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reported-by: Nicolas Chauvet <kwizart@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agodt-bindings: gpio: rcar: Add r8a774a1 (RZ/G2M) support
Fabrizio Castro [Tue, 14 Aug 2018 12:32:37 +0000 (13:32 +0100)]
dt-bindings: gpio: rcar: Add r8a774a1 (RZ/G2M) support

Document Renesas' RZ/G2M (R8A774A1) GPIO blocks compatibility within the
relevant dt-bindings.

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Include the right header
Linus Walleij [Wed, 29 Aug 2018 11:39:54 +0000 (13:39 +0200)]
pinctrl: ingenic: Include the right header

This is a GPIO driver so only include <linux/gpio/driver.h>

Cc: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ingenic: Remove driver
Paul Cercueil [Tue, 21 Aug 2018 16:42:36 +0000 (18:42 +0200)]
gpio: ingenic: Remove driver

The pinctrl-ingenic driver is now handling the GPIO chips directly.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Drop dependency on MACH_INGENIC
Paul Cercueil [Tue, 21 Aug 2018 16:42:35 +0000 (18:42 +0200)]
pinctrl: ingenic: Drop dependency on MACH_INGENIC

Depending on MACH_INGENIC prevent us from creating a generic kernel that
works on more than one MIPS board. Instead, we just depend on MIPS being
set.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Add support for the JZ4725B
Paul Cercueil [Tue, 21 Aug 2018 16:42:34 +0000 (18:42 +0200)]
pinctrl: ingenic: Add support for the JZ4725B

Add support for the JZ4725B and compatible SoCs from Ingenic.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Implement .get_direction for GPIO chips
Paul Cercueil [Tue, 21 Aug 2018 16:42:33 +0000 (18:42 +0200)]
pinctrl: ingenic: Implement .get_direction for GPIO chips

This allows to read from debugfs whether the GPIOs requested are set as
input or output.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Merge GPIO functionality
Paul Cercueil [Tue, 21 Aug 2018 16:42:32 +0000 (18:42 +0200)]
pinctrl: ingenic: Merge GPIO functionality

Merge the code of the gpio-ingenic driver into the pinctrl-ingenic
driver.

The reason behind this, is that the same hardware block handles both pin
config / muxing and GPIO.

ingenic_gpio_probe() have been marked as __init, but for the most part,
the code is the exact same as what it was in the gpio-ingenic driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Mark probe function as __init
Paul Cercueil [Tue, 21 Aug 2018 16:42:31 +0000 (18:42 +0200)]
pinctrl: ingenic: Mark probe function as __init

By using platform_driver_probe() instead of platform_driver_register(),
we can mark the ingenic_pinctrl_probe() function as __init.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agopinctrl: ingenic: Probe driver at subsys_initcall
Paul Cercueil [Tue, 21 Aug 2018 16:42:30 +0000 (18:42 +0200)]
pinctrl: ingenic: Probe driver at subsys_initcall

Using postcore_initcall() makes the driver try to initialize way too
early.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agodt-bindings: pinctrl: Update pinctrl-ingenic for JZ4725B and GPIO merge
Paul Cercueil [Tue, 21 Aug 2018 16:42:29 +0000 (18:42 +0200)]
dt-bindings: pinctrl: Update pinctrl-ingenic for JZ4725B and GPIO merge

The pinctrl-ingenic driver now supports the JZ4725B SoC.

Furthermore, the gpio-ingenic driver was dropped and the pinctrl-ingenic
driver is now responsible for providing the GPIO functionality.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agodrivers: gpio: Update MODULE AUTHOR email address
Michael Hennerich [Tue, 14 Aug 2018 11:29:18 +0000 (13:29 +0200)]
drivers: gpio: Update MODULE AUTHOR email address

no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agodt-bindings: gpio: rcar: Add gpio-reserved-ranges support
Biju Das [Tue, 7 Aug 2018 07:57:03 +0000 (08:57 +0100)]
dt-bindings: gpio: rcar: Add gpio-reserved-ranges support

Update the DT bindings documentation with the optional gpio-reserved-ranges
properties.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: rcar: Add GPIO hole support
Biju Das [Tue, 7 Aug 2018 07:57:02 +0000 (08:57 +0100)]
gpio: rcar: Add GPIO hole support

GPIO hole is present in RZ/G1C SoC. Valid GPIO pins on bank3 are in the
range GP3_0 to GP3_16 and GP3_27 to GP3_29. The GPIO pins between GP3_17
to GP3_26 are unused. Add support for handling unused GPIO's.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Switch A and B to use GPIOLIB_IRQCHIP
Linus Walleij [Wed, 22 Aug 2018 20:41:11 +0000 (22:41 +0200)]
gpio: ep93xx: Switch A and B to use GPIOLIB_IRQCHIP

We can quite easily switch banks/ports A and B to use
GPIOLIB_IRQCHIP which is code that will be more careful
about handling interrupt descriptors and use a proper
irqdomain for translating the IRQs. This cuts down some
code in favor of using the implementation inside
gpiolib.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Cut gpio_to_irq() usage
Linus Walleij [Wed, 22 Aug 2018 20:41:10 +0000 (22:41 +0200)]
gpio: ep93xx: Cut gpio_to_irq() usage

This removes the callback into the gpiolib creating a
circular call to convert between GPIO numbers and IRQs
and pushes the whole business into the driver, just
using an array of IRQ bases for the three IRQ capable
ports.

This way we get rid of including <linux/gpio.h> that
no driver should include.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Use for_each_set_bit() in IRQ handler
Linus Walleij [Wed, 22 Aug 2018 20:41:09 +0000 (22:41 +0200)]
gpio: ep93xx: Use for_each_set_bit() in IRQ handler

This simplifies and standardizes the AB IRQ handler by using
the for_each_set_bit() library function.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Use the hwirq and port
Linus Walleij [Wed, 22 Aug 2018 20:41:08 +0000 (22:41 +0200)]
gpio: ep93xx: Use the hwirq and port

In the IRQ-related functions, switch to using the hwirq
and port number found from the current struct gpio_chip *

As the lower 3 bits of the IRQ number is identical to the
lower 3 bits of the GPIO number we can cut some corners.

Call directly into the gpiochip to set up the direction
and read the input instead of using the consumer API.

This enabled us to cut the confusing irq_to_gpio() macro
that is a remnant of the old generic GPIO API as well.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Do not pingpong irq numbers
Linus Walleij [Wed, 22 Aug 2018 20:41:07 +0000 (22:41 +0200)]
gpio: ep93xx: Do not pingpong irq numbers

For setting debounce config we want to write an offset in
a per-gpiochip register, and we know which gpiochip we are
on. Instead of a roundtrip over the IRQ number, figure out
what port we are on for this GPIO chip, then index to the
right register and write the value.

This adds the ep93xx_gpio_port() that finds the port index
from a struct gpio_chip * that we can later exploit to
simplify more code.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Properly call the chained IRQ handler
Linus Walleij [Wed, 22 Aug 2018 20:41:06 +0000 (22:41 +0200)]
gpio: ep93xx: Properly call the chained IRQ handler

The chained irq handler should call chained_irq_enter()
and chained_irq_exit() before/after handling the chained
IRQ.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Rename has_debounce to has_irq
Linus Walleij [Wed, 22 Aug 2018 20:41:05 +0000 (22:41 +0200)]
gpio: ep93xx: Rename has_debounce to has_irq

This is closer to what the variable (per bank) actually
means. We have the .gpio_to_irq() hook registered only
when this is true.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Pass around struct gpio_chip
Linus Walleij [Wed, 22 Aug 2018 20:41:04 +0000 (22:41 +0200)]
gpio: ep93xx: Pass around struct gpio_chip

Instead of using a global variable, pass around the
struct gpio_chip * pointer and dereference to the state
container struct ep93xx_gpio as needed, like all other
drivers do.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
6 years agogpio: ep93xx: Switch to SPDX license tag
Linus Walleij [Wed, 22 Aug 2018 20:41:03 +0000 (22:41 +0200)]
gpio: ep93xx: Switch to SPDX license tag

The subject says it all. Cut down on boilerplate.

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>