regulator: tps6286x-regulator: Enable REGCACHE_FLAT
PATCH 1/1 regulator: tps6286x-regulator: Enable REGCACHE_FLAT
Enable regmap cache to reduce i2c transactions and corresponding interrupts if regulator is accessed frequently. Since the register map is small, we use a FLAT regmap cache.
Signed-off-by Jisheng Zhang <[email protected]>
--- drivers/regulator/tps6286x-regulator.c | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/regulator/tps6286x-regulator.c +36 -0
@@ -19,13 +19,49 @@#define TPS6286X_CONTROL_FPWM BIT(4)#define TPS6286X_CONTROL_SWEN BIT(5) +#define TPS6286X_STATUS 0x05 +#define TPS6286X_MAX_REGS (TPS6286X_STATUS + 1) +#define TPS6286X_MIN_MV 400#define TPS6286X_MAX_MV 1675#define TPS6286X_STEP_MV 5 +static bool tps6286x_writeable_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { + case TPS6286X_VOUT1 ... TPS6286X_CONTROL: +return true; +default : +return false; + } +} + +static bool tps6286x_readable_reg (struct device *dev,unsigned int reg) +{ +switch (reg) { + case TPS6286X_VOUT1 ... TPS6286X_CONTROL: +case TPS6286X_STATUS : +return true; +default : +return false; + } +} + +static bool tps6286x_volatile_reg (struct device *dev,unsigned int reg) +{ +if (reg ==TPS6286X_STATUS ) +return true; +return false; +} +static const struct regmap_config tps6286x_regmap_config = { .reg_bits =8 , .val_bits =8 , + .num_reg_defaults_raw =TPS6286X_MAX_REGS , + .cache_type =REGCACHE_FLAT , + .writeable_reg = tps6286x_writeable_reg, + .readable_reg = tps6286x_readable_reg, + .volatile_reg = tps6286x_volatile_reg, };static int tps6286x_set_mode (struct regulator_dev *rdev,unsigned int mode)
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 3 lines · Jisheng Zhang
Enable regmap cache to reduce i2c transactions and corresponding interrupts if regulator is accessed frequently. Since the register map is small, we use a FLAT regmap cache.
There are a number of disadvantages to the flat cache, especially the lack of sparseness, so it is generally better to use the maple cache unless there's a specific need for the flat cache (usually the fact that it doesn't allocate).