Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support
@ 2026-11-26 18:03 Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

This series fixes a regmap range / burst-transfer issue in gpio-fxl6408
and extends the binding and driver to cover its pin- and
register-compatible second source (Diodes Incorporated PI4IOE5V6408) as
well as the hardware features omitted from the initial minimal driver:

- Patch 1 fixes rd_range/wr_range exposing reserved even register 0x04
  (and omitting readable 0x07), and disables unsupported I2C burst
  transfers via use_single_read/use_single_write.
- Patch 2 splits fcs,fxl6408 out of trivial-gpio.yaml into a dedicated
  schema documenting reset-gpios, vcc/vddio supplies, and interrupt
  controller properties, and adds the diodes,pi4ioe5v6408 compatible
  with fallback to fcs,fxl6408.
- Patch 3 adds optional vcc/vddio regulator enablement and reset-gpios
  handling during probe.
- Patch 4 implements pull-up, pull-down, and bias-disable pin
  configuration via gpio-regmap's .set_config hook.
- Patch 5 adds rising/falling edge interrupt controller support using
  regmap-irq and gpio-regmap.

Hardware-tested on a Diodes Incorporated PI4IOE5V6408 (I2C register
access, reset-gpios, pull-up/pull-down/bias-disable configuration,
push-pull output, input status, and rising/falling edge interrupts).

Gianfranco Mariotti (5):
  gpio: fxl6408: Fix reserved register access and disable burst
    transfers
  dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add
    diodes,pi4ioe5v6408
  gpio: fxl6408: Support optional power supplies and reset GPIO
  gpio: fxl6408: Add pull-up and pull-down bias configuration
  gpio: fxl6408: Add interrupt controller support

 .../devicetree/bindings/gpio/fcs,fxl6408.yaml |  97 ++++++++++
 .../bindings/gpio/trivial-gpio.yaml           |   1 -
 drivers/gpio/Kconfig                          |   2 +
 drivers/gpio/gpio-fxl6408.c                   | 181 +++++++++++++++++-
 4 files changed, 278 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml


base-commit: c6d8ebd7324cefda867a701b4341605b681aa3f5
-- 
2.25.1


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

