Skip to contentSkip to conversation

Rework Nomadik GPIO to add Mobileye EyeQ5 support

PATCH In review Théo Lebrun 3 participants 65 messages Feb 28, 2024 – Feb 29, 2024

Subsystems (7)
lore
Share & tools
lore

Théo Lebrun

author maintainer
#0 lore raw

v2 cover Rework Nomadik GPIO to add Mobileye EyeQ5 support

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/[email protected]/
[1]: https://lore.kernel.org/linux-mips/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/

To: Linus Walleij <[email protected]>
To: Bartosz Golaszewski <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Philipp Zabel <[email protected]>
To: Thomas Bogendoerfer <[email protected]>

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/[email protected]

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

Signature · 1 line
Théo Lebrun <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/30 dt-bindings: gpio: nomadik: convert into yaml format

Create gpio/st,nomadik-gpio.yaml json-schema dt-bindings file as a direct translation from gpio-nmk.txt. Remove the txt file.

Add clocks and gpio-ranges properties which were missing and are being used in Nomadik devicetrees.

---
 .../devicetree/bindings/gpio/gpio-nmk.txt          | 31 ---------
 .../devicetree/bindings/gpio/st,nomadik-gpio.yaml  | 76 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 3 files changed, 77 insertions(+), 31 deletions(-)
Documentation/devicetree/bindings/gpio/gpio-nmk.txt deleted +0 -31
deleted file mode 100644
index 8315ac7780ef..000000000000
@@ -1,31 +0,0 @@
-Nomadik GPIO controller
-
-Required properties:
-- compatible            : Should be "st,nomadik-gpio".
-- reg                   : Physical base address and length of the controller's registers.
-- interrupts            : The interrupt outputs from the controller.
-- #gpio-cells           : Should be two:
-                            The first cell is the pin number.
-                            The second cell is used to specify optional parameters:
-                              - bits[3:0] trigger type and level flags:
-                                  1 = low-to-high edge triggered.
-                                  2 = high-to-low edge triggered.
-                                  4 = active high level-sensitive.
-                                  8 = active low level-sensitive.
-- gpio-controller       : Marks the device node as a GPIO controller.
-- interrupt-controller  : Marks the device node as an interrupt controller.
-- gpio-bank             : Specifies which bank a controller owns.
-- st,supports-sleepmode : Specifies whether controller can sleep or not
-
-Example:
-
-                gpio1: gpio@8012e080 {
-                        compatible = "st,nomadik-gpio";
-                        reg =  <0x8012e080 0x80>;
-                        interrupts = <0 120 0x4>;
-                        #gpio-cells = <2>;
-                        gpio-controller;
-                        interrupt-controller;
-                        st,supports-sleepmode;
-                        gpio-bank = <1>;
-                };
Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml new file +76 -0

76 lines not on this page · raw message

MAINTAINERS +1 -0
index 73bd2851eb4c..854b41ee4dcc 100644
@@ -2465,6 +2465,7 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git
 F:	Documentation/devicetree/bindings/arm/ste-*
 F:	Documentation/devicetree/bindings/arm/ux500.yaml
 F:	Documentation/devicetree/bindings/arm/ux500/
+F:	Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml
 F:	Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml
 F:	arch/arm/boot/dts/st/ste-*
 F:	arch/arm/mach-nomadik/
Signature · 1 line
2.44.0
Reviewed-by on v2 1/30
#2 lore raw

Re: [PATCH v2 01/30] dt-bindings: gpio: nomadik: convert into yaml format

Quoted 1 line

+ gpio1: gpio@8012e080 {

The gpio1 label is not used and can be removed.

Otherwise,

Cheers,
Conor.

Quoted 9 lines
Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml new file +9 -0
+        compatible = "st,nomadik-gpio";
+        reg =  <0x8012e080 0x80>;
+        interrupts = <0 120 0x4>;
+        #gpio-cells = <2>;
+        gpio-controller;
+        interrupt-controller;
+        st,supports-sleepmode;
+        gpio-bank = <1>;
+    };
#3 lore raw

Re: [PATCH v2 01/30] dt-bindings: gpio: nomadik: convert into yaml format

In reply to Théo Lebrun
Quoted 8 lines · Théo Lebrun

Create gpio/st,nomadik-gpio.yaml json-schema dt-bindings file as a direct translation from gpio-nmk.txt. Remove the txt file.

Add clocks and gpio-ranges properties which were missing and are being used in Nomadik devicetrees.

I will be queueing this through the pinctrl tree so I applied this patch to an immutable branch, and I dropped the unused label as pointed out by Conor.

Yours,
Linus Walleij

author maintainer
#4 lore raw

PATCH v2 2/30 dt-bindings: gpio: nomadik: add optional ngpios property

In reply to Théo Lebrun

This GPIO controller can support a lesser number of GPIOs than 32. Express that in devicetree using an optional, generic property.

---
 Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml +4 -0
index 69774f36e03f..4080e94702d5 100644
@@ -51,6 +51,10 @@ properties:
   gpio-ranges:
     maxItems: 1
 
+  ngpios:
+    minimum: 0
+    maximum: 32
+
 required:
   - compatible
   - reg
Signature · 1 line
2.44.0
author maintainer
#6 lore raw

PATCH v2 3/30 dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible

In reply to Théo Lebrun

This GPIO controller is used on the Mobileye EyeQ5 SoC. Add its compatible to the dt-bindings. One difference is that the block as integrated on EyeQ5 does not support sleep-mode.

---
 .../devicetree/bindings/gpio/st,nomadik-gpio.yaml          | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml +13 -1
index 4080e94702d5..8e7f21988e9e 100644
@@ -19,7 +19,9 @@ properties:
     pattern: "^gpio@[0-9a-f]+$"
 
   compatible:
-    const: st,nomadik-gpio
+    enum:
+      - st,nomadik-gpio
+      - mobileye,eyeq5-gpio
 
   reg:
     maxItems: 1
