* [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; 6+ 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] 6+ 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:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ 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 [flat|nested] 6+ 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; 6+ 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 = <®_1v8>;
+ vddio-supply = <®_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 [flat|nested] 6+ 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; 6+ 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, ®map);
if (IS_ERR(gpio_config.regmap))
return dev_err_probe(dev, PTR_ERR(gpio_config.regmap),
--
2.25.1
^ permalink raw reply [flat|nested] 6+ 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; 6+ 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 [flat|nested] 6+ 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
4 siblings, 0 replies; 6+ 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 [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-26 18:03 UTC | newest]
Thread overview: 6+ 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: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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®