Skip to content

Commit 99f9b6c

Browse files
bivvyrkhuangtao
authored andcommitted
mfd: max96745: Enable regcache
Signed-off-by: Wyon Bi <[email protected]> Change-Id: I044343b2de644e2939f014fff84cbc22cd4c29b2
1 parent 7f56984 commit 99f9b6c

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

drivers/mfd/max96745.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,31 @@ static const struct mfd_cell max96745_devs[] = {
3232
},
3333
};
3434

35+
static bool max96745_volatile_reg(struct device *dev, unsigned int reg)
36+
{
37+
switch (reg) {
38+
case 0x0028 ... 0x0029:
39+
case 0x0032 ... 0x0033:
40+
case 0x0076:
41+
case 0x0086:
42+
case 0x0100:
43+
case 0x0200 ... 0x02ce:
44+
case 0x7000:
45+
case 0x7070:
46+
case 0x7074:
47+
return false;
48+
default:
49+
return true;
50+
}
51+
}
52+
3553
static const struct regmap_config max96745_regmap_config = {
3654
.name = "max96745",
3755
.reg_bits = 16,
3856
.val_bits = 8,
3957
.max_register = 0x8000,
58+
.volatile_reg = max96745_volatile_reg,
59+
.cache_type = REGCACHE_RBTREE,
4060
};
4161

4262
static int max96745_select(struct i2c_mux_core *muxc, u32 chan)
@@ -101,7 +121,6 @@ static int max96745_power_on(struct max96745 *max96745)
101121
regmap_update_bits(max96745->regmap, 0x0086, DIS_REM_CC,
102122
FIELD_PREP(DIS_REM_CC, 1));
103123

104-
105124
return 0;
106125
}
107126

@@ -192,6 +211,28 @@ static void max96745_i2c_shutdown(struct i2c_client *client)
192211
max96745_power_off(max96745);
193212
}
194213

214+
static int __maybe_unused max96745_suspend(struct device *dev)
215+
{
216+
struct max96745 *max96745 = dev_get_drvdata(dev);
217+
218+
regcache_mark_dirty(max96745->regmap);
219+
regcache_cache_only(max96745->regmap, true);
220+
221+
return 0;
222+
}
223+
224+
static int __maybe_unused max96745_resume(struct device *dev)
225+
{
226+
struct max96745 *max96745 = dev_get_drvdata(dev);
227+
228+
regcache_cache_only(max96745->regmap, false);
229+
regcache_sync(max96745->regmap);
230+
231+
return 0;
232+
}
233+
234+
static SIMPLE_DEV_PM_OPS(max96745_pm_ops, max96745_suspend, max96745_resume);
235+
195236
static const struct of_device_id max96745_of_match[] = {
196237
{ .compatible = "maxim,max96745", },
197238
{}
@@ -202,6 +243,7 @@ static struct i2c_driver max96745_i2c_driver = {
202243
.driver = {
203244
.name = "max96745",
204245
.of_match_table = max96745_of_match,
246+
.pm = &max96745_pm_ops,
205247
},
206248
.probe_new = max96745_i2c_probe,
207249
.remove = max96745_i2c_remove,

0 commit comments

Comments
 (0)