[PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration
From: Gianfranco Mariotti
Date: Thu Nov 26 2026 - 13:03:42 EST
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@xxxxxxxxx>
---
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@xxxxxxxxxxx>
*/
+#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