]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: codecs: es8323: Enable proper DAPM widgets for chip power
authorBinbin Zhou <zhoubinbin@loongson.cn>
Sat, 17 Jan 2026 09:20:15 +0000 (17:20 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 19 Jan 2026 14:42:16 +0000 (14:42 +0000)
Remove initialization of the chip power register from the
es8323_set_bias_level routine, and add proper DAPM power supply widgets
to DAPM, which really should be handled by the DAPM subsystem.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://patch.msgid.link/db47e56e7c72bb900a84a33ee07d4ffcf0a908a3.1768641428.git.zhoubinbin@loongson.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/es8323.c
sound/soc/codecs/es8323.h

index 001e63b4e3453011b33a4fb894026c883108f0cd..605375b154c80230425f74a4711608199b9eb19a 100644 (file)
@@ -217,6 +217,23 @@ static const struct snd_soc_dapm_widget es8323_dapm_widgets[] = {
        SND_SOC_DAPM_SUPPLY("Mic Bias Gen", ES8323_ADCPOWER,
                            ES8323_ADCPOWER_PDNADCBIS_OFF, 1, NULL, 0),
 
+       SND_SOC_DAPM_SUPPLY("DAC STM", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_DACSTM_RESET, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("ADC STM", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_ADCSTM_RESET, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("DAC DIG", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_DACDIG_OFF, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("ADC DIG", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_ADCDIG_OFF, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("DAC DLL", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_DACDLL_OFF, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("ADC DLL", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_ADCDLL_OFF, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("ADC Vref", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_ADCVREF_OFF, 1, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("DAC Vref", ES8323_CHIPPOWER,
+                           ES8323_CHIPPOWER_DACVREF_OFF, 1, NULL, 0),
+
        /* Muxes */
        SND_SOC_DAPM_MUX("Left PGA Mux", ES8323_ADCPOWER,
                         ES8323_ADCPOWER_PDNAINL_OFF, 1, &es8323_left_dac_mux_controls),
@@ -287,6 +304,20 @@ static const struct snd_soc_dapm_route es8323_dapm_routes[] = {
 
        { "Mic Bias", NULL, "Mic Bias Gen" },
 
+       { "ADC DIG", NULL, "ADC STM" },
+       { "ADC DIG", NULL, "ADC Vref" },
+       { "ADC DIG", NULL, "ADC DLL" },
+
+       { "Left ADC", NULL, "ADC DIG" },
+       { "Right ADC", NULL, "ADC DIG" },
+
+       { "DAC DIG", NULL, "DAC STM" },
+       { "DAC DIG", NULL, "DAC Vref" },
+       { "DAC DIG", NULL, "DAC DLL" },
+
+       { "Left DAC", NULL, "DAC DIG" },
+       { "Right DAC", NULL, "DAC DIG" },
+
        {"Left Line Mux", "Line 1L", "LINPUT1"},
        {"Left Line Mux", "Line 2L", "LINPUT2"},
        {"Left Line Mux", "MicL", "Left PGA Mux"},
@@ -644,7 +675,7 @@ static int es8323_probe(struct snd_soc_component *component)
        }
 
        snd_soc_component_write(component, ES8323_CONTROL2, 0x60);
-       snd_soc_component_write(component, ES8323_CHIPPOWER, 0x00);
+       snd_soc_component_write(component, ES8323_DACCONTROL21, 0x80);
 
        return 0;
 }
@@ -657,34 +688,23 @@ static int es8323_set_bias_level(struct snd_soc_component *component,
 
        switch (level) {
        case SND_SOC_BIAS_ON:
+               break;
+       case SND_SOC_BIAS_PREPARE:
                ret = clk_prepare_enable(es8323->mclk);
                if (ret)
                        return ret;
 
-               snd_soc_component_write(component, ES8323_CHIPPOWER, 0xf0);
-               usleep_range(18000, 20000);
-               snd_soc_component_write(component, ES8323_ANAVOLMANAG, 0x7c);
                snd_soc_component_write(component, ES8323_CHIPLOPOW1, 0x00);
                snd_soc_component_write(component, ES8323_CHIPLOPOW2, 0x00);
-               snd_soc_component_write(component, ES8323_CHIPPOWER, 0x00);
-               snd_soc_component_write(component, ES8323_ADCCONTROL14, 0x00);
                snd_soc_component_update_bits(component, ES8323_ADCPOWER,
                                              ES8323_ADCPOWER_PDNADCBIS, 0);
                break;
-       case SND_SOC_BIAS_PREPARE:
-               break;
        case SND_SOC_BIAS_STANDBY:
-               snd_soc_component_write(component, ES8323_ANAVOLMANAG, 0x7c);
-               snd_soc_component_write(component, ES8323_CHIPLOPOW1, 0x00);
-               snd_soc_component_write(component, ES8323_CHIPLOPOW2, 0x00);
-               snd_soc_component_write(component, ES8323_CHIPPOWER, 0x00);
                break;
        case SND_SOC_BIAS_OFF:
-               clk_disable_unprepare(es8323->mclk);
                snd_soc_component_write(component, ES8323_CHIPLOPOW1, 0xff);
                snd_soc_component_write(component, ES8323_CHIPLOPOW2, 0xff);
-               snd_soc_component_write(component, ES8323_CHIPPOWER, 0xff);
-               snd_soc_component_write(component, ES8323_ANAVOLMANAG, 0x7b);
+               clk_disable_unprepare(es8323->mclk);
                break;
        }
 
index 4d4ac4f2e4aea345d2aa94d69a3576d71597b68b..6e37e0480f0452c03315d5a530593bb14c285630 100644 (file)
 #define ES8323_CONTROL1                0x00
 #define ES8323_CONTROL2                0x01
 #define ES8323_CHIPPOWER       0x02
+
+#define ES8323_CHIPPOWER_DACVREF_OFF   0
+#define ES8323_CHIPPOWER_ADCVREF_OFF   1
+#define ES8323_CHIPPOWER_DACDLL_OFF    2
+#define ES8323_CHIPPOWER_ADCDLL_OFF    3
+#define ES8323_CHIPPOWER_DACSTM_RESET  4
+#define ES8323_CHIPPOWER_ADCSTM_RESET  5
+#define ES8323_CHIPPOWER_DACDIG_OFF    6
+#define ES8323_CHIPPOWER_ADCDIG_OFF    7
+
 #define ES8323_ADCPOWER                0x03
 
 #define ES8323_ADCPOWER_INT1LP         BIT(0)