mbox series

[v2,00/30] Rework Nomadik GPIO to add Mobileye EyeQ5 support

Message ID 20240228-mbly-gpio-v2-0-3ba757474006@bootlin.com
Headers show
Series Rework Nomadik GPIO to add Mobileye EyeQ5 support | expand

Message

Théo Lebrun Feb. 28, 2024, 11:27 a.m. UTC
Hi,

This patch series reworks the Nomadik GPIO driver to bring it up to date
to current kernel standards. We then add Mobileye EyeQ5 support that
uses the same IP block but with limited functionality. We also add
features required by our newly supported platform:

 - Dynamic GPIO ID allocation;
 - Make clock optional;
 - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
 - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
 - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).

This GPIO platform driver was previously declared & registered inside
drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
Now that gpio-nomadik is used for another platform, we loosen the
relationship. The behavior should not change on already supported
hardware but I do not have Nomadik hardware to test for that.

We have some dependencies. Those are:
- The base platform support series from Grégory [0], present in
  mips-next. It in turns depends on [1], also in mips-next. This
  relates to the last four patches (27 thru 30), ie defconfig and
  devicetree.
- The OLB syscon support series [2]. It provides reset and pinctrl nodes
  inside the devicetree. This relates to the last two patches (29 and
  30), ie resets and gpio-ranges DT props. GPIO works fine if patches
  29 and 30 are dropped and bootloader deasserts the reset (it does).

This has been tested on the EyeQ5 hardware, with the two parent series
applied. It also works fine without the OLB syscon series when our last
two patches are removed. It has been built on both Arm defconfigs that
rely on pinctrl-nomadik: nhk8815_defconfig and u8500_defconfig. I don't
have any Nomadik hardware to test though.

Have a nice day,
Théo

[0]: https://lore.kernel.org/lkml/20240216174227.409400-1-gregory.clement@bootlin.com/
[1]: https://lore.kernel.org/linux-mips/20240209-regname-v1-0-2125efa016ef@flygoat.com/
[2]: https://lore.kernel.org/lkml/20240227-mbly-clk-v8-0-c57fbda7664a@bootlin.com/

To: Linus Walleij <linus.walleij@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
To: Rob Herring <robh+dt@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-gpio@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mips@vger.kernel.org
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Changes in v2:
- dt-bindings: add description to gpio-bank.
- dt-bindings: fix disabling of st,supports-sleepmode prop with
  st,supports-sleepmode compatible.
- gpio: move "fix offset bug in nmk_pmx_set()" to the start of the
  series and add a Fixes trailer. The patch changed because of that.
- pinctrl: allow building PINCTRL_NOMADIK and co with COMPILE_TEST.
- gpio: in "support shared GPIO IRQs" remove fake raw lock and use
  generic_handle_domain_irq_safe() helper.
- gpio: remove OF API calls.
    of_property_read_*()     => device_property_read_*()
    of_find_device_by_node() => bus_find_device_by_of_node()
- gpio: use device_is_compatible() rather than match data to detect for
  Mobileye SoC. If GPIO device is populated by pinctrl match data is
  unavailable.
- gpio: rename quirk_mbly field to is_mobileye_soc.
- gpio: add comment about unbalanced reset_control_deassert() and
  disable bind sysfs attributes.
- gpio: use devm_platform_ioremap_resource() helper.
- gpio: use devres version of clk_get*() in case of probe failure.
- gpio: add missing <linux/slab.h> include.
- Documentation: gpio: replace outdated comment of using a fake spin
  lock and mention the generic_handle_irq_safe() helper.
- gpio: in "follow whitespace kernel coding conventions", add missing
  newline before headers.
- Take 6 Reviewed-By Linus, 1 Reviewed-by and 1 Acked-by Krzysztof.
- Link to v1: https://lore.kernel.org/r/20240214-mbly-gpio-v1-0-f88c0ccf372b@bootlin.com

