Devicetree
 help / color / mirror / Atom feed
From: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
To: Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Francesco Dolcini <francesco.dolcini@toradex.com>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
Subject: [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration
Date: Thu, 26 Nov 2026 19:03:14 +0100	[thread overview]
Message-ID: <20261126180315.98034-5-gianfranco.mariotti94@gmail.com> (raw)
In-Reply-To: <20261126180315.98034-1-gianfranco.mariotti94@gmail.com>

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


  parent reply	other threads:[~2026-11-26 18:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Gianfranco Mariotti [this message]
2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126180315.98034-5-gianfranco.mariotti94@gmail.com \
    --to=gianfranco.mariotti94@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox