diff options
author | Mark Brown <broonie@kernel.org> | 2024-02-25 14:59:27 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-02-26 13:46:48 +0000 |
commit | b65e9149bdb76e9b09f6fb76fea1f10bde256619 (patch) | |
tree | e99c3f0f5736b4b6c1144c808242b785f91d0d75 | |
parent | b9262cc1b988cdaf9bb5c2a4411d4ad4e7128e8d (diff) |
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 <m.reichl@fivetechno.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://msgid.link/r/20240225-regulator-mp8859-v1-1-68ee2c839ded@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/mp8859.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/regulator/mp8859.c b/drivers/regulator/mp8859.c index b820bd6043e5..689b56680d93 100644 --- a/drivers/regulator/mp8859.c +++ b/drivers/regulator/mp8859.c @@ -77,11 +77,47 @@ static const struct linear_range mp8859_dcdc_ranges[] = { REGULATOR_LINEAR_RANGE(0, VOL_MIN_IDX, VOL_MAX_IDX, 10000), }; +static bool mp8859_readable(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MP8859_VOUT_L_REG: + case MP8859_VOUT_H_REG: + case MP8859_VOUT_GO_REG: + case MP8859_IOUT_LIM_REG: + case MP8859_CTL1_REG: + case MP8859_CTL2_REG: + case MP8859_STATUS_REG: + case MP8859_INTERRUPT_REG: + case MP8859_MASK_REG: + case MP8859_ID1_REG: + case MP8859_MFR_ID_REG: + case MP8859_DEV_ID_REG: + case MP8859_IC_REV_REG: + return true; + default: + return false; + } +} + +static bool mp8859_volatile(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MP8859_VOUT_GO_REG: + case MP8859_STATUS_REG: + case MP8859_INTERRUPT_REG: + return true; + default: + return false; + } +} + static const struct regmap_config mp8859_regmap = { .reg_bits = 8, .val_bits = 8, .max_register = MP8859_MAX_REG, - .cache_type = REGCACHE_RBTREE, + .cache_type = REGCACHE_MAPLE, + .readable_reg = mp8859_readable, + .volatile_reg = mp8859_volatile, }; static const struct regulator_ops mp8859_ops = { |