---
Théo Lebrun (30):
      dt-bindings: gpio: nomadik: convert into yaml format
      dt-bindings: gpio: nomadik: add optional ngpios property
      dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible
      dt-bindings: gpio: nomadik: add optional reset property
      gpio: nomadik: fix offset bug in nmk_pmx_set()
      gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/
      pinctrl: nomadik: Kconfig: allow building with COMPILE_TEST
      pinctrl: nomadik: fix build warning (-Wformat)
      pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast)
      pinctrl: nomadik: minimise indentation in probe
      pinctrl: nomadik: follow type-system kernel coding conventions
      pinctrl: nomadik: follow whitespace kernel coding conventions
      pinctrl: nomadik: follow conditional kernel coding conventions
      gpio: nomadik: add #include <linux/slab.h>
      gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node()
      gpio: nomadik: replace of_property_read_*() by device_property_read_*()
      gpio: nomadik: use devm_platform_ioremap_resource() helper
      gpio: nomadik: use devres version of clk_get*()
      gpio: nomadik: request dynamic ID allocation
      gpio: nomadik: make clock optional
      gpio: nomadik: change driver name from gpio to gpio-nomadik
      gpio: nomadik: support shared GPIO IRQs
      gpio: nomadik: handle variadic GPIO count
      gpio: nomadik: support mobileye,eyeq5-gpio
      gpio: nomadik: grab optional reset control and deassert it at probe
      Documentation: gpio: mention generic_handle_irq_safe()
      MIPS: eyeq5_defconfig: enable GPIO by default
      MIPS: mobileye: eyeq5: add two GPIO bank nodes
      MIPS: mobileye: eyeq5: add resets to GPIO banks
      MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges

 .../devicetree/bindings/gpio/gpio-nmk.txt          |  31 -
 .../devicetree/bindings/gpio/st,nomadik-gpio.yaml  |  95 +++
 Documentation/driver-api/gpio/driver.rst           |  11 +-
 MAINTAINERS                                        |   2 +
 arch/mips/boot/dts/mobileye/eyeq5.dtsi             |  30 +
 arch/mips/configs/eyeq5_defconfig                  |   2 +
 drivers/gpio/Kconfig                               |  13 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-nomadik.c                        | 722 ++++++++++++++++
 drivers/pinctrl/nomadik/Kconfig                    |   7 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c   |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-stn8815.c  |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          | 939 +++------------------
 .../linux/gpio/gpio-nomadik.h                      | 123 ++-
 14 files changed, 1117 insertions(+), 865 deletions(-)
---
base-commit: 3ebad8a9638d4c667e8925968806a82e1b9025ea
change-id: 20231023-mbly-gpio-a30571ec3283

Best regards,

Comments

Linus Walleij Feb. 29, 2024, 9:22 a.m. UTC | #1
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Previously, the statement looked like:
>
>     slpm[x] &= ~BIT(g->grp.pins[i]);
>
> Where:
>  - slpm is a unsigned int pointer;
>  - g->grp.pins[i] is a pin number. It can grow to more than 32.
>
> The expected shift amount is a pin bank offset.
>
> This bug does not occur on every group or pin: the altsetting must be
> NMK_GPIO_ALT_C and the pin must be 32 or above. It might have occured.
> For example, in pinctrl-nomadik-db8500.c, pin group i2c3_c_2 has the
> right altsetting and pins 229 and 230.
>
> Fixes: dbfe8ca259e1 ("pinctrl/nomadik: implement pin multiplexing")
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Since the bug is not affecting the deployed UX500 systems I have merged
it with the rest as non-urgent fix, but it can be backported as a standalone
patch if the stable maintainers want it after the release of v6.9-rc1.

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:24 a.m. UTC | #2
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied.

It's good to get this move done, then we can iron out minor issues to
the GPIO part in the GPIO tree as we move along.