@@ -66,6 +68,16 @@ required:
 
 unevaluatedProperties: false
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mobileye,eyeq5-gpio
+    then:
+      properties:
+        st,supports-sleepmode: false
+
 examples:
   - |
     gpio1: gpio@8012e080 {
Signature · 1 line
2.44.0
Acked-by on v2 3/30
#7 lore raw

Re: [PATCH v2 03/30] dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible

Quoted 5 lines · Théo Lebrun

This GPIO controller is used on the Mobileye EyeQ5 SoC. Add its compatible to the dt-bindings. One difference is that the block as integrated on EyeQ5 does not support sleep-mode.

Cheers,
Conor.

#8 lore raw

Re: [PATCH v2 03/30] dt-bindings: gpio: nomadik: add mobileye,eyeq5-gpio compatible

In reply to Théo Lebrun
Quoted 5 lines · Théo Lebrun

This GPIO controller is used on the Mobileye EyeQ5 SoC. Add its compatible to the dt-bindings. One difference is that the block as integrated on EyeQ5 does not support sleep-mode.

Patch applied!

Yours,
Linus Walleij

author maintainer
#9 lore raw

PATCH v2 4/30 dt-bindings: gpio: nomadik: add optional reset property

In reply to Théo Lebrun

Add optional reset device-tree property to the Nomadik GPIO controller.

---
 Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml +3 -0
index 8e7f21988e9e..c624e20c3ed3 100644
@@ -57,6 +57,9 @@ properties:
     minimum: 0
     maximum: 32
 
+  resets:
+    maxItems: 1
+
 required:
   - compatible
   - reg
Signature · 1 line
2.44.0
author maintainer
#11 lore raw

PATCH v2 5/30 gpio: nomadik: fix offset bug in nmk_pmx_set()

In reply to Théo Lebrun

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")
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +4 -2
index 7911353ac97d..4f7c4af4f93c 100644
@@ -1579,8 +1579,10 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
 		 * Then mask the pins that need to be sleeping now when we're
 		 * switching to the ALT C function.
 		 */
-		for (i = 0; i < g->grp.npins; i++)
-			slpm[g->grp.pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(g->grp.pins[i]);
+		for (i = 0; i < g->grp.npins; i++) {
+			unsigned int bit = g->grp.pins[i] % NMK_GPIO_PER_CHIP;
+			slpm[g->grp.pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(bit);
+		}
 		nmk_gpio_glitch_slpm_init(slpm);
 	}
 
Signature · 1 line
2.44.0
#12 lore raw

Re: [PATCH v2 05/30] gpio: nomadik: fix offset bug in nmk_pmx_set()

Quoted 10 lines · Théo Lebrun

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.

Quoted 8 lines

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

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

author maintainer
#13 lore raw

PATCH v2 6/30 gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/

In reply to Théo Lebrun

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.

---
 MAINTAINERS                                        |   1 +
 drivers/gpio/Kconfig                               |  12 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-nomadik.c                        | 660 +++++++++++++++++++
 drivers/pinctrl/nomadik/Kconfig                    |   5 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c   |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik-stn8815.c  |   3 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          | 722 +--------------------
 .../linux/gpio/gpio-nomadik.h                      | 122 +++-
 9 files changed, 804 insertions(+), 725 deletions(-)
MAINTAINERS +1 -0
index 854b41ee4dcc..5a207d19d7c2 100644
@@ -2474,6 +2474,7 @@ F:	drivers/clk/clk-nomadik.c
 F:	drivers/clocksource/clksrc-dbx500-prcmu.c
 F:	drivers/dma/ste_dma40*
 F:	drivers/pmdomain/st/ste-ux500-pm-domain.c
+F:	drivers/gpio/gpio-nomadik.c
 F:	drivers/hwspinlock/u8500_hsem.c
 F:	drivers/i2c/busses/i2c-nomadik.c
 F:	drivers/iio/adc/ab8500-gpadc.c
drivers/gpio/Kconfig +12 -0
index 1301cec94f12..ff83371251c1 100644
@@ -478,6 +478,18 @@ config GPIO_MXS
 	select GPIO_GENERIC
 	select GENERIC_IRQ_CHIP
 
+config GPIO_NOMADIK
+	bool "Nomadik GPIO driver"
+	depends on ARCH_U8500 || ARCH_NOMADIK || COMPILE_TEST
+	select OF_GPIO
+	select GPIOLIB_IRQCHIP
+	help
+	  Say yes here to support the Nomadik SoC GPIO block.
+
+	  It handles up to 32 GPIOs per bank, that can all be interrupt sources.
+	  It is deeply interconnected with the associated pinctrl driver as GPIO
+	  registers handle muxing ("alternate functions") as well.
+
 config GPIO_NPCM_SGPIO
 	bool "Nuvoton SGPIO support"
 	depends on ARCH_NPCM || COMPILE_TEST
drivers/gpio/Makefile +1 -0
index 9e40af196aae..9fc2f5931b22 100644
@@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621)		+= gpio-mt7621.o
 obj-$(CONFIG_GPIO_MVEBU)		+= gpio-mvebu.o
 obj-$(CONFIG_GPIO_MXC)			+= gpio-mxc.o
 obj-$(CONFIG_GPIO_MXS)			+= gpio-mxs.o
+obj-$(CONFIG_GPIO_NOMADIK)		+= gpio-nomadik.o
 obj-$(CONFIG_GPIO_NPCM_SGPIO)		+= gpio-npcm-sgpio.o
 obj-$(CONFIG_GPIO_OCTEON)		+= gpio-octeon.o
 obj-$(CONFIG_GPIO_OMAP)			+= gpio-omap.o
drivers/gpio/gpio-nomadik.c new file +660 -0

660 lines not on this page · raw message

drivers/pinctrl/nomadik/Kconfig +2 -3
index 0fea167c283f..f47f0755a835 100644
@@ -22,11 +22,10 @@ if (ARCH_U8500 || ARCH_NOMADIK)
 
 config PINCTRL_NOMADIK
 	bool "Nomadik pin controller driver"
-	depends on OF && GPIOLIB
+	depends on OF
 	select PINMUX
 	select PINCONF
-	select OF_GPIO
-	select GPIOLIB_IRQCHIP
+	select GPIO_NOMADIK
 
 config PINCTRL_STN8815
 	bool "STN8815 pin controller driver"
drivers/pinctrl/nomadik/pinctrl-nomadik-db8500.c +2 -1
index 490e0959e8be..0b4a3dd9d8c7 100644
@@ -3,8 +3,9 @@
 #include <linux/types.h>
 
 #include <linux/pinctrl/pinctrl.h>
+#include <linux/gpio/driver.h>
 
-#include "pinctrl-nomadik.h"
+#include <linux/gpio/gpio-nomadik.h>
 
 /* All the pins that can be used for GPIO and some other functions */
 #define _GPIO(offset)		(offset)
drivers/pinctrl/nomadik/pinctrl-nomadik-stn8815.c +2 -1
index 1552222ac68e..c5a52fcaba30 100644
@@ -3,8 +3,9 @@
 #include <linux/types.h>
 
 #include <linux/pinctrl/pinctrl.h>
+#include <linux/gpio/driver.h>
 
-#include "pinctrl-nomadik.h"
+#include <linux/gpio/gpio-nomadik.h>
 
 /* All the pins that can be used for GPIO and some other functions */
 #define _GPIO(offset)		(offset)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +15 -707

816 lines not on this page · raw message

include/linux/gpio/gpio-nomadik.h renamed from drivers/pinctrl/nomadik/pinctrl-nomadik.h +109 -13

149 lines not on this page · raw message

Signature · 1 line
2.44.0
#14 lore raw

Re: [PATCH v2 06/30] gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/

Quoted 16 lines · Théo Lebrun

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.

Quoted 4 lines

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

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

author maintainer
#15 lore raw

PATCH v2 7/30 pinctrl: nomadik: Kconfig: allow building with COMPILE_TEST

In reply to Théo Lebrun

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.

---
 drivers/pinctrl/nomadik/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nomadik/Kconfig +1 -1
index f47f0755a835..59d0d885651c 100644
@@ -18,7 +18,7 @@ config PINCTRL_AB8505
 
 endif
 
-if (ARCH_U8500 || ARCH_NOMADIK)
+if (ARCH_U8500 || ARCH_NOMADIK || COMPILE_TEST)
 
 config PINCTRL_NOMADIK
 	bool "Nomadik pin controller driver"
Signature · 1 line
2.44.0
#16 lore raw

Re: [PATCH v2 07/30] pinctrl: nomadik: Kconfig: allow building with COMPILE_TEST

Quoted 5 lines · Théo Lebrun

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.

Patch applied to my immutable branch.

Yours,
Linus Walleij

author maintainer
#17 lore raw

PATCH v2 8/30 pinctrl: nomadik: fix build warning (-Wformat)

In reply to Théo Lebrun

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

---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +1 -1
index 16d836157f74..1be0c48712b7 100644
@@ -871,7 +871,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
 	if (g->altsetting < 0)
 		return -EINVAL;
 
-	dev_dbg(npct->dev, "enable group %s, %u pins\n", g->grp.name, g->grp.npins);
+	dev_dbg(npct->dev, "enable group %s, %zu pins\n", g->grp.name, g->grp.npins);
 
 	/*
 	 * If we're setting altfunc C by setting both AFSLA and AFSLB to 1,
Signature · 1 line
2.44.0
#18 lore raw

Re: [PATCH v2 08/30] pinctrl: nomadik: fix build warning (-Wformat)

Quoted 8 lines · Théo Lebrun

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

Patch applied!

Yours,
Linus Walleij

author maintainer
#19 lore raw

PATCH v2 9/30 pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast)

In reply to Théo Lebrun

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]

---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +2 -2
index 1be0c48712b7..c8d2699be985 100644
@@ -1176,14 +1176,14 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *prcm_np;
 	struct nmk_pinctrl *npct;
-	unsigned int version = 0;
+	uintptr_t version = 0;
 	int i;
 
 	npct = devm_kzalloc(&pdev->dev, sizeof(*npct), GFP_KERNEL);
 	if (!npct)
 		return -ENOMEM;
 
-	version = (unsigned int)device_get_match_data(&pdev->dev);
+	version = (uintptr_t)device_get_match_data(&pdev->dev);
 
 	/* Poke in other ASIC variants here */
 	if (version == PINCTRL_NMK_STN8815)
Signature · 1 line
2.44.0
#20 lore raw

Re: [PATCH v2 09/30] pinctrl: nomadik: fix build warning (-Wpointer-to-int-cast)

Quoted 7 lines · Théo Lebrun

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]

Patch applied!

Yours,
Linus Walleij

author maintainer
#21 lore raw

PATCH v2 10/30 pinctrl: nomadik: minimise indentation in probe

In reply to Théo Lebrun

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 ...
	}
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +10 -11
index c8d2699be985..69b421bea1f4 100644
@@ -1203,17 +1203,16 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
 		struct nmk_gpio_chip *nmk_chip;
 
 		gpio_np = of_parse_phandle(np, "nomadik-gpio-chips", i);
-		if (gpio_np) {
-			dev_info(&pdev->dev,
-				 "populate NMK GPIO %d \"%pOFn\"\n",
-				 i, gpio_np);
-			nmk_chip = nmk_gpio_populate_chip(gpio_np, pdev);
-			if (IS_ERR(nmk_chip))
-				dev_err(&pdev->dev,
-					"could not populate nmk chip struct "
-					"- continue anyway\n");
-			of_node_put(gpio_np);
-		}
+		if (!gpio_np)
+			continue;
+
+		dev_info(&pdev->dev, "populate NMK GPIO %d \"%pOFn\"\n",
+			 i, gpio_np);
+		nmk_chip = nmk_gpio_populate_chip(gpio_np, pdev);
+		if (IS_ERR(nmk_chip))
+			dev_err(&pdev->dev,
+				"could not populate nmk chip struct - continue anyway\n");
+		of_node_put(gpio_np);
 	}
 
 	prcm_np = of_parse_phandle(np, "prcm", 0);
Signature · 1 line
2.44.0
#22 lore raw

Re: [PATCH v2 10/30] pinctrl: nomadik: minimise indentation in probe

Quoted 23 lines · Théo Lebrun

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 ...
        }
Quoted 1 line

Patch applied!

Yours,
Linus Walleij

author maintainer
#23 lore raw

PATCH v2 11/30 pinctrl: nomadik: follow type-system kernel coding conventions

In reply to Théo Lebrun

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.
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 78 +++++++++++++++----------------
 1 file changed, 38 insertions(+), 40 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +38 -40
index 69b421bea1f4..bb3b4fbbfc54 100644
@@ -71,8 +71,6 @@
  * PIN_CFG	   - default config with alternate function
  */
 
-typedef unsigned long pin_cfg_t;
-
 #define PIN_NUM_MASK		0x1ff
 #define PIN_NUM(x)		((x) & PIN_NUM_MASK)
 
@@ -215,7 +213,7 @@ struct nmk_gpio_chip *nmk_gpio_chips[NMK_MAX_BANKS];
 DEFINE_SPINLOCK(nmk_gpio_slpm_lock);
 
 static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip,
-				unsigned offset, int gpio_mode)
+				unsigned int offset, int gpio_mode)
 {
 	u32 afunc, bfunc;
 
@@ -230,7 +228,7 @@ static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip,
 }
 
 static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip,
-				unsigned offset, enum nmk_gpio_pull pull)
+				unsigned int offset, enum nmk_gpio_pull pull)
 {
 	u32 pdis;
 
@@ -254,7 +252,7 @@ static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip,
 }
 
 static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip,
-				  unsigned offset, bool lowemi)
+				  unsigned int offset, bool lowemi)
 {
 	bool enabled = nmk_chip->lowemi & BIT(offset);
 
@@ -271,13 +269,13 @@ static void __nmk_gpio_set_lowemi(struct nmk_gpio_chip *nmk_chip,
 }
 
 static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip,
-				  unsigned offset)
+				  unsigned int offset)
 {
 	writel(BIT(offset), nmk_chip->addr + NMK_GPIO_DIRC);
 }
 
 static void __nmk_gpio_set_mode_safe(struct nmk_gpio_chip *nmk_chip,
-				     unsigned offset, int gpio_mode,
+				     unsigned int offset, int gpio_mode,
 				     bool glitch)
 {
 	u32 rwimsc = nmk_chip->rwimsc;
@@ -304,7 +302,7 @@ static void __nmk_gpio_set_mode_safe(struct nmk_gpio_chip *nmk_chip,
 }
 
 static void
-nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned offset)
+nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned int offset)
 {
 	u32 falling = nmk_chip->fimsc & BIT(offset);
 	u32 rising = nmk_chip->rimsc & BIT(offset);
@@ -343,7 +341,7 @@ static void nmk_write_masked(void __iomem *reg, u32 mask, u32 value)
 }
 
 static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
-	unsigned offset, unsigned alt_num)
+	unsigned int offset, unsigned int alt_num)
 {
 	int i;
 	u16 reg;
@@ -515,15 +513,15 @@ static int nmk_get_groups_cnt(struct pinctrl_dev *pctldev)
 }
 
 static const char *nmk_get_group_name(struct pinctrl_dev *pctldev,
-				       unsigned selector)
+				       unsigned int selector)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 
 	return npct->soc->groups[selector].grp.name;
 }
 
-static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
-			      const unsigned **pins,
+static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned int selector,
+			      const unsigned int **pins,
 			      unsigned int *num_pins)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
@@ -533,7 +531,7 @@ static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
 	return 0;
 }
 
-static struct nmk_gpio_chip *find_nmk_gpio_from_pin(unsigned pin)
+static struct nmk_gpio_chip *find_nmk_gpio_from_pin(unsigned int pin)
 {
 	int i;
 	struct nmk_gpio_chip *nmk_gpio;
@@ -549,7 +547,7 @@ static struct nmk_gpio_chip *find_nmk_gpio_from_pin(unsigned pin)
 	return NULL;
 }
 
-static struct gpio_chip *find_gc_from_pin(unsigned pin)
+static struct gpio_chip *find_gc_from_pin(unsigned int pin)
 {
 	struct nmk_gpio_chip *nmk_gpio = find_nmk_gpio_from_pin(pin);
 
@@ -559,7 +557,7 @@ static struct gpio_chip *find_gc_from_pin(unsigned pin)
 }
 
 static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
-		   unsigned offset)
+		   unsigned int offset)
 {
 	struct gpio_chip *chip = find_gc_from_pin(offset);
 
@@ -570,8 +568,8 @@ static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
 	nmk_gpio_dbg_show_one(s, pctldev, chip, offset - chip->base, offset);
 }
 
-static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps,
-		unsigned *num_maps, const char *group,
+static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned int *reserved_maps,
+		unsigned int *num_maps, const char *group,
 		const char *function)
 {
 	if (*num_maps == *reserved_maps)
@@ -586,9 +584,9 @@ static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps,
 }
 
 static int nmk_dt_add_map_configs(struct pinctrl_map **map,
-		unsigned *reserved_maps,
-		unsigned *num_maps, const char *group,
-		unsigned long *configs, unsigned num_configs)
+		unsigned int *reserved_maps,
+		unsigned int *num_maps, const char *group,
+		unsigned long *configs, unsigned int num_configs)
 {
 	unsigned long *dup_configs;
 
@@ -727,8 +725,8 @@ static bool nmk_pinctrl_dt_get_config(struct device_node *np,
 static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 		struct device_node *np,
 		struct pinctrl_map **map,
-		unsigned *reserved_maps,
-		unsigned *num_maps)
+		unsigned int *reserved_maps,
+		unsigned int *num_maps)
 {
 	int ret;
 	const char *function = NULL;
@@ -795,9 +793,9 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 
 static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
-				 struct pinctrl_map **map, unsigned *num_maps)
+				 struct pinctrl_map **map, unsigned int *num_maps)
 {
-	unsigned reserved_maps;
+	unsigned int reserved_maps;
 	struct device_node *np;
 	int ret;
 
@@ -835,7 +833,7 @@ static int nmk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
 }
 
 static const char *nmk_pmx_get_func_name(struct pinctrl_dev *pctldev,
-					 unsigned function)
+					 unsigned int function)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 
@@ -843,7 +841,7 @@ static const char *nmk_pmx_get_func_name(struct pinctrl_dev *pctldev,
 }
 
 static int nmk_pmx_get_func_groups(struct pinctrl_dev *pctldev,
-				   unsigned function,
+				   unsigned int function,
 				   const char * const **groups,
 				   unsigned * const num_groups)
 {
@@ -855,8 +853,8 @@ static int nmk_pmx_get_func_groups(struct pinctrl_dev *pctldev,
 	return 0;
 }
 
-static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
-		       unsigned group)
+static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned int function,
+		       unsigned int group)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 	const struct nmk_pingroup *g;
@@ -915,7 +913,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
 
 	for (i = 0; i < g->grp.npins; i++) {
 		struct nmk_gpio_chip *nmk_chip;
-		unsigned bit;
+		unsigned int bit;
 
 		nmk_chip = find_nmk_gpio_from_pin(g->grp.pins[i]);
 		if (!nmk_chip) {
@@ -968,12 +966,12 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
 
 static int nmk_gpio_request_enable(struct pinctrl_dev *pctldev,
 				   struct pinctrl_gpio_range *range,
-				   unsigned offset)
+				   unsigned int offset)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 	struct nmk_gpio_chip *nmk_chip;
 	struct gpio_chip *chip;
-	unsigned bit;
+	unsigned int bit;
 
 	if (!range) {
 		dev_err(npct->dev, "invalid range\n");
@@ -999,7 +997,7 @@ static int nmk_gpio_request_enable(struct pinctrl_dev *pctldev,
 
 static void nmk_gpio_disable_free(struct pinctrl_dev *pctldev,
 				  struct pinctrl_gpio_range *range,
-				  unsigned offset)
+				  unsigned int offset)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 
@@ -1017,30 +1015,30 @@ static const struct pinmux_ops nmk_pinmux_ops = {
 	.strict = true,
 };
 
-static int nmk_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
+static int nmk_pin_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
 			      unsigned long *config)
 {
 	/* Not implemented */
 	return -EINVAL;
 }
 
-static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
-			      unsigned long *configs, unsigned num_configs)
+static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
+			      unsigned long *configs, unsigned int num_configs)
 {
-	static const char *pullnames[] = {
+	static const char * const pullnames[] = {
 		[NMK_GPIO_PULL_NONE]	= "none",
 		[NMK_GPIO_PULL_UP]	= "up",
 		[NMK_GPIO_PULL_DOWN]	= "down",
 		[3] /* illegal */	= "??"
 	};
-	static const char *slpmnames[] = {
+	static const char * const slpmnames[] = {
 		[NMK_GPIO_SLPM_INPUT]		= "input/wakeup",
 		[NMK_GPIO_SLPM_NOCHANGE]	= "no-change/no-wakeup",
 	};
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 	struct nmk_gpio_chip *nmk_chip;
-	unsigned bit;
-	pin_cfg_t cfg;
+	unsigned int bit;
+	unsigned long cfg;
 	int pull, slpm, output, val, i;
 	bool lowemi, gpiomode, sleep;
 
@@ -1057,7 +1055,7 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
 		 * here we just ignore that part. It's being handled by the
 		 * framework and pinmux callback respectively.
 		 */
-		cfg = (pin_cfg_t) configs[i];
+		cfg = configs[i];
 		pull = PIN_PULL(cfg);
 		slpm = PIN_SLPM(cfg);
 		output = PIN_DIR(cfg);
Signature · 1 line
2.44.0
#24 lore raw

Re: [PATCH v2 11/30] pinctrl: nomadik: follow type-system kernel coding conventions

Quoted 8 lines · Théo Lebrun

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

Quoted 4 lines
Total messages before: 1 errors, 40 warnings, 39 checks.
Total messages after:  1 errors,  2 warnings, 38 checks.

Patch applied!

Yours,
Linus Walleij

author maintainer
#25 lore raw

PATCH v2 12/30 pinctrl: nomadik: follow whitespace kernel coding conventions

In reply to Théo Lebrun

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.
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 66 +++++++++++++++----------------
 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +33 -33
index bb3b4fbbfc54..95181ab575e0 100644
@@ -9,6 +9,7 @@
  *   Rewritten based on work by Prafulla WADASKAR <[email protected]>
  * Copyright (C) 2011-2013 Linus Walleij <[email protected]>
  */
+
 #include <linux/bitops.h>
 #include <linux/cleanup.h>
 #include <linux/clk.h>
@@ -165,7 +166,6 @@
 #define PIN_SLEEPMODE_DISABLED	(0 << PIN_SLEEPMODE_SHIFT)
 #define PIN_SLEEPMODE_ENABLED	(1 << PIN_SLEEPMODE_SHIFT)
 
-
 /* Shortcuts.  Use these instead of separate DIR, PULL, and VAL.  */
 #define PIN_INPUT_PULLDOWN	(PIN_DIR_INPUT | PIN_PULL_DOWN)
 #define PIN_INPUT_PULLUP	(PIN_DIR_INPUT | PIN_PULL_UP)
@@ -341,7 +341,7 @@ static void nmk_write_masked(void __iomem *reg, u32 mask, u32 value)
 }
 
 static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
-	unsigned int offset, unsigned int alt_num)
+				    unsigned int offset, unsigned int alt_num)
 {
 	int i;
 	u16 reg;
@@ -385,7 +385,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 					nmk_write_masked(npct->prcm_base + reg, BIT(bit), 0);
 					dev_dbg(npct->dev,
 						"PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n",
-						offset, i+1);
+						offset, i + 1);
 				}
 			}
 		}
@@ -395,8 +395,8 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 	alt_index = alt_num - 1;
 	if (pin_desc->altcx[alt_index].used == false) {
 		dev_warn(npct->dev,
-			"PRCM GPIOCR: pin %i: alternate-C%i does not exist\n",
-			offset, alt_num);
+			 "PRCM GPIOCR: pin %i: alternate-C%i does not exist\n",
+			 offset, alt_num);
 		return;
 	}
 
@@ -414,7 +414,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 				nmk_write_masked(npct->prcm_base + reg, BIT(bit), 0);
 				dev_dbg(npct->dev,
 					"PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n",
-					offset, i+1);
+					offset, i + 1);
 			}
 		}
 	}
@@ -422,7 +422,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 	reg = gpiocr_regs[pin_desc->altcx[alt_index].reg_index];
 	bit = pin_desc->altcx[alt_index].control_bit;
 	dev_dbg(npct->dev, "PRCM GPIOCR: pin %i: alternate-C%i has been selected\n",
-		offset, alt_index+1);
+		offset, alt_index + 1);
 	nmk_write_masked(npct->prcm_base + reg, BIT(bit), BIT(bit));
 }
 
@@ -499,7 +499,7 @@ int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpi
 			reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
 			bit = pin_desc->altcx[i].control_bit;
 			if (readl(npct->prcm_base + reg) & BIT(bit))
-				return NMK_GPIO_ALT_C+i+1;
+				return NMK_GPIO_ALT_C + i + 1;
 		}
 	}
 	return NMK_GPIO_ALT_C;
@@ -513,7 +513,7 @@ static int nmk_get_groups_cnt(struct pinctrl_dev *pctldev)
 }
 
 static const char *nmk_get_group_name(struct pinctrl_dev *pctldev,
-				       unsigned int selector)
+				      unsigned int selector)
 {
 	struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
 
@@ -536,12 +536,12 @@ static struct nmk_gpio_chip *find_nmk_gpio_from_pin(unsigned int pin)
 	int i;
 	struct nmk_gpio_chip *nmk_gpio;
 
-	for(i = 0; i < NMK_MAX_BANKS; i++) {
+	for (i = 0; i < NMK_MAX_BANKS; i++) {
 		nmk_gpio = nmk_gpio_chips[i];
 		if (!nmk_gpio)
 			continue;
 		if (pin >= nmk_gpio->chip.base &&
-			pin < nmk_gpio->chip.base + nmk_gpio->chip.ngpio)
+		    pin < nmk_gpio->chip.base + nmk_gpio->chip.ngpio)
 			return nmk_gpio;
 	}
 	return NULL;
@@ -557,7 +557,7 @@ static struct gpio_chip *find_gc_from_pin(unsigned int pin)
 }
 
 static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
-		   unsigned int offset)
+			     unsigned int offset)
 {
 	struct gpio_chip *chip = find_gc_from_pin(offset);
 
@@ -569,8 +569,8 @@ static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
 }
 
 static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned int *reserved_maps,
-		unsigned int *num_maps, const char *group,
-		const char *function)
+			      unsigned int *num_maps, const char *group,
+			      const char *function)
 {
 	if (*num_maps == *reserved_maps)
 		return -ENOSPC;
@@ -584,9 +584,9 @@ static int nmk_dt_add_map_mux(struct pinctrl_map **map, unsigned int *reserved_m
 }
 
 static int nmk_dt_add_map_configs(struct pinctrl_map **map,
-		unsigned int *reserved_maps,
-		unsigned int *num_maps, const char *group,
-		unsigned long *configs, unsigned int num_configs)
+				  unsigned int *reserved_maps,
+				  unsigned int *num_maps, const char *group,
+				  unsigned long *configs, unsigned int num_configs)
 {
 	unsigned long *dup_configs;
 
@@ -702,15 +702,14 @@ static const char *nmk_find_pin_name(struct pinctrl_dev *pctldev, const char *pi
 }
 
 static bool nmk_pinctrl_dt_get_config(struct device_node *np,
-		unsigned long *configs)
+				      unsigned long *configs)
 {
 	bool has_config = 0;
 	unsigned long cfg = 0;
 	int i, val, ret;
 
 	for (i = 0; i < ARRAY_SIZE(nmk_cfg_params); i++) {
-		ret = of_property_read_u32(np,
-				nmk_cfg_params[i].property, &val);
+		ret = of_property_read_u32(np, nmk_cfg_params[i].property, &val);
 		if (ret != -EINVAL) {
 			if (nmk_dt_pin_config(i, val, &cfg) == 0) {
 				*configs |= cfg;
@@ -723,10 +722,10 @@ static bool nmk_pinctrl_dt_get_config(struct device_node *np,
 }
 
 static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
-		struct device_node *np,
-		struct pinctrl_map **map,
-		unsigned int *reserved_maps,
-		unsigned int *num_maps)
+					 struct device_node *np,
+					 struct pinctrl_map **map,
+					 unsigned int *reserved_maps,
+					 unsigned int *num_maps)
 {
 	int ret;
 	const char *function = NULL;
@@ -751,7 +750,7 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 
 		of_property_for_each_string(np, "groups", prop, group) {
 			ret = nmk_dt_add_map_mux(map, reserved_maps, num_maps,
-					  group, function);
+						 group, function);
 			if (ret < 0)
 				goto exit;
 		}
@@ -792,8 +791,9 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
 }
 
 static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
-				 struct device_node *np_config,
-				 struct pinctrl_map **map, unsigned int *num_maps)
+				      struct device_node *np_config,
+				      struct pinctrl_map **map,
+				      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
 	struct device_node *np;
