Thread (2 messages) 2 messages, 2 authors, 2026-01-26

Re: [PATCH v6 3/5] ASoC: meson: g12a-toacodec: Add S4 tocodec driver

From: Jiebing Chen <hidden>
Date: 2026-01-26 13:27:29
Also in: linux-amlogic, linux-arm-kernel, linux-clk, linux-sound, lkml

在 2026/1/26 19:04, Jerome Brunet 写道:
[ EXTERNAL EMAIL ]

On lun. 26 janv. 2026 at 06:01, Jiebing Chen via B4 Relay [off-list ref] wrote:
quoted
From: Jiebing Chen <redacted>

The S4 requires additional clock control bits to be turn on while enabled.
The S4 has 8 TDM lanes, instead of 4 on previous SoC.
Update the widget accordingly.

Signed-off-by: Jiebing Chen <redacted>
---
  sound/soc/meson/g12a-toacodec.c | 36 ++++++++++++++++++++++++++++++++++++
  1 file changed, 36 insertions(+)
diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index a95375b53f0a..a7f9ac2d08f7 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -41,6 +41,9 @@
  #define  CTRL0_BCLK_SEL_LSB          4
  #define  CTRL0_MCLK_SEL                      GENMASK(2, 0)

+#define CTRL0_BCLK_ENABLE_SHIFT              30
+#define CTRL0_MCLK_ENABLE_SHIFT              29
+
  #define TOACODEC_OUT_CHMAX           2

  struct g12a_toacodec {
@@ -141,6 +144,13 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = {
                           &g12a_toacodec_out_enable),
  };

+static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
+     SND_SOC_DAPM_MUX("SRC", TOACODEC_CTRL0, CTRL0_BCLK_ENABLE_SHIFT, 0,
+                      &sm1_toacodec_mux),
+     SND_SOC_DAPM_SWITCH("OUT EN", TOACODEC_CTRL0, CTRL0_MCLK_ENABLE_SHIFT, 0,
+                         &g12a_toacodec_out_enable),
I guess that works but it is a bit hackish to hijack the output control
to enable a something really clock related. A supply widget connect to
this widget would be more approriate I think
Hi, jerome

Thanks for your suggestion. A supply widget is  appropriate.

I will add the supply widget in next version
quoted
+};
+
  static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream,
                                        struct snd_pcm_hw_params *params,
                                        struct snd_soc_dai *dai)
@@ -234,6 +244,10 @@ static const struct snd_kcontrol_new sm1_toacodec_controls[] = {
       SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 3, 0),
  };

+static const struct snd_kcontrol_new s4_toacodec_controls[] = {
+     SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 7, 0),
+};
+
  static const struct snd_soc_component_driver g12a_toacodec_component_drv = {
       .probe                  = g12a_toacodec_component_probe,
       .controls               = g12a_toacodec_controls,
@@ -256,6 +270,17 @@ static const struct snd_soc_component_driver sm1_toacodec_component_drv = {
       .endianness             = 1,
  };

+static const struct snd_soc_component_driver s4_toacodec_component_drv = {
+     .probe                  = sm1_toacodec_component_probe,
+     .controls               = s4_toacodec_controls,
+     .num_controls           = ARRAY_SIZE(s4_toacodec_controls),
+     .dapm_widgets           = s4_toacodec_widgets,
+     .num_dapm_widgets       = ARRAY_SIZE(s4_toacodec_widgets),
+     .dapm_routes            = g12a_toacodec_routes,
+     .num_dapm_routes        = ARRAY_SIZE(g12a_toacodec_routes),
+     .endianness             = 1,
+};
+
  static const struct regmap_config g12a_toacodec_regmap_cfg = {
       .reg_bits       = 32,
       .val_bits       = 32,
@@ -276,6 +301,13 @@ static const struct g12a_toacodec_match_data sm1_toacodec_match_data = {
       .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
  };

+static const struct g12a_toacodec_match_data s4_toacodec_match_data = {
+     .component_drv  = &s4_toacodec_component_drv,
+     .field_dat_sel  = REG_FIELD(TOACODEC_CTRL0, 19, 20),
+     .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
+     .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
+};
+
  static const struct of_device_id g12a_toacodec_of_match[] = {
       {
               .compatible = "amlogic,g12a-toacodec",
@@ -285,6 +317,10 @@ static const struct of_device_id g12a_toacodec_of_match[] = {
               .compatible = "amlogic,sm1-toacodec",
               .data = &sm1_toacodec_match_data,
       },
+     {
+             .compatible = "amlogic,s4-toacodec",
+             .data = &s4_toacodec_match_data,
+     },
       {}
  };
  MODULE_DEVICE_TABLE(of, g12a_toacodec_of_match);
--
Jerome
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help