[PATCH 1/2] regulator: mt6363: Use 8-bit register values
Alexandre Mergnat
amergnat at baylibre.com
Mon Nov 2 07:54:17 PST 2026
The registers are 8 bits wide, but the regulator regmap uses 16-bit
values, so every access also covers the next register. On little-endian
CPUs, each regmap_write() also writes zero to the next register:
disabling VS2 or a VBUCK rail through its clear register 0x212 also
clears the enable bits of VS1, VS3 and three VSRAM rails in 0x213.
Change the regmap values to 8 bits. Store the BUCK and TMA keys as
__le16 so that the low byte goes to the first key register on any CPU,
as it did on little-endian CPUs.
Fixes: 3c36965df808 ("regulator: Add support for MediaTek MT6363 SPMI PMIC Regulators")
Signed-off-by: Alexandre Mergnat <amergnat at baylibre.com>
---
I had this patch ready when GIBEOM LEE posted the same regmap change:
https://lore.kernel.org/all/20261101164405.1743177-2-rtx4060@gmail.com/
The only difference in behavior is the BUCK_TOP key: that patch keeps
it as a u16, which a big-endian kernel writes high byte first; this one
stores it as __le16.
---
drivers/regulator/mt6363-regulator.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/mt6363-regulator.c b/drivers/regulator/mt6363-regulator.c
index aa6a8eb7ac4b..ac79ad6698bf 100644
--- a/drivers/regulator/mt6363-regulator.c
+++ b/drivers/regulator/mt6363-regulator.c
@@ -381,7 +381,7 @@ static unsigned int mt6363_regulator_get_mode(struct regulator_dev *rdev)
static int mt6363_buck_unlock(struct regmap *map, bool unlock)
{
- u16 buf = unlock ? MT6363_BUCK_TOP_UNLOCK_VALUE : 0;
+ __le16 buf = cpu_to_le16(unlock ? MT6363_BUCK_TOP_UNLOCK_VALUE : 0);
return regmap_bulk_write(map, MT6363_BUCK_TOP_KEY_PROT_LO, &buf, sizeof(buf));
}
@@ -482,7 +482,8 @@ static int mt6363_regulator_set_load(struct regulator_dev *rdev, int load_uA)
static int mt6363_vemc_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
{
- const u16 tma_unlock_key = MT6363_TMA_UNLOCK_VALUE;
+ const __le16 tma_unlock_key = cpu_to_le16(MT6363_TMA_UNLOCK_VALUE);
+ const __le16 tma_lock_key = cpu_to_le16(0);
const struct regulator_desc *rdesc = rdev->desc;
struct regmap *regmap = rdev->regmap;
unsigned int range, val;
@@ -539,8 +540,8 @@ static int mt6363_vemc_set_voltage_sel(struct regulator_dev *rdev, unsigned int
lock_tma:
/* Unconditionally re-lock TMA */
- val = 0;
- regmap_bulk_write(rdev->regmap, MT6363_TOP_TMA_KEY_L, &val, 2);
+ regmap_bulk_write(rdev->regmap, MT6363_TOP_TMA_KEY_L,
+ &tma_lock_key, sizeof(tma_lock_key));
return ret;
}
@@ -811,7 +812,7 @@ static struct regmap *mt6363_spmi_register_regmap(struct device *dev)
{
struct regmap_config mt6363_regmap_config = {
.reg_bits = 16,
- .val_bits = 16,
+ .val_bits = 8,
.max_register = 0x1f90,
.fast_io = true,
};
--
2.43.0
More information about the linux-arm-kernel
mailing list