From: Jisheng Zhang <jszhang@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] gpio: fxl6408: Add suspend/resume support
Date: Sun, 2 Nov 2025 18:05:15 +0800 [thread overview]
Message-ID: <20251102100515.9506-3-jszhang@kernel.org> (raw)
In-Reply-To: <20251102100515.9506-1-jszhang@kernel.org>
Currently, during suspend, do nothing; during resume, just sync the
regmap cache to hw regs.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
drivers/gpio/gpio-fxl6408.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
index ae520305f7a9..805a623ef89c 100644
--- a/drivers/gpio/gpio-fxl6408.c
+++ b/drivers/gpio/gpio-fxl6408.c
@@ -43,6 +43,10 @@
#define FXL6408_NGPIO 8
+struct fxl6408_chip {
+ struct regmap *regmap;
+};
+
static const struct regmap_range rd_range[] = {
{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
@@ -105,6 +109,7 @@ static int fxl6408_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct gpio_desc *reset_gpio;
+ struct fxl6408_chip *chip;
int ret;
struct gpio_regmap_config gpio_config = {
.parent = dev,
@@ -115,6 +120,10 @@ static int fxl6408_probe(struct i2c_client *client)
.ngpio_per_reg = FXL6408_NGPIO,
};
+ chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
+
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio))
return dev_err_probe(dev, PTR_ERR(reset_gpio), "Failed to get reset gpio\n");
@@ -128,6 +137,9 @@ static int fxl6408_probe(struct i2c_client *client)
if (ret)
return ret;
+ chip->regmap = gpio_config.regmap;
+ i2c_set_clientdata(client, chip);
+
/* Disable High-Z of outputs, so that our OUTPUT updates actually take effect. */
ret = regmap_write(gpio_config.regmap, FXL6408_REG_OUTPUT_HIGH_Z, 0);
if (ret)
@@ -136,6 +148,16 @@ static int fxl6408_probe(struct i2c_client *client)
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
}
+static int fxl6408_resume(struct device *dev)
+{
+ struct fxl6408_chip *chip = dev_get_drvdata(dev);
+
+ regcache_mark_dirty(chip->regmap);
+ return regcache_sync(chip->regmap);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(fxl6408_pm_ops, NULL, fxl6408_resume);
+
static const __maybe_unused struct of_device_id fxl6408_dt_ids[] = {
{ .compatible = "fcs,fxl6408" },
{ }
@@ -151,6 +173,7 @@ MODULE_DEVICE_TABLE(i2c, fxl6408_id);
static struct i2c_driver fxl6408_driver = {
.driver = {
.name = "fxl6408",
+ .pm = pm_sleep_ptr(&fxl6408_pm_ops),
.of_match_table = fxl6408_dt_ids,
},
.probe = fxl6408_probe,
--
2.51.0
prev parent reply other threads:[~2025-11-02 10:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 10:05 [PATCH 0/2] gpio: fxl6408: add optional reset and suspend/resume Jisheng Zhang
2025-11-02 10:05 ` [PATCH 1/2] gpio: fxl6408: Add optional reset gpio control Jisheng Zhang
2025-11-02 22:25 ` kernel test robot
2025-11-02 22:35 ` kernel test robot
2025-11-02 10:05 ` Jisheng Zhang [this message]
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=20251102100515.9506-3-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.