History log of /linux-master/drivers/gpio/gpio-nomadik.c
Revision Date Author Comments
# fa63587f 11-Mar-2024 Max Kellermann <max.kellermann@ionos.com>

drivers/gpio/nomadik: move dummy nmk_gpio_dbg_show_one() to header

When `CONFIG_DEBUG_FS` is disabled, nmk_gpio_dbg_show_one() is an
empty dummy function; this however triggers a `-Wmissing-prototypes`
warning and later a linker error because the function is also used by
drivers/pinctrl/nomadik/pinctrl-nomadik.c, therefore it needs to be
non-static.

To allow both sources to access this dummy function, this patch moves
it to the header, adding the `#ifdef CONFIG_DEBUG_FS` there as well.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Link: https://lore.kernel.org/r/20240311133223.3429428-1-max.kellermann@ionos.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 289b950b 11-Mar-2024 Dan Carpenter <dan.carpenter@linaro.org>

gpio: nomadik: remove BUG_ON() in nmk_gpio_populate_chip()

Using BUG_ON() is discouraged and also the check wasn't done early
enough to prevent an out of bounds access. Check earlier and return
an error instead of calling BUG().

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/ae643df0-3a3e-4270-8dbf-be390ee4b478@moroto.mountain
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 5545d501 05-Mar-2024 Linus Walleij <linus.walleij@linaro.org>

gpio: nomadik: Back out some managed resources

Several commits introduce managed resources (devm_*) into the
nmk_gpio_populate_chip() function.

This isn't always working because when called from the Nomadik pin
control driver we just want to populate some states for the device as
the same states are used by the pin control driver.

Some managed resources such as devm_kzalloc() etc will work, as the
passed in platform device will be used for lifecycle management,
but in some cases where we used the looked-up platform device
for the GPIO block, this will cause problems for the combined
pin control and GPIO driver, because it adds managed resources
to the GPIO device before it is probed, which is something that
the device core will not accept, and all of the GPIO blocks will
refuse to probe:

platform 8012e000.gpio: Resources present before probing
platform 8012e080.gpio: Resources present before probing
(...)

Fix this by not tying any managed resources to the looked-up
gpio_pdev/gpio_dev device, let's just live with the fact that
these need imperative resource management for now.

Drop in some notes and use a local *dev variable to clarify the
code.

Cc: Théo Lebrun <theo.lebrun@bootlin.com>
Fixes: 12410e95903c ("gpio: nomadik: use devm_platform_ioremap_resource() helper")
Link: https://lore.kernel.org/r/20240305-fix-nomadik-gpio-v2-1-e5d1fbdc3f5c@linaro.org
[Fixed some last minut print formatting]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# caddc92c 02-Mar-2024 Andy Shevchenko <andy.shevchenko@gmail.com>

gpio: nomadik: Finish conversion to use firmware node APIs

Previously driver got a few updates in order to replace OF APIs by
respective firmware node, however it was not finished to the logical
end, e.g., some APIs that has been used are still require OF node
to be passed. Finish that job by converting leftovers to use firmware
node APIs.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240302173401.217830-1-andy.shevchenko@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 6ad679cf 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: grab optional reset control and deassert it at probe

Fetch a reference to the optional shared reset control and deassert it
if it exists.

Optional because not all platforms that use this driver have a reset
attached to the reset block. Shared because some platforms that use the
reset (at least Mobileye EyeQ5) share the reset across banks.

Do not keep a reference to the reset control as it is not needed
afterwards; the driver does not handle suspend, does not use runtime
PM, does not register a remove callback and does not support unbinding
from sysfs (made explicit with suppress_bind_attrs).

The operation is done in nmk_gpio_populate_chip(). This function is
called by either gpio-nomadik or pinctrl-nomadik, whoever comes first.
This is here for historic reasons and could probably be removed now; it
seems gpio-ranges enforces the ordering to be pinctrl-first. It is not
the topic of the present patch however.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 3c30cc26 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: support mobileye,eyeq5-gpio

We create a custom compatible for the STA2X11 IP block as integrated
into the Mobileye EyeQ5 platform. Its wake and alternate functions have
been disabled, we want to avoid touching those registers.