I will send the patches to Bartosz with an optional pull request for
this immutable branch.

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:24 a.m. UTC | #3
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> PINCTRL_NOMADIK, PINCTRL_STN8815 and PINCTRL_DB8500 depend on ARCH_U8500
> or ARCH_NOMADIK. Add COMPILE_TEST as an option to allow test building
> the driver.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied to my immutable branch.

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:25 a.m. UTC | #4
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Fix compiler warning found in the pinctrl-nomadik platform driver. GCC
> message is as such:
>
> drivers/pinctrl/nomadik/pinctrl-nomadik.c:855:21: warning:
> format ‘%u’ expects argument of type ‘unsigned int’, but argument 5
> has type ‘size_t {aka const long unsigned int}’ [-Wformat=]
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:25 a.m. UTC | #5
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Fix compiler warning found in the pinctrl-nomadik platform driver. GCC
> message is as such:
>
> drivers/pinctrl/nomadik/pinctrl-nomadik.c:1169:12: warning: cast from
> pointer to integer of different size [-Wpointer-to-int-cast]
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:26 a.m. UTC | #6
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> nmk_pinctrl_probe() iterates over each GPIO block. Use an early
> conditional continue to skip to the next iteration rather than indent
> all the loop code block.
>
> Do not change code logic. The block is changed from:
>
>         for (i = 0; i < NMK_MAX_BANKS; i++) {
>                 x = of_parse_phandle(...);
>                 if (x) {
>                         ... do work ...
>                 }
>         }
>
> To:
>
>         for (i = 0; i < NMK_MAX_BANKS; i++) {
>                 x = of_parse_phandle(...);
>                 if (!x)
>                         continue;
>
>                 ... do work ...
>         }
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:27 a.m. UTC | #7
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Fix strict checkpatch warnings relative to types. Warning types
> addressed:
>
>    WARNING: do not add new typedefs
>    WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
>    WARNING: static const char * array should probably be static const
>             char * const
>
> Total messages before: 1 errors, 40 warnings, 39 checks.
> Total messages after:  1 errors,  2 warnings, 38 checks.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:28 a.m. UTC | #8
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Fix strict checkpatch warnings relative to whitespace. Message types
> addressed:
>
>    ERROR: space required before the open parenthesis '('
>    WARNING: quoted string split across lines
>    CHECK: Alignment should match open parenthesis
>    CHECK: Please don't use multiple blank lines
>    CHECK: line length of 103 exceeds 100 columns
>    CHECK: spaces preferred around that '+' (ctx:VxV)
>
> Before: 1 errors, 2 warnings, 38 checks.
> After:  0 errors, 1 warnings, 16 checks.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:28 a.m. UTC | #9
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Fix strict checkpatch warnings relative to if-else blocks and bool
> expressions. Message types addressed:
>
>    CHECK: Comparison to NULL could be written "!nmk_cfg_params[index].choice"
>    CHECK: Unbalanced braces around else statement
>    CHECK: Using comparison to false is error prone
>    CHECK: Using comparison to true is error prone
>    CHECK: braces {} should be used on all arms of this statement
>
> Before: 0 errors, 1 warnings, 16 checks.
> After:  0 errors, 1 warnings,  7 checks.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:29 a.m. UTC | #10
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Add linux/slab.h header include for GFP flags.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:30 a.m. UTC | #11
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:30 a.m. UTC | #12
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:31 a.m. UTC | #13
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:31 a.m. UTC | #14
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:33 a.m. UTC | #15
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:33 a.m. UTC | #16
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:35 a.m. UTC | #17
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> 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>
(...)
> -               .name = "gpio",
> +               .name = "nomadik-gpio",

Patch applied after amending $SUBJECT to be nomadik-gpio rather than
gpio-nomadik.

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:36 a.m. UTC | #18
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:36 a.m. UTC | #19
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:38 a.m. UTC | #20
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Just as I wanted it.

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:38 a.m. UTC | #21
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

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