* [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers
  2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
@ 2026-11-26 18:03 ` Gianfranco Mariotti
  2026-11-26 18:19   ` sashiko-bot
  2026-11-26 18:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

All valid registers on the FXL6408 are at odd addresses (0x01..0x13),
while all even addresses (0x02..0x12) are marked Reserved in the
datasheet. In addition, the FXL6408 datasheet explicitly states that I2C
burst read and write modes are not supported.

Currently rd_range and wr_range specify { FXL6408_REG_IO_DIR,
FXL6408_REG_OUTPUT } (0x03..0x05), which exposes the reserved register
0x04 to regcache_hw_init() and debugfs, and causes REGCACHE_MAPLE to
group 0x03..0x05 into a contiguous block that regcache_sync() attempts
to restore with a multi-byte raw I2C write on resume. Meanwhile, the
read/write OUTPUT_HIGH_Z register (0x07) was omitted from rd_range.

List only the valid odd registers in rd_range and wr_range, include
FXL6408_REG_OUTPUT_HIGH_Z in rd_range, and set use_single_read and
use_single_write in regmap_config.

Fixes: 03810031c91d ("gpio: fxl6408: add I2C GPIO expander driver")
Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpio/gpio-fxl6408.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index 8a7e70180efd9..9f80ea1214e03 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -45,13 +45,16 @@
 
 static const struct regmap_range rd_range[] = {
 	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
-	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
+	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
+	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
+	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
 	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
 };
 
 static const struct regmap_range wr_range[] = {
 	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
-	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
+	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
+	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
 	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
 };
 
@@ -78,6 +81,8 @@ static const struct regmap_access_table volatile_table = {
 static const struct regmap_config regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
+	.use_single_read = true,
+	.use_single_write = true,
 
 	.max_register = FXL6408_REG_INT_STS,
 	.wr_table = &wr_table,
-- 
2.25.1


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

* [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408
  2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
@ 2026-11-26 18:03 ` Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO Gianfranco Mariotti
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

The Fairchild FXL6408 and its pin- and register-compatible second source
Diodes Incorporated PI4IOE5V6408 provide an active-low hardware reset
input, dual power rails (I2C bus and GPIO port bank), and an open-drain
interrupt output.

Move fcs,fxl6408 out of trivial-gpio.yaml back into a dedicated schema
to document reset-gpios, power supplies, and interrupt controller
properties, and add the diodes,pi4ioe5v6408 compatible with fallback to
fcs,fxl6408.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 .../devicetree/bindings/gpio/fcs,fxl6408.yaml | 97 +++++++++++++++++++
 .../bindings/gpio/trivial-gpio.yaml           |  1 -
 2 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml

diff --git a/Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml b/Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml
new file mode 100644
index 0000000000000..5977aa026ec14
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/fcs,fxl6408.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Fairchild FXL6408 I2C GPIO Expander
+
+maintainers:
+  - Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - const: diodes,pi4ioe5v6408
+          - const: fcs,fxl6408
+      - const: fcs,fxl6408
+
+  reg:
+    maxItems: 1
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-controller: true
+
+  gpio-line-names:
+    minItems: 1
+    maxItems: 8
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+  reset-gpios:
+    maxItems: 1
+    description: Active-low GPIO connected to the RESET pin.
+
+  vcc-supply:
+    description: I2C-bus interface power supply (VCC / VDD(I2C_bus)).
+
+  vddio-supply:
+    description: GPIO port power supply (VDDIO / VDD(P)).
+
+  wakeup-source: true
+
+dependencies:
+  interrupt-controller: [ interrupts ]
+  "#interrupt-cells": [ interrupt-controller ]
+  wakeup-source: [ interrupts ]
+
+patternProperties:
+  "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$":
+    type: object
+    required:
+      - gpio-hog
+
+required:
+  - compatible
+  - reg
+  - gpio-controller
+  - "#gpio-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        gpio@43 {
+            compatible = "diodes,pi4ioe5v6408", "fcs,fxl6408";
+            reg = <0x43>;
+            gpio-controller;
+            #gpio-cells = <2>;
+            interrupt-parent = <&gpio1>;
+            interrupts = <5 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <2>;
+            reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+            vcc-supply = <&reg_1v8>;
+            vddio-supply = <&reg_3v3>;
+            gpio-line-names = "Wi-Fi_W_DISABLE", "Wi-Fi_WKUP_WLAN",
+                              "PWR_EN_+V3.3_WiFi_N", "PCIe_REF_CLK_EN",
+                              "USB_RESET_N", "USB_BYPASS_N", "Wi-Fi_PDn",
+                              "Wi-Fi_WKUP_BT";
+        };
+    };
diff --git a/Documentation/devicetree/bindings/gpio/trivial-gpio.yaml b/Documentation/devicetree/bindings/gpio/trivial-gpio.yaml
index fe9b14a72d698..aca42dd1ad20a 100644
--- a/Documentation/devicetree/bindings/gpio/trivial-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/trivial-gpio.yaml
@@ -21,7 +21,6 @@ properties:
           - cirrus,ep7209-gpio
           - cznic,moxtet-gpio
           - dlg,slg7xl45106
-          - fcs,fxl6408
           - fsl,ls1046aqds-fpga-gpio-stat-pres2
           - fsl,lx2160ardb-fpga-gpio-sfp
           - gateworks,pld-gpio
-- 
2.25.1


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

* [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO
  2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
@ 2026-11-26 18:03 ` Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
  4 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

Enable the optional vcc and vddio power supplies and pulse the optional
reset GPIO (minimum pulse width and recovery time of 150 ns according to
the FXL6408 / PI4IOE5V6408 datasheets) prior to initializing the I2C
regmap and reading the device ID.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpio/gpio-fxl6408.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index 9f80ea1214e03..5132177ab2837 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -7,12 +7,15 @@
  * Author: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
  */
 
+#include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio/regmap.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 
 #define FXL6408_REG_DEVICE_ID		0x01
 #define FXL6408_MF_FAIRCHILD		0b101
@@ -106,9 +109,15 @@ static int fxl6408_identify(struct device *dev, struct regmap *regmap)
 	return 0;
 }
 
+static const char * const fxl6408_supplies[] = {
+	"vcc",
+	"vddio",
+};
+
 static int fxl6408_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
+	struct gpio_desc *reset_gpio;
 	int ret;
 	struct gpio_regmap_config gpio_config = {
 		.parent = dev,
@@ -119,6 +128,21 @@ static int fxl6408_probe(struct i2c_client *client)
 		.ngpio_per_reg = FXL6408_NGPIO,
 	};
 
+	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(fxl6408_supplies),
+					     fxl6408_supplies);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to enable supplies\n");
+
+	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(reset_gpio),
+				     "failed to get reset GPIO\n");
+	if (reset_gpio) {
+		fsleep(1);
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		fsleep(1);
+	}
+
 	gpio_config.regmap = devm_regmap_init_i2c(client, &regmap);
 	if (IS_ERR(gpio_config.regmap))
 		return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