@@ -805,7 +805,7 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	for_each_child_of_node(np_config, np) {
 		ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map,
-				&reserved_maps, num_maps);
+						    &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
 			of_node_put(np);
@@ -922,7 +922,8 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned int function,
 				g->grp.pins[i], g->grp.name, i);
 			goto out_glitch;
 		}
-		dev_dbg(npct->dev, "setting pin %d to altsetting %d\n", g->grp.pins[i], g->altsetting);
+		dev_dbg(npct->dev, "setting pin %d to altsetting %d\n",
+			g->grp.pins[i], g->altsetting);
 
 		clk_enable(nmk_chip->clk);
 		bit = g->grp.pins[i] % NMK_GPIO_PER_CHIP;
@@ -936,7 +937,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned int function,
 		nmk_gpio_disable_lazy_irq(nmk_chip, bit);
 
 		__nmk_gpio_set_mode_safe(nmk_chip, bit,
-			(g->altsetting & NMK_GPIO_ALT_C), glitch);
+					 (g->altsetting & NMK_GPIO_ALT_C), glitch);
 		clk_disable(nmk_chip->clk);
 
 		/*
@@ -949,7 +950,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned int function,
 		 */
 		if ((g->altsetting & NMK_GPIO_ALT_C) == NMK_GPIO_ALT_C)
 			nmk_prcm_altcx_set_mode(npct, g->grp.pins[i],
-				g->altsetting >> NMK_GPIO_ALT_CX_SHIFT);
+						g->altsetting >> NMK_GPIO_ALT_CX_SHIFT);
 	}
 
 	/* When all pins are successfully reconfigured we get here */
@@ -1221,8 +1222,7 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
 	if (!npct->prcm_base) {
 		if (version == PINCTRL_NMK_STN8815) {
 			dev_info(&pdev->dev,
-				 "No PRCM base, "
-				 "assuming no ALT-Cx control is available\n");
+				 "No PRCM base, assuming no ALT-Cx control is available\n");
 		} else {
 			dev_err(&pdev->dev, "missing PRCM base address\n");
 			return -EINVAL;
Signature · 1 line
2.44.0
#26 lore raw

Re: [PATCH v2 12/30] pinctrl: nomadik: follow whitespace kernel coding conventions

Quoted 10 lines · Théo Lebrun

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)

Quoted 4 lines
Before: 1 errors, 2 warnings, 38 checks.
After:  0 errors, 1 warnings, 16 checks.

Patch applied!

Yours,
Linus Walleij

author maintainer
#27 lore raw

PATCH v2 13/30 pinctrl: nomadik: follow conditional kernel coding conventions