Patch applied!

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:40 a.m. UTC | #22
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> generic_handle_irq() must be called from a no-IRQ context. Documentation
> advices on using a fake raw lock to call generic_handle_irq() from any
> context.
>
> Since 509853f9e1e7 ("genirq: Provide generic_handle_irq_safe()"), a
> better alternative is available.
>
> To: Stephen Warren <swarren@wwwdotorg.org>
> To: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
I leave this one off from my branch, Bartosz can apply it separately.

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:40 a.m. UTC | #23
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Add both CONFIG_GPIOLIB=y and CONFIG_GPIO_NOMADIK=y to our platform
> defconfig. Default config is CONFIG_GPIOLIB=n.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:41 a.m. UTC | #24
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> This platform uses the same GPIO controller as Nomadik. It however has
> its own pinconf & pinmux controller. EyeQ5 is the first platform to use
> gpio-nomadik independently from pinctrl-nomadik.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:42 a.m. UTC | #25
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> The two GPIO banks share a single reset line.
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:42 a.m. UTC | #26
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> Create a mapping between the GPIO controllers and the pin controllers.
> GPIO is handled in a one-instance-per-bank manner while pinctrl is done
> with a single instance for both pin banks.
>
> See gpio-ranges documentation:
> Documentation/devicetree/bindings/gpio/gpio.txt
>
> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij Feb. 29, 2024, 9:44 a.m. UTC | #27
On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:

> This patch series reworks the Nomadik GPIO driver to bring it up to date
> to current kernel standards. We then add Mobileye EyeQ5 support that
> uses the same IP block but with limited functionality. We also add
> features required by our newly supported platform:
>
>  - Dynamic GPIO ID allocation;
>  - Make clock optional;
>  - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
>  - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
>  - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).
>
> This GPIO platform driver was previously declared & registered inside
> drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
> pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
> Now that gpio-nomadik is used for another platform, we loosen the
> relationship. The behavior should not change on already supported
> hardware but I do not have Nomadik hardware to test for that.

I have queued the relevant patches to an immutable branch in the
pinctrl tree for testing and I can also pick up some ACKs if they arrive.

When I'm confident in the branch, I will send an optional pull request
to Bartosz for it!

Yours,
Linus Walleij
Théo Lebrun Feb. 29, 2024, 9:56 a.m. UTC | #28
Hello,

On Thu Feb 29, 2024 at 10:44 AM CET, Linus Walleij wrote:
> On Wed, Feb 28, 2024 at 12:28 PM Théo Lebrun <theo.lebrun@bootlin.com> wrote:
>
> > This patch series reworks the Nomadik GPIO driver to bring it up to date
> > to current kernel standards. We then add Mobileye EyeQ5 support that
> > uses the same IP block but with limited functionality. We also add
> > features required by our newly supported platform:
> >
> >  - Dynamic GPIO ID allocation;
> >  - Make clock optional;
> >  - Shared IRQ (usecase: EyeQ5 has two banks using the same IRQ);
> >  - Handle variadic GPIO counts (usecase: EyeQ5 has <32 GPIOs per bank);
> >  - Grab optional reset at probe (usecase: EyeQ5 has a shared GPIO reset).
> >
> > This GPIO platform driver was previously declared & registered inside
> > drivers/pinctrl/nomadik/pinctrl-nomadik.c, side-by-side with the
> > pinctrl driver. Both are tightly integrated, mostly for muxing reasons.
> > Now that gpio-nomadik is used for another platform, we loosen the
> > relationship. The behavior should not change on already supported
> > hardware but I do not have Nomadik hardware to test for that.
>
> I have queued the relevant patches to an immutable branch in the
> pinctrl tree for testing and I can also pick up some ACKs if they arrive.
>
> When I'm confident in the branch, I will send an optional pull request
> to Bartosz for it!

That is all great news, thanks Linus! I'm staying available if you
encounter anything that needs action.

Have a nice day,

--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com