[PATCH 1/2] ASoC: es8328: describe the power-on register values in the regmap

From: Bob Hui

Date: Sat Oct 24 2026 - 04:48:44 EST


The driver uses REGCACHE_MAPLE but does not provide reg_defaults, so the
cache starts out empty: a register that has not been written yet is read
back from the hardware and cached at that point. The two then drift
apart whenever something else, such as the bootloader or a previous
kernel, has left the codec in a non-default state, and the control
values reported to userspace no longer describe the chip.

Fill in the reset values from the ES8328 datasheet (Revision 1.0, the
per-register sections 6.1.1 to 6.3.30) so the cache matches what the
codec comes up with on power-up.

Assisted-by: Hermes:deepseek-v4-flash
Signed-off-by: Bob Hui <bg9oxa@xxxxxxx>
---
sound/soc/codecs/es8328.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)

diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
index aaa6646ad4c5e..d7f93de82f69a 100644
--- a/sound/soc/codecs/es8328.c
+++ b/sound/soc/codecs/es8328.c
@@ -856,11 +856,69 @@ static void es8328_remove(struct snd_soc_component *component)
es8328->supplies);
}

+static const struct reg_default es8328_reg_defaults[] = {
+ { ES8328_CONTROL1, 0x06 },
+ { ES8328_CONTROL2, 0x1c },
+ { ES8328_CHIPPOWER, 0xc3 },
+ { ES8328_ADCPOWER, 0xfc },
+ { ES8328_DACPOWER, 0xc0 },
+ { ES8328_CHIPLOPOW1, 0x00 },
+ { ES8328_CHIPLOPOW2, 0x00 },
+ { ES8328_ANAVOLMANAG, 0x7c },
+ { ES8328_MASTERMODE, 0x80 },
+ { ES8328_ADCCONTROL1, 0x00 },
+ { ES8328_ADCCONTROL2, 0x00 },
+ { ES8328_ADCCONTROL3, 0x06 },
+ { ES8328_ADCCONTROL4, 0x00 },
+ { ES8328_ADCCONTROL5, 0x06 },
+ { ES8328_ADCCONTROL6, 0x30 },
+ { ES8328_ADCCONTROL7, 0x30 },
+ { ES8328_ADCCONTROL8, 0xc0 },
+ { ES8328_ADCCONTROL9, 0xc0 },
+ { ES8328_ADCCONTROL10, 0x38 },
+ { ES8328_ADCCONTROL11, 0xb0 },
+ { ES8328_ADCCONTROL12, 0x32 },
+ { ES8328_ADCCONTROL13, 0x06 },
+ { ES8328_ADCCONTROL14, 0x00 },
+ { ES8328_DACCONTROL1, 0x00 },
+ { ES8328_DACCONTROL2, 0x06 },
+ { ES8328_DACCONTROL3, 0x32 },
+ { ES8328_DACCONTROL4, 0xc0 },
+ { ES8328_DACCONTROL5, 0xc0 },
+ { ES8328_DACCONTROL6, 0x08 },
+ { ES8328_DACCONTROL7, 0x06 },
+ { ES8328_DACCONTROL8, 0x1f },
+ { ES8328_DACCONTROL9, 0xf7 },
+ { ES8328_DACCONTROL10, 0xfd },
+ { ES8328_DACCONTROL11, 0xff },
+ { ES8328_DACCONTROL12, 0x1f },
+ { ES8328_DACCONTROL13, 0xf7 },
+ { ES8328_DACCONTROL14, 0xfd },
+ { ES8328_DACCONTROL15, 0xff },
+ { ES8328_DACCONTROL16, 0x00 },
+ { ES8328_DACCONTROL17, 0x38 },
+ { ES8328_DACCONTROL18, 0x38 },
+ { ES8328_DACCONTROL19, 0x38 },
+ { ES8328_DACCONTROL20, 0x38 },
+ { ES8328_DACCONTROL21, 0x38 },
+ { ES8328_DACCONTROL22, 0x38 },
+ { ES8328_DACCONTROL23, 0x00 },
+ { ES8328_LOUT1VOL, 0x00 },
+ { ES8328_ROUT1VOL, 0x00 },
+ { ES8328_LOUT2VOL, 0x00 },
+ { ES8328_ROUT2VOL, 0x00 },
+ { ES8328_MONOOUTVOL, 0x00 },
+ { ES8328_DACCONTROL29, 0x00 },
+ { ES8328_DACCONTROL30, 0x00 },
+};
+
const struct regmap_config es8328_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = ES8328_REG_MAX,
.cache_type = REGCACHE_MAPLE,
+ .reg_defaults = es8328_reg_defaults,
+ .num_reg_defaults = ARRAY_SIZE(es8328_reg_defaults),
.use_single_read = true,
.use_single_write = true,
};

--
2.34.1