-- 
2.25.1


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

* [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration
  2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
                   ` (2 preceding siblings ...)
  2026-11-26 18:03 ` [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO Gianfranco Mariotti
@ 2026-11-26 18:03 ` Gianfranco Mariotti
  2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
  4 siblings, 0 replies; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

The FXL6408 and PI4IOE5V6408 GPIO expanders provide per-pin programmable
pull-up / pull-down resistor selection (register 0x0d) and enable
control (register 0x0b).

Expose both registers in the regmap access tables and wire up the
gpio-regmap .set_config callback to support PIN_CONFIG_BIAS_DISABLE,
PIN_CONFIG_BIAS_PULL_UP, and PIN_CONFIG_BIAS_PULL_DOWN.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpio/gpio-fxl6408.c | 47 +++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index 5132177ab2837..ae9003fc513a1 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -7,6 +7,7 @@
  * Author: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
  */
 
+#include <linux/bits.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
@@ -14,6 +15,7 @@
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/pinctrl/pinconf-generic.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 
@@ -33,6 +35,12 @@
 /* Bits here make the output High-Z, instead of the OUTPUT value. */
 #define FXL6408_REG_OUTPUT_HIGH_Z	0x07
 
+/* Bits here enable either pull-up or pull-down according to FXL6408_REG_PULL_UP. */
+#define FXL6408_REG_PULL_ENABLE		0x0b
+
+/* Bits set here (when PULL_ENABLE is set) select pull-up instead of pull-down. */
+#define FXL6408_REG_PULL_UP		0x0d
+
 /* Returns the current status (1 = HIGH) of the input pins. */
 #define FXL6408_REG_INPUT_STATUS	0x0f
 
@@ -51,6 +59,8 @@ static const struct regmap_range rd_range[] = {
 	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
 	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
 	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
+	{ FXL6408_REG_PULL_ENABLE, FXL6408_REG_PULL_ENABLE },
+	{ FXL6408_REG_PULL_UP, FXL6408_REG_PULL_UP },
 	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
 };
 
@@ -59,6 +69,8 @@ static const struct regmap_range wr_range[] = {
 	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
 	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
 	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
+	{ FXL6408_REG_PULL_ENABLE, FXL6408_REG_PULL_ENABLE },
+	{ FXL6408_REG_PULL_UP, FXL6408_REG_PULL_UP },
 };
 
 static const struct regmap_range volatile_range[] = {
@@ -96,6 +108,38 @@ static const struct regmap_config regmap = {
 	.num_reg_defaults_raw = FXL6408_REG_INT_STS + 1,
 };
 
+static int fxl6408_gpio_set_config(struct gpio_regmap *gpio,
+				   struct gpio_chip *chip,
+				   unsigned int offset, unsigned long config)
+{
+	struct regmap *regmap = gpio_regmap_get_drvdata(gpio);
+	unsigned int mask = BIT(offset);
+	unsigned int enable = 0, pullup = 0;
+	int ret;
+
+	switch (pinconf_to_config_param(config)) {
+	case PIN_CONFIG_BIAS_DISABLE:
+		break;
+	case PIN_CONFIG_BIAS_PULL_UP:
+		enable = mask;
+		pullup = mask;
+		break;
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		enable = mask;
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	if (enable) {
+		ret = regmap_update_bits(regmap, FXL6408_REG_PULL_UP, mask, pullup);
+		if (ret)
+			return ret;
+	}
+
+	return regmap_update_bits(regmap, FXL6408_REG_PULL_ENABLE, mask, enable);
+}
+
 static int fxl6408_identify(struct device *dev, struct regmap *regmap)
 {
 	int val, ret;
@@ -126,6 +170,7 @@ static int fxl6408_probe(struct i2c_client *client)
 		.reg_set_base = GPIO_REGMAP_ADDR(FXL6408_REG_OUTPUT),
 		.reg_dir_out_base = GPIO_REGMAP_ADDR(FXL6408_REG_IO_DIR),
 		.ngpio_per_reg = FXL6408_NGPIO,
+		.set_config = fxl6408_gpio_set_config,
 	};
 
 	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(fxl6408_supplies),
@@ -148,6 +193,8 @@ static int fxl6408_probe(struct i2c_client *client)
 		return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
 				     "failed to allocate register map\n");
 
+	gpio_config.drvdata = gpio_config.regmap;
+
 	ret = fxl6408_identify(dev, gpio_config.regmap);
 	if (ret)
 		return ret;
-- 
2.25.1


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

* [PATCH 5/5] gpio: fxl6408: Add interrupt controller support
  2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
                   ` (3 preceding siblings ...)
  2026-11-26 18:03 ` [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration Gianfranco Mariotti
@ 2026-11-26 18:03 ` Gianfranco Mariotti
  2026-11-26 18:25   ` sashiko-bot
  4 siblings, 1 reply; 8+ messages in thread
From: Gianfranco Mariotti @ 2026-11-26 18:03 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Emanuele Ghidoli, Andy Shevchenko, Francesco Dolcini, linux-gpio,
	devicetree, linux-kernel, Gianfranco Mariotti

The FXL6408 and PI4IOE5V6408 GPIO expanders feature an open-drain
active-low interrupt output asserted when an unmasked input transitions
away from the state programmed in INPUT_DEFAULT_STATE (register 0x09).
Reading INT_STS (register 0x13) clears all latched interrupt status bits
and releases the INT line, requiring the input to return to its default
state before another interrupt is generated.

Wire up interrupt controller support via regmap-irq and gpio-regmap for
rising and falling edge triggers, mark the clear-on-read registers
(DEVICE_ID and INT_STS) as precious, and clear RST_INT on system resume
in case power was lost during suspend.

Signed-off-by: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
---
 drivers/gpio/Kconfig        |   2 +
 drivers/gpio/gpio-fxl6408.c | 101 ++++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0e197fd2bd6d2..a622cee9df1bd 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1204,8 +1204,10 @@ config GPIO_ADNP
 
 config GPIO_FXL6408
 	tristate "FXL6408 I2C GPIO expander"
+	select GPIOLIB_IRQCHIP
 	select GPIO_REGMAP
 	select REGMAP_I2C
+	select REGMAP_IRQ
 	help
 	  GPIO driver for Fairchild Semiconductor FXL6408 GPIO expander.
 
diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index ae9003fc513a1..d503383fb119b 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -13,11 +13,14 @@
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/regmap.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
 #define FXL6408_REG_DEVICE_ID		0x01
 #define FXL6408_MF_FAIRCHILD		0b101
@@ -35,6 +38,12 @@
 /* Bits here make the output High-Z, instead of the OUTPUT value. */
 #define FXL6408_REG_OUTPUT_HIGH_Z	0x07
 
+/*
+ * Bits here define the expected input state of the GPIO.
+ * INT_STS bits are set when the input transitions away from this value.
+ */
+#define FXL6408_REG_INPUT_DEFAULT_STATE	0x09
+
 /* Bits here enable either pull-up or pull-down according to FXL6408_REG_PULL_UP. */
 #define FXL6408_REG_PULL_ENABLE		0x0b
 
@@ -44,6 +53,9 @@
 /* Returns the current status (1 = HIGH) of the input pins. */
 #define FXL6408_REG_INPUT_STATUS	0x0f
 
+/* Bits set here mask (disable) interrupts from the corresponding input pins. */
+#define FXL6408_REG_INT_MASK		0x11
+
 /*
  * Return the current interrupt status
  * This bit is HIGH if input GPIO != default state (register 09h).
@@ -59,9 +71,12 @@ static const struct regmap_range rd_range[] = {
 	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
 	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
 	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
+	{ FXL6408_REG_INPUT_DEFAULT_STATE, FXL6408_REG_INPUT_DEFAULT_STATE },
 	{ FXL6408_REG_PULL_ENABLE, FXL6408_REG_PULL_ENABLE },
 	{ FXL6408_REG_PULL_UP, FXL6408_REG_PULL_UP },
 	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
+	{ FXL6408_REG_INT_MASK, FXL6408_REG_INT_MASK },
+	{ FXL6408_REG_INT_STS, FXL6408_REG_INT_STS },
 };
 
 static const struct regmap_range wr_range[] = {
@@ -69,13 +84,21 @@ static const struct regmap_range wr_range[] = {
 	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
 	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
 	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
+	{ FXL6408_REG_INPUT_DEFAULT_STATE, FXL6408_REG_INPUT_DEFAULT_STATE },
 	{ FXL6408_REG_PULL_ENABLE, FXL6408_REG_PULL_ENABLE },
 	{ FXL6408_REG_PULL_UP, FXL6408_REG_PULL_UP },
+	{ FXL6408_REG_INT_MASK, FXL6408_REG_INT_MASK },
 };
 
 static const struct regmap_range volatile_range[] = {
 	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
 	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
+	{ FXL6408_REG_INT_STS, FXL6408_REG_INT_STS },
+};
+
+static const struct regmap_range precious_range[] = {
+	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
+	{ FXL6408_REG_INT_STS, FXL6408_REG_INT_STS },
 };
 
 static const struct regmap_access_table rd_table = {
@@ -93,6 +116,11 @@ static const struct regmap_access_table volatile_table = {
 	.n_yes_ranges = ARRAY_SIZE(volatile_range),
 };
 
+static const struct regmap_access_table precious_table = {
+	.yes_ranges = precious_range,
+	.n_yes_ranges = ARRAY_SIZE(precious_range),
+};
+
 static const struct regmap_config regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -103,11 +131,53 @@ static const struct regmap_config regmap = {
 	.wr_table = &wr_table,
 	.rd_table = &rd_table,
 	.volatile_table = &volatile_table,
+	.precious_table = &precious_table,
 
 	.cache_type = REGCACHE_MAPLE,
 	.num_reg_defaults_raw = FXL6408_REG_INT_STS + 1,
 };
 
+static const unsigned int fxl6408_irq_config_base[] = {
+	FXL6408_REG_INPUT_DEFAULT_STATE,
+};
+
+#define FXL6408_REGMAP_IRQ(_n)						\
+	[_n] = {							\
+		.mask = BIT(_n),					\
+		.type = {						\
+			.types_supported = IRQ_TYPE_SENSE_MASK,		\
+		},							\
+	}
+
+static const struct regmap_irq fxl6408_regmap_irqs[FXL6408_NGPIO] = {
+	FXL6408_REGMAP_IRQ(0),
+	FXL6408_REGMAP_IRQ(1),
+	FXL6408_REGMAP_IRQ(2),
+	FXL6408_REGMAP_IRQ(3),
+	FXL6408_REGMAP_IRQ(4),
+	FXL6408_REGMAP_IRQ(5),
+	FXL6408_REGMAP_IRQ(6),
+	FXL6408_REGMAP_IRQ(7),
+};
+
+static int fxl6408_irq_set_type_config(unsigned int **buf, unsigned int type,
+				       const struct regmap_irq *irq_data,
+				       int idx, void *irq_drv_data)
+{
+	switch (type) {
+	case IRQ_TYPE_EDGE_FALLING:
+		buf[0][idx] |= irq_data->mask;
+		break;
+	case IRQ_TYPE_EDGE_RISING:
+		buf[0][idx] &= ~irq_data->mask;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int fxl6408_gpio_set_config(struct gpio_regmap *gpio,
 				   struct gpio_chip *chip,
 				   unsigned int offset, unsigned long config)
@@ -206,12 +276,43 @@ static int fxl6408_probe(struct i2c_client *client)
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n");
 
+	if (client->irq > 0) {
+		struct regmap_irq_chip *irq_chip;
+
+		irq_chip = devm_kzalloc_obj(dev, *irq_chip);
+		if (!irq_chip)
+			return -ENOMEM;
+
+		irq_chip->name = dev_name(dev);
+		irq_chip->status_base = FXL6408_REG_INT_STS;
+		irq_chip->mask_base = FXL6408_REG_INT_MASK;
+		irq_chip->config_base = fxl6408_irq_config_base;
+		irq_chip->num_config_bases = ARRAY_SIZE(fxl6408_irq_config_base);
+		irq_chip->num_config_regs = 1;
+		irq_chip->num_regs = 1;
+		irq_chip->irqs = fxl6408_regmap_irqs;
+		irq_chip->num_irqs = ARRAY_SIZE(fxl6408_regmap_irqs);
+		irq_chip->init_ack_masked = true;
+		irq_chip->clear_on_unmask = true;
+		irq_chip->set_type_config = fxl6408_irq_set_type_config;
+
+		gpio_config.regmap_irq_chip = irq_chip;
+		gpio_config.regmap_irq_line = client->irq;
+		gpio_config.regmap_irq_flags = IRQF_ONESHOT | IRQF_SHARED;
+	}
+
 	return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
 }
 
 static int fxl6408_resume(struct device *dev)
 {
 	struct regmap *regmap = dev_get_drvdata(dev);
+	int val, ret;
+
+	/* Clear RST_INT in case power was lost during suspend. */
+	ret = regmap_read(regmap, FXL6408_REG_DEVICE_ID, &val);
+	if (ret)
+		return ret;
 
 	regcache_mark_dirty(regmap);
 	return regcache_sync(regmap);
-- 
2.25.1


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

* Re: [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers
  2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
@ 2026-11-26 18:19   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-26 18:19 UTC (permalink / raw)
  To: Gianfranco Mariotti; +Cc: linux-gpio, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] gpio: fxl6408: raw read of reserved regs in
  regcache_hw_init()
- [Medium] gpio: fxl6408: skipped OUTPUT_HIGH_Z restore in
  fxl6408_resume()
--

commit 1f216d3ac023de920e5ee09cfeb09b23ea1d4d61
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

gpio: fxl6408: Fix reserved register access and disable burst transfers

This commit restricts rd_range and wr_range to valid odd register addresses,
adds FXL6408_REG_OUTPUT_HIGH_Z to rd_range, and enables use_single_read and
use_single_write in regmap_config.

> diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
> index 8a7e70180efd9..9f80ea1214e03 100644
> --- a/drivers/gpio/gpio-fxl6408.c
> +++ b/drivers/gpio/gpio-fxl6408.c
> @@ -45,13 +45,16 @@
>  
>  static const struct regmap_range rd_range[] = {
>  	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
> -	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
> +	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
>  	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
>  };

[Severity: Medium]
Can adding FXL6408_REG_OUTPUT_HIGH_Z to rd_range while relying on
num_reg_defaults_raw cause fxl6408_resume() to skip restoring
FXL6408_REG_OUTPUT_HIGH_Z?

With FXL6408_REG_OUTPUT_HIGH_Z in rd_range, regcache_hw_init() reads its
live value during devm_regmap_init_i2c() and records that as
map->reg_defaults[] before fxl6408_probe() writes 0 to disable High-Z mode.
If the register was already 0 at probe time (for example from the bootloader
or across a driver rebind or warm reboot), map->reg_defaults[] records 0
instead of the power-on reset default (0xff).  If the chip loses power during
suspend and resets to 0xff, regcache_mark_dirty() and regcache_sync() in
fxl6408_resume() see the cached 0 matching map->reg_defaults[] and skip the
write, leaving all GPIO outputs stuck in High-Z.

>  static const struct regmap_range wr_range[] = {
>  	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
> -	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
> +	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
>  	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
>  };
>  
> @@ -78,6 +81,8 @@ static const struct regmap_access_table volatile_table = {
>  static const struct regmap_config regmap = {
>  	.reg_bits = 8,
>  	.val_bits = 8,
> +	.use_single_read = true,
> +	.use_single_write = true,
>  
>  	.max_register = FXL6408_REG_INT_STS,
>  	.wr_table = &wr_table,

[Severity: Medium]
Does setting use_single_read with num_reg_defaults_raw = FXL6408_REG_INT_STS
+ 1 still read every reserved even register during regcache_hw_init()?

When reg_defaults_raw is unset, regcache_hw_init() sets map->cache_bypass =
true and calls regmap_raw_read(map, 0, tmp_buf, map->cache_size_raw) before
falling back to the loop that checks regmap_readable() and
regmap_volatile().  In regmap_raw_read(), cache_bypass and use_single_read
split that 20-byte transfer into 20 single-byte _regmap_raw_read() calls
across 0x00..0x13 without consulting rd_table or volatile_table, reading all
reserved even addresses as well as the clear-on-read status registers 0x01
and 0x13.

Providing explicit reg_defaults for the cacheable registers instead of
num_reg_defaults_raw would avoid both the raw hardware readback in
regcache_hw_init() and the stale default snapshot for
FXL6408_REG_OUTPUT_HIGH_Z.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126180315.98034-1-gianfranco.mariotti94@gmail.com?part=1

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

* Re: [PATCH 5/5] gpio: fxl6408: Add interrupt controller support
  2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
@ 2026-11-26 18:25   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-26 18:25 UTC (permalink / raw)
  To: Gianfranco Mariotti; +Cc: linux-gpio, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] gpio: fxl6408: level-low IRQ storm and stale INT_STS in
  fxl6408_resume()
- [High] gpio: fxl6408: spurious and lost IRQs on unmask in
  fxl6408_probe()
--

commit 727720e716ae84ca553c153e1d2e86dd4241253c
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

gpio: fxl6408: Add interrupt controller support

This commit adds interrupt controller support for the FXL6408 and
PI4IOE5V6408 GPIO expanders via regmap-irq and gpio-regmap, marks
FXL6408_REG_DEVICE_ID and FXL6408_REG_INT_STS as precious, and clears
RST_INT on resume.

> diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
> index ae9003fc513a1..d503383fb119b 100644
> --- a/drivers/gpio/gpio-fxl6408.c
> +++ b/drivers/gpio/gpio-fxl6408.c

[ ... ]

> @@ -206,12 +276,43 @@ static int fxl6408_probe(struct i2c_client *client)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n");
>  
> +	if (client->irq > 0) {
> +		struct regmap_irq_chip *irq_chip;
> +
> +		irq_chip = devm_kzalloc_obj(dev, *irq_chip);
> +		if (!irq_chip)
> +			return -ENOMEM;
> +
> +		irq_chip->name = dev_name(dev);
> +		irq_chip->status_base = FXL6408_REG_INT_STS;
> +		irq_chip->mask_base = FXL6408_REG_INT_MASK;
> +		irq_chip->config_base = fxl6408_irq_config_base;
> +		irq_chip->num_config_bases = ARRAY_SIZE(fxl6408_irq_config_base);
> +		irq_chip->num_config_regs = 1;
> +		irq_chip->num_regs = 1;
> +		irq_chip->irqs = fxl6408_regmap_irqs;
> +		irq_chip->num_irqs = ARRAY_SIZE(fxl6408_regmap_irqs);
> +		irq_chip->init_ack_masked = true;
> +		irq_chip->clear_on_unmask = true;
> +		irq_chip->set_type_config = fxl6408_irq_set_type_config;

[Severity: High]
Does configuring FXL6408_REG_INPUT_DEFAULT_STATE through config_base
with clear_on_unmask cause spurious interrupts and drop pending ones on
other lines?

In drivers/base/regmap/regmap-irq.c, regmap_irq_sync_unlock() reads and
discards status_base (FXL6408_REG_INT_STS) first, writes mask_base
(FXL6408_REG_INT_MASK) second, and writes config_base
(FXL6408_REG_INPUT_DEFAULT_STATE) last.  When IRQ_TYPE_EDGE_FALLING is
requested on a line that is already low, FXL6408_REG_INT_STS is cleared
while FXL6408_REG_INPUT_DEFAULT_STATE still holds 0, the line is
unmasked, and setting the default state bit to 1 makes hardware latch
an immediate interrupt because the current input (0) differs from the
new default state (1).

In addition, reading FXL6408_REG_INT_STS clears all eight status bits
at once and requires an input to return to its default state before
another interrupt can latch.  When clear_on_unmask discards
FXL6408_REG_INT_STS while enabling one line, any interrupt already
latched on the other seven lines is lost, leaving an active peripheral
on another pin unable to trigger again.

> +
> +		gpio_config.regmap_irq_chip = irq_chip;
> +		gpio_config.regmap_irq_line = client->irq;
> +		gpio_config.regmap_irq_flags = IRQF_ONESHOT | IRQF_SHARED;
> +	}
> +
>  	return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
>  }
>  
>  static int fxl6408_resume(struct device *dev)
>  {
>  	struct regmap *regmap = dev_get_drvdata(dev);
> +	int val, ret;
> +
> +	/* Clear RST_INT in case power was lost during suspend. */
> +	ret = regmap_read(regmap, FXL6408_REG_DEVICE_ID, &val);
> +	if (ret)
> +		return ret;
>  
>  	regcache_mark_dirty(regmap);
>  	return regcache_sync(regmap);

[Severity: High]
Can losing power during suspend trigger an interrupt storm before
fxl6408_resume() runs, and spurious interrupts after regcache_sync()?

On power-on reset, RST_INT in FXL6408_REG_DEVICE_ID asserts the
active-low INT line until register 0x01 is read.  Because fxl6408_pm_ops
has no suspend callback to disable client->irq, resume_device_irqs()
unmasks the parent IRQ in dpm_resume_noirq() before fxl6408_resume()
runs in dpm_resume().  regmap_irq_thread() then wakes repeatedly and
only reads FXL6408_REG_INT_STS, which does not clear RST_INT in
FXL6408_REG_DEVICE_ID.

Furthermore, while FXL6408_REG_INPUT_DEFAULT_STATE and the pull
registers are at their 0x00 reset values (and while regcache_sync()
restores register 0x09 before the pull registers at 0x0b and 0x0d), any
input that is high latches its bit in FXL6408_REG_INT_STS.  Without
reading FXL6408_REG_INT_STS after restoring configuration and before
unmasking FXL6408_REG_INT_MASK, unmasking fires those stale interrupts.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126180315.98034-1-gianfranco.mariotti94@gmail.com?part=5

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

end of thread, other threads:[~2026-11-26 18:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
2026-11-26 18:19   ` sashiko-bot
2026-11-26 18:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
2026-11-26 18:25   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox