]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: fxl6408: Add suspend/resume support
authorJisheng Zhang <jszhang@kernel.org>
Wed, 19 Nov 2025 14:04:55 +0000 (22:04 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 20 Nov 2025 13:15:30 +0000 (14:15 +0100)
Currently, during suspend, do nothing; during resume, just sync the
regmap cache to hw regs.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://lore.kernel.org/r/20251119140455.10096-1-jszhang@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-fxl6408.c

index 86ebc66b11041c7cc9058297786786b7eb0f81d3..afc1b8461dabbbfcc96b9f59c3d12d84e642e6f5 100644 (file)
@@ -123,6 +123,8 @@ static int fxl6408_probe(struct i2c_client *client)
        if (ret)
                return ret;
 
+       i2c_set_clientdata(client, gpio_config.regmap);
+
        /* 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)
@@ -131,6 +133,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 regmap *regmap = dev_get_drvdata(dev);
+
+       regcache_mark_dirty(regmap);
+       return regcache_sync(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" },
        { }
@@ -146,6 +158,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,