Skip to content

Commit b65e914

Browse files
committed
regulator: mp8859: Specify register accessibility and enable caching
Avoid needless accesses to the hardware by caching register values that we know, marking status registers as volatile as appropriate. Tested-by: Markus Reichl <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b9262cc commit b65e914

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

drivers/regulator/mp8859.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,47 @@ static const struct linear_range mp8859_dcdc_ranges[] = {
7777
REGULATOR_LINEAR_RANGE(0, VOL_MIN_IDX, VOL_MAX_IDX, 10000),
7878
};
7979

80+
static bool mp8859_readable(struct device *dev, unsigned int reg)
81+
{
82+
switch (reg) {
83+
case MP8859_VOUT_L_REG:
84+
case MP8859_VOUT_H_REG:
85+
case MP8859_VOUT_GO_REG:
86+
case MP8859_IOUT_LIM_REG:
87+
case MP8859_CTL1_REG:
88+
case MP8859_CTL2_REG:
89+
case MP8859_STATUS_REG:
90+
case MP8859_INTERRUPT_REG:
91+
case MP8859_MASK_REG:
92+
case MP8859_ID1_REG:
93+
case MP8859_MFR_ID_REG:
94+
case MP8859_DEV_ID_REG:
95+
case MP8859_IC_REV_REG:
96+
return true;
97+
default:
98+
return false;
99+
}
100+
}
101+
102+
static bool mp8859_volatile(struct device *dev, unsigned int reg)
103+
{
104+
switch (reg) {
105+
case MP8859_VOUT_GO_REG:
106+
case MP8859_STATUS_REG:
107+
case MP8859_INTERRUPT_REG:
108+
return true;
109+
default:
110+
return false;
111+
}
112+
}
113+
80114
static const struct regmap_config mp8859_regmap = {
81115
.reg_bits = 8,
82116
.val_bits = 8,
83117
.max_register = MP8859_MAX_REG,
84-
.cache_type = REGCACHE_RBTREE,
118+
.cache_type = REGCACHE_MAPLE,
119+
.readable_reg = mp8859_readable,
120+
.volatile_reg = mp8859_volatile,
85121
};
86122

87123
static const struct regulator_ops mp8859_ops = {

0 commit comments

Comments
 (0)