From ccf03b5e2d0ec20501238190b1dc5c5beff800fa Mon Sep 17 00:00:00 2001 From: Guochun Huang Date: Sat, 20 Aug 2022 15:25:23 +0800 Subject: [PATCH] mfd: max96755f: Enable regcache Signed-off-by: Guochun Huang Change-Id: I1554f964da231b2b0557010fee31dcfbeda3997a --- drivers/mfd/max96755f.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/mfd/max96755f.c b/drivers/mfd/max96755f.c index 30a533395468..6b7b10339ecf 100644 --- a/drivers/mfd/max96755f.c +++ b/drivers/mfd/max96755f.c @@ -37,11 +37,33 @@ static const struct mfd_cell max96755f_devs[] = { }, }; +static bool max96755f_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x0002: + case 0x0010: + case 0x0013: + case 0x0053: + case 0x0057: + case 0x02be ... 0x02fc: + case 0x0311: + case 0x032a: + case 0x0330 ... 0x0331: + case 0x0385 ... 0x0387: + case 0x03a4 ... 0x03ae: + return false; + default: + return true; + } +} + static const struct regmap_config max96755f_regmap_config = { .name = "max96755f", .reg_bits = 16, .val_bits = 8, .max_register = 0x1b17, + .volatile_reg = max96755f_volatile_reg, + .cache_type = REGCACHE_RBTREE, }; static int max96755f_select(struct i2c_mux_core *muxc, u32 chan) @@ -309,6 +331,28 @@ static void max96755f_i2c_shutdown(struct i2c_client *client) max96755f_power_off(max96755f); } +static int __maybe_unused max96755f_suspend(struct device *dev) +{ + struct max96755f *max96755f = dev_get_drvdata(dev); + + regcache_mark_dirty(max96755f->regmap); + regcache_cache_only(max96755f->regmap, true); + + return 0; +} + +static int __maybe_unused max96755f_resume(struct device *dev) +{ + struct max96755f *max96755f = dev_get_drvdata(dev); + + regcache_cache_only(max96755f->regmap, false); + regcache_sync(max96755f->regmap); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(max96755f_pm_ops, max96755f_suspend, max96755f_resume); + static const struct of_device_id max96755f_of_match[] = { { .compatible = "maxim,max96755f", }, {} @@ -319,6 +363,7 @@ static struct i2c_driver max96755f_i2c_driver = { .driver = { .name = "max96755f", .of_match_table = max96755f_of_match, + .pm = &max96755f_pm_ops, }, .probe_new = max96755f_i2c_probe, .remove = max96755f_i2c_remove,