In reply to Théo Lebrun

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.
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/nomadik/pinctrl-nomadik.c +8 -8
index 95181ab575e0..b74378302229 100644
@@ -378,7 +378,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 	 */
 	if (!alt_num) {
 		for (i = 0 ; i < PRCM_IDX_GPIOCR_ALTC_MAX ; i++) {
-			if (pin_desc->altcx[i].used == true) {
+			if (pin_desc->altcx[i].used) {
 				reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
 				bit = pin_desc->altcx[i].control_bit;
 				if (readl(npct->prcm_base + reg) & BIT(bit)) {
@@ -393,7 +393,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 	}
 
 	alt_index = alt_num - 1;
-	if (pin_desc->altcx[alt_index].used == false) {
+	if (!pin_desc->altcx[alt_index].used) {
 		dev_warn(npct->dev,
 			 "PRCM GPIOCR: pin %i: alternate-C%i does not exist\n",
 			 offset, alt_num);
@@ -407,7 +407,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
 	for (i = 0 ; i < PRCM_IDX_GPIOCR_ALTC_MAX ; i++) {
 		if (i == alt_index)
 			continue;
-		if (pin_desc->altcx[i].used == true) {
+		if (pin_desc->altcx[i].used) {
 			reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
 			bit = pin_desc->altcx[i].control_bit;
 			if (readl(npct->prcm_base + reg) & BIT(bit)) {
@@ -495,7 +495,7 @@ int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpi
 	pin_desc = npct->soc->altcx_pins + i;
 	gpiocr_regs = npct->soc->prcm_gpiocr_registers;
 	for (i = 0; i < PRCM_IDX_GPIOCR_ALTC_MAX; i++) {
-		if (pin_desc->altcx[i].used == true) {
+		if (pin_desc->altcx[i].used) {
 			reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
 			bit = pin_desc->altcx[i].control_bit;
 			if (readl(npct->prcm_base + reg) & BIT(bit))
@@ -677,9 +677,9 @@ static const struct nmk_cfg_param nmk_cfg_params[] = {
 
 static int nmk_dt_pin_config(int index, int val, unsigned long *config)
 {
-	if (nmk_cfg_params[index].choice == NULL)
+	if (!nmk_cfg_params[index].choice) {
 		*config = nmk_cfg_params[index].config;
-	else {
+	} else {
 		/* test if out of range */
 		if  (val < nmk_cfg_params[index].size) {
 			*config = nmk_cfg_params[index].config |
@@ -1105,9 +1105,9 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
 		if (gpiomode)
 			/* No glitch when going to GPIO mode */
 			__nmk_gpio_set_mode(nmk_chip, bit, NMK_GPIO_ALT_GPIO);
-		if (output)
+		if (output) {
 			__nmk_gpio_make_output(nmk_chip, bit, val);
-		else {
+		} else {
 			__nmk_gpio_make_input(nmk_chip, bit);
 			__nmk_gpio_set_pull(nmk_chip, bit, pull);
 		}
Signature · 1 line
2.44.0
#28 lore raw

Re: [PATCH v2 13/30] pinctrl: nomadik: follow conditional kernel coding conventions

Quoted 9 lines · Théo Lebrun

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

Quoted 4 lines
Before: 0 errors, 1 warnings, 16 checks.
After:  0 errors, 1 warnings,  7 checks.

Patch applied!

Yours,
Linus Walleij

author maintainer
#29 lore raw

PATCH v2 14/30 gpio: nomadik: add #include <linux/slab.h>

In reply to Théo Lebrun

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

---
 drivers/gpio/gpio-nomadik.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-nomadik.c +1 -0
index e39477e1a58f..9347c93af62c 100644
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <linux/gpio/gpio-nomadik.h>
Signature · 1 line
2.44.0
author maintainer
#31 lore raw

PATCH v2 15/30 gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node()

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpio/gpio-nomadik.c +8 -5
index 9347c93af62c..f3ef3b4d08eb 100644
@@ -483,17 +483,20 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 {
 	struct nmk_gpio_chip *nmk_chip;
 	struct platform_device *gpio_pdev;
+	struct device *gpio_dev;
 	struct gpio_chip *chip;
 	struct resource *res;
 	struct clk *clk;
 	void __iomem *base;
 	u32 id;
 
-	gpio_pdev = of_find_device_by_node(np);
-	if (!gpio_pdev) {
+	gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
+	if (!gpio_dev) {
 		pr_err("populate \"%pOFn\": device not found\n", np);
 		return ERR_PTR(-ENODEV);
 	}
+	gpio_pdev = to_platform_device(gpio_dev);
+
 	if (of_property_read_u32(np, "gpio-bank", &id)) {
 		dev_err(&pdev->dev, "populate: gpio-bank property not found\n");
 		platform_device_put(gpio_pdev);
@@ -519,8 +522,8 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	chip = &nmk_chip->chip;
 	chip->base = id * NMK_GPIO_PER_CHIP;
 	chip->ngpio = NMK_GPIO_PER_CHIP;
-	chip->label = dev_name(&gpio_pdev->dev);
-	chip->parent = &gpio_pdev->dev;
+	chip->label = dev_name(gpio_dev);
+	chip->parent = gpio_dev;
 
 	res = platform_get_resource(gpio_pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, res);
@@ -530,7 +533,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	}
 	nmk_chip->addr = base;
 
-	clk = clk_get(&gpio_pdev->dev, NULL);
+	clk = clk_get(gpio_dev, NULL);
 	if (IS_ERR(clk)) {
 		platform_device_put(gpio_pdev);
 		return (void *)clk;
Signature · 1 line
2.44.0
#32 lore raw

Re: [PATCH v2 15/30] gpio: nomadik: replace of_find_*() by bus_find_device_by_of_node()

Quoted 7 lines · Théo Lebrun

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#33 lore raw

PATCH v2 16/30 gpio: nomadik: replace of_property_read_*() by device_property_read_*()

In reply to Théo Lebrun

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

---
 drivers/gpio/gpio-nomadik.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-nomadik.c +2 -2
index f3ef3b4d08eb..bba183c0b597 100644
@@ -497,7 +497,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	}
 	gpio_pdev = to_platform_device(gpio_dev);
 
-	if (of_property_read_u32(np, "gpio-bank", &id)) {
+	if (device_property_read_u32(gpio_dev, "gpio-bank", &id)) {
 		dev_err(&pdev->dev, "populate: gpio-bank property not found\n");
 		platform_device_put(gpio_pdev);
 		return ERR_PTR(-EINVAL);
@@ -587,7 +587,7 @@ static int nmk_gpio_probe(struct platform_device *dev)
 	}
 
 	supports_sleepmode =
-		of_property_read_bool(np, "st,supports-sleepmode");
+		device_property_read_bool(dev, "st,supports-sleepmode");
 
 	/* Correct platform device ID */
 	dev->id = nmk_chip->bank;
Signature · 1 line
2.44.0
#34 lore raw

Re: [PATCH v2 16/30] gpio: nomadik: replace of_property_read_*() by device_property_read_*()

Quoted 4 lines · Théo Lebrun

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

Patch applied!

Yours,
Linus Walleij

author maintainer
#35 lore raw

PATCH v2 17/30 gpio: nomadik: use devm_platform_ioremap_resource() helper

In reply to Théo Lebrun

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

---
 drivers/gpio/gpio-nomadik.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/gpio-nomadik.c +1 -3
index bba183c0b597..93015fa3d010 100644
@@ -485,7 +485,6 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	struct platform_device *gpio_pdev;
 	struct device *gpio_dev;
 	struct gpio_chip *chip;
-	struct resource *res;
 	struct clk *clk;
 	void __iomem *base;
 	u32 id;
@@ -525,8 +524,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	chip->label = dev_name(gpio_dev);
 	chip->parent = gpio_dev;
 
-	res = platform_get_resource(gpio_pdev, IORESOURCE_MEM, 0);
-	base = devm_ioremap_resource(&pdev->dev, res);
+	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base)) {
 		platform_device_put(gpio_pdev);
 		return ERR_CAST(base);
Signature · 1 line
2.44.0
#36 lore raw

Re: [PATCH v2 17/30] gpio: nomadik: use devm_platform_ioremap_resource() helper

Quoted 4 lines · Théo Lebrun

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

Patch applied!

Yours,
Linus Walleij

author maintainer
#37 lore raw

PATCH v2 18/30 gpio: nomadik: use devres version of clk_get*()

In reply to Théo Lebrun

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

---
 drivers/gpio/gpio-nomadik.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-nomadik.c +1 -1
index 93015fa3d010..fb821a9b6c5f 100644
@@ -531,7 +531,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	}
 	nmk_chip->addr = base;
 
-	clk = clk_get(gpio_dev, NULL);
+	clk = devm_clk_get(gpio_dev, NULL);
 	if (IS_ERR(clk)) {
 		platform_device_put(gpio_pdev);
 		return (void *)clk;
Signature · 1 line
2.44.0
#38 lore raw

Re: [PATCH v2 18/30] gpio: nomadik: use devres version of clk_get*()

Quoted 4 lines · Théo Lebrun

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

Patch applied!

Yours,
Linus Walleij

author maintainer
#39 lore raw

PATCH v2 19/30 gpio: nomadik: request dynamic ID allocation

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c               |  2 +-
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 54 ++++++++++++++++++++-----------
 2 files changed, 37 insertions(+), 19 deletions(-)
drivers/gpio/gpio-nomadik.c +1 -1
index fb821a9b6c5f..b7d76cc901dc 100644
@@ -519,7 +519,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 
 	nmk_chip->bank = id;
 	chip = &nmk_chip->chip;
-	chip->base = id * NMK_GPIO_PER_CHIP;
+	chip->base = -1;
 	chip->ngpio = NMK_GPIO_PER_CHIP;
 	chip->label = dev_name(gpio_dev);
 	chip->parent = gpio_dev;
drivers/pinctrl/nomadik/pinctrl-nomadik.c +36 -18

135 lines not on this page · raw message

Signature · 1 line
2.44.0
#40 lore raw

Re: [PATCH v2 19/30] gpio: nomadik: request dynamic ID allocation

Quoted 11 lines · Théo Lebrun

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.

Quoted 4 lines

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#41 lore raw

PATCH v2 20/30 gpio: nomadik: make clock optional

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-nomadik.c +1 -1
index b7d76cc901dc..3ccbb731cb68 100644
@@ -531,7 +531,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	}
 	nmk_chip->addr = base;
 
-	clk = devm_clk_get(gpio_dev, NULL);
+	clk = devm_clk_get_optional(gpio_dev, NULL);
 	if (IS_ERR(clk)) {
 		platform_device_put(gpio_pdev);
 		return (void *)clk;
Signature · 1 line
2.44.0
#42 lore raw

Re: [PATCH v2 20/30] gpio: nomadik: make clock optional

Quoted 5 lines · Théo Lebrun

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#43 lore raw

PATCH v2 21/30 gpio: nomadik: change driver name from gpio to gpio-nomadik

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-nomadik.c +1 -1
index 3ccbb731cb68..c22a0864ca70 100644
@@ -649,7 +649,7 @@ static const struct of_device_id nmk_gpio_match[] = {
 
 static struct platform_driver nmk_gpio_driver = {
 	.driver = {
-		.name = "gpio",
+		.name = "nomadik-gpio",
 		.of_match_table = nmk_gpio_match,
 	},
 	.probe = nmk_gpio_probe,
Signature · 1 line
2.44.0
#44 lore raw

Re: [PATCH v2 21/30] gpio: nomadik: change driver name from gpio to gpio-nomadik

Quoted 5 lines · Théo Lebrun

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.

(...)

drivers/gpio/gpio-nomadik.c static const struct of_device_id nmk_gpio_match[] = { · line 652

Quoted 2 lines
drivers/gpio/gpio-nomadik.c +1 -1
-               .name = "gpio",
+               .name = "nomadik-gpio",

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

Yours,
Linus Walleij

author maintainer
#45 lore raw

PATCH v2 22/30 gpio: nomadik: support shared GPIO IRQs

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 68 ++++++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 32 deletions(-)
drivers/gpio/gpio-nomadik.c +36 -32
index c22a0864ca70..ca5c28965224 100644
@@ -255,27 +255,28 @@ static void nmk_gpio_irq_shutdown(struct irq_data *d)
 	clk_disable(nmk_chip->clk);
 }
 
-static void nmk_gpio_irq_handler(struct irq_desc *desc)
+static irqreturn_t nmk_gpio_irq_handler(int irq, void *dev_id)
 {
-	struct irq_chip *host_chip = irq_desc_get_chip(desc);
-	struct gpio_chip *chip = irq_desc_get_handler_data(desc);
-	struct nmk_gpio_chip *nmk_chip = gpiochip_get_data(chip);
-	u32 status;
-
-	chained_irq_enter(host_chip, desc);
+	struct nmk_gpio_chip *nmk_chip = dev_id;
+	struct gpio_chip *chip = &nmk_chip->chip;
+	unsigned long mask = GENMASK(chip->ngpio - 1, 0);
+	unsigned long status;
+	int bit;
 
 	clk_enable(nmk_chip->clk);
+
 	status = readl(nmk_chip->addr + NMK_GPIO_IS);
-	clk_disable(nmk_chip->clk);
 
-	while (status) {
-		int bit = __ffs(status);
+	/* Ensure we cannot leave pending bits; this should never occur. */
+	if (unlikely(status & ~mask))
+		writel(status & ~mask, nmk_chip->addr + NMK_GPIO_IC);
 
-		generic_handle_domain_irq(chip->irq.domain, bit);
-		status &= ~BIT(bit);
-	}
+	clk_disable(nmk_chip->clk);
 
-	chained_irq_exit(host_chip, desc);
+	for_each_set_bit(bit, &status, chip->ngpio)
+		generic_handle_domain_irq_safe(chip->irq.domain, bit);
+
+	return IRQ_RETVAL((status & mask) != 0);
 }
 
 /* I/O Functions */
@@ -568,19 +569,20 @@ static const struct irq_chip nmk_irq_chip = {
 	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
-static int nmk_gpio_probe(struct platform_device *dev)
+static int nmk_gpio_probe(struct platform_device *pdev)
 {
-	struct device_node *np = dev->dev.of_node;
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
 	struct nmk_gpio_chip *nmk_chip;
-	struct gpio_chip *chip;
 	struct gpio_irq_chip *girq;
 	bool supports_sleepmode;
+	struct gpio_chip *chip;
 	int irq;
 	int ret;
 
-	nmk_chip = nmk_gpio_populate_chip(np, dev);
+	nmk_chip = nmk_gpio_populate_chip(np, pdev);
 	if (IS_ERR(nmk_chip)) {
-		dev_err(&dev->dev, "could not populate nmk chip struct\n");
+		dev_err(dev, "could not populate nmk chip struct\n");
 		return PTR_ERR(nmk_chip);
 	}
 
@@ -588,9 +590,9 @@ static int nmk_gpio_probe(struct platform_device *dev)
 		device_property_read_bool(dev, "st,supports-sleepmode");
 
 	/* Correct platform device ID */
-	dev->id = nmk_chip->bank;
+	pdev->id = nmk_chip->bank;
 
-	irq = platform_get_irq(dev, 0);
+	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
 
@@ -602,7 +604,7 @@ static int nmk_gpio_probe(struct platform_device *dev)
 	spin_lock_init(&nmk_chip->lock);
 
 	chip = &nmk_chip->chip;
-	chip->parent = &dev->dev;
+	chip->parent = dev;
 	chip->request = gpiochip_generic_request;
 	chip->free = gpiochip_generic_free;
 	chip->get_direction = nmk_gpio_get_dir;
@@ -616,17 +618,19 @@ static int nmk_gpio_probe(struct platform_device *dev)
 
 	girq = &chip->irq;
 	gpio_irq_chip_set_chip(girq, &nmk_irq_chip);
-	girq->parent_handler = nmk_gpio_irq_handler;
-	girq->num_parents = 1;
-	girq->parents = devm_kcalloc(&dev->dev, 1,
-				     sizeof(*girq->parents),
-				     GFP_KERNEL);
-	if (!girq->parents)
-		return -ENOMEM;
-	girq->parents[0] = irq;
+	girq->parent_handler = NULL;
+	girq->num_parents = 0;
+	girq->parents = NULL;
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_edge_irq;
 
+	ret = devm_request_irq(dev, irq, nmk_gpio_irq_handler, IRQF_SHARED,
+			       dev_name(dev), nmk_chip);
+	if (ret) {
+		dev_err(dev, "failed requesting IRQ\n");
+		return ret;
+	}
+
 	clk_enable(nmk_chip->clk);
 	nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI);
 	clk_disable(nmk_chip->clk);
@@ -635,9 +639,9 @@ static int nmk_gpio_probe(struct platform_device *dev)
 	if (ret)
 		return ret;
 
-	platform_set_drvdata(dev, nmk_chip);
+	platform_set_drvdata(pdev, nmk_chip);
 
-	dev_info(&dev->dev, "chip registered\n");
+	dev_info(dev, "chip registered\n");
 
 	return 0;
 }
Signature · 1 line
2.44.0
#46 lore raw

Re: [PATCH v2 22/30] gpio: nomadik: support shared GPIO IRQs

Quoted 11 lines · Théo Lebrun

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#47 lore raw

PATCH v2 23/30 gpio: nomadik: handle variadic GPIO count

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-nomadik.c +7 -2
index ca5c28965224..19394dc7e34a 100644
@@ -488,7 +488,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	struct gpio_chip *chip;
 	struct clk *clk;
 	void __iomem *base;
-	u32 id;
+	u32 id, ngpio;
 
 	gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
 	if (!gpio_dev) {
@@ -518,10 +518,15 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 		return ERR_PTR(-ENOMEM);
 	}
 
+	if (device_property_read_u32(gpio_dev, "ngpios", &ngpio)) {
+		ngpio = NMK_GPIO_PER_CHIP;
+		dev_dbg(&pdev->dev, "populate: using default ngpio (%d)\n", ngpio);
+	}
+
 	nmk_chip->bank = id;
 	chip = &nmk_chip->chip;
 	chip->base = -1;
-	chip->ngpio = NMK_GPIO_PER_CHIP;
+	chip->ngpio = ngpio;
 	chip->label = dev_name(gpio_dev);
 	chip->parent = gpio_dev;
 
Signature · 1 line
2.44.0
#48 lore raw

Re: [PATCH v2 23/30] gpio: nomadik: handle variadic GPIO count

Quoted 10 lines · Théo Lebrun

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#49 lore raw

PATCH v2 24/30 gpio: nomadik: support mobileye,eyeq5-gpio

In reply to Théo Lebrun

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.

---
 drivers/gpio/Kconfig                      |  5 ++--
 drivers/gpio/gpio-nomadik.c               | 42 ++++++++++++++++++++++++++-----
 drivers/pinctrl/nomadik/pinctrl-nomadik.c |  2 ++
 include/linux/gpio/gpio-nomadik.h         |  1 +
 4 files changed, 42 insertions(+), 8 deletions(-)
drivers/gpio/Kconfig +3 -2
index ff83371251c1..fe6112abb73a 100644
@@ -480,11 +480,12 @@ config GPIO_MXS
 
 config GPIO_NOMADIK
 	bool "Nomadik GPIO driver"
-	depends on ARCH_U8500 || ARCH_NOMADIK || COMPILE_TEST
+	depends on ARCH_U8500 || ARCH_NOMADIK || MACH_EYEQ5 || COMPILE_TEST
 	select OF_GPIO
 	select GPIOLIB_IRQCHIP
 	help
-	  Say yes here to support the Nomadik SoC GPIO block.
+	  Say yes here to support the Nomadik SoC GPIO block. This block is also
+	  used by the Mobileye EyeQ5 SoC.
 
 	  It handles up to 32 GPIOs per bank, that can all be interrupt sources.
 	  It is deeply interconnected with the associated pinctrl driver as GPIO
drivers/gpio/gpio-nomadik.c +36 -6

114 lines not on this page · raw message

drivers/pinctrl/nomadik/pinctrl-nomadik.c +2 -0
index 5633f0ec2715..7849144b3b80 100644
@@ -1230,6 +1230,8 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"could not populate nmk chip struct - continue anyway\n");
 		of_node_put(gpio_np);
+		/* We are NOT compatible with mobileye,eyeq5-gpio. */
+		BUG_ON(nmk_chip->is_mobileye_soc);
 	}
 
 	prcm_np = of_parse_phandle(np, "prcm", 0);
include/linux/gpio/gpio-nomadik.h +1 -0
index 0166ddb71f43..9bdb09fda4c9 100644
@@ -57,6 +57,7 @@ struct nmk_gpio_chip {
 	void (*set_ioforce)(bool enable);
 	spinlock_t lock;
 	bool sleepmode;
+	bool is_mobileye_soc;
 	/* Keep track of configured edges */
 	u32 edge_rising;
 	u32 edge_falling;
Signature · 1 line
2.44.0
#50 lore raw

Re: [PATCH v2 24/30] gpio: nomadik: support mobileye,eyeq5-gpio

Quoted 4 lines · Théo Lebrun

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.

Quoted 8 lines

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.

Just as I wanted it.

Patch applied!

Yours,
Linus Walleij

author maintainer
#51 lore raw

PATCH v2 25/30 gpio: nomadik: grab optional reset control and deassert it at probe

In reply to Théo Lebrun

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.

---
 drivers/gpio/gpio-nomadik.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpio/gpio-nomadik.c +21 -0
index 6adb3c4417d3..c9fd6631e0aa 100644
@@ -509,11 +509,13 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 {
 	struct nmk_gpio_chip *nmk_chip;
 	struct platform_device *gpio_pdev;
+	struct reset_control *reset;
 	struct device *gpio_dev;
 	struct gpio_chip *chip;
 	struct clk *clk;
 	void __iomem *base;
 	u32 id, ngpio;
+	int ret;
 
 	gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
 	if (!gpio_dev) {
@@ -572,6 +574,24 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
 	clk_prepare(clk);
 	nmk_chip->clk = clk;
 
+	reset = devm_reset_control_get_optional_shared(gpio_dev, NULL);
+	if (IS_ERR(reset)) {
+		dev_err(&pdev->dev, "failed getting reset control: %ld\n",
+			PTR_ERR(reset));
+		return ERR_CAST(reset);
+	}
+
+	/*
+	 * Reset might be shared and asserts/deasserts calls are unbalanced. We
+	 * only support sharing this reset with other gpio-nomadik devices that
+	 * use this reset to ensure deassertion at probe.
+	 */
+	ret = reset_control_deassert(reset);
+	if (ret) {
+		dev_err(&pdev->dev, "failed reset deassert: %d\n", ret);
+		return ERR_PTR(ret);
+	}
+
 #ifdef CONFIG_PINCTRL_NOMADIK
 	BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips));
 	nmk_gpio_chips[id] = nmk_chip;
@@ -690,6 +710,7 @@ static struct platform_driver nmk_gpio_driver = {
 	.driver = {
 		.name = "nomadik-gpio",
 		.of_match_table = nmk_gpio_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = nmk_gpio_probe,
 };
Signature · 1 line
2.44.0
#52 lore raw

Re: [PATCH v2 25/30] gpio: nomadik: grab optional reset control and deassert it at probe

Quoted 12 lines · Théo Lebrun

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

Quoted 7 lines

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.

Patch applied!

Yours,
Linus Walleij

author maintainer
#53 lore raw

PATCH v2 26/30 Documentation: gpio: mention generic_handle_irq_safe()

In reply to Théo Lebrun

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 <[email protected]>
To: Jonathan Corbet <[email protected]>

---
 Documentation/driver-api/gpio/driver.rst | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
Documentation/driver-api/gpio/driver.rst +2 -9
index bf6319cc531b..550d167a82ed 100644
@@ -339,15 +339,8 @@ Cascaded GPIO irqchips usually fall in one of three categories:
 
   The generic_handle_irq() is expected to be called with IRQ disabled,
   so the IRQ core will complain if it is called from an IRQ handler which is
-  forced to a thread. The "fake?" raw lock can be used to work around this
-  problem::
-
-    raw_spinlock_t wa_lock;
-    static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank)
-        unsigned long wa_lock_flags;
-        raw_spin_lock_irqsave(&bank->wa_lock, wa_lock_flags);
-        generic_handle_irq(irq_find_mapping(bank->chip.irq.domain, bit));
-        raw_spin_unlock_irqrestore(&bank->wa_lock, wa_lock_flags);
+  forced to a thread. generic_handle_irq_safe() can be used to work around
+  this problem; it can safely be called from any context.
 
 - GENERIC CHAINED GPIO IRQCHIPS: these are the same as "CHAINED GPIO irqchips",
   but chained IRQ handlers are not used. Instead GPIO IRQs dispatching is
Signature · 1 line
2.44.0
Reviewed-by on v2 26/30
#54 lore raw

Re: [PATCH v2 26/30] Documentation: gpio: mention generic_handle_irq_safe()

Quoted 11 lines · Théo Lebrun

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 <[email protected]>
To: Jonathan Corbet <[email protected]>

I leave this one off from my branch, Bartosz can apply it separately.

Yours,
Linus Walleij

author maintainer
#55 lore raw

PATCH v2 27/30 MIPS: eyeq5_defconfig: enable GPIO by default

In reply to Théo Lebrun

Add both CONFIG_GPIOLIB=y and CONFIG_GPIO_NOMADIK=y to our platform defconfig. Default config is CONFIG_GPIOLIB=n.

---
 arch/mips/configs/eyeq5_defconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/configs/eyeq5_defconfig +2 -0
index c35c29a4d479..6f052d4c5e58 100644
@@ -66,6 +66,8 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
 CONFIG_HW_RANDOM=y
 # CONFIG_PTP_1588_CLOCK is not set
 CONFIG_PINCTRL=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_NOMADIK=y
 CONFIG_MFD_SYSCON=y
 CONFIG_HID_A4TECH=y
 CONFIG_HID_BELKIN=y
Signature · 1 line
2.44.0
author maintainer
#57 lore raw

PATCH v2 28/30 MIPS: mobileye: eyeq5: add two GPIO bank nodes

In reply to Théo Lebrun

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.

---
 arch/mips/boot/dts/mobileye/eyeq5.dtsi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/mips/boot/dts/mobileye/eyeq5.dtsi +26 -0
index 8d4f65ec912d..0f18ac73620b 100644
@@ -158,6 +158,32 @@ timer {
 				clocks = <&core0_clk>;
 			};
 		};
+
+		gpio0: gpio@1400000 {
+			compatible = "mobileye,eyeq5-gpio";
+			reg = <0x0 0x1400000 0x0 0x1000>;
+			gpio-bank = <0>;
+			ngpios = <29>;
+			interrupt-parent = <&gic>;
+			interrupts = <GIC_SHARED 14 IRQ_TYPE_LEVEL_HIGH>;
+			gpio-controller;
+			#gpio-cells = <2>;
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
+
+		gpio1: gpio@1500000 {
+			compatible = "mobileye,eyeq5-gpio";
+			reg = <0x0 0x1500000 0x0 0x1000>;
+			gpio-bank = <1>;
+			ngpios = <23>;
+			interrupt-parent = <&gic>;
+			interrupts = <GIC_SHARED 14 IRQ_TYPE_LEVEL_HIGH>;
+			gpio-controller;
+			#gpio-cells = <2>;
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
 	};
 };
 
Signature · 1 line
2.44.0
Acked-by on v2 28/30
#58 lore raw

Re: [PATCH v2 28/30] MIPS: mobileye: eyeq5: add two GPIO bank nodes

Quoted 5 lines · Théo Lebrun

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.

Yours,
Linus Walleij

author maintainer
#59 lore raw

PATCH v2 29/30 MIPS: mobileye: eyeq5: add resets to GPIO banks

In reply to Théo Lebrun

The two GPIO banks share a single reset line.

---
 arch/mips/boot/dts/mobileye/eyeq5.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/boot/dts/mobileye/eyeq5.dtsi +2 -0
index 0f18ac73620b..5f00d129c057 100644
@@ -170,6 +170,7 @@ gpio0: gpio@1400000 {
 			#gpio-cells = <2>;
 			interrupt-controller;
 			#interrupt-cells = <2>;
+			resets = <&reset 0 26>;
 		};
 
 		gpio1: gpio@1500000 {
@@ -183,6 +184,7 @@ gpio1: gpio@1500000 {
 			#gpio-cells = <2>;
 			interrupt-controller;
 			#interrupt-cells = <2>;
+			resets = <&reset 0 26>;
 		};
 	};
 };
Signature · 1 line
2.44.0
author maintainer
#61 lore raw

PATCH v2 30/30 MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges

In reply to Théo Lebrun

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

---
 arch/mips/boot/dts/mobileye/eyeq5.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/boot/dts/mobileye/eyeq5.dtsi +2 -0
index 5f00d129c057..68f6c81331d7 100644
@@ -168,6 +168,7 @@ gpio0: gpio@1400000 {
 			interrupts = <GIC_SHARED 14 IRQ_TYPE_LEVEL_HIGH>;
 			gpio-controller;
 			#gpio-cells = <2>;
+			gpio-ranges = <&pinctrl 0 0 29>;
 			interrupt-controller;
 			#interrupt-cells = <2>;
 			resets = <&reset 0 26>;
@@ -182,6 +183,7 @@ gpio1: gpio@1500000 {
 			interrupts = <GIC_SHARED 14 IRQ_TYPE_LEVEL_HIGH>;
 			gpio-controller;
 			#gpio-cells = <2>;
+			gpio-ranges = <&pinctrl 0 29 23>;
 			interrupt-controller;
 			#interrupt-cells = <2>;
 			resets = <&reset 0 26>;
Signature · 1 line
2.44.0
Acked-by on v2 30/30
#62 lore raw

Re: [PATCH v2 30/30] MIPS: mobileye: eyeq5: map GPIOs to pins using gpio-ranges

Quoted 8 lines · Théo Lebrun

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

Yours,
Linus Walleij

#63 lore raw
In reply to Théo Lebrun
Quoted 11 lines · Théo Lebrun

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

Quoted 6 lines

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

author maintainer
#64 lore raw

Hello,

Quoted 20 lines · Linus Walleij
Quoted 11 lines · Théo Lebrun

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

Quoted 6 lines

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.

Quoted 5 lines

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