We both do: (1) early return in functions that do not support the
platform, but with warnings, and (2) avoid calling those functions in
the first place.

We ensure that pinctrl-nomadik is not used with this STA2X11 variant.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-24-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 50bc2a49 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: handle variadic GPIO count

Read the "ngpios" property to determine the number of GPIOs for a bank.
If not available, fallback to NMK_GPIO_PER_CHIP ie 32 ie the current
behavior.

The IP block always supports 32 GPIOs, but platforms can expose a lesser
amount. The Mobileye EyeQ5 is in this case; one bank is 29 GPIOs and
the other is 23.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-23-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 8d74c3dc 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: support shared GPIO IRQs

Support a single IRQs used by multiple GPIO banks. Change the IRQ
handler type from a chained handler (as used by gpiolib
for ->parent_handler) to a threaded IRQ.

Use the generic_handle_domain_irq_safe() helper. The non-safe version
must be called in a no-IRQ context.

The Mobileye EyeQ5 platform uses this GPIO controller and share an IRQ
for its two banks.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-22-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 98c031fa 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: change driver name from gpio to nomadik-gpio

This GPIO driver is historically related to the Nomadik platform. It
however can be used by others as it implements the ST STA2X11 IP block.
Pick a less ambiguous name for it.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-21-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# eac86aae 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: make clock optional

Not all platforms using this platform driver expose a clock for this
GPIO controller. Turn devm_clk_get() into devm_clk_get_optional() to
avoid failing when no clocks are provided.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-20-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 75d270fd 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: request dynamic ID allocation

Move away from statically allocated GPIO IDs. Switch to dynamic ID
allocation. Static IDs are deprecated because they cause issues when
multiple GPIO controllers are to be found on the same platform.

Add a bit of complexity to do pin number -> GPIO chip + offset.
Previously, bank number and offsets were retrieved using division and
remainder (bank size being constant 32). Now, to get the pin number
matching a bank base, we must know the sum of ngpios of previous banks.
This is done in find_nmk_gpio_from_pin() which also exposes the offset
inside the bank.

Also remove the assumption that bank sizes are constant. Instead of
using NMK_GPIO_PER_CHIP as bank size, use nmk_gpio_chips[i]->ngpio.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-19-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 2f8875dd 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: use devres version of clk_get*()

Replace call to clk_get() by call to devm_clk_get(). Allow automatic
cleanup of the clock in case of probe error.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-18-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 12410e95 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: use devm_platform_ioremap_resource() helper

Replace calls to platform_get_resource() then devm_ioremap_resource() by
a single call to devm_platform_ioremap_resource().

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-17-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# be0552e1 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: replace of_property_read_*() by device_property_read_*()

Avoid OF APIs in the GPIO subsystem. Here, replace
of_property_read_{u32,bool}() call by device_property_read_{u32,bool}().

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-16-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 0b95fcd1 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node()

Avoid OF APIs in the GPIO subsystem. Here, replace
of_find_device_by_node() call by bus_find_device_by_of_node().

The new helper returns a struct device pointer. Store it in a new local
variable and use it down the road.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-15-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 9b82653d 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: add #include <linux/slab.h>

Add linux/slab.h header include for GFP flags.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-14-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 966942ae 27-Feb-2024 Théo Lebrun <theo.lebrun@bootlin.com>

gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/

Previously, drivers/pinctrl/nomadik/pinctrl-nomadik.c registered two
platform drivers: pinctrl & GPIO. Move the GPIO aspect to the
drivers/gpio/ folder, as would be expected.

Both drivers are intertwined for a reason; pinctrl requires access to
GPIO registers for pinmuxing, pull-disable, disabling interrupts while
setting the muxing and wakeup control. Information sharing is done
through a shared array containing GPIO chips and a few helper
functions. That shared array is not touched from gpio-nomadik when
CONFIG_PINCTRL_NOMADIK is not defined.

Make no change to the code that moved into gpio-nomadik; there should be
no behavior change following. A few functions are shared and header
comments are added. Checkpatch warnings are addressed. NUM_BANKS is
renamed to NMK_MAX_BANKS.

It is supported to compile gpio-nomadik without pinctrl-nomadik. The
opposite is not true.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-6-3ba757474006@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>