* [PATCH] regulator: tps6286x-regulator: Enable REGCACHE_FLAT
@ 2024-04-30 1:00 Jisheng Zhang
2024-04-30 2:09 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Jisheng Zhang @ 2024-04-30 1:00 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
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 <jszhang@kernel.org>
---
drivers/regulator/tps6286x-regulator.c | 36 ++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/regulator/tps6286x-regulator.c b/drivers/regulator/tps6286x-regulator.c
index 758c70269653..adef970972a7 100644
--- a/drivers/regulator/tps6286x-regulator.c
+++ b/drivers/regulator/tps6286x-regulator.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: tps6286x-regulator: Enable REGCACHE_FLAT
2024-04-30 1:00 [PATCH] regulator: tps6286x-regulator: Enable REGCACHE_FLAT Jisheng Zhang
@ 2024-04-30 2:09 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-04-30 2:09 UTC (permalink / raw)
To: Jisheng Zhang; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
On Tue, Apr 30, 2024 at 09:00:19AM +0800, Jisheng Zhang wrote:
> 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).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-30 2:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 1:00 [PATCH] regulator: tps6286x-regulator: Enable REGCACHE_FLAT Jisheng Zhang
2024-04-30 2:09 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.