linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for S4 audio
@ 2025-01-13  6:35 jiebing chen via B4 Relay
  2025-01-13  6:35 ` [PATCH 1/3] ASoC: dt-bindings: Add Amlogic " jiebing chen via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: jiebing chen via B4 Relay @ 2025-01-13  6:35 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl
  Cc: linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, jiebing chen

Add the tdmout pad control and tocodec control driver. 

Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
---
jiebing chen (3):
      ASoC: dt-bindings: Add Amlogic S4 audio
      ASoC: meson: s4:support for the on-chip audio
      arm64: dts: amlogic: Add Amlogic S4 Audio

 .../bindings/sound/amlogic,s4-tdmout-pad.yaml      |  36 ++
 .../bindings/sound/amlogic,s4-tocodec.yaml         |  44 +++
 .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
 arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
 sound/soc/meson/Kconfig                            |  16 +
 sound/soc/meson/Makefile                           |   6 +
 sound/soc/meson/s4-pad-out-control.c               | 372 ++++++++++++++++++++
 sound/soc/meson/s4-tocodec-control.c               | 376 ++++++++++++++++++++
 sound/soc/meson/t9015.c                            |   5 +-
 9 files changed, 1461 insertions(+), 5 deletions(-)
---
base-commit: 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab
change-id: 20250110-audio_drvier-07a5381c494b

Best regards,
-- 
jiebing chen <jiebing.chen@amlogic.com>




^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/3] ASoC: dt-bindings: Add Amlogic S4 audio
  2025-01-13  6:35 [PATCH 0/3] Add support for S4 audio jiebing chen via B4 Relay
@ 2025-01-13  6:35 ` jiebing chen via B4 Relay
  2025-01-13  7:19   ` Rob Herring (Arm)
  2025-01-13  6:35 ` [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio jiebing chen via B4 Relay
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: jiebing chen via B4 Relay @ 2025-01-13  6:35 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl
  Cc: linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, jiebing chen

From: jiebing chen <jiebing.chen@amlogic.com>

Add documentation describing the Amlogic S4 TDM output pad and toacodec.

Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
---
 .../bindings/sound/amlogic,s4-tdmout-pad.yaml      | 36 ++++++++++++++++++
 .../bindings/sound/amlogic,s4-tocodec.yaml         | 44 ++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/amlogic,s4-tdmout-pad.yaml b/Documentation/devicetree/bindings/sound/amlogic,s4-tdmout-pad.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..52c945e63fb277c92149fad7abd69355f5c9fc9d
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,s4-tdmout-pad.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2024 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,s4-tdmout-pad.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic TDM Internal PAD
+
+maintainers:
+  - Jiebing Chen <jiebing.chen@amlogic.com>
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: amlogic,s4-tdmout-pad
+  reg:
+    maxItems: 1
+
+  sound-name-prefix: true
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    audio-controller@e58 {
+        compatible = "amlogic,s4-tdmout-pad";
+        reg = <0xe58 0x28>;
+    };
diff --git a/Documentation/devicetree/bindings/sound/amlogic,s4-tocodec.yaml b/Documentation/devicetree/bindings/sound/amlogic,s4-tocodec.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..a4d7388c0e48095b4aea0530c7feafcaf066b063
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/amlogic,s4-tocodec.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2024 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/amlogic,s4-tocodec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic S4 Audio Tocodec Control
+
+maintainers:
+  - Jiebing Chen <jiebing.chen@amlogic.com>
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: amlogic,s4-tocodec
+
+  reg:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  sound-name-prefix: true
+
+required:
+  - compatible
+  - reg
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/reset/amlogic,meson-g12a-reset.h>
+    audio-controller@740 {
+        compatible = "amlogic,s4-tocodec";
+        reg = <0x0 0x740 0x0 0x4>;
+        sound-name-prefix = "TOACODEC";
+        resets = <&clkc_audio AUD_RESET_TOACODEC>;
+    };

-- 
2.43.0




^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-13  6:35 [PATCH 0/3] Add support for S4 audio jiebing chen via B4 Relay
  2025-01-13  6:35 ` [PATCH 1/3] ASoC: dt-bindings: Add Amlogic " jiebing chen via B4 Relay
@ 2025-01-13  6:35 ` jiebing chen via B4 Relay
  2025-01-13 14:31   ` Jerome Brunet
  2025-01-14  9:09   ` kernel test robot
  2025-01-13  6:35 ` [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio jiebing chen via B4 Relay
  2025-01-13 15:26 ` [PATCH 0/3] Add support for S4 audio Rob Herring (Arm)
  3 siblings, 2 replies; 27+ messages in thread
From: jiebing chen via B4 Relay @ 2025-01-13  6:35 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl
  Cc: linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, jiebing chen

From: jiebing chen <jiebing.chen@amlogic.com>

Add audio support for Amlogic S4.The audio output pad
can be freelycombined with the output lane,and the tocodec
control logic has been optimized.

Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
---
 sound/soc/meson/Kconfig              |  16 ++
 sound/soc/meson/Makefile             |   6 +
 sound/soc/meson/s4-pad-out-control.c | 372 ++++++++++++++++++++++++++++++++++
 sound/soc/meson/s4-tocodec-control.c | 376 +++++++++++++++++++++++++++++++++++
 sound/soc/meson/t9015.c              |   5 +-
 5 files changed, 771 insertions(+), 4 deletions(-)

diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
index 6458d5dc4902f665211bb9e4ae7d274e4bff2fdc..d01e284642fd987cf4bdf88e5bf5f7c9a241af59 100644
--- a/sound/soc/meson/Kconfig
+++ b/sound/soc/meson/Kconfig
@@ -69,6 +69,8 @@ config SND_MESON_AXG_SOUND_CARD
 	imply SND_MESON_AXG_SPDIFIN
 	imply SND_MESON_AXG_PDM
 	imply SND_MESON_G12A_TOACODEC
+	imply SND_SOC_MESON_PAD_OUT
+	imply SND_SOC_MESON_TOCODEC_CONTROL
 	imply SND_MESON_G12A_TOHDMITX if DRM_MESON_DW_HDMI
 	help
 	  Select Y or M to add support for the AXG SoC sound card
@@ -135,4 +137,18 @@ config SND_SOC_MESON_T9015
 	help
 	  Say Y or M if you want to add support for the internal DAC found
 	  on GXL, G12 and SM1 SoC family.
+
+config SND_SOC_MESON_PAD_OUT
+	tristate "Amlogic PAD OUT"
+	select REGMAP_MMIO
+	help
+	  Say Y or M if you want to add support for the S4 Audio Output from
+	  the data Pad.
+
+config SND_SOC_MESON_TOCODEC_CONTROL
+	tristate "Amlogic TOCODEC CONTROL"
+	select REGMAP_MMIO
+	help
+	 Say Y or M if you want to add support for the internal DAC control
+	 on SM1 SoC family.
 endmenu
diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile
index 24078e4396b02d545d8ba4bcb1632979001354e3..afbefcb1313670f9b1365e88b8eb1a0badd7dc1e 100644
--- a/sound/soc/meson/Makefile
+++ b/sound/soc/meson/Makefile
@@ -24,8 +24,11 @@ snd-soc-meson-codec-glue-y := meson-codec-glue.o
 snd-soc-meson-gx-sound-card-y := gx-card.o
 snd-soc-meson-g12a-toacodec-y := g12a-toacodec.o
 snd-soc-meson-g12a-tohdmitx-y := g12a-tohdmitx.o
+snd-soc-meson-s4-padout-objs := s4-pad-out-control.o
+snd-soc-meson-s4-tocodec-control-objs := s4-tocodec-control.o
 snd-soc-meson-t9015-y := t9015.o
 
+
 obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
 obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
@@ -43,4 +46,7 @@ obj-$(CONFIG_SND_MESON_CODEC_GLUE) += snd-soc-meson-codec-glue.o
 obj-$(CONFIG_SND_MESON_GX_SOUND_CARD) += snd-soc-meson-gx-sound-card.o
 obj-$(CONFIG_SND_MESON_G12A_TOACODEC) += snd-soc-meson-g12a-toacodec.o
 obj-$(CONFIG_SND_MESON_G12A_TOHDMITX) += snd-soc-meson-g12a-tohdmitx.o
+obj-$(CONFIG_SND_SOC_MESON_PAD_OUT) += snd-soc-meson-s4-padout.o
+obj-$(CONFIG_SND_SOC_MESON_TOCODEC_CONTROL) += snd-soc-meson-s4-tocodec-control.o
 obj-$(CONFIG_SND_SOC_MESON_T9015) += snd-soc-meson-t9015.o
+
diff --git a/sound/soc/meson/s4-pad-out-control.c b/sound/soc/meson/s4-pad-out-control.c
new file mode 100644
index 0000000000000000000000000000000000000000..a86dcf8a5995926f0ddf8d2911f42006daed0feb
--- /dev/null
+++ b/sound/soc/meson/s4-pad-out-control.c
@@ -0,0 +1,372 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+/*
+ * Copyright (C) 2024 Amlogic, Inc. All rights reserved
+ */
+
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <sound/soc.h>
+#include <sound/soc-dai.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include<linux/kstrtox.h>
+
+#include "axg-tdm.h"
+
+static const struct regmap_config tdmout_pad_regmap_cfg = {
+	.reg_bits	= 32,
+	.val_bits	= 32,
+	.reg_stride	= 4,
+	.max_register	= 0x28,
+};
+
+#define TDM_IFACE 0
+#define TDM_A_PAD 0
+#define TDM_B_PAD 1
+#define TDM_C_PAD 2
+
+#define EE_AUDIO_DAT_PAD_CTRL6 0x0
+#define EE_AUDIO_DAT_PAD_CTRL7 0x4
+#define EE_AUDIO_DAT_PAD_CTRL8 0x8
+#define EE_AUDIO_DAT_PAD_CTRL9 0xc
+#define EE_AUDIO_DAT_PAD_CTRLA 0x10
+#define EE_AUDIO_DAT_PAD_CTRLB 0x14
+#define EE_AUDIO_DAT_PAD_CTRLC 0x1c
+#define EE_AUDIO_DAT_PAD_CTRLD 0x20
+#define EE_AUDIO_DAT_PAD_CTRLE 0x24
+#define EE_AUDIO_DAT_PAD_CTRLF 0x28
+
+#define REG_OFFSET 4
+
+static const char * const s4_tdmout_sel_texts[] = {
+	"TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", "TDM_D6", "TDM_D7",
+	"TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", "TDM_D13", "TDM_D14", "TDM_D15",
+	"TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", "TDM_D21", "TDM_D22", "TDM_D23",
+	"TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", "TDM_D29", "TDM_D30", "TDM_D31"
+};
+
+static const struct soc_enum tdmout_sel_enum =
+	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
+			s4_tdmout_sel_texts);
+
+static struct snd_soc_dai *tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
+{
+	struct snd_soc_dapm_path *p;
+	struct snd_soc_dai *be;
+
+	snd_soc_dapm_widget_for_each_source_path(w, p) {
+		if (p->source->id == snd_soc_dapm_dai_in)
+			return (struct snd_soc_dai *)p->source->priv;
+		be = tdm_get_ahead_be(p->source);
+		if (be && be->id == TDM_IFACE)
+			return be;
+	}
+	return NULL;
+}
+
+#define SND_SOC_DAPM_DEMUX_E(wname, wreg, wshift, winvert, wcontrols, \
+	wevent, wflags) \
+((struct snd_soc_dapm_widget) { \
+	.id = snd_soc_dapm_demux, .name = wname, \
+	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
+	.kcontrol_news = wcontrols, .num_kcontrols = 1, \
+	.event = wevent, .event_flags = wflags})
+
+static const struct snd_kcontrol_new tdmout_sel_demux[] = {
+	SOC_DAPM_ENUM("TDMOUTA SEL", tdmout_sel_enum),
+	SOC_DAPM_ENUM("TDMOUTB SEL", tdmout_sel_enum),
+	SOC_DAPM_ENUM("TDMOUTC SEL", tdmout_sel_enum),
+};
+
+static unsigned int aml_simple_strtoull(const char *cp)
+{
+	unsigned int result = 0;
+	unsigned int value = 0;
+	unsigned int len =  strlen(cp);
+
+	while (len != 0) {
+		len--;
+		value = isdigit(*cp);
+		if (value) {
+			value = *cp - '0';
+		} else {
+			cp++;
+			continue;
+		}
+		cp++;
+		result = result * 10 + value;
+	}
+	return result;
+}
+
+static int tdm_out_pad_set(struct snd_soc_dapm_widget *w)
+{
+	struct snd_soc_dai *be;
+	struct axg_tdm_stream *stream;
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	unsigned int tdm_id = TDM_A_PAD;
+	const char *dai_widget_name;
+	struct snd_soc_dapm_path *p;
+	unsigned int lane_num = 0;
+	unsigned long pin = 0;
+	unsigned int reg, mask, val = 0;
+	int lane_cnt;
+
+	be = tdm_get_ahead_be(w);
+	if (!be) {
+		dev_err(component->dev, "%s not find the be\n", __func__);
+		return -EINVAL;
+	}
+	stream = snd_soc_dai_dma_data_get_playback(be);
+	if (!stream) {
+		dev_err(component->dev, "%s not find the stream\n", __func__);
+		return -EINVAL;
+	}
+	lane_cnt = (stream->channels - 1) / stream->iface->slots + 1;
+	/*we like to use dai id, but it is fixed val*/
+	dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
+	if (strstr(dai_widget_name, "TDM_A"))
+		tdm_id = TDM_A_PAD;
+	else if (strstr(dai_widget_name, "TDM_B"))
+		tdm_id = TDM_B_PAD;
+	else if (strstr(dai_widget_name, "TDM_C"))
+		tdm_id = TDM_C_PAD;
+	else
+		dev_err(component->dev, "%s not find the be dai widget\n", __func__);
+	dev_dbg(component->dev, "tdm_id:%d, channel:%d, slot:%d\n",
+		tdm_id, stream->channels, stream->iface->slots);
+	snd_soc_dapm_widget_for_each_sink_path(w, p) {
+		if (p->sink->id == snd_soc_dapm_output) {
+			if (p->connect) {
+				pin = aml_simple_strtoull(p->name);
+				reg = (pin / 4) * REG_OFFSET;
+				/*calculate mask pos */
+				mask = 0x1f << ((pin % 4) * 8);
+				val = tdm_id * 8 + lane_num;
+				snd_soc_component_update_bits(component, reg, mask, val);
+				snd_soc_component_update_bits(component, EE_AUDIO_DAT_PAD_CTRLF,
+							      0x1 << pin, 0 << pin);
+				lane_num++;
+				if (lane_num > lane_cnt - 1)
+					break;
+			}
+		}
+	}
+	return 0;
+}
+
+static int tdmout_sel_pad_event(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *control,
+				int event)
+{
+	int ret = 0;
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		tdm_out_pad_set(w);
+		break;
+
+	case SND_SOC_DAPM_PRE_PMD:
+		break;
+
+	default:
+		dev_err(component->dev, "Unexpected event %d\n", event);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static const struct snd_soc_dapm_widget s4_tdmout_pad_dapm_widgets[] = {
+	SND_SOC_DAPM_DEMUX_E("TDMA_OUT SEL", SND_SOC_NOPM, 0, 0,
+			     &tdmout_sel_demux[TDM_A_PAD], tdmout_sel_pad_event,
+			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
+	SND_SOC_DAPM_DEMUX_E("TDMB_OUT SEL", SND_SOC_NOPM, 0, 0,
+			     &tdmout_sel_demux[TDM_B_PAD], tdmout_sel_pad_event,
+			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
+	SND_SOC_DAPM_DEMUX_E("TDMC_OUT SEL", SND_SOC_NOPM, 0, 0,
+			     &tdmout_sel_demux[TDM_C_PAD], tdmout_sel_pad_event,
+			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
+	SND_SOC_DAPM_OUTPUT("TDM_D0"),
+	SND_SOC_DAPM_OUTPUT("TDM_D1"),
+	SND_SOC_DAPM_OUTPUT("TDM_D2"),
+	SND_SOC_DAPM_OUTPUT("TDM_D3"),
+	SND_SOC_DAPM_OUTPUT("TDM_D4"),
+	SND_SOC_DAPM_OUTPUT("TDM_D5"),
+	SND_SOC_DAPM_OUTPUT("TDM_D6"),
+	SND_SOC_DAPM_OUTPUT("TDM_D7"),
+	SND_SOC_DAPM_OUTPUT("TDM_D8"),
+	SND_SOC_DAPM_OUTPUT("TDM_D9"),
+	SND_SOC_DAPM_OUTPUT("TDM_D10"),
+	SND_SOC_DAPM_OUTPUT("TDM_D11"),
+	SND_SOC_DAPM_OUTPUT("TDM_D12"),
+	SND_SOC_DAPM_OUTPUT("TDM_D13"),
+	SND_SOC_DAPM_OUTPUT("TDM_D14"),
+	SND_SOC_DAPM_OUTPUT("TDM_D15"),
+	SND_SOC_DAPM_OUTPUT("TDM_D16"),
+	SND_SOC_DAPM_OUTPUT("TDM_D17"),
+	SND_SOC_DAPM_OUTPUT("TDM_D18"),
+	SND_SOC_DAPM_OUTPUT("TDM_D19"),
+	SND_SOC_DAPM_OUTPUT("TDM_D20"),
+	SND_SOC_DAPM_OUTPUT("TDM_D21"),
+	SND_SOC_DAPM_OUTPUT("TDM_D22"),
+	SND_SOC_DAPM_OUTPUT("TDM_D23"),
+	SND_SOC_DAPM_OUTPUT("TDM_D24"),
+	SND_SOC_DAPM_OUTPUT("TDM_D25"),
+	SND_SOC_DAPM_OUTPUT("TDM_D26"),
+	SND_SOC_DAPM_OUTPUT("TDM_D27"),
+	SND_SOC_DAPM_OUTPUT("TDM_D28"),
+	SND_SOC_DAPM_OUTPUT("TDM_D29"),
+	SND_SOC_DAPM_OUTPUT("TDM_D30"),
+	SND_SOC_DAPM_OUTPUT("TDM_D31"),
+};
+
+static const struct snd_soc_dapm_route s4_tdmout_pad_dapm_routes[] = {
+	{ "TDM_D0", "TDM_D0", "TDMA_OUT SEL" },
+	{ "TDM_D1", "TDM_D1", "TDMA_OUT SEL" },
+	{ "TDM_D2", "TDM_D2", "TDMA_OUT SEL" },
+	{ "TDM_D3", "TDM_D3", "TDMA_OUT SEL" },
+	{ "TDM_D4", "TDM_D4", "TDMA_OUT SEL" },
+	{ "TDM_D5", "TDM_D5", "TDMA_OUT SEL" },
+	{ "TDM_D6", "TDM_D6", "TDMA_OUT SEL" },
+	{ "TDM_D7", "TDM_D7", "TDMA_OUT SEL" },
+	{ "TDM_D8", "TDM_D8", "TDMA_OUT SEL" },
+	{ "TDM_D9", "TDM_D9", "TDMA_OUT SEL" },
+	{ "TDM_D10", "TDM_D10", "TDMA_OUT SEL" },
+	{ "TDM_D11", "TDM_D11", "TDMA_OUT SEL" },
+	{ "TDM_D12", "TDM_D12", "TDMA_OUT SEL" },
+	{ "TDM_D13", "TDM_D13", "TDMA_OUT SEL" },
+	{ "TDM_D14", "TDM_D14", "TDMA_OUT SEL" },
+	{ "TDM_D15", "TDM_D15", "TDMA_OUT SEL" },
+	{ "TDM_D16", "TDM_D16", "TDMA_OUT SEL" },
+	{ "TDM_D17", "TDM_D17", "TDMA_OUT SEL" },
+	{ "TDM_D18", "TDM_D18", "TDMA_OUT SEL" },
+	{ "TDM_D19", "TDM_D19", "TDMA_OUT SEL" },
+	{ "TDM_D20", "TDM_D20", "TDMA_OUT SEL" },
+	{ "TDM_D21", "TDM_D21", "TDMA_OUT SEL" },
+	{ "TDM_D22", "TDM_D22", "TDMA_OUT SEL" },
+	{ "TDM_D23", "TDM_D23", "TDMA_OUT SEL" },
+	{ "TDM_D24", "TDM_D24", "TDMA_OUT SEL" },
+	{ "TDM_D25", "TDM_D25", "TDMA_OUT SEL" },
+	{ "TDM_D26", "TDM_D26", "TDMA_OUT SEL" },
+	{ "TDM_D27", "TDM_D27", "TDMA_OUT SEL" },
+	{ "TDM_D28", "TDM_D28", "TDMA_OUT SEL" },
+	{ "TDM_D29", "TDM_D29", "TDMA_OUT SEL" },
+	{ "TDM_D30", "TDM_D30", "TDMA_OUT SEL" },
+	{ "TDM_D31", "TDM_D31", "TDMA_OUT SEL" },
+	{ "TDM_D0", "TDM_D0", "TDMB_OUT SEL" },
+	{ "TDM_D1", "TDM_D1", "TDMB_OUT SEL" },
+	{ "TDM_D2", "TDM_D2", "TDMB_OUT SEL" },
+	{ "TDM_D3", "TDM_D3", "TDMB_OUT SEL" },
+	{ "TDM_D4", "TDM_D4", "TDMB_OUT SEL" },
+	{ "TDM_D5", "TDM_D5", "TDMB_OUT SEL" },
+	{ "TDM_D6", "TDM_D6", "TDMB_OUT SEL" },
+	{ "TDM_D7", "TDM_D7", "TDMB_OUT SEL" },
+	{ "TDM_D8", "TDM_D8", "TDMB_OUT SEL" },
+	{ "TDM_D9", "TDM_D9", "TDMB_OUT SEL" },
+	{ "TDM_D10", "TDM_D10", "TDMB_OUT SEL" },
+	{ "TDM_D11", "TDM_D11", "TDMB_OUT SEL" },
+	{ "TDM_D12", "TDM_D12", "TDMB_OUT SEL" },
+	{ "TDM_D13", "TDM_D13", "TDMB_OUT SEL" },
+	{ "TDM_D14", "TDM_D14", "TDMB_OUT SEL" },
+	{ "TDM_D15", "TDM_D15", "TDMB_OUT SEL" },
+
+	{ "TDM_D16", "TDM_D16", "TDMB_OUT SEL" },
+	{ "TDM_D17", "TDM_D17", "TDMB_OUT SEL" },
+	{ "TDM_D18", "TDM_D18", "TDMB_OUT SEL" },
+	{ "TDM_D19", "TDM_D19", "TDMB_OUT SEL" },
+	{ "TDM_D20", "TDM_D20", "TDMB_OUT SEL" },
+	{ "TDM_D21", "TDM_D21", "TDMB_OUT SEL" },
+	{ "TDM_D22", "TDM_D22", "TDMB_OUT SEL" },
+	{ "TDM_D23", "TDM_D23", "TDMB_OUT SEL" },
+	{ "TDM_D24", "TDM_D24", "TDMB_OUT SEL" },
+	{ "TDM_D25", "TDM_D25", "TDMB_OUT SEL" },
+	{ "TDM_D26", "TDM_D26", "TDMB_OUT SEL" },
+	{ "TDM_D27", "TDM_D27", "TDMB_OUT SEL" },
+	{ "TDM_D28", "TDM_D28", "TDMB_OUT SEL" },
+	{ "TDM_D29", "TDM_D29", "TDMB_OUT SEL" },
+	{ "TDM_D30", "TDM_D30", "TDMB_OUT SEL" },
+	{ "TDM_D31", "TDM_D31", "TDMB_OUT SEL" },
+	{ "TDM_D0", "TDM_D0", "TDMC_OUT SEL" },
+	{ "TDM_D1", "TDM_D1", "TDMC_OUT SEL" },
+	{ "TDM_D2", "TDM_D2", "TDMC_OUT SEL" },
+	{ "TDM_D3", "TDM_D3", "TDMC_OUT SEL" },
+	{ "TDM_D4", "TDM_D4", "TDMC_OUT SEL" },
+	{ "TDM_D5", "TDM_D5", "TDMC_OUT SEL" },
+	{ "TDM_D6", "TDM_D6", "TDMC_OUT SEL" },
+	{ "TDM_D7", "TDM_D7", "TDMC_OUT SEL" },
+	{ "TDM_D8", "TDM_D8", "TDMC_OUT SEL" },
+	{ "TDM_D9", "TDM_D9", "TDMC_OUT SEL" },
+	{ "TDM_D10", "TDM_D10", "TDMC_OUT SEL" },
+	{ "TDM_D11", "TDM_D11", "TDMC_OUT SEL" },
+	{ "TDM_D12", "TDM_D12", "TDMC_OUT SEL" },
+	{ "TDM_D13", "TDM_D13", "TDMC_OUT SEL" },
+	{ "TDM_D14", "TDM_D14", "TDMC_OUT SEL" },
+	{ "TDM_D15", "TDM_D15", "TDMC_OUT SEL" },
+	{ "TDM_D16", "TDM_D16", "TDMC_OUT SEL" },
+	{ "TDM_D17", "TDM_D17", "TDMC_OUT SEL" },
+	{ "TDM_D18", "TDM_D18", "TDMC_OUT SEL" },
+	{ "TDM_D19", "TDM_D19", "TDMC_OUT SEL" },
+	{ "TDM_D20", "TDM_D20", "TDMC_OUT SEL" },
+	{ "TDM_D21", "TDM_D21", "TDMC_OUT SEL" },
+	{ "TDM_D22", "TDM_D22", "TDMC_OUT SEL" },
+	{ "TDM_D23", "TDM_D23", "TDMC_OUT SEL" },
+	{ "TDM_D24", "TDM_D24", "TDMC_OUT SEL" },
+	{ "TDM_D25", "TDM_D25", "TDMC_OUT SEL" },
+	{ "TDM_D26", "TDM_D26", "TDMC_OUT SEL" },
+	{ "TDM_D27", "TDM_D27", "TDMC_OUT SEL" },
+	{ "TDM_D28", "TDM_D28", "TDMC_OUT SEL" },
+	{ "TDM_D29", "TDM_D29", "TDMC_OUT SEL" },
+	{ "TDM_D30", "TDM_D30", "TDMC_OUT SEL" },
+	{ "TDM_D31", "TDM_D31", "TDMC_OUT SEL" },
+};
+
+static const struct snd_soc_component_driver s4_tdmout_pad_component_drv = {
+	.dapm_widgets		= s4_tdmout_pad_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(s4_tdmout_pad_dapm_widgets),
+	.dapm_routes		= s4_tdmout_pad_dapm_routes,
+	.num_dapm_routes	= ARRAY_SIZE(s4_tdmout_pad_dapm_routes),
+
+};
+
+static const struct of_device_id s4_tdmout_pad_of_match[] = {
+	{
+		.compatible = "amlogic,s4-tdmout-pad",
+	}, {}
+};
+
+MODULE_DEVICE_TABLE(of, s4_tdmout_pad_of_match);
+
+static int tdm_pad_out_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct regmap *map;
+	void __iomem *regs;
+
+	regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
+
+	map = devm_regmap_init_mmio(dev, regs, &tdmout_pad_regmap_cfg);
+	if (IS_ERR(map))
+		return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
+
+	return devm_snd_soc_register_component(dev, &s4_tdmout_pad_component_drv,
+					       NULL, 0);
+}
+
+static struct platform_driver tdmout_pad_pdrv = {
+	.probe = tdm_pad_out_probe,
+	.driver = {
+		.name = "s4-pad-out",
+		.of_match_table = s4_tdmout_pad_of_match,
+	},
+};
+
+module_platform_driver(tdmout_pad_pdrv);
+
+MODULE_DESCRIPTION("Amlogic TDM PAD DRIVER");
+MODULE_AUTHOR("jiebing.chen@amlogic.com");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/meson/s4-tocodec-control.c b/sound/soc/meson/s4-tocodec-control.c
new file mode 100644
index 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
--- /dev/null
+++ b/sound/soc/meson/s4-tocodec-control.c
@@ -0,0 +1,376 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+/*
+ * Copyright (C) 2023 Amlogic, Inc. All rights reserved
+ */
+
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <sound/soc.h>
+#include <sound/soc-dai.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include<linux/kstrtox.h>
+#include <linux/clk-provider.h>
+#include <linux/reset.h>
+#include "axg-tdm.h"
+
+#define TOACODEC_CTRL0			0x0
+
+#define CTRL0_ENABLE_SHIFT		31
+#define CTRL0_BCLK_ENABLE_SHIFT		30
+#define CTRL0_MCLK_ENABLE_SHIFT		29
+#define CTRL0_BLK_CAP_INV_SHIFT		9
+
+#define TDM_IFACE 0
+#define TDM_A_PAD 0
+#define TDM_B_PAD 1
+#define TDM_C_PAD 2
+
+struct toacodec {
+	struct regmap_field *field_dat_sel;
+	struct regmap_field *field_lrclk_sel;
+	struct regmap_field *field_bclk_sel;
+	struct regmap_field *field_mclk_sel;
+};
+
+struct toacodec_match_data {
+	const struct snd_soc_component_driver *component_drv;
+	const struct reg_field field_dat_sel;
+	const struct reg_field field_lrclk_sel;
+	const struct reg_field field_bclk_sel;
+	const struct reg_field field_mclk_sel;
+};
+
+static const struct regmap_config tocodec_regmap_cfg = {
+	.reg_bits	= 32,
+	.val_bits	= 32,
+	.reg_stride	= 4,
+	.max_register	= 0x1,
+};
+
+#define S4_LANE_OFFSET 8
+
+static const char * const s4_tocodec_lane_sel_texts[] = {
+	"Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", "Lane7"
+};
+
+static const struct soc_enum s4_tocodec_lane_sel_enum =
+	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_lane_sel_texts),
+			s4_tocodec_lane_sel_texts);
+
+static const struct snd_kcontrol_new s4_tocodec_lane_sel =
+	SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
+
+static const char * const s4_tocodec_src_sel_texts[] = {
+	"TDMA", "TDMB", "TDMC"
+};
+
+static const struct soc_enum s4_tocodec_src_sel_enum =
+	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_src_sel_texts),
+			s4_tocodec_src_sel_texts);
+
+static const struct snd_kcontrol_new s4_tocodec_src_sel =
+	SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
+
+static const struct snd_kcontrol_new s4_toacodec_out_enable =
+	SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
+				    CTRL0_ENABLE_SHIFT, 1, 0);
+
+static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
+{
+	struct snd_soc_dapm_path *p;
+	struct snd_soc_dai *be;
+
+	snd_soc_dapm_widget_for_each_source_path(w, p) {
+		if (!p->connect)
+			continue;
+		if (p->source->id == snd_soc_dapm_dai_in)
+			return (struct snd_soc_dai *)p->source->priv;
+		be = tocodec_tdm_get_ahead_be(p->source);
+		if (be && be->id == TDM_IFACE)
+			return be;
+	}
+	return NULL;
+}
+
+static unsigned int aml_simple_strtoull(const char *cp)
+{
+	unsigned int result = 0;
+	unsigned int value = 0;
+	unsigned int len = strlen(cp);
+
+	while (len != 0) {
+		len--;
+		value = isdigit(*cp);
+		if (value) {
+			value = *cp - '0';
+		} else {
+			cp++;
+			continue;
+		}
+		cp++;
+		result = result * 10 + value;
+	}
+	return result;
+}
+
+static int aml_get_clk_id(const char *name)
+{
+	int clk_id = 0;
+
+	if (strstr(name, "mst_a"))
+		clk_id = 0;
+	else if (strstr(name, "mst_b"))
+		clk_id = 1;
+	else if (strstr(name, "mst_c"))
+		clk_id = 2;
+	else if (strstr(name, "mst_d"))
+		clk_id = 3;
+	else if (strstr(name, "mst_e"))
+		clk_id = 4;
+	else if (strstr(name, "mst_f"))
+		clk_id = 5;
+
+	return clk_id;
+}
+
+static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
+{
+	struct snd_soc_dai *be;
+	struct axg_tdm_stream *stream;
+	struct axg_tdm_iface *iface;
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct toacodec *priv = snd_soc_component_get_drvdata(component);
+	unsigned int tdm_id = TDM_A_PAD;
+	const char *dai_widget_name;
+	struct snd_soc_dapm_path *p;
+	unsigned int lane = 0;
+	unsigned int val = 0;
+	struct clk *sclk, *mclk;
+	char *clk_name;
+	int mclk_id, sclk_id;
+
+	be = tocodec_tdm_get_ahead_be(w);
+	if (!be) {
+		dev_err(component->dev, "%s not find the be\n", __func__);
+		return -EINVAL;
+	}
+	stream = snd_soc_dai_dma_data_get_playback(be);
+	if (!stream) {
+		dev_err(component->dev, "%s not find the stream\n", __func__);
+		return -EINVAL;
+	}
+	/*we like to use dai id, but it is fixed val*/
+	dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
+	if (strstr(dai_widget_name, "TDM_A"))
+		tdm_id = TDM_A_PAD;
+	else if (strstr(dai_widget_name, "TDM_B"))
+		tdm_id = TDM_B_PAD;
+	else if (strstr(dai_widget_name, "TDM_C"))
+		tdm_id = TDM_C_PAD;
+	snd_soc_dapm_widget_for_each_source_path(w, p) {
+		if (p->connect && p->name) {
+			lane = aml_simple_strtoull(p->name);
+			val = lane + tdm_id * S4_LANE_OFFSET;
+			regmap_field_write(priv->field_dat_sel, val);
+		}
+	}
+	iface = stream->iface;
+	mclk = iface->mclk;
+	sclk = iface->sclk;
+	mclk_id = aml_get_clk_id(__clk_get_name(mclk));
+	sclk_id = aml_get_clk_id(__clk_get_name(sclk));
+	regmap_field_write(priv->field_mclk_sel, mclk_id);
+	regmap_field_write(priv->field_bclk_sel, sclk_id);
+	regmap_field_write(priv->field_lrclk_sel, sclk_id);
+
+	return 0;
+}
+
+static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
+			     struct snd_kcontrol *control,
+			     int event)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	int ret = 0;
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		ret = aml_tocodec_sel_set(w);
+		break;
+
+	case SND_SOC_DAPM_PRE_PMD:
+		break;
+
+	default:
+		dev_err(component->dev, "Unexpected event %d\n", event);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
+			      struct snd_kcontrol *control,
+			      int event)
+{
+	int ret = 0;
+	unsigned int mask = 0, val = 0;
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+
+	snd_soc_component_update_bits(component, TOACODEC_CTRL0,
+				      1 << CTRL0_BLK_CAP_INV_SHIFT, 1 << CTRL0_BLK_CAP_INV_SHIFT);
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
+		val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
+		snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
+		break;
+	case SND_SOC_DAPM_PRE_PMD:
+		mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
+		val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << CTRL0_BCLK_ENABLE_SHIFT;
+		snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
+		break;
+	default:
+		dev_err(component->dev, "Unexpected event %d\n", event);
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
+static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
+	SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
+			   &s4_tocodec_lane_sel, tocodec_sel_event,
+			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
+	SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, &s4_tocodec_src_sel),
+	SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
+			      &s4_toacodec_out_enable, tocodec_clk_enable,
+				(SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
+	SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
+};
+
+static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
+	{ "INPUT SRC", "TDMA", "TDMA"},
+	{ "INPUT SRC", "TDMB", "TDMB"},
+	{ "INPUT SRC", "TDMC", "TDMC"},
+	{ "Lane0", NULL, "INPUT SRC" },
+	{ "Lane1", NULL, "INPUT SRC"},
+	{ "Lane2", NULL, "INPUT SRC"},
+	{ "Lane3", NULL, "INPUT SRC"},
+	{ "Lane4", NULL, "INPUT SRC"},
+	{ "Lane5", NULL, "INPUT SRC"},
+	{ "Lane6", NULL, "INPUT SRC"},
+	{ "Lane7", NULL, "INPUT SRC"},
+	{ "Lane SRC", "Lane0", "Lane0"},
+	{ "Lane SRC", "Lane1", "Lane1"},
+	{ "Lane SRC", "Lane2", "Lane2"},
+	{ "Lane SRC", "Lane3", "Lane3"},
+	{ "Lane SRC", "Lane4", "Lane4"},
+	{ "Lane SRC", "Lane5", "Lane5"},
+	{ "Lane SRC", "Lane6", "Lane6"},
+	{ "Lane SRC", "Lane7", "Lane7"},
+	{ "OUT EN", "Switch", "Lane SRC"},
+	{ "TDM_TO_ACODEC", NULL, "OUT EN"},
+
+};
+
+static const struct snd_soc_component_driver s4_tocodec_component_drv = {
+	.dapm_widgets		= s4_toacodec_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(s4_toacodec_widgets),
+	.dapm_routes		= s4_tocodec_dapm_routes,
+	.num_dapm_routes	= ARRAY_SIZE(s4_tocodec_dapm_routes),
+};
+
+static const struct toacodec_match_data s4_toacodec_match_data = {
+	.component_drv	= &s4_tocodec_component_drv,
+	.field_dat_sel	= REG_FIELD(TOACODEC_CTRL0, 16, 20),
+	.field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
+	.field_bclk_sel	= REG_FIELD(TOACODEC_CTRL0, 4, 6),
+	.field_mclk_sel	= REG_FIELD(TOACODEC_CTRL0, 0, 2),
+};
+
+static const struct of_device_id s4_tocodec_of_match[] = {
+	{
+		.compatible = "amlogic,s4-tocodec",
+		.data = &s4_toacodec_match_data,
+	}, {}
+};
+
+MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
+
+static int tocodec_probe(struct platform_device *pdev)
+{
+	const struct toacodec_match_data *data;
+	struct device *dev = &pdev->dev;
+	struct toacodec *priv;
+	void __iomem *regs;
+	struct regmap *map;
+	int ret;
+
+	data = device_get_match_data(dev);
+	if (!data)
+		return dev_err_probe(dev, -ENODEV, "failed to match device\n");
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+
+	ret = device_reset(dev);
+	if (ret)
+		return ret;
+
+	regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
+
+	map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
+	if (IS_ERR(map))
+		return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
+
+	priv->field_dat_sel = devm_regmap_field_alloc(dev, map, data->field_dat_sel);
+	if (IS_ERR(priv->field_dat_sel))
+		return PTR_ERR(priv->field_dat_sel);
+
+	priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, data->field_lrclk_sel);
+	if (IS_ERR(priv->field_lrclk_sel))
+		return PTR_ERR(priv->field_lrclk_sel);
+
+	priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, data->field_bclk_sel);
+	if (IS_ERR(priv->field_bclk_sel))
+		return PTR_ERR(priv->field_bclk_sel);
+
+	priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, data->field_mclk_sel);
+	if (IS_ERR(priv->field_mclk_sel))
+		return PTR_ERR(priv->field_mclk_sel);
+
+	return devm_snd_soc_register_component(dev,
+			data->component_drv, NULL, 0);
+}
+
+static struct platform_driver tocodec_pdrv = {
+	.probe = tocodec_probe,
+	.driver = {
+		.name = "s4-tocodec",
+		.of_match_table = s4_tocodec_of_match,
+	},
+};
+
+module_platform_driver(tocodec_pdrv);
+
+MODULE_DESCRIPTION("Amlogic to codec driver");
+MODULE_AUTHOR("jiebing.chen@amlogic.com");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
index 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 100644
--- a/sound/soc/meson/t9015.c
+++ b/sound/soc/meson/t9015.c
@@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
 		.channels_min = 1,
 		.channels_max = 2,
 		.rates = SNDRV_PCM_RATE_8000_96000,
-		.formats = (SNDRV_PCM_FMTBIT_S8 |
-			    SNDRV_PCM_FMTBIT_S16_LE |
-			    SNDRV_PCM_FMTBIT_S20_LE |
-			    SNDRV_PCM_FMTBIT_S24_LE),
+		.formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE),
 	},
 	.ops = &t9015_dai_ops,
 };

-- 
2.43.0




^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-13  6:35 [PATCH 0/3] Add support for S4 audio jiebing chen via B4 Relay
  2025-01-13  6:35 ` [PATCH 1/3] ASoC: dt-bindings: Add Amlogic " jiebing chen via B4 Relay
  2025-01-13  6:35 ` [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio jiebing chen via B4 Relay
@ 2025-01-13  6:35 ` jiebing chen via B4 Relay
  2025-01-13 14:50   ` Jerome Brunet
  2025-01-13 15:26 ` [PATCH 0/3] Add support for S4 audio Rob Herring (Arm)
  3 siblings, 1 reply; 27+ messages in thread
From: jiebing chen via B4 Relay @ 2025-01-13  6:35 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl
  Cc: linux-sound, devicetree, linux-kernel, linux-arm-kernel,
	linux-amlogic, jiebing chen

From: jiebing chen <jiebing.chen@amlogic.com>

Add basic audio driver support for the Amlogic S4 based Amlogic
AQ222 board.

Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
---
 .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
 arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
 2 files changed, 610 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
--- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
@@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
 	       regulator-always-on;
 	};
 
+	vcc5v_reg: regulator-vcc-5v {
+		compatible = "regulator-fixed";
+		vin-supply = <&main_12v>;
+		regulator-name = "VCC5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
+		startup-delay-us = <7000>;
+		enable-active-high;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
 	/* SY8120B1ABC DC/DC Regulator. */
 	vddcpu: regulator-vddcpu {
 		compatible = "pwm-regulator";
@@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
 				<699000 98>,
 				<689000 100>;
 	};
+	dmics: audio-codec-1 {
+		compatible = "dmic-codec";
+		#sound-dai-cells = <0>;
+		num-channels = <2>;
+		wakeup-delay-ms = <50>;
+		sound-name-prefix = "MIC";
+	};
+
+	dioo2133: audio-amplifier-0 {
+		compatible = "simple-audio-amplifier";
+		enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
+		VCC-supply = <&vcc5v_reg>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "10U2";
+	};
+
+	spdif_dir: audio-spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "DIR";
+	};
+
+	spdif_dit: audio-spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "DIT";
+	};
+
+	sound {
+		compatible = "amlogic,axg-sound-card";
+		model = "aq222";
+		audio-widgets = "Line", "Lineout";
+		audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
+				 <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
+				 <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
+		audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
+				"TDMOUT_A IN 1", "FRDDR_B OUT 0",
+				"TDMOUT_A IN 2", "FRDDR_C OUT 0",
+				"TDM_A Playback", "TDMOUT_A OUT",
+				"TDMA_OUT SEL",   "TDM_A Playback",
+				"TDMOUT_B IN 0", "FRDDR_A OUT 1",
+				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
+				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
+				"TDM_B Playback", "TDMOUT_B OUT",
+				"TDMB_OUT SEL",   "TDM_B Playback",
+				"TDMOUT_C IN 0", "FRDDR_A OUT 2",
+				"TDMOUT_C IN 1", "FRDDR_B OUT 2",
+				"TDMOUT_C IN 2", "FRDDR_C OUT 2",
+				"TDM_C Playback", "TDMOUT_C OUT",
+				"TDMC_OUT SEL",   "TDM_C Playback",
+				"TOACODEC TDMA", "TDM_A Playback",
+				"TOACODEC TDMB", "TDM_B Playback",
+				"TOACODEC TDMC", "TDM_C Playback",
+				"SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
+				"SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
+				"SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
+				"SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
+				"SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
+				"SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
+				"TDMIN_A IN 0", "TDM_A Capture",
+				"TDMIN_A IN 1", "TDM_B Capture",
+				"TDMIN_A IN 2", "TDM_C Capture",
+				"TDMIN_A IN 3", "TDM_A Loopback",
+				"TDMIN_A IN 4", "TDM_B Loopback",
+				"TDMIN_A IN 5", "TDM_C Loopback",
+				"TDMIN_B IN 0", "TDM_A Capture",
+				"TDMIN_B IN 1", "TDM_B Capture",
+				"TDMIN_B IN 2", "TDM_C Capture",
+				"TDMIN_B IN 3", "TDM_A Loopback",
+				"TDMIN_B IN 4", "TDM_B Loopback",
+				"TDMIN_B IN 5", "TDM_C Loopback",
+				"TDMIN_C IN 0", "TDM_A Capture",
+				"TDMIN_C IN 1", "TDM_B Capture",
+				"TDMIN_C IN 2", "TDM_C Capture",
+				"TDMIN_C IN 3", "TDM_A Loopback",
+				"TDMIN_C IN 4", "TDM_B Loopback",
+				"TDMIN_C IN 5", "TDM_C Loopback",
+				"TDMIN_LB IN 3", "TDM_A Capture",
+				"TDMIN_LB IN 4", "TDM_B Capture",
+				"TDMIN_LB IN 5", "TDM_C Capture",
+				"TDMIN_LB IN 0", "TDM_A Loopback",
+				"TDMIN_LB IN 1", "TDM_B Loopback",
+				"TDMIN_LB IN 2", "TDM_C Loopback",
+				"TODDR_A IN 0", "TDMIN_A OUT",
+				"TODDR_B IN 0", "TDMIN_A OUT",
+				"TODDR_C IN 0", "TDMIN_A OUT",
+				"TODDR_A IN 1", "TDMIN_B OUT",
+				"TODDR_B IN 1", "TDMIN_B OUT",
+				"TODDR_C IN 1", "TDMIN_B OUT",
+				"TODDR_A IN 2", "TDMIN_C OUT",
+				"TODDR_B IN 2", "TDMIN_C OUT",
+				"TODDR_C IN 2", "TDMIN_C OUT",
+				"TODDR_A IN 3", "SPDIFIN Capture",
+				"TODDR_B IN 3", "SPDIFIN Capture",
+				"TODDR_C IN 3", "SPDIFIN Capture",
+				"TODDR_A IN 6", "TDMIN_LB OUT",
+				"TODDR_B IN 6", "TDMIN_LB OUT",
+				"TODDR_C IN 6", "TDMIN_LB OUT",
+				"10U2 INL", "ACODEC LOLP",
+				"10U2 INR", "ACODEC LORP",
+				"Lineout", "10U2 OUTL",
+				"Lineout", "10U2 OUTR";
+		assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
+				  <&clkc_pll CLKID_MPLL2>,
+				  <&clkc_pll CLKID_MPLL0>,
+				  <&clkc_pll CLKID_MPLL1>;
+		assigned-clock-rates = <491520000>,
+				       <294912000>,
+				       <270950400>,
+				       <393216000>;
+
+		dai-link-0 {
+			sound-dai = <&frddr_a>;
+		};
+
+		dai-link-1 {
+			sound-dai = <&frddr_b>;
+		};
+
+		dai-link-2 {
+			sound-dai = <&frddr_c>;
+		};
+
+		dai-link-3 {
+			sound-dai = <&toddr_a>;
+		};
+
+		dai-link-4 {
+			sound-dai = <&toddr_b>;
+		};
+
+		dai-link-5 {
+			sound-dai = <&toddr_c>;
+		};
+
+		/* Connected to the WIFI/BT chip */
+		dai-link-6 {
+			sound-dai = <&tdmif_a>;
+			dai-format = "dsp_a";
+			dai-tdm-slot-tx-mask-0 = <1 1>;
+			mclk-fs = <256>;
+			codec-0 {
+				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
+			};
+		};
+
+		/* Connected to the onboard AD82584F DAC */
+		dai-link-7 {
+			sound-dai = <&tdmif_b>;
+			dai-format = "i2s";
+			dai-tdm-slot-tx-mask-0 = <1 1>;
+			mclk-fs = <256>;
+
+			codec-0 {
+				sound-dai = <&acodec>;
+			};
+
+			codec-1 {
+				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
+			};
+		};
+
+		/* 8ch HDMI interface */
+		dai-link-8 {
+			sound-dai = <&tdmif_c>;
+			dai-format = "i2s";
+			dai-tdm-slot-tx-mask-0 = <1 1>;
+			dai-tdm-slot-tx-mask-1 = <1 1>;
+			dai-tdm-slot-tx-mask-2 = <1 1>;
+			dai-tdm-slot-tx-mask-3 = <1 1>;
+			mclk-fs = <256>;
+
+			codec-0 {
+				sound-dai = <&acodec>;
+			};
+
+			codec-1 {
+				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
+			};
+		};
+
+		/* spdif hdmi and coax output */
+		dai-link-9 {
+			sound-dai = <&spdifout_a>;
+
+			codec-0 {
+				sound-dai = <&spdif_dit>;
+			};
+
+			codec-1 {
+				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
+			};
+		};
+
+		/* spdif hdmi interface */
+		dai-link-10 {
+			sound-dai = <&spdifout_b>;
+
+			codec {
+				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
+			};
+		};
+
+		/* spdif coax input */
+		dai-link-11 {
+			sound-dai = <&spdifin>;
+
+			codec {
+				sound-dai = <&spdif_dir>;
+			};
+		};
+	};
+
 };
 
 &pwm_ef {
diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
index 957577d986c0675a503115e1ccbc4387c2051620..87a00ace23131e31822bb43fbe956b8abcbaef40 100644
--- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
@@ -11,7 +11,11 @@
 #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
 #include <dt-bindings/power/meson-s4-power.h>
 #include <dt-bindings/reset/amlogic,meson-s4-reset.h>
-
+#include <dt-bindings/clock/axg-audio-clkc.h>
+#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
+#include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
+#include <dt-bindings/sound/meson-g12a-toacodec.h>
+#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
 / {
 	cpus {
 		#address-cells = <2>;
@@ -46,6 +50,42 @@ cpu3: cpu@3 {
 		};
 	};
 
+	tdmif_a: audio-controller-0 {
+		compatible = "amlogic,axg-tdm-iface";
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "TDM_A";
+		clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
+			 <&clkc_audio AUD_CLKID_MST_A_SCLK>,
+			 <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
+		clock-names = "mclk", "sclk", "lrclk";
+		assigned-clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK_SEL>;
+		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
+	};
+
+	tdmif_b: audio-controller-1 {
+		compatible = "amlogic,axg-tdm-iface";
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "TDM_B";
+		clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK>,
+			 <&clkc_audio AUD_CLKID_MST_B_SCLK>,
+			 <&clkc_audio AUD_CLKID_MST_B_LRCLK>;
+		clock-names = "mclk", "sclk", "lrclk";
+		assigned-clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK_SEL>;
+		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
+	};
+
+	tdmif_c: audio-controller-2 {
+		compatible = "amlogic,axg-tdm-iface";
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "TDM_C";
+		clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK>,
+			 <&clkc_audio AUD_CLKID_MST_C_SCLK>,
+			 <&clkc_audio AUD_CLKID_MST_C_LRCLK>;
+		clock-names = "mclk", "sclk", "lrclk";
+		assigned-clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK_SEL>;
+		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
@@ -850,3 +890,346 @@ emmc: mmc@fe08c000 {
 		};
 	};
 };
+
+&apb4 {
+	audio: bus@330000 {
+		compatible = "simple-bus";
+		reg = <0x0 0x330000 0x0 0x1000>;
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges = <0x0 0x0 0x0 0x330000 0x0 0x1000>;
+
+		clkc_audio: clock-controller@0 {
+			compatible = "amlogic,sm1-audio-clkc";
+			reg = <0x0 0x0 0x0 0xb4>;
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+			power-domains = <&pwrc PWRC_S4_AUDIO_ID>;
+			clocks = <&clkc_periphs CLKID_AUDIO>,
+				 <&clkc_pll CLKID_MPLL0>,
+				 <&clkc_pll CLKID_MPLL1>,
+				 <&clkc_pll CLKID_MPLL2>,
+				 <&clkc_pll CLKID_MPLL3>,
+				 <&clkc_pll CLKID_HIFI_PLL>,
+				 <&clkc_pll CLKID_FCLK_DIV3>,
+				 <&clkc_pll CLKID_FCLK_DIV4>,
+				 <&clkc_pll CLKID_FCLK_DIV5>;
+			clock-names = "pclk",
+				      "mst_in0",
+				      "mst_in1",
+				      "mst_in2",
+				      "mst_in3",
+				      "mst_in4",
+				      "mst_in5",
+				      "mst_in6",
+				      "mst_in7";
+
+			resets = <&reset RESET_AUDIO>;
+		};
+
+		toddr_a: audio-controller@100 {
+			compatible = "amlogic,sm1-toddr",
+				     "amlogic,axg-toddr";
+			reg = <0x0 0x100 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "TODDR_A";
+			interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_TODDR_A>;
+			resets = <&arb AXG_ARB_TODDR_A>,
+				 <&clkc_audio AUD_RESET_TODDR_A>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <8192>;
+		};
+
+		toddr_b: audio-controller@140 {
+			compatible = "amlogic,sm1-toddr",
+				     "amlogic,axg-toddr";
+			reg = <0x0 0x140 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "TODDR_B";
+			interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_TODDR_B>;
+			resets = <&arb AXG_ARB_TODDR_B>,
+				 <&clkc_audio AUD_RESET_TODDR_B>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		toddr_c: audio-controller@180 {
+			compatible = "amlogic,sm1-toddr",
+				     "amlogic,axg-toddr";
+			reg = <0x0 0x180 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "TODDR_C";
+			interrupts = <GIC_SPI 34 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_TODDR_C>;
+			resets = <&arb AXG_ARB_TODDR_C>,
+				 <&clkc_audio AUD_RESET_TODDR_C>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		frddr_a: audio-controller@1c0 {
+			compatible = "amlogic,sm1-frddr",
+				     "amlogic,axg-frddr";
+			reg = <0x0 0x1c0 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "FRDDR_A";
+			interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
+			resets = <&arb AXG_ARB_FRDDR_A>,
+				 <&clkc_audio AUD_RESET_FRDDR_A>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <512>;
+		};
+
+		frddr_b: audio-controller@200 {
+			compatible = "amlogic,sm1-frddr",
+				     "amlogic,axg-frddr";
+			reg = <0x0 0x200 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "FRDDR_B";
+			interrupts = <GIC_SPI 37 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_FRDDR_B>;
+			resets = <&arb AXG_ARB_FRDDR_B>,
+				 <&clkc_audio AUD_RESET_FRDDR_B>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		frddr_c: audio-controller@240 {
+			compatible = "amlogic,sm1-frddr",
+				     "amlogic,axg-frddr";
+			reg = <0x0 0x240 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "FRDDR_C";
+			interrupts = <GIC_SPI 38 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_FRDDR_C>;
+			resets = <&arb AXG_ARB_FRDDR_C>,
+				 <&clkc_audio AUD_RESET_FRDDR_C>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		arb: reset-controller@280 {
+			compatible = "amlogic,meson-sm1-audio-arb";
+			reg = <0x0 0x280 0x0 0x4>;
+			#reset-cells = <1>;
+			clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
+		};
+
+		tdmin_a: audio-controller@300 {
+			compatible = "amlogic,sm1-tdmin",
+				     "amlogic,axg-tdmin";
+			reg = <0x0 0x300 0x0 0x40>;
+			sound-name-prefix = "TDMIN_A";
+			resets = <&clkc_audio AUD_RESET_TDMIN_A>;
+			clocks = <&clkc_audio AUD_CLKID_TDMIN_A>,
+				 <&clkc_audio AUD_CLKID_TDMIN_A_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_A_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		tdmin_b: audio-controller@340 {
+			compatible = "amlogic,sm1-tdmin",
+				     "amlogic,axg-tdmin";
+			reg = <0x0 0x340 0x0 0x40>;
+			sound-name-prefix = "TDMIN_B";
+			resets = <&clkc_audio AUD_RESET_TDMIN_B>;
+			clocks = <&clkc_audio AUD_CLKID_TDMIN_B>,
+				 <&clkc_audio AUD_CLKID_TDMIN_B_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_B_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		tdmin_c: audio-controller@380 {
+			compatible = "amlogic,sm1-tdmin",
+				     "amlogic,axg-tdmin";
+			reg = <0x0 0x380 0x0 0x40>;
+			sound-name-prefix = "TDMIN_C";
+			resets = <&clkc_audio AUD_RESET_TDMIN_C>;
+			clocks = <&clkc_audio AUD_CLKID_TDMIN_C>,
+				 <&clkc_audio AUD_CLKID_TDMIN_C_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_C_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		tdmin_lb: audio-controller@3c0 {
+			compatible = "amlogic,sm1-tdmin",
+				     "amlogic,axg-tdmin";
+			reg = <0x0 0x3c0 0x0 0x40>;
+			sound-name-prefix = "TDMIN_LB";
+			resets = <&clkc_audio AUD_RESET_TDMIN_LB>;
+			clocks = <&clkc_audio AUD_CLKID_TDMIN_LB>,
+				 <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		spdifin: audio-controller@400 {
+			compatible = "amlogic,g12a-spdifin",
+				     "amlogic,axg-spdifin";
+			reg = <0x0 0x400 0x0 0x30>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "SPDIFIN";
+			interrupts = <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
+			<&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
+			clock-names = "pclk", "refclk";
+			resets = <&clkc_audio AUD_RESET_SPDIFIN>;
+		};
+
+		spdifout_a: audio-controller@480 {
+			compatible = "amlogic,g12a-spdifout",
+				     "amlogic,axg-spdifout";
+			reg = <0x0 0x480 0x0 0x50>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "SPDIFOUT_A";
+			clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
+			<&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
+			clock-names = "pclk", "mclk";
+			resets = <&clkc_audio AUD_RESET_SPDIFOUT>;
+		};
+
+		tdmout_a: audio-controller@500 {
+			compatible = "amlogic,sm1-tdmout";
+			reg = <0x0 0x500 0x0 0x40>;
+			sound-name-prefix = "TDMOUT_A";
+			resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
+			clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		tdmout_b: audio-controller@540 {
+			compatible = "amlogic,sm1-tdmout";
+			reg = <0x0 0x540 0x0 0x40>;
+			sound-name-prefix = "TDMOUT_B";
+			resets = <&clkc_audio AUD_RESET_TDMOUT_B>;
+			clocks = <&clkc_audio AUD_CLKID_TDMOUT_B>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		tdmout_c: audio-controller@580 {
+			compatible = "amlogic,sm1-tdmout";
+			reg = <0x0 0x580 0x0 0x40>;
+			sound-name-prefix = "TDMOUT_C";
+			resets = <&clkc_audio AUD_RESET_TDMOUT_C>;
+			clocks = <&clkc_audio AUD_CLKID_TDMOUT_C>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK_SEL>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>,
+				 <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>;
+			clock-names = "pclk", "sclk", "sclk_sel",
+				      "lrclk", "lrclk_sel";
+		};
+
+		spdifout_b: audio-controller@680 {
+			compatible = "amlogic,g12a-spdifout",
+				     "amlogic,axg-spdifout";
+			reg = <0x0 0x680 0x0 0x50>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "SPDIFOUT_B";
+			clocks = <&clkc_audio AUD_CLKID_SPDIFOUT_B>,
+				 <&clkc_audio AUD_CLKID_SPDIFOUT_B_CLK>;
+			clock-names = "pclk", "mclk";
+			resets = <&clkc_audio AUD_RESET_SPDIFOUT_B>;
+		};
+
+		toacodec: audio-controller@740 {
+			compatible = "amlogic,s4-tocodec";
+			reg = <0x0 0x740 0x0 0x4>;
+			sound-name-prefix = "TOACODEC";
+			resets = <&clkc_audio AUD_RESET_TOACODEC>;
+		};
+
+		tohdmitx: audio-controller@744 {
+			compatible = "amlogic,sm1-tohdmitx",
+				     "amlogic,g12a-tohdmitx";
+			reg = <0x0 0x744 0x0 0x4>;
+			#sound-dai-cells = <1>;
+			sound-name-prefix = "TOHDMITX";
+			resets = <&clkc_audio AUD_RESET_TOHDMITX>;
+		};
+
+		toddr_d: audio-controller@840 {
+			compatible = "amlogic,sm1-toddr",
+				     "amlogic,axg-toddr";
+			reg = <0x0 0x840 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "TODDR_D";
+			interrupts = <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_TODDR_D>;
+			resets = <&arb AXG_ARB_TODDR_D>,
+				 <&clkc_audio AUD_RESET_TODDR_D>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		frddr_d: audio-controller@880 {
+			 compatible = "amlogic,sm1-frddr",
+				      "amlogic,axg-frddr";
+			reg = <0x0 0x880 0x0 0x2c>;
+			#sound-dai-cells = <0>;
+			sound-name-prefix = "FRDDR_D";
+			interrupts = <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc_audio AUD_CLKID_FRDDR_D>;
+			resets = <&arb AXG_ARB_FRDDR_D>,
+				 <&clkc_audio AUD_RESET_FRDDR_D>;
+			reset-names = "arb", "rst";
+			amlogic,fifo-depth = <256>;
+		};
+
+		tdmout_pad: audio-controller@E58 {
+			compatible = "amlogic,s4-tdmout-pad";
+			reg = <0x0 0xe58 0x0 0x28>;
+		};
+	};
+
+	pdm: audio-controller@331000 {
+		compatible = "amlogic,sm1-pdm",
+			     "amlogic,axg-pdm";
+		reg = <0x0 0x331000 0x0 0x34>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "PDM";
+		clocks = <&clkc_audio AUD_CLKID_PDM>,
+			 <&clkc_audio AUD_CLKID_PDM_DCLK>,
+			 <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
+		clock-names = "pclk", "dclk", "sysclk";
+		resets = <&clkc_audio AUD_RESET_PDM>;
+		assigned-clocks = <&clkc_audio AUD_CLKID_PDM_DCLK_SEL>,
+				  <&clkc_audio AUD_CLKID_PDM_SYSCLK_SEL>;
+		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>,<&clkc_pll CLKID_HIFI_PLL>;
+	};
+	 acodec: audio-controller@1A000 {
+		compatible = "amlogic,t9015";
+		reg = <0x0 0x1A000 0x0 0x14>;
+		#sound-dai-cells = <0>;
+		sound-name-prefix = "ACODEC";
+		clocks = <&clkc_periphs CLKID_ACODEC>;
+		clock-names = "pclk";
+		resets = <&reset RESET_ACODEC>;
+	};
+
+};

-- 
2.43.0




^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/3] ASoC: dt-bindings: Add Amlogic S4 audio
  2025-01-13  6:35 ` [PATCH 1/3] ASoC: dt-bindings: Add Amlogic " jiebing chen via B4 Relay
@ 2025-01-13  7:19   ` Rob Herring (Arm)
  0 siblings, 0 replies; 27+ messages in thread
From: Rob Herring (Arm) @ 2025-01-13  7:19 UTC (permalink / raw)
  To: jiebing chen
  Cc: Jaroslav Kysela, Kevin Hilman, linux-sound, Jerome Brunet,
	Krzysztof Kozlowski, linux-arm-kernel, Neil Armstrong,
	linux-kernel, Conor Dooley, Mark Brown, Takashi Iwai, devicetree,
	linux-amlogic, Martin Blumenstingl, Liam Girdwood


On Mon, 13 Jan 2025 14:35:13 +0800, jiebing chen wrote:
> Add documentation describing the Amlogic S4 TDM output pad and toacodec.
> 
> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
> ---
>  .../bindings/sound/amlogic,s4-tdmout-pad.yaml      | 36 ++++++++++++++++++
>  .../bindings/sound/amlogic,s4-tocodec.yaml         | 44 ++++++++++++++++++++++
>  2 files changed, 80 insertions(+)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/sound/amlogic,s4-tocodec.example.dts:23.35-36 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.dtbs:131: Documentation/devicetree/bindings/sound/amlogic,s4-tocodec.example.dtb] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1506: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250113-audio_drvier-v1-1-8c14770f38a0@amlogic.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-13  6:35 ` [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio jiebing chen via B4 Relay
@ 2025-01-13 14:31   ` Jerome Brunet
  2025-01-14  8:16     ` Jiebing Chen
  2025-01-14  9:09   ` kernel test robot
  1 sibling, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-13 14:31 UTC (permalink / raw)
  To: jiebing chen via B4 Relay
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jaroslav Kysela, Takashi Iwai, Neil Armstrong,
	Kevin Hilman, Martin Blumenstingl, jiebing.chen, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:

> From: jiebing chen <jiebing.chen@amlogic.com>
>
> Add audio support for Amlogic S4.The audio output pad
> can be freelycombined with the output lane,and the tocodec
> control logic has been optimized.

The patch is a mixture of different HW modules.

Each patch should have one clear purpose and, as such, deal with a
single HW module

>
> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
> ---
>  sound/soc/meson/Kconfig              |  16 ++
>  sound/soc/meson/Makefile             |   6 +
>  sound/soc/meson/s4-pad-out-control.c | 372 ++++++++++++++++++++++++++++++++++
>  sound/soc/meson/s4-tocodec-control.c | 376 +++++++++++++++++++++++++++++++++++
>  sound/soc/meson/t9015.c              |   5 +-
>  5 files changed, 771 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
> index 6458d5dc4902f665211bb9e4ae7d274e4bff2fdc..d01e284642fd987cf4bdf88e5bf5f7c9a241af59 100644
> --- a/sound/soc/meson/Kconfig
> +++ b/sound/soc/meson/Kconfig
> @@ -69,6 +69,8 @@ config SND_MESON_AXG_SOUND_CARD
>  	imply SND_MESON_AXG_SPDIFIN
>  	imply SND_MESON_AXG_PDM
>  	imply SND_MESON_G12A_TOACODEC
> +	imply SND_SOC_MESON_PAD_OUT
> +	imply SND_SOC_MESON_TOCODEC_CONTROL
>  	imply SND_MESON_G12A_TOHDMITX if DRM_MESON_DW_HDMI
>  	help
>  	  Select Y or M to add support for the AXG SoC sound card
> @@ -135,4 +137,18 @@ config SND_SOC_MESON_T9015
>  	help
>  	  Say Y or M if you want to add support for the internal DAC found
>  	  on GXL, G12 and SM1 SoC family.
> +
> +config SND_SOC_MESON_PAD_OUT
> +	tristate "Amlogic PAD OUT"
> +	select REGMAP_MMIO
> +	help
> +	  Say Y or M if you want to add support for the S4 Audio Output from
> +	  the data Pad.
> +
> +config SND_SOC_MESON_TOCODEC_CONTROL
> +	tristate "Amlogic TOCODEC CONTROL"
> +	select REGMAP_MMIO
> +	help
> +	 Say Y or M if you want to add support for the internal DAC control
> +	 on SM1 SoC family.
>  endmenu
> diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile
> index 24078e4396b02d545d8ba4bcb1632979001354e3..afbefcb1313670f9b1365e88b8eb1a0badd7dc1e 100644
> --- a/sound/soc/meson/Makefile
> +++ b/sound/soc/meson/Makefile
> @@ -24,8 +24,11 @@ snd-soc-meson-codec-glue-y := meson-codec-glue.o
>  snd-soc-meson-gx-sound-card-y := gx-card.o
>  snd-soc-meson-g12a-toacodec-y := g12a-toacodec.o
>  snd-soc-meson-g12a-tohdmitx-y := g12a-tohdmitx.o
> +snd-soc-meson-s4-padout-objs := s4-pad-out-control.o
> +snd-soc-meson-s4-tocodec-control-objs := s4-tocodec-control.o
>  snd-soc-meson-t9015-y := t9015.o
>  
> +
>  obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o
>  obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
>  obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
> @@ -43,4 +46,7 @@ obj-$(CONFIG_SND_MESON_CODEC_GLUE) += snd-soc-meson-codec-glue.o
>  obj-$(CONFIG_SND_MESON_GX_SOUND_CARD) += snd-soc-meson-gx-sound-card.o
>  obj-$(CONFIG_SND_MESON_G12A_TOACODEC) += snd-soc-meson-g12a-toacodec.o
>  obj-$(CONFIG_SND_MESON_G12A_TOHDMITX) += snd-soc-meson-g12a-tohdmitx.o
> +obj-$(CONFIG_SND_SOC_MESON_PAD_OUT) += snd-soc-meson-s4-padout.o
> +obj-$(CONFIG_SND_SOC_MESON_TOCODEC_CONTROL) += snd-soc-meson-s4-tocodec-control.o
>  obj-$(CONFIG_SND_SOC_MESON_T9015) += snd-soc-meson-t9015.o
> +
> diff --git a/sound/soc/meson/s4-pad-out-control.c b/sound/soc/meson/s4-pad-out-control.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..a86dcf8a5995926f0ddf8d2911f42006daed0feb
> --- /dev/null
> +++ b/sound/soc/meson/s4-pad-out-control.c
> @@ -0,0 +1,372 @@
> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
> +/*
> + * Copyright (C) 2024 Amlogic, Inc. All rights reserved
> + */
> +
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/regmap.h>
> +#include <sound/soc.h>
> +#include <sound/soc-dai.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include<linux/kstrtox.h>
> +
> +#include "axg-tdm.h"
> +
> +static const struct regmap_config tdmout_pad_regmap_cfg = {
> +	.reg_bits	= 32,
> +	.val_bits	= 32,
> +	.reg_stride	= 4,
> +	.max_register	= 0x28,
> +};
> +
> +#define TDM_IFACE 0
> +#define TDM_A_PAD 0
> +#define TDM_B_PAD 1
> +#define TDM_C_PAD 2
> +
> +#define EE_AUDIO_DAT_PAD_CTRL6 0x0
> +#define EE_AUDIO_DAT_PAD_CTRL7 0x4
> +#define EE_AUDIO_DAT_PAD_CTRL8 0x8
> +#define EE_AUDIO_DAT_PAD_CTRL9 0xc
> +#define EE_AUDIO_DAT_PAD_CTRLA 0x10
> +#define EE_AUDIO_DAT_PAD_CTRLB 0x14
> +#define EE_AUDIO_DAT_PAD_CTRLC 0x1c
> +#define EE_AUDIO_DAT_PAD_CTRLD 0x20
> +#define EE_AUDIO_DAT_PAD_CTRLE 0x24
> +#define EE_AUDIO_DAT_PAD_CTRLF 0x28
> +
> +#define REG_OFFSET 4
> +
> +static const char * const s4_tdmout_sel_texts[] = {
> +	"TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", "TDM_D6", "TDM_D7",
> +	"TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", "TDM_D13", "TDM_D14", "TDM_D15",
> +	"TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", "TDM_D21", "TDM_D22", "TDM_D23",
> +	"TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", "TDM_D29", "TDM_D30", "TDM_D31"
> +};

This thing does not belong in ASoC. This is clearly yet another layer of
pinctrl. Please deal with it there.


> +
> +static const struct soc_enum tdmout_sel_enum =
> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
> +			s4_tdmout_sel_texts);
> +
> +static struct snd_soc_dai *tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
> +{
> +	struct snd_soc_dapm_path *p;
> +	struct snd_soc_dai *be;
> +
> +	snd_soc_dapm_widget_for_each_source_path(w, p) {
> +		if (p->source->id == snd_soc_dapm_dai_in)
> +			return (struct snd_soc_dai *)p->source->priv;
> +		be = tdm_get_ahead_be(p->source);
> +		if (be && be->id == TDM_IFACE)
> +			return be;
> +	}
> +	return NULL;
> +}
> +
> +#define SND_SOC_DAPM_DEMUX_E(wname, wreg, wshift, winvert, wcontrols, \
> +	wevent, wflags) \
> +((struct snd_soc_dapm_widget) { \
> +	.id = snd_soc_dapm_demux, .name = wname, \
> +	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
> +	.kcontrol_news = wcontrols, .num_kcontrols = 1, \
> +	.event = wevent, .event_flags = wflags})
> +
> +static const struct snd_kcontrol_new tdmout_sel_demux[] = {
> +	SOC_DAPM_ENUM("TDMOUTA SEL", tdmout_sel_enum),
> +	SOC_DAPM_ENUM("TDMOUTB SEL", tdmout_sel_enum),
> +	SOC_DAPM_ENUM("TDMOUTC SEL", tdmout_sel_enum),
> +};
> +
> +static unsigned int aml_simple_strtoull(const char *cp)
> +{
> +	unsigned int result = 0;
> +	unsigned int value = 0;
> +	unsigned int len =  strlen(cp);
> +
> +	while (len != 0) {
> +		len--;
> +		value = isdigit(*cp);
> +		if (value) {
> +			value = *cp - '0';
> +		} else {
> +			cp++;
> +			continue;
> +		}
> +		cp++;
> +		result = result * 10 + value;
> +	}
> +	return result;
> +}
> +
> +static int tdm_out_pad_set(struct snd_soc_dapm_widget *w)
> +{
> +	struct snd_soc_dai *be;
> +	struct axg_tdm_stream *stream;
> +	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> +	unsigned int tdm_id = TDM_A_PAD;
> +	const char *dai_widget_name;
> +	struct snd_soc_dapm_path *p;
> +	unsigned int lane_num = 0;
> +	unsigned long pin = 0;
> +	unsigned int reg, mask, val = 0;
> +	int lane_cnt;
> +
> +	be = tdm_get_ahead_be(w);
> +	if (!be) {
> +		dev_err(component->dev, "%s not find the be\n", __func__);
> +		return -EINVAL;
> +	}
> +	stream = snd_soc_dai_dma_data_get_playback(be);
> +	if (!stream) {
> +		dev_err(component->dev, "%s not find the stream\n", __func__);
> +		return -EINVAL;
> +	}
> +	lane_cnt = (stream->channels - 1) / stream->iface->slots + 1;
> +	/*we like to use dai id, but it is fixed val*/
> +	dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
> +	if (strstr(dai_widget_name, "TDM_A"))
> +		tdm_id = TDM_A_PAD;
> +	else if (strstr(dai_widget_name, "TDM_B"))
> +		tdm_id = TDM_B_PAD;
> +	else if (strstr(dai_widget_name, "TDM_C"))
> +		tdm_id = TDM_C_PAD;
> +	else
> +		dev_err(component->dev, "%s not find the be dai widget\n", __func__);
> +	dev_dbg(component->dev, "tdm_id:%d, channel:%d, slot:%d\n",
> +		tdm_id, stream->channels, stream->iface->slots);
> +	snd_soc_dapm_widget_for_each_sink_path(w, p) {
> +		if (p->sink->id == snd_soc_dapm_output) {
> +			if (p->connect) {
> +				pin = aml_simple_strtoull(p->name);
> +				reg = (pin / 4) * REG_OFFSET;
> +				/*calculate mask pos */
> +				mask = 0x1f << ((pin % 4) * 8);
> +				val = tdm_id * 8 + lane_num;
> +				snd_soc_component_update_bits(component, reg, mask, val);
> +				snd_soc_component_update_bits(component, EE_AUDIO_DAT_PAD_CTRLF,
> +							      0x1 << pin, 0 << pin);
> +				lane_num++;
> +				if (lane_num > lane_cnt - 1)
> +					break;
> +			}
> +		}
> +	}
> +	return 0;
> +}
> +
> +static int tdmout_sel_pad_event(struct snd_soc_dapm_widget *w,
> +				struct snd_kcontrol *control,
> +				int event)
> +{
> +	int ret = 0;
> +	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> +
> +	switch (event) {
> +	case SND_SOC_DAPM_PRE_PMU:
> +		tdm_out_pad_set(w);
> +		break;
> +
> +	case SND_SOC_DAPM_PRE_PMD:
> +		break;
> +
> +	default:
> +		dev_err(component->dev, "Unexpected event %d\n", event);
> +		return -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +
> +static const struct snd_soc_dapm_widget s4_tdmout_pad_dapm_widgets[] = {
> +	SND_SOC_DAPM_DEMUX_E("TDMA_OUT SEL", SND_SOC_NOPM, 0, 0,
> +			     &tdmout_sel_demux[TDM_A_PAD], tdmout_sel_pad_event,
> +			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> +	SND_SOC_DAPM_DEMUX_E("TDMB_OUT SEL", SND_SOC_NOPM, 0, 0,
> +			     &tdmout_sel_demux[TDM_B_PAD], tdmout_sel_pad_event,
> +			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> +	SND_SOC_DAPM_DEMUX_E("TDMC_OUT SEL", SND_SOC_NOPM, 0, 0,
> +			     &tdmout_sel_demux[TDM_C_PAD], tdmout_sel_pad_event,
> +			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> +	SND_SOC_DAPM_OUTPUT("TDM_D0"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D1"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D2"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D3"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D4"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D5"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D6"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D7"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D8"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D9"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D10"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D11"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D12"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D13"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D14"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D15"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D16"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D17"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D18"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D19"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D20"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D21"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D22"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D23"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D24"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D25"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D26"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D27"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D28"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D29"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D30"),
> +	SND_SOC_DAPM_OUTPUT("TDM_D31"),
> +};
> +
> +static const struct snd_soc_dapm_route s4_tdmout_pad_dapm_routes[] = {
> +	{ "TDM_D0", "TDM_D0", "TDMA_OUT SEL" },
> +	{ "TDM_D1", "TDM_D1", "TDMA_OUT SEL" },
> +	{ "TDM_D2", "TDM_D2", "TDMA_OUT SEL" },
> +	{ "TDM_D3", "TDM_D3", "TDMA_OUT SEL" },
> +	{ "TDM_D4", "TDM_D4", "TDMA_OUT SEL" },
> +	{ "TDM_D5", "TDM_D5", "TDMA_OUT SEL" },
> +	{ "TDM_D6", "TDM_D6", "TDMA_OUT SEL" },
> +	{ "TDM_D7", "TDM_D7", "TDMA_OUT SEL" },
> +	{ "TDM_D8", "TDM_D8", "TDMA_OUT SEL" },
> +	{ "TDM_D9", "TDM_D9", "TDMA_OUT SEL" },
> +	{ "TDM_D10", "TDM_D10", "TDMA_OUT SEL" },
> +	{ "TDM_D11", "TDM_D11", "TDMA_OUT SEL" },
> +	{ "TDM_D12", "TDM_D12", "TDMA_OUT SEL" },
> +	{ "TDM_D13", "TDM_D13", "TDMA_OUT SEL" },
> +	{ "TDM_D14", "TDM_D14", "TDMA_OUT SEL" },
> +	{ "TDM_D15", "TDM_D15", "TDMA_OUT SEL" },
> +	{ "TDM_D16", "TDM_D16", "TDMA_OUT SEL" },
> +	{ "TDM_D17", "TDM_D17", "TDMA_OUT SEL" },
> +	{ "TDM_D18", "TDM_D18", "TDMA_OUT SEL" },
> +	{ "TDM_D19", "TDM_D19", "TDMA_OUT SEL" },
> +	{ "TDM_D20", "TDM_D20", "TDMA_OUT SEL" },
> +	{ "TDM_D21", "TDM_D21", "TDMA_OUT SEL" },
> +	{ "TDM_D22", "TDM_D22", "TDMA_OUT SEL" },
> +	{ "TDM_D23", "TDM_D23", "TDMA_OUT SEL" },
> +	{ "TDM_D24", "TDM_D24", "TDMA_OUT SEL" },
> +	{ "TDM_D25", "TDM_D25", "TDMA_OUT SEL" },
> +	{ "TDM_D26", "TDM_D26", "TDMA_OUT SEL" },
> +	{ "TDM_D27", "TDM_D27", "TDMA_OUT SEL" },
> +	{ "TDM_D28", "TDM_D28", "TDMA_OUT SEL" },
> +	{ "TDM_D29", "TDM_D29", "TDMA_OUT SEL" },
> +	{ "TDM_D30", "TDM_D30", "TDMA_OUT SEL" },
> +	{ "TDM_D31", "TDM_D31", "TDMA_OUT SEL" },
> +	{ "TDM_D0", "TDM_D0", "TDMB_OUT SEL" },
> +	{ "TDM_D1", "TDM_D1", "TDMB_OUT SEL" },
> +	{ "TDM_D2", "TDM_D2", "TDMB_OUT SEL" },
> +	{ "TDM_D3", "TDM_D3", "TDMB_OUT SEL" },
> +	{ "TDM_D4", "TDM_D4", "TDMB_OUT SEL" },
> +	{ "TDM_D5", "TDM_D5", "TDMB_OUT SEL" },
> +	{ "TDM_D6", "TDM_D6", "TDMB_OUT SEL" },
> +	{ "TDM_D7", "TDM_D7", "TDMB_OUT SEL" },
> +	{ "TDM_D8", "TDM_D8", "TDMB_OUT SEL" },
> +	{ "TDM_D9", "TDM_D9", "TDMB_OUT SEL" },
> +	{ "TDM_D10", "TDM_D10", "TDMB_OUT SEL" },
> +	{ "TDM_D11", "TDM_D11", "TDMB_OUT SEL" },
> +	{ "TDM_D12", "TDM_D12", "TDMB_OUT SEL" },
> +	{ "TDM_D13", "TDM_D13", "TDMB_OUT SEL" },
> +	{ "TDM_D14", "TDM_D14", "TDMB_OUT SEL" },
> +	{ "TDM_D15", "TDM_D15", "TDMB_OUT SEL" },
> +
> +	{ "TDM_D16", "TDM_D16", "TDMB_OUT SEL" },
> +	{ "TDM_D17", "TDM_D17", "TDMB_OUT SEL" },
> +	{ "TDM_D18", "TDM_D18", "TDMB_OUT SEL" },
> +	{ "TDM_D19", "TDM_D19", "TDMB_OUT SEL" },
> +	{ "TDM_D20", "TDM_D20", "TDMB_OUT SEL" },
> +	{ "TDM_D21", "TDM_D21", "TDMB_OUT SEL" },
> +	{ "TDM_D22", "TDM_D22", "TDMB_OUT SEL" },
> +	{ "TDM_D23", "TDM_D23", "TDMB_OUT SEL" },
> +	{ "TDM_D24", "TDM_D24", "TDMB_OUT SEL" },
> +	{ "TDM_D25", "TDM_D25", "TDMB_OUT SEL" },
> +	{ "TDM_D26", "TDM_D26", "TDMB_OUT SEL" },
> +	{ "TDM_D27", "TDM_D27", "TDMB_OUT SEL" },
> +	{ "TDM_D28", "TDM_D28", "TDMB_OUT SEL" },
> +	{ "TDM_D29", "TDM_D29", "TDMB_OUT SEL" },
> +	{ "TDM_D30", "TDM_D30", "TDMB_OUT SEL" },
> +	{ "TDM_D31", "TDM_D31", "TDMB_OUT SEL" },
> +	{ "TDM_D0", "TDM_D0", "TDMC_OUT SEL" },
> +	{ "TDM_D1", "TDM_D1", "TDMC_OUT SEL" },
> +	{ "TDM_D2", "TDM_D2", "TDMC_OUT SEL" },
> +	{ "TDM_D3", "TDM_D3", "TDMC_OUT SEL" },
> +	{ "TDM_D4", "TDM_D4", "TDMC_OUT SEL" },
> +	{ "TDM_D5", "TDM_D5", "TDMC_OUT SEL" },
> +	{ "TDM_D6", "TDM_D6", "TDMC_OUT SEL" },
> +	{ "TDM_D7", "TDM_D7", "TDMC_OUT SEL" },
> +	{ "TDM_D8", "TDM_D8", "TDMC_OUT SEL" },
> +	{ "TDM_D9", "TDM_D9", "TDMC_OUT SEL" },
> +	{ "TDM_D10", "TDM_D10", "TDMC_OUT SEL" },
> +	{ "TDM_D11", "TDM_D11", "TDMC_OUT SEL" },
> +	{ "TDM_D12", "TDM_D12", "TDMC_OUT SEL" },
> +	{ "TDM_D13", "TDM_D13", "TDMC_OUT SEL" },
> +	{ "TDM_D14", "TDM_D14", "TDMC_OUT SEL" },
> +	{ "TDM_D15", "TDM_D15", "TDMC_OUT SEL" },
> +	{ "TDM_D16", "TDM_D16", "TDMC_OUT SEL" },
> +	{ "TDM_D17", "TDM_D17", "TDMC_OUT SEL" },
> +	{ "TDM_D18", "TDM_D18", "TDMC_OUT SEL" },
> +	{ "TDM_D19", "TDM_D19", "TDMC_OUT SEL" },
> +	{ "TDM_D20", "TDM_D20", "TDMC_OUT SEL" },
> +	{ "TDM_D21", "TDM_D21", "TDMC_OUT SEL" },
> +	{ "TDM_D22", "TDM_D22", "TDMC_OUT SEL" },
> +	{ "TDM_D23", "TDM_D23", "TDMC_OUT SEL" },
> +	{ "TDM_D24", "TDM_D24", "TDMC_OUT SEL" },
> +	{ "TDM_D25", "TDM_D25", "TDMC_OUT SEL" },
> +	{ "TDM_D26", "TDM_D26", "TDMC_OUT SEL" },
> +	{ "TDM_D27", "TDM_D27", "TDMC_OUT SEL" },
> +	{ "TDM_D28", "TDM_D28", "TDMC_OUT SEL" },
> +	{ "TDM_D29", "TDM_D29", "TDMC_OUT SEL" },
> +	{ "TDM_D30", "TDM_D30", "TDMC_OUT SEL" },
> +	{ "TDM_D31", "TDM_D31", "TDMC_OUT SEL" },
> +};
> +
> +static const struct snd_soc_component_driver s4_tdmout_pad_component_drv = {
> +	.dapm_widgets		= s4_tdmout_pad_dapm_widgets,
> +	.num_dapm_widgets	= ARRAY_SIZE(s4_tdmout_pad_dapm_widgets),
> +	.dapm_routes		= s4_tdmout_pad_dapm_routes,
> +	.num_dapm_routes	= ARRAY_SIZE(s4_tdmout_pad_dapm_routes),
> +
> +};
> +
> +static const struct of_device_id s4_tdmout_pad_of_match[] = {
> +	{
> +		.compatible = "amlogic,s4-tdmout-pad",
> +	}, {}
> +};
> +
> +MODULE_DEVICE_TABLE(of, s4_tdmout_pad_of_match);
> +
> +static int tdm_pad_out_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct regmap *map;
> +	void __iomem *regs;
> +
> +	regs = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(regs))
> +		return PTR_ERR(regs);
> +
> +	map = devm_regmap_init_mmio(dev, regs, &tdmout_pad_regmap_cfg);
> +	if (IS_ERR(map))
> +		return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
> +
> +	return devm_snd_soc_register_component(dev, &s4_tdmout_pad_component_drv,
> +					       NULL, 0);
> +}
> +
> +static struct platform_driver tdmout_pad_pdrv = {
> +	.probe = tdm_pad_out_probe,
> +	.driver = {
> +		.name = "s4-pad-out",
> +		.of_match_table = s4_tdmout_pad_of_match,
> +	},
> +};
> +
> +module_platform_driver(tdmout_pad_pdrv);
> +
> +MODULE_DESCRIPTION("Amlogic TDM PAD DRIVER");
> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
> +MODULE_LICENSE("GPL");
> diff --git a/sound/soc/meson/s4-tocodec-control.c b/sound/soc/meson/s4-tocodec-control.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
> --- /dev/null
> +++ b/sound/soc/meson/s4-tocodec-control.c

There is already a to-acodec driver a not reason has been provided as to why a
completly new driver is required.

Please have look at the existing driver and do try to use it.
If you need to do things so differently, clear justification are necessary.

> @@ -0,0 +1,376 @@
> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
> +/*
> + * Copyright (C) 2023 Amlogic, Inc. All rights reserved
> + */
> +
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/regmap.h>
> +#include <sound/soc.h>
> +#include <sound/soc-dai.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include<linux/kstrtox.h>
> +#include <linux/clk-provider.h>
> +#include <linux/reset.h>
> +#include "axg-tdm.h"
> +
> +#define TOACODEC_CTRL0			0x0
> +
> +#define CTRL0_ENABLE_SHIFT		31
> +#define CTRL0_BCLK_ENABLE_SHIFT		30
> +#define CTRL0_MCLK_ENABLE_SHIFT		29
> +#define CTRL0_BLK_CAP_INV_SHIFT		9
> +
> +#define TDM_IFACE 0
> +#define TDM_A_PAD 0
> +#define TDM_B_PAD 1
> +#define TDM_C_PAD 2
> +
> +struct toacodec {
> +	struct regmap_field *field_dat_sel;
> +	struct regmap_field *field_lrclk_sel;
> +	struct regmap_field *field_bclk_sel;
> +	struct regmap_field *field_mclk_sel;
> +};
> +
> +struct toacodec_match_data {
> +	const struct snd_soc_component_driver *component_drv;
> +	const struct reg_field field_dat_sel;
> +	const struct reg_field field_lrclk_sel;
> +	const struct reg_field field_bclk_sel;
> +	const struct reg_field field_mclk_sel;
> +};
> +
> +static const struct regmap_config tocodec_regmap_cfg = {
> +	.reg_bits	= 32,
> +	.val_bits	= 32,
> +	.reg_stride	= 4,
> +	.max_register	= 0x1,
> +};
> +
> +#define S4_LANE_OFFSET 8
> +
> +static const char * const s4_tocodec_lane_sel_texts[] = {
> +	"Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", "Lane7"
> +};
> +
> +static const struct soc_enum s4_tocodec_lane_sel_enum =
> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_lane_sel_texts),
> +			s4_tocodec_lane_sel_texts);
> +
> +static const struct snd_kcontrol_new s4_tocodec_lane_sel =
> +	SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
> +
> +static const char * const s4_tocodec_src_sel_texts[] = {
> +	"TDMA", "TDMB", "TDMC"
> +};
> +
> +static const struct soc_enum s4_tocodec_src_sel_enum =
> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_src_sel_texts),
> +			s4_tocodec_src_sel_texts);
> +
> +static const struct snd_kcontrol_new s4_tocodec_src_sel =
> +	SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
> +
> +static const struct snd_kcontrol_new s4_toacodec_out_enable =
> +	SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
> +				    CTRL0_ENABLE_SHIFT, 1, 0);
> +
> +static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
> +{
> +	struct snd_soc_dapm_path *p;
> +	struct snd_soc_dai *be;
> +
> +	snd_soc_dapm_widget_for_each_source_path(w, p) {
> +		if (!p->connect)
> +			continue;
> +		if (p->source->id == snd_soc_dapm_dai_in)
> +			return (struct snd_soc_dai *)p->source->priv;
> +		be = tocodec_tdm_get_ahead_be(p->source);
> +		if (be && be->id == TDM_IFACE)
> +			return be;
> +	}
> +	return NULL;
> +}
> +
> +static unsigned int aml_simple_strtoull(const char *cp)
> +{
> +	unsigned int result = 0;
> +	unsigned int value = 0;
> +	unsigned int len = strlen(cp);
> +
> +	while (len != 0) {
> +		len--;
> +		value = isdigit(*cp);
> +		if (value) {
> +			value = *cp - '0';
> +		} else {
> +			cp++;
> +			continue;
> +		}
> +		cp++;
> +		result = result * 10 + value;
> +	}
> +	return result;
> +}
> +
> +static int aml_get_clk_id(const char *name)
> +{
> +	int clk_id = 0;
> +
> +	if (strstr(name, "mst_a"))
> +		clk_id = 0;
> +	else if (strstr(name, "mst_b"))
> +		clk_id = 1;
> +	else if (strstr(name, "mst_c"))
> +		clk_id = 2;
> +	else if (strstr(name, "mst_d"))
> +		clk_id = 3;
> +	else if (strstr(name, "mst_e"))
> +		clk_id = 4;
> +	else if (strstr(name, "mst_f"))
> +		clk_id = 5;
> +
> +	return clk_id;
> +}
> +
> +static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
> +{
> +	struct snd_soc_dai *be;
> +	struct axg_tdm_stream *stream;
> +	struct axg_tdm_iface *iface;
> +	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> +	struct toacodec *priv = snd_soc_component_get_drvdata(component);
> +	unsigned int tdm_id = TDM_A_PAD;
> +	const char *dai_widget_name;
> +	struct snd_soc_dapm_path *p;
> +	unsigned int lane = 0;
> +	unsigned int val = 0;
> +	struct clk *sclk, *mclk;
> +	char *clk_name;
> +	int mclk_id, sclk_id;
> +
> +	be = tocodec_tdm_get_ahead_be(w);
> +	if (!be) {
> +		dev_err(component->dev, "%s not find the be\n", __func__);
> +		return -EINVAL;
> +	}
> +	stream = snd_soc_dai_dma_data_get_playback(be);
> +	if (!stream) {
> +		dev_err(component->dev, "%s not find the stream\n", __func__);
> +		return -EINVAL;
> +	}
> +	/*we like to use dai id, but it is fixed val*/
> +	dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
> +	if (strstr(dai_widget_name, "TDM_A"))
> +		tdm_id = TDM_A_PAD;
> +	else if (strstr(dai_widget_name, "TDM_B"))
> +		tdm_id = TDM_B_PAD;
> +	else if (strstr(dai_widget_name, "TDM_C"))
> +		tdm_id = TDM_C_PAD;
> +	snd_soc_dapm_widget_for_each_source_path(w, p) {
> +		if (p->connect && p->name) {
> +			lane = aml_simple_strtoull(p->name);
> +			val = lane + tdm_id * S4_LANE_OFFSET;
> +			regmap_field_write(priv->field_dat_sel, val);
> +		}
> +	}
> +	iface = stream->iface;
> +	mclk = iface->mclk;
> +	sclk = iface->sclk;
> +	mclk_id = aml_get_clk_id(__clk_get_name(mclk));
> +	sclk_id = aml_get_clk_id(__clk_get_name(sclk));
> +	regmap_field_write(priv->field_mclk_sel, mclk_id);
> +	regmap_field_write(priv->field_bclk_sel, sclk_id);
> +	regmap_field_write(priv->field_lrclk_sel, sclk_id);
> +
> +	return 0;
> +}
> +
> +static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
> +			     struct snd_kcontrol *control,
> +			     int event)
> +{
> +	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> +	int ret = 0;
> +
> +	switch (event) {
> +	case SND_SOC_DAPM_PRE_PMU:
> +		ret = aml_tocodec_sel_set(w);
> +		break;
> +
> +	case SND_SOC_DAPM_PRE_PMD:
> +		break;
> +
> +	default:
> +		dev_err(component->dev, "Unexpected event %d\n", event);
> +		return -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +
> +static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
> +			      struct snd_kcontrol *control,
> +			      int event)
> +{
> +	int ret = 0;
> +	unsigned int mask = 0, val = 0;
> +	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> +
> +	snd_soc_component_update_bits(component, TOACODEC_CTRL0,
> +				      1 << CTRL0_BLK_CAP_INV_SHIFT, 1 << CTRL0_BLK_CAP_INV_SHIFT);
> +	switch (event) {
> +	case SND_SOC_DAPM_PRE_PMU:
> +		mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
> +		val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
> +		snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
> +		break;
> +	case SND_SOC_DAPM_PRE_PMD:
> +		mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
> +		val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << CTRL0_BCLK_ENABLE_SHIFT;
> +		snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
> +		break;
> +	default:
> +		dev_err(component->dev, "Unexpected event %d\n", event);
> +		return -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +
> +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
> +	SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
> +			   &s4_tocodec_lane_sel, tocodec_sel_event,
> +			   (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> +	SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, &s4_tocodec_src_sel),
> +	SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
> +			      &s4_toacodec_out_enable, tocodec_clk_enable,
> +				(SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
> +	SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
> +	SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
> +	SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
> +};
> +
> +static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
> +	{ "INPUT SRC", "TDMA", "TDMA"},
> +	{ "INPUT SRC", "TDMB", "TDMB"},
> +	{ "INPUT SRC", "TDMC", "TDMC"},
> +	{ "Lane0", NULL, "INPUT SRC" },
> +	{ "Lane1", NULL, "INPUT SRC"},
> +	{ "Lane2", NULL, "INPUT SRC"},
> +	{ "Lane3", NULL, "INPUT SRC"},
> +	{ "Lane4", NULL, "INPUT SRC"},
> +	{ "Lane5", NULL, "INPUT SRC"},
> +	{ "Lane6", NULL, "INPUT SRC"},
> +	{ "Lane7", NULL, "INPUT SRC"},
> +	{ "Lane SRC", "Lane0", "Lane0"},
> +	{ "Lane SRC", "Lane1", "Lane1"},
> +	{ "Lane SRC", "Lane2", "Lane2"},
> +	{ "Lane SRC", "Lane3", "Lane3"},
> +	{ "Lane SRC", "Lane4", "Lane4"},
> +	{ "Lane SRC", "Lane5", "Lane5"},
> +	{ "Lane SRC", "Lane6", "Lane6"},
> +	{ "Lane SRC", "Lane7", "Lane7"},
> +	{ "OUT EN", "Switch", "Lane SRC"},
> +	{ "TDM_TO_ACODEC", NULL, "OUT EN"},
> +
> +};
> +
> +static const struct snd_soc_component_driver s4_tocodec_component_drv = {
> +	.dapm_widgets		= s4_toacodec_widgets,
> +	.num_dapm_widgets	= ARRAY_SIZE(s4_toacodec_widgets),
> +	.dapm_routes		= s4_tocodec_dapm_routes,
> +	.num_dapm_routes	= ARRAY_SIZE(s4_tocodec_dapm_routes),
> +};
> +
> +static const struct toacodec_match_data s4_toacodec_match_data = {
> +	.component_drv	= &s4_tocodec_component_drv,
> +	.field_dat_sel	= REG_FIELD(TOACODEC_CTRL0, 16, 20),
> +	.field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
> +	.field_bclk_sel	= REG_FIELD(TOACODEC_CTRL0, 4, 6),
> +	.field_mclk_sel	= REG_FIELD(TOACODEC_CTRL0, 0, 2),
> +};
> +
> +static const struct of_device_id s4_tocodec_of_match[] = {
> +	{
> +		.compatible = "amlogic,s4-tocodec",
> +		.data = &s4_toacodec_match_data,
> +	}, {}
> +};
> +
> +MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
> +
> +static int tocodec_probe(struct platform_device *pdev)
> +{
> +	const struct toacodec_match_data *data;
> +	struct device *dev = &pdev->dev;
> +	struct toacodec *priv;
> +	void __iomem *regs;
> +	struct regmap *map;
> +	int ret;
> +
> +	data = device_get_match_data(dev);
> +	if (!data)
> +		return dev_err_probe(dev, -ENODEV, "failed to match device\n");
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, priv);
> +
> +	ret = device_reset(dev);
> +	if (ret)
> +		return ret;
> +
> +	regs = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(regs))
> +		return PTR_ERR(regs);
> +
> +	map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
> +	if (IS_ERR(map))
> +		return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
> +
> +	priv->field_dat_sel = devm_regmap_field_alloc(dev, map, data->field_dat_sel);
> +	if (IS_ERR(priv->field_dat_sel))
> +		return PTR_ERR(priv->field_dat_sel);
> +
> +	priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, data->field_lrclk_sel);
> +	if (IS_ERR(priv->field_lrclk_sel))
> +		return PTR_ERR(priv->field_lrclk_sel);
> +
> +	priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, data->field_bclk_sel);
> +	if (IS_ERR(priv->field_bclk_sel))
> +		return PTR_ERR(priv->field_bclk_sel);
> +
> +	priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, data->field_mclk_sel);
> +	if (IS_ERR(priv->field_mclk_sel))
> +		return PTR_ERR(priv->field_mclk_sel);
> +
> +	return devm_snd_soc_register_component(dev,
> +			data->component_drv, NULL, 0);
> +}
> +
> +static struct platform_driver tocodec_pdrv = {
> +	.probe = tocodec_probe,
> +	.driver = {
> +		.name = "s4-tocodec",
> +		.of_match_table = s4_tocodec_of_match,
> +	},
> +};
> +
> +module_platform_driver(tocodec_pdrv);
> +
> +MODULE_DESCRIPTION("Amlogic to codec driver");
> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
> +MODULE_LICENSE("GPL");
> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
> index 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 100644
> --- a/sound/soc/meson/t9015.c
> +++ b/sound/soc/meson/t9015.c
> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>  		.channels_min = 1,
>  		.channels_max = 2,
>  		.rates = SNDRV_PCM_RATE_8000_96000,
> -		.formats = (SNDRV_PCM_FMTBIT_S8 |
> -			    SNDRV_PCM_FMTBIT_S16_LE |
> -			    SNDRV_PCM_FMTBIT_S20_LE |
> -			    SNDRV_PCM_FMTBIT_S24_LE),
> +		.formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE),

Again, mixed up changes with zero justification.

This drops S8 and S16 format support for the existing SoCs (such as GXL)
which is known to work and add S32 support on an HW documented as 24bits
only. Can you explain ?

>  	},
>  	.ops = &t9015_dai_ops,
>  };

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-13  6:35 ` [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio jiebing chen via B4 Relay
@ 2025-01-13 14:50   ` Jerome Brunet
  2025-01-14  8:52     ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-13 14:50 UTC (permalink / raw)
  To: jiebing chen via B4 Relay
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jaroslav Kysela, Takashi Iwai, Neil Armstrong,
	Kevin Hilman, Martin Blumenstingl, jiebing.chen, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:

> From: jiebing chen <jiebing.chen@amlogic.com>
>
> Add basic audio driver support for the Amlogic S4 based Amlogic
> AQ222 board.
>
> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
> ---
>  .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>  arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>  2 files changed, 610 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>  	       regulator-always-on;
>  	};
>  
> +	vcc5v_reg: regulator-vcc-5v {
> +		compatible = "regulator-fixed";
> +		vin-supply = <&main_12v>;
> +		regulator-name = "VCC5V";
> +		regulator-min-microvolt = <5000000>;
> +		regulator-max-microvolt = <5000000>;
> +		gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
> +		startup-delay-us = <7000>;
> +		enable-active-high;
> +		regulator-boot-on;
> +		regulator-always-on;
> +	};
> +
>  	/* SY8120B1ABC DC/DC Regulator. */
>  	vddcpu: regulator-vddcpu {
>  		compatible = "pwm-regulator";
> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>  				<699000 98>,
>  				<689000 100>;
>  	};
> +	dmics: audio-codec-1 {
> +		compatible = "dmic-codec";
> +		#sound-dai-cells = <0>;
> +		num-channels = <2>;
> +		wakeup-delay-ms = <50>;
> +		sound-name-prefix = "MIC";
> +	};
> +
> +	dioo2133: audio-amplifier-0 {
> +		compatible = "simple-audio-amplifier";
> +		enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
> +		VCC-supply = <&vcc5v_reg>;
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "10U2";
> +	};
> +
> +	spdif_dir: audio-spdif-in {
> +		compatible = "linux,spdif-dir";
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "DIR";
> +	};
> +
> +	spdif_dit: audio-spdif-out {
> +		compatible = "linux,spdif-dit";
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "DIT";
> +	};
> +
> +	sound {
> +		compatible = "amlogic,axg-sound-card";
> +		model = "aq222";
> +		audio-widgets = "Line", "Lineout";
> +		audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
> +				 <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
> +				 <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
> +		audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
> +				"TDMOUT_A IN 1", "FRDDR_B OUT 0",
> +				"TDMOUT_A IN 2", "FRDDR_C OUT 0",
> +				"TDM_A Playback", "TDMOUT_A OUT",
> +				"TDMA_OUT SEL",   "TDM_A Playback",
> +				"TDMOUT_B IN 0", "FRDDR_A OUT 1",
> +				"TDMOUT_B IN 1", "FRDDR_B OUT 1",
> +				"TDMOUT_B IN 2", "FRDDR_C OUT 1",
> +				"TDM_B Playback", "TDMOUT_B OUT",
> +				"TDMB_OUT SEL",   "TDM_B Playback",
> +				"TDMOUT_C IN 0", "FRDDR_A OUT 2",
> +				"TDMOUT_C IN 1", "FRDDR_B OUT 2",
> +				"TDMOUT_C IN 2", "FRDDR_C OUT 2",
> +				"TDM_C Playback", "TDMOUT_C OUT",
> +				"TDMC_OUT SEL",   "TDM_C Playback",
> +				"TOACODEC TDMA", "TDM_A Playback",
> +				"TOACODEC TDMB", "TDM_B Playback",
> +				"TOACODEC TDMC", "TDM_C Playback",
> +				"SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
> +				"SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
> +				"SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
> +				"SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
> +				"SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
> +				"SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
> +				"TDMIN_A IN 0", "TDM_A Capture",
> +				"TDMIN_A IN 1", "TDM_B Capture",
> +				"TDMIN_A IN 2", "TDM_C Capture",
> +				"TDMIN_A IN 3", "TDM_A Loopback",
> +				"TDMIN_A IN 4", "TDM_B Loopback",
> +				"TDMIN_A IN 5", "TDM_C Loopback",
> +				"TDMIN_B IN 0", "TDM_A Capture",
> +				"TDMIN_B IN 1", "TDM_B Capture",
> +				"TDMIN_B IN 2", "TDM_C Capture",
> +				"TDMIN_B IN 3", "TDM_A Loopback",
> +				"TDMIN_B IN 4", "TDM_B Loopback",
> +				"TDMIN_B IN 5", "TDM_C Loopback",
> +				"TDMIN_C IN 0", "TDM_A Capture",
> +				"TDMIN_C IN 1", "TDM_B Capture",
> +				"TDMIN_C IN 2", "TDM_C Capture",
> +				"TDMIN_C IN 3", "TDM_A Loopback",
> +				"TDMIN_C IN 4", "TDM_B Loopback",
> +				"TDMIN_C IN 5", "TDM_C Loopback",
> +				"TDMIN_LB IN 3", "TDM_A Capture",
> +				"TDMIN_LB IN 4", "TDM_B Capture",
> +				"TDMIN_LB IN 5", "TDM_C Capture",
> +				"TDMIN_LB IN 0", "TDM_A Loopback",
> +				"TDMIN_LB IN 1", "TDM_B Loopback",
> +				"TDMIN_LB IN 2", "TDM_C Loopback",
> +				"TODDR_A IN 0", "TDMIN_A OUT",
> +				"TODDR_B IN 0", "TDMIN_A OUT",
> +				"TODDR_C IN 0", "TDMIN_A OUT",
> +				"TODDR_A IN 1", "TDMIN_B OUT",
> +				"TODDR_B IN 1", "TDMIN_B OUT",
> +				"TODDR_C IN 1", "TDMIN_B OUT",
> +				"TODDR_A IN 2", "TDMIN_C OUT",
> +				"TODDR_B IN 2", "TDMIN_C OUT",
> +				"TODDR_C IN 2", "TDMIN_C OUT",
> +				"TODDR_A IN 3", "SPDIFIN Capture",
> +				"TODDR_B IN 3", "SPDIFIN Capture",
> +				"TODDR_C IN 3", "SPDIFIN Capture",
> +				"TODDR_A IN 6", "TDMIN_LB OUT",
> +				"TODDR_B IN 6", "TDMIN_LB OUT",
> +				"TODDR_C IN 6", "TDMIN_LB OUT",
> +				"10U2 INL", "ACODEC LOLP",
> +				"10U2 INR", "ACODEC LORP",
> +				"Lineout", "10U2 OUTL",
> +				"Lineout", "10U2 OUTR";
> +		assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
> +				  <&clkc_pll CLKID_MPLL2>,
> +				  <&clkc_pll CLKID_MPLL0>,
> +				  <&clkc_pll CLKID_MPLL1>;
> +		assigned-clock-rates = <491520000>,
> +				       <294912000>,
> +				       <270950400>,
> +				       <393216000>;

Why do you need 4 base rates ? Which rate family does each provide ?

> +
> +		dai-link-0 {
> +			sound-dai = <&frddr_a>;
> +		};
> +
> +		dai-link-1 {
> +			sound-dai = <&frddr_b>;
> +		};
> +
> +		dai-link-2 {
> +			sound-dai = <&frddr_c>;
> +		};
> +
> +		dai-link-3 {
> +			sound-dai = <&toddr_a>;
> +		};
> +
> +		dai-link-4 {
> +			sound-dai = <&toddr_b>;
> +		};
> +
> +		dai-link-5 {
> +			sound-dai = <&toddr_c>;
> +		};
> +
> +		/* Connected to the WIFI/BT chip */
> +		dai-link-6 {
> +			sound-dai = <&tdmif_a>;
> +			dai-format = "dsp_a";
> +			dai-tdm-slot-tx-mask-0 = <1 1>;
> +			mclk-fs = <256>;
> +			codec-0 {
> +				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
> +			};
> +		};
> +
> +		/* Connected to the onboard AD82584F DAC */
> +		dai-link-7 {
> +			sound-dai = <&tdmif_b>;
> +			dai-format = "i2s";
> +			dai-tdm-slot-tx-mask-0 = <1 1>;
> +			mclk-fs = <256>;
> +
> +			codec-0 {
> +				sound-dai = <&acodec>;
> +			};
> +
> +			codec-1 {
> +				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
> +			};
> +		};
> +
> +		/* 8ch HDMI interface */
> +		dai-link-8 {
> +			sound-dai = <&tdmif_c>;
> +			dai-format = "i2s";
> +			dai-tdm-slot-tx-mask-0 = <1 1>;
> +			dai-tdm-slot-tx-mask-1 = <1 1>;
> +			dai-tdm-slot-tx-mask-2 = <1 1>;
> +			dai-tdm-slot-tx-mask-3 = <1 1>;
> +			mclk-fs = <256>;
> +
> +			codec-0 {
> +				sound-dai = <&acodec>;
> +			};
> +
> +			codec-1 {
> +				sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
> +			};
> +		};
> +
> +		/* spdif hdmi and coax output */
> +		dai-link-9 {
> +			sound-dai = <&spdifout_a>;
> +
> +			codec-0 {
> +				sound-dai = <&spdif_dit>;
> +			};
> +
> +			codec-1 {
> +				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
> +			};
> +		};
> +
> +		/* spdif hdmi interface */
> +		dai-link-10 {
> +			sound-dai = <&spdifout_b>;
> +
> +			codec {
> +				sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
> +			};
> +		};
> +
> +		/* spdif coax input */
> +		dai-link-11 {
> +			sound-dai = <&spdifin>;
> +
> +			codec {
> +				sound-dai = <&spdif_dir>;
> +			};
> +		};
> +	};
> +
>  };
>  
>  &pwm_ef {
> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> index 957577d986c0675a503115e1ccbc4387c2051620..87a00ace23131e31822bb43fbe956b8abcbaef40 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
> @@ -11,7 +11,11 @@
>  #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
>  #include <dt-bindings/power/meson-s4-power.h>
>  #include <dt-bindings/reset/amlogic,meson-s4-reset.h>
> -
> +#include <dt-bindings/clock/axg-audio-clkc.h>
> +#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
> +#include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
> +#include <dt-bindings/sound/meson-g12a-toacodec.h>
> +#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
>  / {
>  	cpus {
>  		#address-cells = <2>;
> @@ -46,6 +50,42 @@ cpu3: cpu@3 {
>  		};
>  	};
>  
> +	tdmif_a: audio-controller-0 {
> +		compatible = "amlogic,axg-tdm-iface";
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "TDM_A";
> +		clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_A_SCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
> +		clock-names = "mclk", "sclk", "lrclk";
> +		assigned-clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK_SEL>;
> +		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;

Based on clock provider used, I doubt this is of any use.

> +	};
> +
> +	tdmif_b: audio-controller-1 {
> +		compatible = "amlogic,axg-tdm-iface";
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "TDM_B";
> +		clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_B_SCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_B_LRCLK>;
> +		clock-names = "mclk", "sclk", "lrclk";
> +		assigned-clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK_SEL>;
> +		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
> +	};
> +
> +	tdmif_c: audio-controller-2 {
> +		compatible = "amlogic,axg-tdm-iface";
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "TDM_C";
> +		clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_C_SCLK>,
> +			 <&clkc_audio AUD_CLKID_MST_C_LRCLK>;
> +		clock-names = "mclk", "sclk", "lrclk";
> +		assigned-clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK_SEL>;
> +		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
> +	};
> +
>  	timer {
>  		compatible = "arm,armv8-timer";
>  		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
> @@ -850,3 +890,346 @@ emmc: mmc@fe08c000 {
>  		};
>  	};
>  };
> +
> +&apb4 {
> +	audio: bus@330000 {
> +		compatible = "simple-bus";
> +		reg = <0x0 0x330000 0x0 0x1000>;
> +		#address-cells = <2>;
> +		#size-cells = <2>;
> +		ranges = <0x0 0x0 0x0 0x330000 0x0 0x1000>;
> +
> +		clkc_audio: clock-controller@0 {
> +			compatible = "amlogic,sm1-audio-clkc";

I suspect the DT folks would like having SoC specific compatible in
addition to the fall back. In that case, I think that would be wise. I
doubt the compatibility will hold in the long run.

Same goes for the other HW components.

> +			reg = <0x0 0x0 0x0 0xb4>;
> +			#clock-cells = <1>;
> +			#reset-cells = <1>;
> +			power-domains = <&pwrc PWRC_S4_AUDIO_ID>;
> +			clocks = <&clkc_periphs CLKID_AUDIO>,
> +				 <&clkc_pll CLKID_MPLL0>,
> +				 <&clkc_pll CLKID_MPLL1>,
> +				 <&clkc_pll CLKID_MPLL2>,
> +				 <&clkc_pll CLKID_MPLL3>,
> +				 <&clkc_pll CLKID_HIFI_PLL>,
> +				 <&clkc_pll CLKID_FCLK_DIV3>,
> +				 <&clkc_pll CLKID_FCLK_DIV4>,
> +				 <&clkc_pll CLKID_FCLK_DIV5>;
> +			clock-names = "pclk",
> +				      "mst_in0",
> +				      "mst_in1",
> +				      "mst_in2",
> +				      "mst_in3",
> +				      "mst_in4",
> +				      "mst_in5",
> +				      "mst_in6",
> +				      "mst_in7";
> +
> +			resets = <&reset RESET_AUDIO>;
> +		};
> +
> +		toddr_a: audio-controller@100 {
> +			compatible = "amlogic,sm1-toddr",
> +				     "amlogic,axg-toddr";
> +			reg = <0x0 0x100 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "TODDR_A";
> +			interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_TODDR_A>;
> +			resets = <&arb AXG_ARB_TODDR_A>,
> +				 <&clkc_audio AUD_RESET_TODDR_A>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <8192>;
> +		};
> +
> +		toddr_b: audio-controller@140 {
> +			compatible = "amlogic,sm1-toddr",
> +				     "amlogic,axg-toddr";
> +			reg = <0x0 0x140 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "TODDR_B";
> +			interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_TODDR_B>;
> +			resets = <&arb AXG_ARB_TODDR_B>,
> +				 <&clkc_audio AUD_RESET_TODDR_B>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		toddr_c: audio-controller@180 {
> +			compatible = "amlogic,sm1-toddr",
> +				     "amlogic,axg-toddr";
> +			reg = <0x0 0x180 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "TODDR_C";
> +			interrupts = <GIC_SPI 34 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_TODDR_C>;
> +			resets = <&arb AXG_ARB_TODDR_C>,
> +				 <&clkc_audio AUD_RESET_TODDR_C>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		frddr_a: audio-controller@1c0 {
> +			compatible = "amlogic,sm1-frddr",
> +				     "amlogic,axg-frddr";
> +			reg = <0x0 0x1c0 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "FRDDR_A";
> +			interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
> +			resets = <&arb AXG_ARB_FRDDR_A>,
> +				 <&clkc_audio AUD_RESET_FRDDR_A>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <512>;
> +		};
> +
> +		frddr_b: audio-controller@200 {
> +			compatible = "amlogic,sm1-frddr",
> +				     "amlogic,axg-frddr";
> +			reg = <0x0 0x200 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "FRDDR_B";
> +			interrupts = <GIC_SPI 37 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_FRDDR_B>;
> +			resets = <&arb AXG_ARB_FRDDR_B>,
> +				 <&clkc_audio AUD_RESET_FRDDR_B>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		frddr_c: audio-controller@240 {
> +			compatible = "amlogic,sm1-frddr",
> +				     "amlogic,axg-frddr";
> +			reg = <0x0 0x240 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "FRDDR_C";
> +			interrupts = <GIC_SPI 38 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_FRDDR_C>;
> +			resets = <&arb AXG_ARB_FRDDR_C>,
> +				 <&clkc_audio AUD_RESET_FRDDR_C>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		arb: reset-controller@280 {
> +			compatible = "amlogic,meson-sm1-audio-arb";
> +			reg = <0x0 0x280 0x0 0x4>;
> +			#reset-cells = <1>;
> +			clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
> +		};
> +
> +		tdmin_a: audio-controller@300 {
> +			compatible = "amlogic,sm1-tdmin",
> +				     "amlogic,axg-tdmin";
> +			reg = <0x0 0x300 0x0 0x40>;
> +			sound-name-prefix = "TDMIN_A";
> +			resets = <&clkc_audio AUD_RESET_TDMIN_A>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMIN_A>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_A_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_A_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		tdmin_b: audio-controller@340 {
> +			compatible = "amlogic,sm1-tdmin",
> +				     "amlogic,axg-tdmin";
> +			reg = <0x0 0x340 0x0 0x40>;
> +			sound-name-prefix = "TDMIN_B";
> +			resets = <&clkc_audio AUD_RESET_TDMIN_B>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMIN_B>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_B_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_B_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		tdmin_c: audio-controller@380 {
> +			compatible = "amlogic,sm1-tdmin",
> +				     "amlogic,axg-tdmin";
> +			reg = <0x0 0x380 0x0 0x40>;
> +			sound-name-prefix = "TDMIN_C";
> +			resets = <&clkc_audio AUD_RESET_TDMIN_C>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMIN_C>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_C_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_C_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		tdmin_lb: audio-controller@3c0 {
> +			compatible = "amlogic,sm1-tdmin",
> +				     "amlogic,axg-tdmin";
> +			reg = <0x0 0x3c0 0x0 0x40>;
> +			sound-name-prefix = "TDMIN_LB";
> +			resets = <&clkc_audio AUD_RESET_TDMIN_LB>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMIN_LB>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		spdifin: audio-controller@400 {
> +			compatible = "amlogic,g12a-spdifin",
> +				     "amlogic,axg-spdifin";
> +			reg = <0x0 0x400 0x0 0x30>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "SPDIFIN";
> +			interrupts = <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
> +			<&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
> +			clock-names = "pclk", "refclk";
> +			resets = <&clkc_audio AUD_RESET_SPDIFIN>;
> +		};
> +
> +		spdifout_a: audio-controller@480 {
> +			compatible = "amlogic,g12a-spdifout",
> +				     "amlogic,axg-spdifout";
> +			reg = <0x0 0x480 0x0 0x50>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "SPDIFOUT_A";
> +			clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
> +			<&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
> +			clock-names = "pclk", "mclk";
> +			resets = <&clkc_audio AUD_RESET_SPDIFOUT>;
> +		};
> +
> +		tdmout_a: audio-controller@500 {
> +			compatible = "amlogic,sm1-tdmout";
> +			reg = <0x0 0x500 0x0 0x40>;
> +			sound-name-prefix = "TDMOUT_A";
> +			resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		tdmout_b: audio-controller@540 {
> +			compatible = "amlogic,sm1-tdmout";
> +			reg = <0x0 0x540 0x0 0x40>;
> +			sound-name-prefix = "TDMOUT_B";
> +			resets = <&clkc_audio AUD_RESET_TDMOUT_B>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMOUT_B>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		tdmout_c: audio-controller@580 {
> +			compatible = "amlogic,sm1-tdmout";
> +			reg = <0x0 0x580 0x0 0x40>;
> +			sound-name-prefix = "TDMOUT_C";
> +			resets = <&clkc_audio AUD_RESET_TDMOUT_C>;
> +			clocks = <&clkc_audio AUD_CLKID_TDMOUT_C>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK_SEL>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>,
> +				 <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>;
> +			clock-names = "pclk", "sclk", "sclk_sel",
> +				      "lrclk", "lrclk_sel";
> +		};
> +
> +		spdifout_b: audio-controller@680 {
> +			compatible = "amlogic,g12a-spdifout",
> +				     "amlogic,axg-spdifout";
> +			reg = <0x0 0x680 0x0 0x50>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "SPDIFOUT_B";
> +			clocks = <&clkc_audio AUD_CLKID_SPDIFOUT_B>,
> +				 <&clkc_audio AUD_CLKID_SPDIFOUT_B_CLK>;
> +			clock-names = "pclk", "mclk";
> +			resets = <&clkc_audio AUD_RESET_SPDIFOUT_B>;
> +		};
> +
> +		toacodec: audio-controller@740 {
> +			compatible = "amlogic,s4-tocodec";
> +			reg = <0x0 0x740 0x0 0x4>;
> +			sound-name-prefix = "TOACODEC";
> +			resets = <&clkc_audio AUD_RESET_TOACODEC>;
> +		};
> +
> +		tohdmitx: audio-controller@744 {
> +			compatible = "amlogic,sm1-tohdmitx",
> +				     "amlogic,g12a-tohdmitx";
> +			reg = <0x0 0x744 0x0 0x4>;
> +			#sound-dai-cells = <1>;
> +			sound-name-prefix = "TOHDMITX";
> +			resets = <&clkc_audio AUD_RESET_TOHDMITX>;
> +		};
> +
> +		toddr_d: audio-controller@840 {
> +			compatible = "amlogic,sm1-toddr",
> +				     "amlogic,axg-toddr";
> +			reg = <0x0 0x840 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "TODDR_D";
> +			interrupts = <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_TODDR_D>;
> +			resets = <&arb AXG_ARB_TODDR_D>,
> +				 <&clkc_audio AUD_RESET_TODDR_D>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		frddr_d: audio-controller@880 {
> +			 compatible = "amlogic,sm1-frddr",
> +				      "amlogic,axg-frddr";
> +			reg = <0x0 0x880 0x0 0x2c>;
> +			#sound-dai-cells = <0>;
> +			sound-name-prefix = "FRDDR_D";
> +			interrupts = <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc_audio AUD_CLKID_FRDDR_D>;
> +			resets = <&arb AXG_ARB_FRDDR_D>,
> +				 <&clkc_audio AUD_RESET_FRDDR_D>;
> +			reset-names = "arb", "rst";
> +			amlogic,fifo-depth = <256>;
> +		};
> +
> +		tdmout_pad: audio-controller@E58 {
> +			compatible = "amlogic,s4-tdmout-pad";
> +			reg = <0x0 0xe58 0x0 0x28>;
> +		};
> +	};
> +
> +	pdm: audio-controller@331000 {
> +		compatible = "amlogic,sm1-pdm",
> +			     "amlogic,axg-pdm";
> +		reg = <0x0 0x331000 0x0 0x34>;
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "PDM";
> +		clocks = <&clkc_audio AUD_CLKID_PDM>,
> +			 <&clkc_audio AUD_CLKID_PDM_DCLK>,
> +			 <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
> +		clock-names = "pclk", "dclk", "sysclk";
> +		resets = <&clkc_audio AUD_RESET_PDM>;
> +		assigned-clocks = <&clkc_audio AUD_CLKID_PDM_DCLK_SEL>,
> +				  <&clkc_audio AUD_CLKID_PDM_SYSCLK_SEL>;
> +		assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>,<&clkc_pll CLKID_HIFI_PLL>;
> +	};
> +	 acodec: audio-controller@1A000 {
> +		compatible = "amlogic,t9015";
> +		reg = <0x0 0x1A000 0x0 0x14>;
> +		#sound-dai-cells = <0>;
> +		sound-name-prefix = "ACODEC";
> +		clocks = <&clkc_periphs CLKID_ACODEC>;
> +		clock-names = "pclk";
> +		resets = <&reset RESET_ACODEC>;
> +	};
> +
> +};

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 0/3] Add support for S4 audio
  2025-01-13  6:35 [PATCH 0/3] Add support for S4 audio jiebing chen via B4 Relay
                   ` (2 preceding siblings ...)
  2025-01-13  6:35 ` [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio jiebing chen via B4 Relay
@ 2025-01-13 15:26 ` Rob Herring (Arm)
  3 siblings, 0 replies; 27+ messages in thread
From: Rob Herring (Arm) @ 2025-01-13 15:26 UTC (permalink / raw)
  To: jiebing chen
  Cc: Martin Blumenstingl, Mark Brown, Kevin Hilman, Jaroslav Kysela,
	linux-kernel, Conor Dooley, Jerome Brunet, devicetree,
	Liam Girdwood, linux-arm-kernel, Krzysztof Kozlowski,
	Takashi Iwai, linux-amlogic, linux-sound, Neil Armstrong


On Mon, 13 Jan 2025 14:35:12 +0800, jiebing chen wrote:
> Add the tdmout pad control and tocodec control driver.
> 
> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
> ---
> jiebing chen (3):
>       ASoC: dt-bindings: Add Amlogic S4 audio
>       ASoC: meson: s4:support for the on-chip audio
>       arm64: dts: amlogic: Add Amlogic S4 Audio
> 
>  .../bindings/sound/amlogic,s4-tdmout-pad.yaml      |  36 ++
>  .../bindings/sound/amlogic,s4-tocodec.yaml         |  44 +++
>  .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>  arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>  sound/soc/meson/Kconfig                            |  16 +
>  sound/soc/meson/Makefile                           |   6 +
>  sound/soc/meson/s4-pad-out-control.c               | 372 ++++++++++++++++++++
>  sound/soc/meson/s4-tocodec-control.c               | 376 ++++++++++++++++++++
>  sound/soc/meson/t9015.c                            |   5 +-
>  9 files changed, 1461 insertions(+), 5 deletions(-)
> ---
> base-commit: 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab
> change-id: 20250110-audio_drvier-07a5381c494b
> 
> Best regards,
> --
> jiebing chen <jiebing.chen@amlogic.com>
> 
> 
> 


My bot found new DTB warnings on the .dts files added or changed in this
series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings
are fixed by another series. Ultimately, it is up to the platform
maintainer whether these warnings are acceptable or not. No need to reply
unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then
make sure dt-schema is up to date:

  pip3 install dtschema --upgrade


New warnings running 'make CHECK_DTBS=y for arch/arm64/boot/dts/amlogic/' for 20250113-audio_drvier-v1-0-8c14770f38a0@amlogic.com:

arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-0: clock-names:0: 'sclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-0: clock-names:1: 'lrclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-0: clock-names:2: 'mclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-0: Unevaluated properties are not allowed ('clock-names' was unexpected)
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-1: clock-names:0: 'sclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-1: clock-names:1: 'lrclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-1: clock-names:2: 'mclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-1: Unevaluated properties are not allowed ('clock-names' was unexpected)
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-2: clock-names:0: 'sclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-2: clock-names:1: 'lrclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-2: clock-names:2: 'mclk' was expected
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller-2: Unevaluated properties are not allowed ('clock-names' was unexpected)
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-iface.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: bus@fe000000: audio-controller@1A000: 'ranges' is a required property
	from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: bus@330000: audio-controller@E58: 'ranges' is a required property
	from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: clock-controller@0: 'power-domains' does not match any of the regexes: 'pinctrl-[0-9]+'
	from schema $id: http://devicetree.org/schemas/clock/amlogic,axg-audio-clkc.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller@300: compatible: ['amlogic,sm1-tdmin', 'amlogic,axg-tdmin'] is too long
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-formatters.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller@340: compatible: ['amlogic,sm1-tdmin', 'amlogic,axg-tdmin'] is too long
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-formatters.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller@380: compatible: ['amlogic,sm1-tdmin', 'amlogic,axg-tdmin'] is too long
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-formatters.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller@3c0: compatible: ['amlogic,sm1-tdmin', 'amlogic,axg-tdmin'] is too long
	from schema $id: http://devicetree.org/schemas/sound/amlogic,axg-tdm-formatters.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-controller@1A000: 'AVDD-supply' is a required property
	from schema $id: http://devicetree.org/schemas/sound/amlogic,t9015.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: audio-amplifier-0: '#sound-dai-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
	from schema $id: http://devicetree.org/schemas/sound/simple-audio-amplifier.yaml#
arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dtb: sound: 'anyOf' conditional failed, one must be fixed:
	'clocks' is a required property
	'#clock-cells' is a required property
	from schema $id: http://devicetree.org/schemas/clock/clock.yaml#







^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-13 14:31   ` Jerome Brunet
@ 2025-01-14  8:16     ` Jiebing Chen
  2025-01-14 11:20       ` Jiebing Chen
  2025-01-14 11:29       ` Jerome Brunet
  0 siblings, 2 replies; 27+ messages in thread
From: Jiebing Chen @ 2025-01-14  8:16 UTC (permalink / raw)
  To: Jerome Brunet, jiebing chen via B4 Relay
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jaroslav Kysela, Takashi Iwai, Neil Armstrong,
	Kevin Hilman, Martin Blumenstingl, linux-sound, devicetree,
	linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/13 22:31, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>
>> From: jiebing chen <jiebing.chen@amlogic.com>
>>
>> Add audio support for Amlogic S4.The audio output pad
>> can be freelycombined with the output lane,and the tocodec
>> control logic has been optimized.
> The patch is a mixture of different HW modules.
>
> Each patch should have one clear purpose and, as such, deal with a
> single HW module
>
>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>> ---
>>   sound/soc/meson/Kconfig              |  16 ++
>>   sound/soc/meson/Makefile             |   6 +
>>   sound/soc/meson/s4-pad-out-control.c | 372 ++++++++++++++++++++++++++++++++++
>>   sound/soc/meson/s4-tocodec-control.c | 376 +++++++++++++++++++++++++++++++++++
>>   sound/soc/meson/t9015.c              |   5 +-
>>   5 files changed, 771 insertions(+), 4 deletions(-)
>>
>> diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
>> index 6458d5dc4902f665211bb9e4ae7d274e4bff2fdc..d01e284642fd987cf4bdf88e5bf5f7c9a241af59 100644
>> --- a/sound/soc/meson/Kconfig
>> +++ b/sound/soc/meson/Kconfig
>> @@ -69,6 +69,8 @@ config SND_MESON_AXG_SOUND_CARD
>>        imply SND_MESON_AXG_SPDIFIN
>>        imply SND_MESON_AXG_PDM
>>        imply SND_MESON_G12A_TOACODEC
>> +     imply SND_SOC_MESON_PAD_OUT
>> +     imply SND_SOC_MESON_TOCODEC_CONTROL
>>        imply SND_MESON_G12A_TOHDMITX if DRM_MESON_DW_HDMI
>>        help
>>          Select Y or M to add support for the AXG SoC sound card
>> @@ -135,4 +137,18 @@ config SND_SOC_MESON_T9015
>>        help
>>          Say Y or M if you want to add support for the internal DAC found
>>          on GXL, G12 and SM1 SoC family.
>> +
>> +config SND_SOC_MESON_PAD_OUT
>> +     tristate "Amlogic PAD OUT"
>> +     select REGMAP_MMIO
>> +     help
>> +       Say Y or M if you want to add support for the S4 Audio Output from
>> +       the data Pad.
>> +
>> +config SND_SOC_MESON_TOCODEC_CONTROL
>> +     tristate "Amlogic TOCODEC CONTROL"
>> +     select REGMAP_MMIO
>> +     help
>> +      Say Y or M if you want to add support for the internal DAC control
>> +      on SM1 SoC family.
>>   endmenu
>> diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile
>> index 24078e4396b02d545d8ba4bcb1632979001354e3..afbefcb1313670f9b1365e88b8eb1a0badd7dc1e 100644
>> --- a/sound/soc/meson/Makefile
>> +++ b/sound/soc/meson/Makefile
>> @@ -24,8 +24,11 @@ snd-soc-meson-codec-glue-y := meson-codec-glue.o
>>   snd-soc-meson-gx-sound-card-y := gx-card.o
>>   snd-soc-meson-g12a-toacodec-y := g12a-toacodec.o
>>   snd-soc-meson-g12a-tohdmitx-y := g12a-tohdmitx.o
>> +snd-soc-meson-s4-padout-objs := s4-pad-out-control.o
>> +snd-soc-meson-s4-tocodec-control-objs := s4-tocodec-control.o
>>   snd-soc-meson-t9015-y := t9015.o
>>
>> +
>>   obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o
>>   obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
>>   obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
>> @@ -43,4 +46,7 @@ obj-$(CONFIG_SND_MESON_CODEC_GLUE) += snd-soc-meson-codec-glue.o
>>   obj-$(CONFIG_SND_MESON_GX_SOUND_CARD) += snd-soc-meson-gx-sound-card.o
>>   obj-$(CONFIG_SND_MESON_G12A_TOACODEC) += snd-soc-meson-g12a-toacodec.o
>>   obj-$(CONFIG_SND_MESON_G12A_TOHDMITX) += snd-soc-meson-g12a-tohdmitx.o
>> +obj-$(CONFIG_SND_SOC_MESON_PAD_OUT) += snd-soc-meson-s4-padout.o
>> +obj-$(CONFIG_SND_SOC_MESON_TOCODEC_CONTROL) += snd-soc-meson-s4-tocodec-control.o
>>   obj-$(CONFIG_SND_SOC_MESON_T9015) += snd-soc-meson-t9015.o
>> +
>> diff --git a/sound/soc/meson/s4-pad-out-control.c b/sound/soc/meson/s4-pad-out-control.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..a86dcf8a5995926f0ddf8d2911f42006daed0feb
>> --- /dev/null
>> +++ b/sound/soc/meson/s4-pad-out-control.c
>> @@ -0,0 +1,372 @@
>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>> +/*
>> + * Copyright (C) 2024 Amlogic, Inc. All rights reserved
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/regmap.h>
>> +#include <sound/soc.h>
>> +#include <sound/soc-dai.h>
>> +#include <linux/init.h>
>> +#include <linux/kernel.h>
>> +#include<linux/kstrtox.h>
>> +
>> +#include "axg-tdm.h"
>> +
>> +static const struct regmap_config tdmout_pad_regmap_cfg = {
>> +     .reg_bits       = 32,
>> +     .val_bits       = 32,
>> +     .reg_stride     = 4,
>> +     .max_register   = 0x28,
>> +};
>> +
>> +#define TDM_IFACE 0
>> +#define TDM_A_PAD 0
>> +#define TDM_B_PAD 1
>> +#define TDM_C_PAD 2
>> +
>> +#define EE_AUDIO_DAT_PAD_CTRL6 0x0
>> +#define EE_AUDIO_DAT_PAD_CTRL7 0x4
>> +#define EE_AUDIO_DAT_PAD_CTRL8 0x8
>> +#define EE_AUDIO_DAT_PAD_CTRL9 0xc
>> +#define EE_AUDIO_DAT_PAD_CTRLA 0x10
>> +#define EE_AUDIO_DAT_PAD_CTRLB 0x14
>> +#define EE_AUDIO_DAT_PAD_CTRLC 0x1c
>> +#define EE_AUDIO_DAT_PAD_CTRLD 0x20
>> +#define EE_AUDIO_DAT_PAD_CTRLE 0x24
>> +#define EE_AUDIO_DAT_PAD_CTRLF 0x28
>> +
>> +#define REG_OFFSET 4
>> +
>> +static const char * const s4_tdmout_sel_texts[] = {
>> +     "TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", "TDM_D6", "TDM_D7",
>> +     "TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", "TDM_D13", "TDM_D14", "TDM_D15",
>> +     "TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", "TDM_D21", "TDM_D22", "TDM_D23",
>> +     "TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", "TDM_D29", "TDM_D30", "TDM_D31"
>> +};
> This thing does not belong in ASoC. This is clearly yet another layer of
> pinctrl. Please deal with it there.

Thanks for your suggestion, add audio pinctrl driver to control the which tdm_dx pin can map the which tdm lane_x
for example
	tdm_d6_pin {
		mux {
			groups = "tdm_d6";
			function = "tdmoutb_lane0";
		};
	}
tdm_d6 pin map the tdmoutb lane 0, right ?

>> +
>> +static const struct soc_enum tdmout_sel_enum =
>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
>> +                     s4_tdmout_sel_texts);
>> +
>> +static struct snd_soc_dai *tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
>> +{
>> +     struct snd_soc_dapm_path *p;
>> +     struct snd_soc_dai *be;
>> +
>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>> +             if (p->source->id == snd_soc_dapm_dai_in)
>> +                     return (struct snd_soc_dai *)p->source->priv;
>> +             be = tdm_get_ahead_be(p->source);
>> +             if (be && be->id == TDM_IFACE)
>> +                     return be;
>> +     }
>> +     return NULL;
>> +}
>> +
>> +#define SND_SOC_DAPM_DEMUX_E(wname, wreg, wshift, winvert, wcontrols, \
>> +     wevent, wflags) \
>> +((struct snd_soc_dapm_widget) { \
>> +     .id = snd_soc_dapm_demux, .name = wname, \
>> +     SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
>> +     .kcontrol_news = wcontrols, .num_kcontrols = 1, \
>> +     .event = wevent, .event_flags = wflags})
>> +
>> +static const struct snd_kcontrol_new tdmout_sel_demux[] = {
>> +     SOC_DAPM_ENUM("TDMOUTA SEL", tdmout_sel_enum),
>> +     SOC_DAPM_ENUM("TDMOUTB SEL", tdmout_sel_enum),
>> +     SOC_DAPM_ENUM("TDMOUTC SEL", tdmout_sel_enum),
>> +};
>> +
>> +static unsigned int aml_simple_strtoull(const char *cp)
>> +{
>> +     unsigned int result = 0;
>> +     unsigned int value = 0;
>> +     unsigned int len =  strlen(cp);
>> +
>> +     while (len != 0) {
>> +             len--;
>> +             value = isdigit(*cp);
>> +             if (value) {
>> +                     value = *cp - '0';
>> +             } else {
>> +                     cp++;
>> +                     continue;
>> +             }
>> +             cp++;
>> +             result = result * 10 + value;
>> +     }
>> +     return result;
>> +}
>> +
>> +static int tdm_out_pad_set(struct snd_soc_dapm_widget *w)
>> +{
>> +     struct snd_soc_dai *be;
>> +     struct axg_tdm_stream *stream;
>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>> +     unsigned int tdm_id = TDM_A_PAD;
>> +     const char *dai_widget_name;
>> +     struct snd_soc_dapm_path *p;
>> +     unsigned int lane_num = 0;
>> +     unsigned long pin = 0;
>> +     unsigned int reg, mask, val = 0;
>> +     int lane_cnt;
>> +
>> +     be = tdm_get_ahead_be(w);
>> +     if (!be) {
>> +             dev_err(component->dev, "%s not find the be\n", __func__);
>> +             return -EINVAL;
>> +     }
>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>> +     if (!stream) {
>> +             dev_err(component->dev, "%s not find the stream\n", __func__);
>> +             return -EINVAL;
>> +     }
>> +     lane_cnt = (stream->channels - 1) / stream->iface->slots + 1;
>> +     /*we like to use dai id, but it is fixed val*/
>> +     dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>> +     if (strstr(dai_widget_name, "TDM_A"))
>> +             tdm_id = TDM_A_PAD;
>> +     else if (strstr(dai_widget_name, "TDM_B"))
>> +             tdm_id = TDM_B_PAD;
>> +     else if (strstr(dai_widget_name, "TDM_C"))
>> +             tdm_id = TDM_C_PAD;
>> +     else
>> +             dev_err(component->dev, "%s not find the be dai widget\n", __func__);
>> +     dev_dbg(component->dev, "tdm_id:%d, channel:%d, slot:%d\n",
>> +             tdm_id, stream->channels, stream->iface->slots);
>> +     snd_soc_dapm_widget_for_each_sink_path(w, p) {
>> +             if (p->sink->id == snd_soc_dapm_output) {
>> +                     if (p->connect) {
>> +                             pin = aml_simple_strtoull(p->name);
>> +                             reg = (pin / 4) * REG_OFFSET;
>> +                             /*calculate mask pos */
>> +                             mask = 0x1f << ((pin % 4) * 8);
>> +                             val = tdm_id * 8 + lane_num;
>> +                             snd_soc_component_update_bits(component, reg, mask, val);
>> +                             snd_soc_component_update_bits(component, EE_AUDIO_DAT_PAD_CTRLF,
>> +                                                           0x1 << pin, 0 << pin);
>> +                             lane_num++;
>> +                             if (lane_num > lane_cnt - 1)
>> +                                     break;
>> +                     }
>> +             }
>> +     }
>> +     return 0;
>> +}
>> +
>> +static int tdmout_sel_pad_event(struct snd_soc_dapm_widget *w,
>> +                             struct snd_kcontrol *control,
>> +                             int event)
>> +{
>> +     int ret = 0;
>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>> +
>> +     switch (event) {
>> +     case SND_SOC_DAPM_PRE_PMU:
>> +             tdm_out_pad_set(w);
>> +             break;
>> +
>> +     case SND_SOC_DAPM_PRE_PMD:
>> +             break;
>> +
>> +     default:
>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>> +             return -EINVAL;
>> +     }
>> +
>> +     return ret;
>> +}
>> +
>> +static const struct snd_soc_dapm_widget s4_tdmout_pad_dapm_widgets[] = {
>> +     SND_SOC_DAPM_DEMUX_E("TDMA_OUT SEL", SND_SOC_NOPM, 0, 0,
>> +                          &tdmout_sel_demux[TDM_A_PAD], tdmout_sel_pad_event,
>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>> +     SND_SOC_DAPM_DEMUX_E("TDMB_OUT SEL", SND_SOC_NOPM, 0, 0,
>> +                          &tdmout_sel_demux[TDM_B_PAD], tdmout_sel_pad_event,
>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>> +     SND_SOC_DAPM_DEMUX_E("TDMC_OUT SEL", SND_SOC_NOPM, 0, 0,
>> +                          &tdmout_sel_demux[TDM_C_PAD], tdmout_sel_pad_event,
>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D0"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D1"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D2"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D3"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D4"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D5"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D6"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D7"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D8"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D9"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D10"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D11"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D12"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D13"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D14"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D15"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D16"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D17"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D18"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D19"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D20"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D21"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D22"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D23"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D24"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D25"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D26"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D27"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D28"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D29"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D30"),
>> +     SND_SOC_DAPM_OUTPUT("TDM_D31"),
>> +};
>> +
>> +static const struct snd_soc_dapm_route s4_tdmout_pad_dapm_routes[] = {
>> +     { "TDM_D0", "TDM_D0", "TDMA_OUT SEL" },
>> +     { "TDM_D1", "TDM_D1", "TDMA_OUT SEL" },
>> +     { "TDM_D2", "TDM_D2", "TDMA_OUT SEL" },
>> +     { "TDM_D3", "TDM_D3", "TDMA_OUT SEL" },
>> +     { "TDM_D4", "TDM_D4", "TDMA_OUT SEL" },
>> +     { "TDM_D5", "TDM_D5", "TDMA_OUT SEL" },
>> +     { "TDM_D6", "TDM_D6", "TDMA_OUT SEL" },
>> +     { "TDM_D7", "TDM_D7", "TDMA_OUT SEL" },
>> +     { "TDM_D8", "TDM_D8", "TDMA_OUT SEL" },
>> +     { "TDM_D9", "TDM_D9", "TDMA_OUT SEL" },
>> +     { "TDM_D10", "TDM_D10", "TDMA_OUT SEL" },
>> +     { "TDM_D11", "TDM_D11", "TDMA_OUT SEL" },
>> +     { "TDM_D12", "TDM_D12", "TDMA_OUT SEL" },
>> +     { "TDM_D13", "TDM_D13", "TDMA_OUT SEL" },
>> +     { "TDM_D14", "TDM_D14", "TDMA_OUT SEL" },
>> +     { "TDM_D15", "TDM_D15", "TDMA_OUT SEL" },
>> +     { "TDM_D16", "TDM_D16", "TDMA_OUT SEL" },
>> +     { "TDM_D17", "TDM_D17", "TDMA_OUT SEL" },
>> +     { "TDM_D18", "TDM_D18", "TDMA_OUT SEL" },
>> +     { "TDM_D19", "TDM_D19", "TDMA_OUT SEL" },
>> +     { "TDM_D20", "TDM_D20", "TDMA_OUT SEL" },
>> +     { "TDM_D21", "TDM_D21", "TDMA_OUT SEL" },
>> +     { "TDM_D22", "TDM_D22", "TDMA_OUT SEL" },
>> +     { "TDM_D23", "TDM_D23", "TDMA_OUT SEL" },
>> +     { "TDM_D24", "TDM_D24", "TDMA_OUT SEL" },
>> +     { "TDM_D25", "TDM_D25", "TDMA_OUT SEL" },
>> +     { "TDM_D26", "TDM_D26", "TDMA_OUT SEL" },
>> +     { "TDM_D27", "TDM_D27", "TDMA_OUT SEL" },
>> +     { "TDM_D28", "TDM_D28", "TDMA_OUT SEL" },
>> +     { "TDM_D29", "TDM_D29", "TDMA_OUT SEL" },
>> +     { "TDM_D30", "TDM_D30", "TDMA_OUT SEL" },
>> +     { "TDM_D31", "TDM_D31", "TDMA_OUT SEL" },
>> +     { "TDM_D0", "TDM_D0", "TDMB_OUT SEL" },
>> +     { "TDM_D1", "TDM_D1", "TDMB_OUT SEL" },
>> +     { "TDM_D2", "TDM_D2", "TDMB_OUT SEL" },
>> +     { "TDM_D3", "TDM_D3", "TDMB_OUT SEL" },
>> +     { "TDM_D4", "TDM_D4", "TDMB_OUT SEL" },
>> +     { "TDM_D5", "TDM_D5", "TDMB_OUT SEL" },
>> +     { "TDM_D6", "TDM_D6", "TDMB_OUT SEL" },
>> +     { "TDM_D7", "TDM_D7", "TDMB_OUT SEL" },
>> +     { "TDM_D8", "TDM_D8", "TDMB_OUT SEL" },
>> +     { "TDM_D9", "TDM_D9", "TDMB_OUT SEL" },
>> +     { "TDM_D10", "TDM_D10", "TDMB_OUT SEL" },
>> +     { "TDM_D11", "TDM_D11", "TDMB_OUT SEL" },
>> +     { "TDM_D12", "TDM_D12", "TDMB_OUT SEL" },
>> +     { "TDM_D13", "TDM_D13", "TDMB_OUT SEL" },
>> +     { "TDM_D14", "TDM_D14", "TDMB_OUT SEL" },
>> +     { "TDM_D15", "TDM_D15", "TDMB_OUT SEL" },
>> +
>> +     { "TDM_D16", "TDM_D16", "TDMB_OUT SEL" },
>> +     { "TDM_D17", "TDM_D17", "TDMB_OUT SEL" },
>> +     { "TDM_D18", "TDM_D18", "TDMB_OUT SEL" },
>> +     { "TDM_D19", "TDM_D19", "TDMB_OUT SEL" },
>> +     { "TDM_D20", "TDM_D20", "TDMB_OUT SEL" },
>> +     { "TDM_D21", "TDM_D21", "TDMB_OUT SEL" },
>> +     { "TDM_D22", "TDM_D22", "TDMB_OUT SEL" },
>> +     { "TDM_D23", "TDM_D23", "TDMB_OUT SEL" },
>> +     { "TDM_D24", "TDM_D24", "TDMB_OUT SEL" },
>> +     { "TDM_D25", "TDM_D25", "TDMB_OUT SEL" },
>> +     { "TDM_D26", "TDM_D26", "TDMB_OUT SEL" },
>> +     { "TDM_D27", "TDM_D27", "TDMB_OUT SEL" },
>> +     { "TDM_D28", "TDM_D28", "TDMB_OUT SEL" },
>> +     { "TDM_D29", "TDM_D29", "TDMB_OUT SEL" },
>> +     { "TDM_D30", "TDM_D30", "TDMB_OUT SEL" },
>> +     { "TDM_D31", "TDM_D31", "TDMB_OUT SEL" },
>> +     { "TDM_D0", "TDM_D0", "TDMC_OUT SEL" },
>> +     { "TDM_D1", "TDM_D1", "TDMC_OUT SEL" },
>> +     { "TDM_D2", "TDM_D2", "TDMC_OUT SEL" },
>> +     { "TDM_D3", "TDM_D3", "TDMC_OUT SEL" },
>> +     { "TDM_D4", "TDM_D4", "TDMC_OUT SEL" },
>> +     { "TDM_D5", "TDM_D5", "TDMC_OUT SEL" },
>> +     { "TDM_D6", "TDM_D6", "TDMC_OUT SEL" },
>> +     { "TDM_D7", "TDM_D7", "TDMC_OUT SEL" },
>> +     { "TDM_D8", "TDM_D8", "TDMC_OUT SEL" },
>> +     { "TDM_D9", "TDM_D9", "TDMC_OUT SEL" },
>> +     { "TDM_D10", "TDM_D10", "TDMC_OUT SEL" },
>> +     { "TDM_D11", "TDM_D11", "TDMC_OUT SEL" },
>> +     { "TDM_D12", "TDM_D12", "TDMC_OUT SEL" },
>> +     { "TDM_D13", "TDM_D13", "TDMC_OUT SEL" },
>> +     { "TDM_D14", "TDM_D14", "TDMC_OUT SEL" },
>> +     { "TDM_D15", "TDM_D15", "TDMC_OUT SEL" },
>> +     { "TDM_D16", "TDM_D16", "TDMC_OUT SEL" },
>> +     { "TDM_D17", "TDM_D17", "TDMC_OUT SEL" },
>> +     { "TDM_D18", "TDM_D18", "TDMC_OUT SEL" },
>> +     { "TDM_D19", "TDM_D19", "TDMC_OUT SEL" },
>> +     { "TDM_D20", "TDM_D20", "TDMC_OUT SEL" },
>> +     { "TDM_D21", "TDM_D21", "TDMC_OUT SEL" },
>> +     { "TDM_D22", "TDM_D22", "TDMC_OUT SEL" },
>> +     { "TDM_D23", "TDM_D23", "TDMC_OUT SEL" },
>> +     { "TDM_D24", "TDM_D24", "TDMC_OUT SEL" },
>> +     { "TDM_D25", "TDM_D25", "TDMC_OUT SEL" },
>> +     { "TDM_D26", "TDM_D26", "TDMC_OUT SEL" },
>> +     { "TDM_D27", "TDM_D27", "TDMC_OUT SEL" },
>> +     { "TDM_D28", "TDM_D28", "TDMC_OUT SEL" },
>> +     { "TDM_D29", "TDM_D29", "TDMC_OUT SEL" },
>> +     { "TDM_D30", "TDM_D30", "TDMC_OUT SEL" },
>> +     { "TDM_D31", "TDM_D31", "TDMC_OUT SEL" },
>> +};
>> +
>> +static const struct snd_soc_component_driver s4_tdmout_pad_component_drv = {
>> +     .dapm_widgets           = s4_tdmout_pad_dapm_widgets,
>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_tdmout_pad_dapm_widgets),
>> +     .dapm_routes            = s4_tdmout_pad_dapm_routes,
>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tdmout_pad_dapm_routes),
>> +
>> +};
>> +
>> +static const struct of_device_id s4_tdmout_pad_of_match[] = {
>> +     {
>> +             .compatible = "amlogic,s4-tdmout-pad",
>> +     }, {}
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, s4_tdmout_pad_of_match);
>> +
>> +static int tdm_pad_out_probe(struct platform_device *pdev)
>> +{
>> +     struct device *dev = &pdev->dev;
>> +     struct regmap *map;
>> +     void __iomem *regs;
>> +
>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>> +     if (IS_ERR(regs))
>> +             return PTR_ERR(regs);
>> +
>> +     map = devm_regmap_init_mmio(dev, regs, &tdmout_pad_regmap_cfg);
>> +     if (IS_ERR(map))
>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
>> +
>> +     return devm_snd_soc_register_component(dev, &s4_tdmout_pad_component_drv,
>> +                                            NULL, 0);
>> +}
>> +
>> +static struct platform_driver tdmout_pad_pdrv = {
>> +     .probe = tdm_pad_out_probe,
>> +     .driver = {
>> +             .name = "s4-pad-out",
>> +             .of_match_table = s4_tdmout_pad_of_match,
>> +     },
>> +};
>> +
>> +module_platform_driver(tdmout_pad_pdrv);
>> +
>> +MODULE_DESCRIPTION("Amlogic TDM PAD DRIVER");
>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>> +MODULE_LICENSE("GPL");
>> diff --git a/sound/soc/meson/s4-tocodec-control.c b/sound/soc/meson/s4-tocodec-control.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
>> --- /dev/null
>> +++ b/sound/soc/meson/s4-tocodec-control.c
> There is already a to-acodec driver a not reason has been provided as to why a
> completly new driver is required.
>
> Please have look at the existing driver and do try to use it.
> If you need to do things so differently, clear justification are necessary.

for g12a-toacodec.c, we find the tocodec clock source can't get 
the clock id from the tdm Be device,

and set it by the kcontrol from user,  For different soc chips, The 
kcontrol value maybe different, The kcontrol configuration doesn't look 
very friendly for user

so we use dapm route path to manage it, 
fe(fddr)->be(tdm)->(tocodec)->(codec),  and use the aux-devs to 
register,  and sound card only include the

sound-dai = <&tdmif_a>

codec-0 {
                 sound-dai = <&acodec>;
  };

and not include

codec-1 {
                 sound-dai = <&toacodec>;
  };

when tdm work, only connect the tocodec path

  "TDM_A Playback" ->"TOACODEC TDMA"->"TOACODEC INPUT SRC"

iterate it find the be device ,and get the struct axg_tdm_stream, so we 
can get the tdm clock id

Take into account behavioral differences, we add new tocodec driver for s4

>> @@ -0,0 +1,376 @@
>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>> +/*
>> + * Copyright (C) 2023 Amlogic, Inc. All rights reserved
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/regmap.h>
>> +#include <sound/soc.h>
>> +#include <sound/soc-dai.h>
>> +#include <linux/init.h>
>> +#include <linux/kernel.h>
>> +#include<linux/kstrtox.h>
>> +#include <linux/clk-provider.h>
>> +#include <linux/reset.h>
>> +#include "axg-tdm.h"
>> +
>> +#define TOACODEC_CTRL0                       0x0
>> +
>> +#define CTRL0_ENABLE_SHIFT           31
>> +#define CTRL0_BCLK_ENABLE_SHIFT              30
>> +#define CTRL0_MCLK_ENABLE_SHIFT              29
>> +#define CTRL0_BLK_CAP_INV_SHIFT              9
>> +
>> +#define TDM_IFACE 0
>> +#define TDM_A_PAD 0
>> +#define TDM_B_PAD 1
>> +#define TDM_C_PAD 2
>> +
>> +struct toacodec {
>> +     struct regmap_field *field_dat_sel;
>> +     struct regmap_field *field_lrclk_sel;
>> +     struct regmap_field *field_bclk_sel;
>> +     struct regmap_field *field_mclk_sel;
>> +};
>> +
>> +struct toacodec_match_data {
>> +     const struct snd_soc_component_driver *component_drv;
>> +     const struct reg_field field_dat_sel;
>> +     const struct reg_field field_lrclk_sel;
>> +     const struct reg_field field_bclk_sel;
>> +     const struct reg_field field_mclk_sel;
>> +};
>> +
>> +static const struct regmap_config tocodec_regmap_cfg = {
>> +     .reg_bits       = 32,
>> +     .val_bits       = 32,
>> +     .reg_stride     = 4,
>> +     .max_register   = 0x1,
>> +};
>> +
>> +#define S4_LANE_OFFSET 8
>> +
>> +static const char * const s4_tocodec_lane_sel_texts[] = {
>> +     "Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", "Lane7"
>> +};
>> +
>> +static const struct soc_enum s4_tocodec_lane_sel_enum =
>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_lane_sel_texts),
>> +                     s4_tocodec_lane_sel_texts);
>> +
>> +static const struct snd_kcontrol_new s4_tocodec_lane_sel =
>> +     SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
>> +
>> +static const char * const s4_tocodec_src_sel_texts[] = {
>> +     "TDMA", "TDMB", "TDMC"
>> +};
>> +
>> +static const struct soc_enum s4_tocodec_src_sel_enum =
>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_src_sel_texts),
>> +                     s4_tocodec_src_sel_texts);
>> +
>> +static const struct snd_kcontrol_new s4_tocodec_src_sel =
>> +     SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
>> +
>> +static const struct snd_kcontrol_new s4_toacodec_out_enable =
>> +     SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
>> +                                 CTRL0_ENABLE_SHIFT, 1, 0);
>> +
>> +static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
>> +{
>> +     struct snd_soc_dapm_path *p;
>> +     struct snd_soc_dai *be;
>> +
>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>> +             if (!p->connect)
>> +                     continue;
>> +             if (p->source->id == snd_soc_dapm_dai_in)
>> +                     return (struct snd_soc_dai *)p->source->priv;
>> +             be = tocodec_tdm_get_ahead_be(p->source);
>> +             if (be && be->id == TDM_IFACE)
>> +                     return be;
>> +     }
>> +     return NULL;
>> +}
>> +
>> +static unsigned int aml_simple_strtoull(const char *cp)
>> +{
>> +     unsigned int result = 0;
>> +     unsigned int value = 0;
>> +     unsigned int len = strlen(cp);
>> +
>> +     while (len != 0) {
>> +             len--;
>> +             value = isdigit(*cp);
>> +             if (value) {
>> +                     value = *cp - '0';
>> +             } else {
>> +                     cp++;
>> +                     continue;
>> +             }
>> +             cp++;
>> +             result = result * 10 + value;
>> +     }
>> +     return result;
>> +}
>> +
>> +static int aml_get_clk_id(const char *name)
>> +{
>> +     int clk_id = 0;
>> +
>> +     if (strstr(name, "mst_a"))
>> +             clk_id = 0;
>> +     else if (strstr(name, "mst_b"))
>> +             clk_id = 1;
>> +     else if (strstr(name, "mst_c"))
>> +             clk_id = 2;
>> +     else if (strstr(name, "mst_d"))
>> +             clk_id = 3;
>> +     else if (strstr(name, "mst_e"))
>> +             clk_id = 4;
>> +     else if (strstr(name, "mst_f"))
>> +             clk_id = 5;
>> +
>> +     return clk_id;
>> +}
>> +
>> +static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
>> +{
>> +     struct snd_soc_dai *be;
>> +     struct axg_tdm_stream *stream;
>> +     struct axg_tdm_iface *iface;
>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>> +     struct toacodec *priv = snd_soc_component_get_drvdata(component);
>> +     unsigned int tdm_id = TDM_A_PAD;
>> +     const char *dai_widget_name;
>> +     struct snd_soc_dapm_path *p;
>> +     unsigned int lane = 0;
>> +     unsigned int val = 0;
>> +     struct clk *sclk, *mclk;
>> +     char *clk_name;
>> +     int mclk_id, sclk_id;
>> +
>> +     be = tocodec_tdm_get_ahead_be(w);
>> +     if (!be) {
>> +             dev_err(component->dev, "%s not find the be\n", __func__);
>> +             return -EINVAL;
>> +     }
>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>> +     if (!stream) {
>> +             dev_err(component->dev, "%s not find the stream\n", __func__);
>> +             return -EINVAL;
>> +     }
>> +     /*we like to use dai id, but it is fixed val*/
>> +     dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>> +     if (strstr(dai_widget_name, "TDM_A"))
>> +             tdm_id = TDM_A_PAD;
>> +     else if (strstr(dai_widget_name, "TDM_B"))
>> +             tdm_id = TDM_B_PAD;
>> +     else if (strstr(dai_widget_name, "TDM_C"))
>> +             tdm_id = TDM_C_PAD;
>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>> +             if (p->connect && p->name) {
>> +                     lane = aml_simple_strtoull(p->name);
>> +                     val = lane + tdm_id * S4_LANE_OFFSET;
>> +                     regmap_field_write(priv->field_dat_sel, val);
>> +             }
>> +     }
>> +     iface = stream->iface;
>> +     mclk = iface->mclk;
>> +     sclk = iface->sclk;
>> +     mclk_id = aml_get_clk_id(__clk_get_name(mclk));
>> +     sclk_id = aml_get_clk_id(__clk_get_name(sclk));
>> +     regmap_field_write(priv->field_mclk_sel, mclk_id);
>> +     regmap_field_write(priv->field_bclk_sel, sclk_id);
>> +     regmap_field_write(priv->field_lrclk_sel, sclk_id);
>> +
>> +     return 0;
>> +}
>> +
>> +static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
>> +                          struct snd_kcontrol *control,
>> +                          int event)
>> +{
>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>> +     int ret = 0;
>> +
>> +     switch (event) {
>> +     case SND_SOC_DAPM_PRE_PMU:
>> +             ret = aml_tocodec_sel_set(w);
>> +             break;
>> +
>> +     case SND_SOC_DAPM_PRE_PMD:
>> +             break;
>> +
>> +     default:
>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>> +             return -EINVAL;
>> +     }
>> +
>> +     return ret;
>> +}
>> +
>> +static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
>> +                           struct snd_kcontrol *control,
>> +                           int event)
>> +{
>> +     int ret = 0;
>> +     unsigned int mask = 0, val = 0;
>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>> +
>> +     snd_soc_component_update_bits(component, TOACODEC_CTRL0,
>> +                                   1 << CTRL0_BLK_CAP_INV_SHIFT, 1 << CTRL0_BLK_CAP_INV_SHIFT);
>> +     switch (event) {
>> +     case SND_SOC_DAPM_PRE_PMU:
>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>> +             val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>> +             break;
>> +     case SND_SOC_DAPM_PRE_PMD:
>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>> +             val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << CTRL0_BCLK_ENABLE_SHIFT;
>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>> +             break;
>> +     default:
>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>> +             return -EINVAL;
>> +     }
>> +
>> +     return ret;
>> +}
>> +
>> +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
>> +     SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
>> +                        &s4_tocodec_lane_sel, tocodec_sel_event,
>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>> +     SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, &s4_tocodec_src_sel),
>> +     SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
>> +                           &s4_toacodec_out_enable, tocodec_clk_enable,
>> +                             (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>> +     SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
>> +     SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
>> +     SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
>> +     SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
>> +};
>> +
>> +static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
>> +     { "INPUT SRC", "TDMA", "TDMA"},
>> +     { "INPUT SRC", "TDMB", "TDMB"},
>> +     { "INPUT SRC", "TDMC", "TDMC"},
>> +     { "Lane0", NULL, "INPUT SRC" },
>> +     { "Lane1", NULL, "INPUT SRC"},
>> +     { "Lane2", NULL, "INPUT SRC"},
>> +     { "Lane3", NULL, "INPUT SRC"},
>> +     { "Lane4", NULL, "INPUT SRC"},
>> +     { "Lane5", NULL, "INPUT SRC"},
>> +     { "Lane6", NULL, "INPUT SRC"},
>> +     { "Lane7", NULL, "INPUT SRC"},
>> +     { "Lane SRC", "Lane0", "Lane0"},
>> +     { "Lane SRC", "Lane1", "Lane1"},
>> +     { "Lane SRC", "Lane2", "Lane2"},
>> +     { "Lane SRC", "Lane3", "Lane3"},
>> +     { "Lane SRC", "Lane4", "Lane4"},
>> +     { "Lane SRC", "Lane5", "Lane5"},
>> +     { "Lane SRC", "Lane6", "Lane6"},
>> +     { "Lane SRC", "Lane7", "Lane7"},
>> +     { "OUT EN", "Switch", "Lane SRC"},
>> +     { "TDM_TO_ACODEC", NULL, "OUT EN"},
>> +
>> +};
>> +
>> +static const struct snd_soc_component_driver s4_tocodec_component_drv = {
>> +     .dapm_widgets           = s4_toacodec_widgets,
>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_toacodec_widgets),
>> +     .dapm_routes            = s4_tocodec_dapm_routes,
>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tocodec_dapm_routes),
>> +};
>> +
>> +static const struct toacodec_match_data s4_toacodec_match_data = {
>> +     .component_drv  = &s4_tocodec_component_drv,
>> +     .field_dat_sel  = REG_FIELD(TOACODEC_CTRL0, 16, 20),
>> +     .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
>> +     .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
>> +     .field_mclk_sel = REG_FIELD(TOACODEC_CTRL0, 0, 2),
>> +};
>> +
>> +static const struct of_device_id s4_tocodec_of_match[] = {
>> +     {
>> +             .compatible = "amlogic,s4-tocodec",
>> +             .data = &s4_toacodec_match_data,
>> +     }, {}
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
>> +
>> +static int tocodec_probe(struct platform_device *pdev)
>> +{
>> +     const struct toacodec_match_data *data;
>> +     struct device *dev = &pdev->dev;
>> +     struct toacodec *priv;
>> +     void __iomem *regs;
>> +     struct regmap *map;
>> +     int ret;
>> +
>> +     data = device_get_match_data(dev);
>> +     if (!data)
>> +             return dev_err_probe(dev, -ENODEV, "failed to match device\n");
>> +     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>> +     if (!priv)
>> +             return -ENOMEM;
>> +
>> +     platform_set_drvdata(pdev, priv);
>> +
>> +     ret = device_reset(dev);
>> +     if (ret)
>> +             return ret;
>> +
>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>> +     if (IS_ERR(regs))
>> +             return PTR_ERR(regs);
>> +
>> +     map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
>> +     if (IS_ERR(map))
>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
>> +
>> +     priv->field_dat_sel = devm_regmap_field_alloc(dev, map, data->field_dat_sel);
>> +     if (IS_ERR(priv->field_dat_sel))
>> +             return PTR_ERR(priv->field_dat_sel);
>> +
>> +     priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, data->field_lrclk_sel);
>> +     if (IS_ERR(priv->field_lrclk_sel))
>> +             return PTR_ERR(priv->field_lrclk_sel);
>> +
>> +     priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, data->field_bclk_sel);
>> +     if (IS_ERR(priv->field_bclk_sel))
>> +             return PTR_ERR(priv->field_bclk_sel);
>> +
>> +     priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, data->field_mclk_sel);
>> +     if (IS_ERR(priv->field_mclk_sel))
>> +             return PTR_ERR(priv->field_mclk_sel);
>> +
>> +     return devm_snd_soc_register_component(dev,
>> +                     data->component_drv, NULL, 0);
>> +}
>> +
>> +static struct platform_driver tocodec_pdrv = {
>> +     .probe = tocodec_probe,
>> +     .driver = {
>> +             .name = "s4-tocodec",
>> +             .of_match_table = s4_tocodec_of_match,
>> +     },
>> +};
>> +
>> +module_platform_driver(tocodec_pdrv);
>> +
>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>> +MODULE_LICENSE("GPL");
>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>> index 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 100644
>> --- a/sound/soc/meson/t9015.c
>> +++ b/sound/soc/meson/t9015.c
>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>                .channels_min = 1,
>>                .channels_max = 2,
>>                .rates = SNDRV_PCM_RATE_8000_96000,
>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE),
> Again, mixed up changes with zero justification.
>
> This drops S8 and S16 format support for the existing SoCs (such as GXL)
> which is known to work and add S32 support on an HW documented as 24bits
> only. Can you explain ?
>
>>        },
>>        .ops = &t9015_dai_ops,
>>   };
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-13 14:50   ` Jerome Brunet
@ 2025-01-14  8:52     ` Jiebing Chen
  2025-01-14 11:16       ` Jerome Brunet
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-14  8:52 UTC (permalink / raw)
  To: Jerome Brunet, jiebing chen via B4 Relay
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jaroslav Kysela, Takashi Iwai, Neil Armstrong,
	Kevin Hilman, Martin Blumenstingl, linux-sound, devicetree,
	linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/13 22:50, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>
>> From: jiebing chen <jiebing.chen@amlogic.com>
>>
>> Add basic audio driver support for the Amlogic S4 based Amlogic
>> AQ222 board.
>>
>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>> ---
>>   .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>>   arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>>   2 files changed, 610 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>               regulator-always-on;
>>        };
>>
>> +     vcc5v_reg: regulator-vcc-5v {
>> +             compatible = "regulator-fixed";
>> +             vin-supply = <&main_12v>;
>> +             regulator-name = "VCC5V";
>> +             regulator-min-microvolt = <5000000>;
>> +             regulator-max-microvolt = <5000000>;
>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>> +             startup-delay-us = <7000>;
>> +             enable-active-high;
>> +             regulator-boot-on;
>> +             regulator-always-on;
>> +     };
>> +
>>        /* SY8120B1ABC DC/DC Regulator. */
>>        vddcpu: regulator-vddcpu {
>>                compatible = "pwm-regulator";
>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>                                <699000 98>,
>>                                <689000 100>;
>>        };
>> +     dmics: audio-codec-1 {
>> +             compatible = "dmic-codec";
>> +             #sound-dai-cells = <0>;
>> +             num-channels = <2>;
>> +             wakeup-delay-ms = <50>;
>> +             sound-name-prefix = "MIC";
>> +     };
>> +
>> +     dioo2133: audio-amplifier-0 {
>> +             compatible = "simple-audio-amplifier";
>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>> +             VCC-supply = <&vcc5v_reg>;
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "10U2";
>> +     };
>> +
>> +     spdif_dir: audio-spdif-in {
>> +             compatible = "linux,spdif-dir";
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "DIR";
>> +     };
>> +
>> +     spdif_dit: audio-spdif-out {
>> +             compatible = "linux,spdif-dit";
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "DIT";
>> +     };
>> +
>> +     sound {
>> +             compatible = "amlogic,axg-sound-card";
>> +             model = "aq222";
>> +             audio-widgets = "Line", "Lineout";
>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>> +                              <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>> +                             "TOACODEC TDMA", "TDM_A Playback",
>> +                             "TOACODEC TDMB", "TDM_B Playback",
>> +                             "TOACODEC TDMC", "TDM_C Playback",
>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>> +                             "10U2 INL", "ACODEC LOLP",
>> +                             "10U2 INR", "ACODEC LORP",
>> +                             "Lineout", "10U2 OUTL",
>> +                             "Lineout", "10U2 OUTR";
>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>> +                               <&clkc_pll CLKID_MPLL2>,
>> +                               <&clkc_pll CLKID_MPLL0>,
>> +                               <&clkc_pll CLKID_MPLL1>;
>> +             assigned-clock-rates = <491520000>,
>> +                                    <294912000>,
>> +                                    <270950400>,
>> +                                    <393216000>;
> Why do you need 4 base rates ? Which rate family does each provide ?

hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000, the 
accuracy of hifipll

is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if 
the tdm and spdif work on

the same time, for example ,tdm 48k. spdif 44.1k, we can't use the same 
pll, so spdif need use the mpll 0

other pll , only set a default value, at the latest chip, we remove all 
mpll for hardware, only two hifipll

>> +
>> +             dai-link-0 {
>> +                     sound-dai = <&frddr_a>;
>> +             };
>> +
>> +             dai-link-1 {
>> +                     sound-dai = <&frddr_b>;
>> +             };
>> +
>> +             dai-link-2 {
>> +                     sound-dai = <&frddr_c>;
>> +             };
>> +
>> +             dai-link-3 {
>> +                     sound-dai = <&toddr_a>;
>> +             };
>> +
>> +             dai-link-4 {
>> +                     sound-dai = <&toddr_b>;
>> +             };
>> +
>> +             dai-link-5 {
>> +                     sound-dai = <&toddr_c>;
>> +             };
>> +
>> +             /* Connected to the WIFI/BT chip */
>> +             dai-link-6 {
>> +                     sound-dai = <&tdmif_a>;
>> +                     dai-format = "dsp_a";
>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>> +                     mclk-fs = <256>;
>> +                     codec-0 {
>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
>> +                     };
>> +             };
>> +
>> +             /* Connected to the onboard AD82584F DAC */
>> +             dai-link-7 {
>> +                     sound-dai = <&tdmif_b>;
>> +                     dai-format = "i2s";
>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>> +                     mclk-fs = <256>;
>> +
>> +                     codec-0 {
>> +                             sound-dai = <&acodec>;
>> +                     };
>> +
>> +                     codec-1 {
>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
>> +                     };
>> +             };
>> +
>> +             /* 8ch HDMI interface */
>> +             dai-link-8 {
>> +                     sound-dai = <&tdmif_c>;
>> +                     dai-format = "i2s";
>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>> +                     dai-tdm-slot-tx-mask-1 = <1 1>;
>> +                     dai-tdm-slot-tx-mask-2 = <1 1>;
>> +                     dai-tdm-slot-tx-mask-3 = <1 1>;
>> +                     mclk-fs = <256>;
>> +
>> +                     codec-0 {
>> +                             sound-dai = <&acodec>;
>> +                     };
>> +
>> +                     codec-1 {
>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
>> +                     };
>> +             };
>> +
>> +             /* spdif hdmi and coax output */
>> +             dai-link-9 {
>> +                     sound-dai = <&spdifout_a>;
>> +
>> +                     codec-0 {
>> +                             sound-dai = <&spdif_dit>;
>> +                     };
>> +
>> +                     codec-1 {
>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
>> +                     };
>> +             };
>> +
>> +             /* spdif hdmi interface */
>> +             dai-link-10 {
>> +                     sound-dai = <&spdifout_b>;
>> +
>> +                     codec {
>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
>> +                     };
>> +             };
>> +
>> +             /* spdif coax input */
>> +             dai-link-11 {
>> +                     sound-dai = <&spdifin>;
>> +
>> +                     codec {
>> +                             sound-dai = <&spdif_dir>;
>> +                     };
>> +             };
>> +     };
>> +
>>   };
>>
>>   &pwm_ef {
>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>> index 957577d986c0675a503115e1ccbc4387c2051620..87a00ace23131e31822bb43fbe956b8abcbaef40 100644
>> --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>> @@ -11,7 +11,11 @@
>>   #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
>>   #include <dt-bindings/power/meson-s4-power.h>
>>   #include <dt-bindings/reset/amlogic,meson-s4-reset.h>
>> -
>> +#include <dt-bindings/clock/axg-audio-clkc.h>
>> +#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
>> +#include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
>> +#include <dt-bindings/sound/meson-g12a-toacodec.h>
>> +#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
>>   / {
>>        cpus {
>>                #address-cells = <2>;
>> @@ -46,6 +50,42 @@ cpu3: cpu@3 {
>>                };
>>        };
>>
>> +     tdmif_a: audio-controller-0 {
>> +             compatible = "amlogic,axg-tdm-iface";
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "TDM_A";
>> +             clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_A_SCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
>> +             clock-names = "mclk", "sclk", "lrclk";
>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK_SEL>;
>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
> Based on clock provider used, I doubt this is of any use.

if not set the mclk parent. we dump clk_summary, the default parent is 
mpll 0

we tend  to use hifipll

>
>> +     };
>> +
>> +     tdmif_b: audio-controller-1 {
>> +             compatible = "amlogic,axg-tdm-iface";
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "TDM_B";
>> +             clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_B_SCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_B_LRCLK>;
>> +             clock-names = "mclk", "sclk", "lrclk";
>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK_SEL>;
>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>> +     };
>> +
>> +     tdmif_c: audio-controller-2 {
>> +             compatible = "amlogic,axg-tdm-iface";
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "TDM_C";
>> +             clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_C_SCLK>,
>> +                      <&clkc_audio AUD_CLKID_MST_C_LRCLK>;
>> +             clock-names = "mclk", "sclk", "lrclk";
>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK_SEL>;
>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>> +     };
>> +
>>        timer {
>>                compatible = "arm,armv8-timer";
>>                interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
>> @@ -850,3 +890,346 @@ emmc: mmc@fe08c000 {
>>                };
>>        };
>>   };
>> +
>> +&apb4 {
>> +     audio: bus@330000 {
>> +             compatible = "simple-bus";
>> +             reg = <0x0 0x330000 0x0 0x1000>;
>> +             #address-cells = <2>;
>> +             #size-cells = <2>;
>> +             ranges = <0x0 0x0 0x0 0x330000 0x0 0x1000>;
>> +
>> +             clkc_audio: clock-controller@0 {
>> +                     compatible = "amlogic,sm1-audio-clkc";
> I suspect the DT folks would like having SoC specific compatible in
> addition to the fall back. In that case, I think that would be wise. I
> doubt the compatibility will hold in the long run.
>
> Same goes for the other HW components.

you are right, for s4 , some clock is different, we will add the 
"amlogic,s4-audio-clkc"

this is a base clk for tdm

>
>> +                     reg = <0x0 0x0 0x0 0xb4>;
>> +                     #clock-cells = <1>;
>> +                     #reset-cells = <1>;
>> +                     power-domains = <&pwrc PWRC_S4_AUDIO_ID>;
>> +                     clocks = <&clkc_periphs CLKID_AUDIO>,
>> +                              <&clkc_pll CLKID_MPLL0>,
>> +                              <&clkc_pll CLKID_MPLL1>,
>> +                              <&clkc_pll CLKID_MPLL2>,
>> +                              <&clkc_pll CLKID_MPLL3>,
>> +                              <&clkc_pll CLKID_HIFI_PLL>,
>> +                              <&clkc_pll CLKID_FCLK_DIV3>,
>> +                              <&clkc_pll CLKID_FCLK_DIV4>,
>> +                              <&clkc_pll CLKID_FCLK_DIV5>;
>> +                     clock-names = "pclk",
>> +                                   "mst_in0",
>> +                                   "mst_in1",
>> +                                   "mst_in2",
>> +                                   "mst_in3",
>> +                                   "mst_in4",
>> +                                   "mst_in5",
>> +                                   "mst_in6",
>> +                                   "mst_in7";
>> +
>> +                     resets = <&reset RESET_AUDIO>;
>> +             };
>> +
>> +             toddr_a: audio-controller@100 {
>> +                     compatible = "amlogic,sm1-toddr",
>> +                                  "amlogic,axg-toddr";
>> +                     reg = <0x0 0x100 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "TODDR_A";
>> +                     interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_A>;
>> +                     resets = <&arb AXG_ARB_TODDR_A>,
>> +                              <&clkc_audio AUD_RESET_TODDR_A>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <8192>;
>> +             };
>> +
>> +             toddr_b: audio-controller@140 {
>> +                     compatible = "amlogic,sm1-toddr",
>> +                                  "amlogic,axg-toddr";
>> +                     reg = <0x0 0x140 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "TODDR_B";
>> +                     interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_B>;
>> +                     resets = <&arb AXG_ARB_TODDR_B>,
>> +                              <&clkc_audio AUD_RESET_TODDR_B>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             toddr_c: audio-controller@180 {
>> +                     compatible = "amlogic,sm1-toddr",
>> +                                  "amlogic,axg-toddr";
>> +                     reg = <0x0 0x180 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "TODDR_C";
>> +                     interrupts = <GIC_SPI 34 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_C>;
>> +                     resets = <&arb AXG_ARB_TODDR_C>,
>> +                              <&clkc_audio AUD_RESET_TODDR_C>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             frddr_a: audio-controller@1c0 {
>> +                     compatible = "amlogic,sm1-frddr",
>> +                                  "amlogic,axg-frddr";
>> +                     reg = <0x0 0x1c0 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "FRDDR_A";
>> +                     interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
>> +                     resets = <&arb AXG_ARB_FRDDR_A>,
>> +                              <&clkc_audio AUD_RESET_FRDDR_A>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <512>;
>> +             };
>> +
>> +             frddr_b: audio-controller@200 {
>> +                     compatible = "amlogic,sm1-frddr",
>> +                                  "amlogic,axg-frddr";
>> +                     reg = <0x0 0x200 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "FRDDR_B";
>> +                     interrupts = <GIC_SPI 37 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_B>;
>> +                     resets = <&arb AXG_ARB_FRDDR_B>,
>> +                              <&clkc_audio AUD_RESET_FRDDR_B>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             frddr_c: audio-controller@240 {
>> +                     compatible = "amlogic,sm1-frddr",
>> +                                  "amlogic,axg-frddr";
>> +                     reg = <0x0 0x240 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "FRDDR_C";
>> +                     interrupts = <GIC_SPI 38 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_C>;
>> +                     resets = <&arb AXG_ARB_FRDDR_C>,
>> +                              <&clkc_audio AUD_RESET_FRDDR_C>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             arb: reset-controller@280 {
>> +                     compatible = "amlogic,meson-sm1-audio-arb";
>> +                     reg = <0x0 0x280 0x0 0x4>;
>> +                     #reset-cells = <1>;
>> +                     clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
>> +             };
>> +
>> +             tdmin_a: audio-controller@300 {
>> +                     compatible = "amlogic,sm1-tdmin",
>> +                                  "amlogic,axg-tdmin";
>> +                     reg = <0x0 0x300 0x0 0x40>;
>> +                     sound-name-prefix = "TDMIN_A";
>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_A>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_A>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             tdmin_b: audio-controller@340 {
>> +                     compatible = "amlogic,sm1-tdmin",
>> +                                  "amlogic,axg-tdmin";
>> +                     reg = <0x0 0x340 0x0 0x40>;
>> +                     sound-name-prefix = "TDMIN_B";
>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_B>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_B>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             tdmin_c: audio-controller@380 {
>> +                     compatible = "amlogic,sm1-tdmin",
>> +                                  "amlogic,axg-tdmin";
>> +                     reg = <0x0 0x380 0x0 0x40>;
>> +                     sound-name-prefix = "TDMIN_C";
>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_C>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_C>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             tdmin_lb: audio-controller@3c0 {
>> +                     compatible = "amlogic,sm1-tdmin",
>> +                                  "amlogic,axg-tdmin";
>> +                     reg = <0x0 0x3c0 0x0 0x40>;
>> +                     sound-name-prefix = "TDMIN_LB";
>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_LB>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_LB>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             spdifin: audio-controller@400 {
>> +                     compatible = "amlogic,g12a-spdifin",
>> +                                  "amlogic,axg-spdifin";
>> +                     reg = <0x0 0x400 0x0 0x30>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "SPDIFIN";
>> +                     interrupts = <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
>> +                     <&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
>> +                     clock-names = "pclk", "refclk";
>> +                     resets = <&clkc_audio AUD_RESET_SPDIFIN>;
>> +             };
>> +
>> +             spdifout_a: audio-controller@480 {
>> +                     compatible = "amlogic,g12a-spdifout",
>> +                                  "amlogic,axg-spdifout";
>> +                     reg = <0x0 0x480 0x0 0x50>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "SPDIFOUT_A";
>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
>> +                     <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
>> +                     clock-names = "pclk", "mclk";
>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT>;
>> +             };
>> +
>> +             tdmout_a: audio-controller@500 {
>> +                     compatible = "amlogic,sm1-tdmout";
>> +                     reg = <0x0 0x500 0x0 0x40>;
>> +                     sound-name-prefix = "TDMOUT_A";
>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             tdmout_b: audio-controller@540 {
>> +                     compatible = "amlogic,sm1-tdmout";
>> +                     reg = <0x0 0x540 0x0 0x40>;
>> +                     sound-name-prefix = "TDMOUT_B";
>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_B>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_B>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             tdmout_c: audio-controller@580 {
>> +                     compatible = "amlogic,sm1-tdmout";
>> +                     reg = <0x0 0x580 0x0 0x40>;
>> +                     sound-name-prefix = "TDMOUT_C";
>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_C>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_C>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK_SEL>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>,
>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>;
>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>> +                                   "lrclk", "lrclk_sel";
>> +             };
>> +
>> +             spdifout_b: audio-controller@680 {
>> +                     compatible = "amlogic,g12a-spdifout",
>> +                                  "amlogic,axg-spdifout";
>> +                     reg = <0x0 0x680 0x0 0x50>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "SPDIFOUT_B";
>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT_B>,
>> +                              <&clkc_audio AUD_CLKID_SPDIFOUT_B_CLK>;
>> +                     clock-names = "pclk", "mclk";
>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT_B>;
>> +             };
>> +
>> +             toacodec: audio-controller@740 {
>> +                     compatible = "amlogic,s4-tocodec";
>> +                     reg = <0x0 0x740 0x0 0x4>;
>> +                     sound-name-prefix = "TOACODEC";
>> +                     resets = <&clkc_audio AUD_RESET_TOACODEC>;
>> +             };
>> +
>> +             tohdmitx: audio-controller@744 {
>> +                     compatible = "amlogic,sm1-tohdmitx",
>> +                                  "amlogic,g12a-tohdmitx";
>> +                     reg = <0x0 0x744 0x0 0x4>;
>> +                     #sound-dai-cells = <1>;
>> +                     sound-name-prefix = "TOHDMITX";
>> +                     resets = <&clkc_audio AUD_RESET_TOHDMITX>;
>> +             };
>> +
>> +             toddr_d: audio-controller@840 {
>> +                     compatible = "amlogic,sm1-toddr",
>> +                                  "amlogic,axg-toddr";
>> +                     reg = <0x0 0x840 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "TODDR_D";
>> +                     interrupts = <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_D>;
>> +                     resets = <&arb AXG_ARB_TODDR_D>,
>> +                              <&clkc_audio AUD_RESET_TODDR_D>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             frddr_d: audio-controller@880 {
>> +                      compatible = "amlogic,sm1-frddr",
>> +                                   "amlogic,axg-frddr";
>> +                     reg = <0x0 0x880 0x0 0x2c>;
>> +                     #sound-dai-cells = <0>;
>> +                     sound-name-prefix = "FRDDR_D";
>> +                     interrupts = <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_D>;
>> +                     resets = <&arb AXG_ARB_FRDDR_D>,
>> +                              <&clkc_audio AUD_RESET_FRDDR_D>;
>> +                     reset-names = "arb", "rst";
>> +                     amlogic,fifo-depth = <256>;
>> +             };
>> +
>> +             tdmout_pad: audio-controller@E58 {
>> +                     compatible = "amlogic,s4-tdmout-pad";
>> +                     reg = <0x0 0xe58 0x0 0x28>;
>> +             };
>> +     };
>> +
>> +     pdm: audio-controller@331000 {
>> +             compatible = "amlogic,sm1-pdm",
>> +                          "amlogic,axg-pdm";
>> +             reg = <0x0 0x331000 0x0 0x34>;
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "PDM";
>> +             clocks = <&clkc_audio AUD_CLKID_PDM>,
>> +                      <&clkc_audio AUD_CLKID_PDM_DCLK>,
>> +                      <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
>> +             clock-names = "pclk", "dclk", "sysclk";
>> +             resets = <&clkc_audio AUD_RESET_PDM>;
>> +             assigned-clocks = <&clkc_audio AUD_CLKID_PDM_DCLK_SEL>,
>> +                               <&clkc_audio AUD_CLKID_PDM_SYSCLK_SEL>;
>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>,<&clkc_pll CLKID_HIFI_PLL>;
>> +     };
>> +      acodec: audio-controller@1A000 {
>> +             compatible = "amlogic,t9015";
>> +             reg = <0x0 0x1A000 0x0 0x14>;
>> +             #sound-dai-cells = <0>;
>> +             sound-name-prefix = "ACODEC";
>> +             clocks = <&clkc_periphs CLKID_ACODEC>;
>> +             clock-names = "pclk";
>> +             resets = <&reset RESET_ACODEC>;
>> +     };
>> +
>> +};
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-13  6:35 ` [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio jiebing chen via B4 Relay
  2025-01-13 14:31   ` Jerome Brunet
@ 2025-01-14  9:09   ` kernel test robot
  1 sibling, 0 replies; 27+ messages in thread
From: kernel test robot @ 2025-01-14  9:09 UTC (permalink / raw)
  To: jiebing chen via B4 Relay, Jerome Brunet, Liam Girdwood,
	Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jaroslav Kysela, Takashi Iwai, Neil Armstrong, Kevin Hilman,
	Martin Blumenstingl
  Cc: oe-kbuild-all, linux-sound, devicetree, linux-kernel,
	linux-arm-kernel, linux-amlogic, jiebing chen

Hi jiebing,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab]

url:    https://github.com/intel-lab-lkp/linux/commits/jiebing-chen-via-B4-Relay/ASoC-dt-bindings-Add-Amlogic-S4-audio/20250113-143911
base:   6ecd20965bdc21b265a0671ccf36d9ad8043f5ab
patch link:    https://lore.kernel.org/r/20250113-audio_drvier-v1-2-8c14770f38a0%40amlogic.com
patch subject: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20250114/202501141658.tM15P1iG-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250114/202501141658.tM15P1iG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501141658.tM15P1iG-lkp@intel.com/

All warnings (new ones prefixed by >>):

   sound/soc/meson/s4-tocodec-control.c: In function 'aml_tocodec_sel_set':
>> sound/soc/meson/s4-tocodec-control.c:151:15: warning: unused variable 'clk_name' [-Wunused-variable]
     151 |         char *clk_name;
         |               ^~~~~~~~


vim +/clk_name +151 sound/soc/meson/s4-tocodec-control.c

   137	
   138	static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
   139	{
   140		struct snd_soc_dai *be;
   141		struct axg_tdm_stream *stream;
   142		struct axg_tdm_iface *iface;
   143		struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
   144		struct toacodec *priv = snd_soc_component_get_drvdata(component);
   145		unsigned int tdm_id = TDM_A_PAD;
   146		const char *dai_widget_name;
   147		struct snd_soc_dapm_path *p;
   148		unsigned int lane = 0;
   149		unsigned int val = 0;
   150		struct clk *sclk, *mclk;
 > 151		char *clk_name;
   152		int mclk_id, sclk_id;
   153	
   154		be = tocodec_tdm_get_ahead_be(w);
   155		if (!be) {
   156			dev_err(component->dev, "%s not find the be\n", __func__);
   157			return -EINVAL;
   158		}
   159		stream = snd_soc_dai_dma_data_get_playback(be);
   160		if (!stream) {
   161			dev_err(component->dev, "%s not find the stream\n", __func__);
   162			return -EINVAL;
   163		}
   164		/*we like to use dai id, but it is fixed val*/
   165		dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
   166		if (strstr(dai_widget_name, "TDM_A"))
   167			tdm_id = TDM_A_PAD;
   168		else if (strstr(dai_widget_name, "TDM_B"))
   169			tdm_id = TDM_B_PAD;
   170		else if (strstr(dai_widget_name, "TDM_C"))
   171			tdm_id = TDM_C_PAD;
   172		snd_soc_dapm_widget_for_each_source_path(w, p) {
   173			if (p->connect && p->name) {
   174				lane = aml_simple_strtoull(p->name);
   175				val = lane + tdm_id * S4_LANE_OFFSET;
   176				regmap_field_write(priv->field_dat_sel, val);
   177			}
   178		}
   179		iface = stream->iface;
   180		mclk = iface->mclk;
   181		sclk = iface->sclk;
   182		mclk_id = aml_get_clk_id(__clk_get_name(mclk));
   183		sclk_id = aml_get_clk_id(__clk_get_name(sclk));
   184		regmap_field_write(priv->field_mclk_sel, mclk_id);
   185		regmap_field_write(priv->field_bclk_sel, sclk_id);
   186		regmap_field_write(priv->field_lrclk_sel, sclk_id);
   187	
   188		return 0;
   189	}
   190	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-14  8:52     ` Jiebing Chen
@ 2025-01-14 11:16       ` Jerome Brunet
  2025-01-14 12:34         ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-14 11:16 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

> 在 2025/1/13 22:50, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>
>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>
>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>> AQ222 board.
>>>
>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>> ---
>>>   .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>>>   arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>>>   2 files changed, 610 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>               regulator-always-on;
>>>        };
>>>
>>> +     vcc5v_reg: regulator-vcc-5v {
>>> +             compatible = "regulator-fixed";
>>> +             vin-supply = <&main_12v>;
>>> +             regulator-name = "VCC5V";
>>> +             regulator-min-microvolt = <5000000>;
>>> +             regulator-max-microvolt = <5000000>;
>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>> +             startup-delay-us = <7000>;
>>> +             enable-active-high;
>>> +             regulator-boot-on;
>>> +             regulator-always-on;
>>> +     };
>>> +
>>>        /* SY8120B1ABC DC/DC Regulator. */
>>>        vddcpu: regulator-vddcpu {
>>>                compatible = "pwm-regulator";
>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>                                <699000 98>,
>>>                                <689000 100>;
>>>        };
>>> +     dmics: audio-codec-1 {
>>> +             compatible = "dmic-codec";
>>> +             #sound-dai-cells = <0>;
>>> +             num-channels = <2>;
>>> +             wakeup-delay-ms = <50>;
>>> +             sound-name-prefix = "MIC";
>>> +     };
>>> +
>>> +     dioo2133: audio-amplifier-0 {
>>> +             compatible = "simple-audio-amplifier";
>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>> +             VCC-supply = <&vcc5v_reg>;
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "10U2";
>>> +     };
>>> +
>>> +     spdif_dir: audio-spdif-in {
>>> +             compatible = "linux,spdif-dir";
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "DIR";
>>> +     };
>>> +
>>> +     spdif_dit: audio-spdif-out {
>>> +             compatible = "linux,spdif-dit";
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "DIT";
>>> +     };
>>> +
>>> +     sound {
>>> +             compatible = "amlogic,axg-sound-card";
>>> +             model = "aq222";
>>> +             audio-widgets = "Line", "Lineout";
>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>> +                              <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>> +                             "10U2 INL", "ACODEC LOLP",
>>> +                             "10U2 INR", "ACODEC LORP",
>>> +                             "Lineout", "10U2 OUTL",
>>> +                             "Lineout", "10U2 OUTR";
>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>> +                               <&clkc_pll CLKID_MPLL2>,
>>> +                               <&clkc_pll CLKID_MPLL0>,
>>> +                               <&clkc_pll CLKID_MPLL1>;
>>> +             assigned-clock-rates = <491520000>,
>>> +                                    <294912000>,
>>> +                                    <270950400>,
>>> +                                    <393216000>;
>> Why do you need 4 base rates ? Which rate family does each provide ?
>
> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000, the
> accuracy of hifipll
>
> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if the
> tdm and spdif work on

It is fine to use the HiFi. I'm glad this clock finally got fixed

>
> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the same
> pll, so spdif need use the mpll 0
>
> other pll , only set a default value, at the latest chip, we remove all
> mpll for hardware, only two hifipll

I'm not sure you understand how this works.
There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz

Each family needs a PLL assigned, so you need 3, not 4, unless there is
another specific rate family you want to support. If that's the case,
document it.

Setting the rate of the PLL should follow this principle:
* Family rate
  - multiplied by (32 x 24): to accomodate different sample sizes
  - multiplied by 2 until you reach the maximum rate of selected PLLs
    This allows to support rates such 192k or even 768k

491520000 is not dividable by 3, it won't allow 24 bits words. It is a
poor choice.

Have a look at the s400 for an example using the HiFi PLL. The axg was
restricted to a 68 PLL multiplier but the S4 is not so you should be
able to use a higher base rate (4 718 592 000 Hz), providing better
accuracy in the end

>
>>> +
>>> +             dai-link-0 {
>>> +                     sound-dai = <&frddr_a>;
>>> +             };
>>> +
>>> +             dai-link-1 {
>>> +                     sound-dai = <&frddr_b>;
>>> +             };
>>> +
>>> +             dai-link-2 {
>>> +                     sound-dai = <&frddr_c>;
>>> +             };
>>> +
>>> +             dai-link-3 {
>>> +                     sound-dai = <&toddr_a>;
>>> +             };
>>> +
>>> +             dai-link-4 {
>>> +                     sound-dai = <&toddr_b>;
>>> +             };
>>> +
>>> +             dai-link-5 {
>>> +                     sound-dai = <&toddr_c>;
>>> +             };
>>> +
>>> +             /* Connected to the WIFI/BT chip */
>>> +             dai-link-6 {
>>> +                     sound-dai = <&tdmif_a>;
>>> +                     dai-format = "dsp_a";
>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>> +                     mclk-fs = <256>;
>>> +                     codec-0 {
>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
>>> +                     };
>>> +             };
>>> +
>>> +             /* Connected to the onboard AD82584F DAC */
>>> +             dai-link-7 {
>>> +                     sound-dai = <&tdmif_b>;
>>> +                     dai-format = "i2s";
>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>> +                     mclk-fs = <256>;
>>> +
>>> +                     codec-0 {
>>> +                             sound-dai = <&acodec>;
>>> +                     };
>>> +
>>> +                     codec-1 {
>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
>>> +                     };
>>> +             };
>>> +
>>> +             /* 8ch HDMI interface */
>>> +             dai-link-8 {
>>> +                     sound-dai = <&tdmif_c>;
>>> +                     dai-format = "i2s";
>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>> +                     dai-tdm-slot-tx-mask-1 = <1 1>;
>>> +                     dai-tdm-slot-tx-mask-2 = <1 1>;
>>> +                     dai-tdm-slot-tx-mask-3 = <1 1>;
>>> +                     mclk-fs = <256>;
>>> +
>>> +                     codec-0 {
>>> +                             sound-dai = <&acodec>;
>>> +                     };
>>> +
>>> +                     codec-1 {
>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
>>> +                     };
>>> +             };
>>> +
>>> +             /* spdif hdmi and coax output */
>>> +             dai-link-9 {
>>> +                     sound-dai = <&spdifout_a>;
>>> +
>>> +                     codec-0 {
>>> +                             sound-dai = <&spdif_dit>;
>>> +                     };
>>> +
>>> +                     codec-1 {
>>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
>>> +                     };
>>> +             };
>>> +
>>> +             /* spdif hdmi interface */
>>> +             dai-link-10 {
>>> +                     sound-dai = <&spdifout_b>;
>>> +
>>> +                     codec {
>>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
>>> +                     };
>>> +             };
>>> +
>>> +             /* spdif coax input */
>>> +             dai-link-11 {
>>> +                     sound-dai = <&spdifin>;
>>> +
>>> +                     codec {
>>> +                             sound-dai = <&spdif_dir>;
>>> +                     };
>>> +             };
>>> +     };
>>> +
>>>   };
>>>
>>>   &pwm_ef {
>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>> index 957577d986c0675a503115e1ccbc4387c2051620..87a00ace23131e31822bb43fbe956b8abcbaef40 100644
>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>> @@ -11,7 +11,11 @@
>>>   #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
>>>   #include <dt-bindings/power/meson-s4-power.h>
>>>   #include <dt-bindings/reset/amlogic,meson-s4-reset.h>
>>> -
>>> +#include <dt-bindings/clock/axg-audio-clkc.h>
>>> +#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
>>> +#include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
>>> +#include <dt-bindings/sound/meson-g12a-toacodec.h>
>>> +#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
>>>   / {
>>>        cpus {
>>>                #address-cells = <2>;
>>> @@ -46,6 +50,42 @@ cpu3: cpu@3 {
>>>                };
>>>        };
>>>
>>> +     tdmif_a: audio-controller-0 {
>>> +             compatible = "amlogic,axg-tdm-iface";
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "TDM_A";
>>> +             clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_A_SCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
>>> +             clock-names = "mclk", "sclk", "lrclk";
>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK_SEL>;
>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>> Based on clock provider used, I doubt this is of any use.
>
> if not set the mclk parent. we dump clk_summary, the default parent is mpll
> 0
>
> we tend  to use hifipll

Have you really tested this ? Master clocks do reparent to the appropriate PLL
depending on the rate required, this is how it has always worked.

>>
>>> +     };
>>> +
>>> +     tdmif_b: audio-controller-1 {
>>> +             compatible = "amlogic,axg-tdm-iface";
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "TDM_B";
>>> +             clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_B_SCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_B_LRCLK>;
>>> +             clock-names = "mclk", "sclk", "lrclk";
>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK_SEL>;
>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>>> +     };
>>> +
>>> +     tdmif_c: audio-controller-2 {
>>> +             compatible = "amlogic,axg-tdm-iface";
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "TDM_C";
>>> +             clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_C_SCLK>,
>>> +                      <&clkc_audio AUD_CLKID_MST_C_LRCLK>;
>>> +             clock-names = "mclk", "sclk", "lrclk";
>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK_SEL>;
>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>>> +     };
>>> +
>>>        timer {
>>>                compatible = "arm,armv8-timer";
>>>                interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
>>> @@ -850,3 +890,346 @@ emmc: mmc@fe08c000 {
>>>                };
>>>        };
>>>   };
>>> +
>>> +&apb4 {
>>> +     audio: bus@330000 {
>>> +             compatible = "simple-bus";
>>> +             reg = <0x0 0x330000 0x0 0x1000>;
>>> +             #address-cells = <2>;
>>> +             #size-cells = <2>;
>>> +             ranges = <0x0 0x0 0x0 0x330000 0x0 0x1000>;
>>> +
>>> +             clkc_audio: clock-controller@0 {
>>> +                     compatible = "amlogic,sm1-audio-clkc";
>> I suspect the DT folks would like having SoC specific compatible in
>> addition to the fall back. In that case, I think that would be wise. I
>> doubt the compatibility will hold in the long run.
>>
>> Same goes for the other HW components.
>
> you are right, for s4 , some clock is different, we will add the
> "amlogic,s4-audio-clkc"
>
> this is a base clk for tdm
>
>>
>>> +                     reg = <0x0 0x0 0x0 0xb4>;
>>> +                     #clock-cells = <1>;
>>> +                     #reset-cells = <1>;
>>> +                     power-domains = <&pwrc PWRC_S4_AUDIO_ID>;
>>> +                     clocks = <&clkc_periphs CLKID_AUDIO>,
>>> +                              <&clkc_pll CLKID_MPLL0>,
>>> +                              <&clkc_pll CLKID_MPLL1>,
>>> +                              <&clkc_pll CLKID_MPLL2>,
>>> +                              <&clkc_pll CLKID_MPLL3>,
>>> +                              <&clkc_pll CLKID_HIFI_PLL>,
>>> +                              <&clkc_pll CLKID_FCLK_DIV3>,
>>> +                              <&clkc_pll CLKID_FCLK_DIV4>,
>>> +                              <&clkc_pll CLKID_FCLK_DIV5>;
>>> +                     clock-names = "pclk",
>>> +                                   "mst_in0",
>>> +                                   "mst_in1",
>>> +                                   "mst_in2",
>>> +                                   "mst_in3",
>>> +                                   "mst_in4",
>>> +                                   "mst_in5",
>>> +                                   "mst_in6",
>>> +                                   "mst_in7";
>>> +
>>> +                     resets = <&reset RESET_AUDIO>;
>>> +             };
>>> +
>>> +             toddr_a: audio-controller@100 {
>>> +                     compatible = "amlogic,sm1-toddr",
>>> +                                  "amlogic,axg-toddr";
>>> +                     reg = <0x0 0x100 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "TODDR_A";
>>> +                     interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_A>;
>>> +                     resets = <&arb AXG_ARB_TODDR_A>,
>>> +                              <&clkc_audio AUD_RESET_TODDR_A>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <8192>;
>>> +             };
>>> +
>>> +             toddr_b: audio-controller@140 {
>>> +                     compatible = "amlogic,sm1-toddr",
>>> +                                  "amlogic,axg-toddr";
>>> +                     reg = <0x0 0x140 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "TODDR_B";
>>> +                     interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_B>;
>>> +                     resets = <&arb AXG_ARB_TODDR_B>,
>>> +                              <&clkc_audio AUD_RESET_TODDR_B>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             toddr_c: audio-controller@180 {
>>> +                     compatible = "amlogic,sm1-toddr",
>>> +                                  "amlogic,axg-toddr";
>>> +                     reg = <0x0 0x180 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "TODDR_C";
>>> +                     interrupts = <GIC_SPI 34 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_C>;
>>> +                     resets = <&arb AXG_ARB_TODDR_C>,
>>> +                              <&clkc_audio AUD_RESET_TODDR_C>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             frddr_a: audio-controller@1c0 {
>>> +                     compatible = "amlogic,sm1-frddr",
>>> +                                  "amlogic,axg-frddr";
>>> +                     reg = <0x0 0x1c0 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "FRDDR_A";
>>> +                     interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
>>> +                     resets = <&arb AXG_ARB_FRDDR_A>,
>>> +                              <&clkc_audio AUD_RESET_FRDDR_A>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <512>;
>>> +             };
>>> +
>>> +             frddr_b: audio-controller@200 {
>>> +                     compatible = "amlogic,sm1-frddr",
>>> +                                  "amlogic,axg-frddr";
>>> +                     reg = <0x0 0x200 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "FRDDR_B";
>>> +                     interrupts = <GIC_SPI 37 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_B>;
>>> +                     resets = <&arb AXG_ARB_FRDDR_B>,
>>> +                              <&clkc_audio AUD_RESET_FRDDR_B>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             frddr_c: audio-controller@240 {
>>> +                     compatible = "amlogic,sm1-frddr",
>>> +                                  "amlogic,axg-frddr";
>>> +                     reg = <0x0 0x240 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "FRDDR_C";
>>> +                     interrupts = <GIC_SPI 38 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_C>;
>>> +                     resets = <&arb AXG_ARB_FRDDR_C>,
>>> +                              <&clkc_audio AUD_RESET_FRDDR_C>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             arb: reset-controller@280 {
>>> +                     compatible = "amlogic,meson-sm1-audio-arb";
>>> +                     reg = <0x0 0x280 0x0 0x4>;
>>> +                     #reset-cells = <1>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
>>> +             };
>>> +
>>> +             tdmin_a: audio-controller@300 {
>>> +                     compatible = "amlogic,sm1-tdmin",
>>> +                                  "amlogic,axg-tdmin";
>>> +                     reg = <0x0 0x300 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMIN_A";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_A>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_A>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             tdmin_b: audio-controller@340 {
>>> +                     compatible = "amlogic,sm1-tdmin",
>>> +                                  "amlogic,axg-tdmin";
>>> +                     reg = <0x0 0x340 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMIN_B";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_B>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_B>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             tdmin_c: audio-controller@380 {
>>> +                     compatible = "amlogic,sm1-tdmin",
>>> +                                  "amlogic,axg-tdmin";
>>> +                     reg = <0x0 0x380 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMIN_C";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_C>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_C>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             tdmin_lb: audio-controller@3c0 {
>>> +                     compatible = "amlogic,sm1-tdmin",
>>> +                                  "amlogic,axg-tdmin";
>>> +                     reg = <0x0 0x3c0 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMIN_LB";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_LB>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_LB>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             spdifin: audio-controller@400 {
>>> +                     compatible = "amlogic,g12a-spdifin",
>>> +                                  "amlogic,axg-spdifin";
>>> +                     reg = <0x0 0x400 0x0 0x30>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "SPDIFIN";
>>> +                     interrupts = <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
>>> +                     <&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
>>> +                     clock-names = "pclk", "refclk";
>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFIN>;
>>> +             };
>>> +
>>> +             spdifout_a: audio-controller@480 {
>>> +                     compatible = "amlogic,g12a-spdifout",
>>> +                                  "amlogic,axg-spdifout";
>>> +                     reg = <0x0 0x480 0x0 0x50>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "SPDIFOUT_A";
>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
>>> +                     <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
>>> +                     clock-names = "pclk", "mclk";
>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT>;
>>> +             };
>>> +
>>> +             tdmout_a: audio-controller@500 {
>>> +                     compatible = "amlogic,sm1-tdmout";
>>> +                     reg = <0x0 0x500 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMOUT_A";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             tdmout_b: audio-controller@540 {
>>> +                     compatible = "amlogic,sm1-tdmout";
>>> +                     reg = <0x0 0x540 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMOUT_B";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_B>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_B>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             tdmout_c: audio-controller@580 {
>>> +                     compatible = "amlogic,sm1-tdmout";
>>> +                     reg = <0x0 0x580 0x0 0x40>;
>>> +                     sound-name-prefix = "TDMOUT_C";
>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_C>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_C>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK_SEL>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>,
>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>;
>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>> +                                   "lrclk", "lrclk_sel";
>>> +             };
>>> +
>>> +             spdifout_b: audio-controller@680 {
>>> +                     compatible = "amlogic,g12a-spdifout",
>>> +                                  "amlogic,axg-spdifout";
>>> +                     reg = <0x0 0x680 0x0 0x50>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "SPDIFOUT_B";
>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT_B>,
>>> +                              <&clkc_audio AUD_CLKID_SPDIFOUT_B_CLK>;
>>> +                     clock-names = "pclk", "mclk";
>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT_B>;
>>> +             };
>>> +
>>> +             toacodec: audio-controller@740 {
>>> +                     compatible = "amlogic,s4-tocodec";
>>> +                     reg = <0x0 0x740 0x0 0x4>;
>>> +                     sound-name-prefix = "TOACODEC";
>>> +                     resets = <&clkc_audio AUD_RESET_TOACODEC>;
>>> +             };
>>> +
>>> +             tohdmitx: audio-controller@744 {
>>> +                     compatible = "amlogic,sm1-tohdmitx",
>>> +                                  "amlogic,g12a-tohdmitx";
>>> +                     reg = <0x0 0x744 0x0 0x4>;
>>> +                     #sound-dai-cells = <1>;
>>> +                     sound-name-prefix = "TOHDMITX";
>>> +                     resets = <&clkc_audio AUD_RESET_TOHDMITX>;
>>> +             };
>>> +
>>> +             toddr_d: audio-controller@840 {
>>> +                     compatible = "amlogic,sm1-toddr",
>>> +                                  "amlogic,axg-toddr";
>>> +                     reg = <0x0 0x840 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "TODDR_D";
>>> +                     interrupts = <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_D>;
>>> +                     resets = <&arb AXG_ARB_TODDR_D>,
>>> +                              <&clkc_audio AUD_RESET_TODDR_D>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             frddr_d: audio-controller@880 {
>>> +                      compatible = "amlogic,sm1-frddr",
>>> +                                   "amlogic,axg-frddr";
>>> +                     reg = <0x0 0x880 0x0 0x2c>;
>>> +                     #sound-dai-cells = <0>;
>>> +                     sound-name-prefix = "FRDDR_D";
>>> +                     interrupts = <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_D>;
>>> +                     resets = <&arb AXG_ARB_FRDDR_D>,
>>> +                              <&clkc_audio AUD_RESET_FRDDR_D>;
>>> +                     reset-names = "arb", "rst";
>>> +                     amlogic,fifo-depth = <256>;
>>> +             };
>>> +
>>> +             tdmout_pad: audio-controller@E58 {
>>> +                     compatible = "amlogic,s4-tdmout-pad";
>>> +                     reg = <0x0 0xe58 0x0 0x28>;
>>> +             };
>>> +     };
>>> +
>>> +     pdm: audio-controller@331000 {
>>> +             compatible = "amlogic,sm1-pdm",
>>> +                          "amlogic,axg-pdm";
>>> +             reg = <0x0 0x331000 0x0 0x34>;
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "PDM";
>>> +             clocks = <&clkc_audio AUD_CLKID_PDM>,
>>> +                      <&clkc_audio AUD_CLKID_PDM_DCLK>,
>>> +                      <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
>>> +             clock-names = "pclk", "dclk", "sysclk";
>>> +             resets = <&clkc_audio AUD_RESET_PDM>;
>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_PDM_DCLK_SEL>,
>>> +                               <&clkc_audio AUD_CLKID_PDM_SYSCLK_SEL>;
>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>,<&clkc_pll CLKID_HIFI_PLL>;
>>> +     };
>>> +      acodec: audio-controller@1A000 {
>>> +             compatible = "amlogic,t9015";
>>> +             reg = <0x0 0x1A000 0x0 0x14>;
>>> +             #sound-dai-cells = <0>;
>>> +             sound-name-prefix = "ACODEC";
>>> +             clocks = <&clkc_periphs CLKID_ACODEC>;
>>> +             clock-names = "pclk";
>>> +             resets = <&reset RESET_ACODEC>;
>>> +     };
>>> +
>>> +};
>> --
>> Jerome

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-14  8:16     ` Jiebing Chen
@ 2025-01-14 11:20       ` Jiebing Chen
  2025-01-14 14:05         ` Jerome Brunet
  2025-01-14 11:29       ` Jerome Brunet
  1 sibling, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-14 11:20 UTC (permalink / raw)
  To: Jerome Brunet, jiebing chen via B4 Relay
  Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Jaroslav Kysela, Takashi Iwai, Neil Armstrong,
	Kevin Hilman, Martin Blumenstingl, linux-sound, devicetree,
	linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/14 16:16, Jiebing Chen 写道:
>
> 在 2025/1/13 22:31, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay 
>> <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>
>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>
>>> Add audio support for Amlogic S4.The audio output pad
>>> can be freelycombined with the output lane,and the tocodec
>>> control logic has been optimized.
>> The patch is a mixture of different HW modules.
>>
>> Each patch should have one clear purpose and, as such, deal with a
>> single HW module
>>
>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>> ---
>>>   sound/soc/meson/Kconfig              |  16 ++
>>>   sound/soc/meson/Makefile             |   6 +
>>>   sound/soc/meson/s4-pad-out-control.c | 372 
>>> ++++++++++++++++++++++++++++++++++
>>>   sound/soc/meson/s4-tocodec-control.c | 376 
>>> +++++++++++++++++++++++++++++++++++
>>>   sound/soc/meson/t9015.c              |   5 +-
>>>   5 files changed, 771 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
>>> index 
>>> 6458d5dc4902f665211bb9e4ae7d274e4bff2fdc..d01e284642fd987cf4bdf88e5bf5f7c9a241af59 
>>> 100644
>>> --- a/sound/soc/meson/Kconfig
>>> +++ b/sound/soc/meson/Kconfig
>>> @@ -69,6 +69,8 @@ config SND_MESON_AXG_SOUND_CARD
>>>        imply SND_MESON_AXG_SPDIFIN
>>>        imply SND_MESON_AXG_PDM
>>>        imply SND_MESON_G12A_TOACODEC
>>> +     imply SND_SOC_MESON_PAD_OUT
>>> +     imply SND_SOC_MESON_TOCODEC_CONTROL
>>>        imply SND_MESON_G12A_TOHDMITX if DRM_MESON_DW_HDMI
>>>        help
>>>          Select Y or M to add support for the AXG SoC sound card
>>> @@ -135,4 +137,18 @@ config SND_SOC_MESON_T9015
>>>        help
>>>          Say Y or M if you want to add support for the internal DAC 
>>> found
>>>          on GXL, G12 and SM1 SoC family.
>>> +
>>> +config SND_SOC_MESON_PAD_OUT
>>> +     tristate "Amlogic PAD OUT"
>>> +     select REGMAP_MMIO
>>> +     help
>>> +       Say Y or M if you want to add support for the S4 Audio 
>>> Output from
>>> +       the data Pad.
>>> +
>>> +config SND_SOC_MESON_TOCODEC_CONTROL
>>> +     tristate "Amlogic TOCODEC CONTROL"
>>> +     select REGMAP_MMIO
>>> +     help
>>> +      Say Y or M if you want to add support for the internal DAC 
>>> control
>>> +      on SM1 SoC family.
>>>   endmenu
>>> diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile
>>> index 
>>> 24078e4396b02d545d8ba4bcb1632979001354e3..afbefcb1313670f9b1365e88b8eb1a0badd7dc1e 
>>> 100644
>>> --- a/sound/soc/meson/Makefile
>>> +++ b/sound/soc/meson/Makefile
>>> @@ -24,8 +24,11 @@ snd-soc-meson-codec-glue-y := meson-codec-glue.o
>>>   snd-soc-meson-gx-sound-card-y := gx-card.o
>>>   snd-soc-meson-g12a-toacodec-y := g12a-toacodec.o
>>>   snd-soc-meson-g12a-tohdmitx-y := g12a-tohdmitx.o
>>> +snd-soc-meson-s4-padout-objs := s4-pad-out-control.o
>>> +snd-soc-meson-s4-tocodec-control-objs := s4-tocodec-control.o
>>>   snd-soc-meson-t9015-y := t9015.o
>>>
>>> +
>>>   obj-$(CONFIG_SND_MESON_AIU) += snd-soc-meson-aiu.o
>>>   obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
>>>   obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
>>> @@ -43,4 +46,7 @@ obj-$(CONFIG_SND_MESON_CODEC_GLUE) += 
>>> snd-soc-meson-codec-glue.o
>>>   obj-$(CONFIG_SND_MESON_GX_SOUND_CARD) += 
>>> snd-soc-meson-gx-sound-card.o
>>>   obj-$(CONFIG_SND_MESON_G12A_TOACODEC) += 
>>> snd-soc-meson-g12a-toacodec.o
>>>   obj-$(CONFIG_SND_MESON_G12A_TOHDMITX) += 
>>> snd-soc-meson-g12a-tohdmitx.o
>>> +obj-$(CONFIG_SND_SOC_MESON_PAD_OUT) += snd-soc-meson-s4-padout.o
>>> +obj-$(CONFIG_SND_SOC_MESON_TOCODEC_CONTROL) += 
>>> snd-soc-meson-s4-tocodec-control.o
>>>   obj-$(CONFIG_SND_SOC_MESON_T9015) += snd-soc-meson-t9015.o
>>> +
>>> diff --git a/sound/soc/meson/s4-pad-out-control.c 
>>> b/sound/soc/meson/s4-pad-out-control.c
>>> new file mode 100644
>>> index 
>>> 0000000000000000000000000000000000000000..a86dcf8a5995926f0ddf8d2911f42006daed0feb
>>> --- /dev/null
>>> +++ b/sound/soc/meson/s4-pad-out-control.c
>>> @@ -0,0 +1,372 @@
>>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>>> +/*
>>> + * Copyright (C) 2024 Amlogic, Inc. All rights reserved
>>> + */
>>> +
>>> +#include <linux/module.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/regmap.h>
>>> +#include <sound/soc.h>
>>> +#include <sound/soc-dai.h>
>>> +#include <linux/init.h>
>>> +#include <linux/kernel.h>
>>> +#include<linux/kstrtox.h>
>>> +
>>> +#include "axg-tdm.h"
>>> +
>>> +static const struct regmap_config tdmout_pad_regmap_cfg = {
>>> +     .reg_bits       = 32,
>>> +     .val_bits       = 32,
>>> +     .reg_stride     = 4,
>>> +     .max_register   = 0x28,
>>> +};
>>> +
>>> +#define TDM_IFACE 0
>>> +#define TDM_A_PAD 0
>>> +#define TDM_B_PAD 1
>>> +#define TDM_C_PAD 2
>>> +
>>> +#define EE_AUDIO_DAT_PAD_CTRL6 0x0
>>> +#define EE_AUDIO_DAT_PAD_CTRL7 0x4
>>> +#define EE_AUDIO_DAT_PAD_CTRL8 0x8
>>> +#define EE_AUDIO_DAT_PAD_CTRL9 0xc
>>> +#define EE_AUDIO_DAT_PAD_CTRLA 0x10
>>> +#define EE_AUDIO_DAT_PAD_CTRLB 0x14
>>> +#define EE_AUDIO_DAT_PAD_CTRLC 0x1c
>>> +#define EE_AUDIO_DAT_PAD_CTRLD 0x20
>>> +#define EE_AUDIO_DAT_PAD_CTRLE 0x24
>>> +#define EE_AUDIO_DAT_PAD_CTRLF 0x28
>>> +
>>> +#define REG_OFFSET 4
>>> +
>>> +static const char * const s4_tdmout_sel_texts[] = {
>>> +     "TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", 
>>> "TDM_D6", "TDM_D7",
>>> +     "TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", 
>>> "TDM_D13", "TDM_D14", "TDM_D15",
>>> +     "TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", 
>>> "TDM_D21", "TDM_D22", "TDM_D23",
>>> +     "TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", 
>>> "TDM_D29", "TDM_D30", "TDM_D31"
>>> +};
>> This thing does not belong in ASoC. This is clearly yet another layer of
>> pinctrl. Please deal with it there.
>
> Thanks for your suggestion, add audio pinctrl driver to control the 
> which tdm_dx pin can map the which tdm lane_x
> for example
>     tdm_d6_pin {
>         mux {
>             groups = "tdm_d6";
>             function = "tdmoutb_lane0";
>         };
>     }
> tdm_d6 pin map the tdmoutb lane 0, right ?
>
>>> +
>>> +static const struct soc_enum tdmout_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
>>> +                     s4_tdmout_sel_texts);
>>> +
>>> +static struct snd_soc_dai *tdm_get_ahead_be(struct 
>>> snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dapm_path *p;
>>> +     struct snd_soc_dai *be;
>>> +
>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>> +             if (p->source->id == snd_soc_dapm_dai_in)
>>> +                     return (struct snd_soc_dai *)p->source->priv;
>>> +             be = tdm_get_ahead_be(p->source);
>>> +             if (be && be->id == TDM_IFACE)
>>> +                     return be;
>>> +     }
>>> +     return NULL;
>>> +}
>>> +
>>> +#define SND_SOC_DAPM_DEMUX_E(wname, wreg, wshift, winvert, 
>>> wcontrols, \
>>> +     wevent, wflags) \
>>> +((struct snd_soc_dapm_widget) { \
>>> +     .id = snd_soc_dapm_demux, .name = wname, \
>>> +     SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
>>> +     .kcontrol_news = wcontrols, .num_kcontrols = 1, \
>>> +     .event = wevent, .event_flags = wflags})
>>> +
>>> +static const struct snd_kcontrol_new tdmout_sel_demux[] = {
>>> +     SOC_DAPM_ENUM("TDMOUTA SEL", tdmout_sel_enum),
>>> +     SOC_DAPM_ENUM("TDMOUTB SEL", tdmout_sel_enum),
>>> +     SOC_DAPM_ENUM("TDMOUTC SEL", tdmout_sel_enum),
>>> +};
>>> +
>>> +static unsigned int aml_simple_strtoull(const char *cp)
>>> +{
>>> +     unsigned int result = 0;
>>> +     unsigned int value = 0;
>>> +     unsigned int len =  strlen(cp);
>>> +
>>> +     while (len != 0) {
>>> +             len--;
>>> +             value = isdigit(*cp);
>>> +             if (value) {
>>> +                     value = *cp - '0';
>>> +             } else {
>>> +                     cp++;
>>> +                     continue;
>>> +             }
>>> +             cp++;
>>> +             result = result * 10 + value;
>>> +     }
>>> +     return result;
>>> +}
>>> +
>>> +static int tdm_out_pad_set(struct snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dai *be;
>>> +     struct axg_tdm_stream *stream;
>>> +     struct snd_soc_component *component = 
>>> snd_soc_dapm_to_component(w->dapm);
>>> +     unsigned int tdm_id = TDM_A_PAD;
>>> +     const char *dai_widget_name;
>>> +     struct snd_soc_dapm_path *p;
>>> +     unsigned int lane_num = 0;
>>> +     unsigned long pin = 0;
>>> +     unsigned int reg, mask, val = 0;
>>> +     int lane_cnt;
>>> +
>>> +     be = tdm_get_ahead_be(w);
>>> +     if (!be) {
>>> +             dev_err(component->dev, "%s not find the be\n", 
>>> __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>>> +     if (!stream) {
>>> +             dev_err(component->dev, "%s not find the stream\n", 
>>> __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     lane_cnt = (stream->channels - 1) / stream->iface->slots + 1;
>>> +     /*we like to use dai id, but it is fixed val*/
>>> +     dai_widget_name = 
>>> be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>>> +     if (strstr(dai_widget_name, "TDM_A"))
>>> +             tdm_id = TDM_A_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_B"))
>>> +             tdm_id = TDM_B_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_C"))
>>> +             tdm_id = TDM_C_PAD;
>>> +     else
>>> +             dev_err(component->dev, "%s not find the be dai 
>>> widget\n", __func__);
>>> +     dev_dbg(component->dev, "tdm_id:%d, channel:%d, slot:%d\n",
>>> +             tdm_id, stream->channels, stream->iface->slots);
>>> +     snd_soc_dapm_widget_for_each_sink_path(w, p) {
>>> +             if (p->sink->id == snd_soc_dapm_output) {
>>> +                     if (p->connect) {
>>> +                             pin = aml_simple_strtoull(p->name);
>>> +                             reg = (pin / 4) * REG_OFFSET;
>>> +                             /*calculate mask pos */
>>> +                             mask = 0x1f << ((pin % 4) * 8);
>>> +                             val = tdm_id * 8 + lane_num;
>>> + snd_soc_component_update_bits(component, reg, mask, val);
>>> + snd_soc_component_update_bits(component, EE_AUDIO_DAT_PAD_CTRLF,
>>> + 0x1 << pin, 0 << pin);
>>> +                             lane_num++;
>>> +                             if (lane_num > lane_cnt - 1)
>>> +                                     break;
>>> +                     }
>>> +             }
>>> +     }
>>> +     return 0;
>>> +}
>>> +
>>> +static int tdmout_sel_pad_event(struct snd_soc_dapm_widget *w,
>>> +                             struct snd_kcontrol *control,
>>> +                             int event)
>>> +{
>>> +     int ret = 0;
>>> +     struct snd_soc_component *component = 
>>> snd_soc_dapm_to_component(w->dapm);
>>> +
>>> +     switch (event) {
>>> +     case SND_SOC_DAPM_PRE_PMU:
>>> +             tdm_out_pad_set(w);
>>> +             break;
>>> +
>>> +     case SND_SOC_DAPM_PRE_PMD:
>>> +             break;
>>> +
>>> +     default:
>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>> +             return -EINVAL;
>>> +     }
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +static const struct snd_soc_dapm_widget 
>>> s4_tdmout_pad_dapm_widgets[] = {
>>> +     SND_SOC_DAPM_DEMUX_E("TDMA_OUT SEL", SND_SOC_NOPM, 0, 0,
>>> +                          &tdmout_sel_demux[TDM_A_PAD], 
>>> tdmout_sel_pad_event,
>>> +                        (SND_SOC_DAPM_PRE_PMU | 
>>> SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_DEMUX_E("TDMB_OUT SEL", SND_SOC_NOPM, 0, 0,
>>> +                          &tdmout_sel_demux[TDM_B_PAD], 
>>> tdmout_sel_pad_event,
>>> +                        (SND_SOC_DAPM_PRE_PMU | 
>>> SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_DEMUX_E("TDMC_OUT SEL", SND_SOC_NOPM, 0, 0,
>>> +                          &tdmout_sel_demux[TDM_C_PAD], 
>>> tdmout_sel_pad_event,
>>> +                        (SND_SOC_DAPM_PRE_PMU | 
>>> SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D0"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D1"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D2"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D3"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D4"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D5"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D6"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D7"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D8"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D9"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D10"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D11"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D12"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D13"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D14"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D15"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D16"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D17"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D18"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D19"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D20"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D21"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D22"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D23"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D24"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D25"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D26"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D27"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D28"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D29"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D30"),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_D31"),
>>> +};
>>> +
>>> +static const struct snd_soc_dapm_route s4_tdmout_pad_dapm_routes[] = {
>>> +     { "TDM_D0", "TDM_D0", "TDMA_OUT SEL" },
>>> +     { "TDM_D1", "TDM_D1", "TDMA_OUT SEL" },
>>> +     { "TDM_D2", "TDM_D2", "TDMA_OUT SEL" },
>>> +     { "TDM_D3", "TDM_D3", "TDMA_OUT SEL" },
>>> +     { "TDM_D4", "TDM_D4", "TDMA_OUT SEL" },
>>> +     { "TDM_D5", "TDM_D5", "TDMA_OUT SEL" },
>>> +     { "TDM_D6", "TDM_D6", "TDMA_OUT SEL" },
>>> +     { "TDM_D7", "TDM_D7", "TDMA_OUT SEL" },
>>> +     { "TDM_D8", "TDM_D8", "TDMA_OUT SEL" },
>>> +     { "TDM_D9", "TDM_D9", "TDMA_OUT SEL" },
>>> +     { "TDM_D10", "TDM_D10", "TDMA_OUT SEL" },
>>> +     { "TDM_D11", "TDM_D11", "TDMA_OUT SEL" },
>>> +     { "TDM_D12", "TDM_D12", "TDMA_OUT SEL" },
>>> +     { "TDM_D13", "TDM_D13", "TDMA_OUT SEL" },
>>> +     { "TDM_D14", "TDM_D14", "TDMA_OUT SEL" },
>>> +     { "TDM_D15", "TDM_D15", "TDMA_OUT SEL" },
>>> +     { "TDM_D16", "TDM_D16", "TDMA_OUT SEL" },
>>> +     { "TDM_D17", "TDM_D17", "TDMA_OUT SEL" },
>>> +     { "TDM_D18", "TDM_D18", "TDMA_OUT SEL" },
>>> +     { "TDM_D19", "TDM_D19", "TDMA_OUT SEL" },
>>> +     { "TDM_D20", "TDM_D20", "TDMA_OUT SEL" },
>>> +     { "TDM_D21", "TDM_D21", "TDMA_OUT SEL" },
>>> +     { "TDM_D22", "TDM_D22", "TDMA_OUT SEL" },
>>> +     { "TDM_D23", "TDM_D23", "TDMA_OUT SEL" },
>>> +     { "TDM_D24", "TDM_D24", "TDMA_OUT SEL" },
>>> +     { "TDM_D25", "TDM_D25", "TDMA_OUT SEL" },
>>> +     { "TDM_D26", "TDM_D26", "TDMA_OUT SEL" },
>>> +     { "TDM_D27", "TDM_D27", "TDMA_OUT SEL" },
>>> +     { "TDM_D28", "TDM_D28", "TDMA_OUT SEL" },
>>> +     { "TDM_D29", "TDM_D29", "TDMA_OUT SEL" },
>>> +     { "TDM_D30", "TDM_D30", "TDMA_OUT SEL" },
>>> +     { "TDM_D31", "TDM_D31", "TDMA_OUT SEL" },
>>> +     { "TDM_D0", "TDM_D0", "TDMB_OUT SEL" },
>>> +     { "TDM_D1", "TDM_D1", "TDMB_OUT SEL" },
>>> +     { "TDM_D2", "TDM_D2", "TDMB_OUT SEL" },
>>> +     { "TDM_D3", "TDM_D3", "TDMB_OUT SEL" },
>>> +     { "TDM_D4", "TDM_D4", "TDMB_OUT SEL" },
>>> +     { "TDM_D5", "TDM_D5", "TDMB_OUT SEL" },
>>> +     { "TDM_D6", "TDM_D6", "TDMB_OUT SEL" },
>>> +     { "TDM_D7", "TDM_D7", "TDMB_OUT SEL" },
>>> +     { "TDM_D8", "TDM_D8", "TDMB_OUT SEL" },
>>> +     { "TDM_D9", "TDM_D9", "TDMB_OUT SEL" },
>>> +     { "TDM_D10", "TDM_D10", "TDMB_OUT SEL" },
>>> +     { "TDM_D11", "TDM_D11", "TDMB_OUT SEL" },
>>> +     { "TDM_D12", "TDM_D12", "TDMB_OUT SEL" },
>>> +     { "TDM_D13", "TDM_D13", "TDMB_OUT SEL" },
>>> +     { "TDM_D14", "TDM_D14", "TDMB_OUT SEL" },
>>> +     { "TDM_D15", "TDM_D15", "TDMB_OUT SEL" },
>>> +
>>> +     { "TDM_D16", "TDM_D16", "TDMB_OUT SEL" },
>>> +     { "TDM_D17", "TDM_D17", "TDMB_OUT SEL" },
>>> +     { "TDM_D18", "TDM_D18", "TDMB_OUT SEL" },
>>> +     { "TDM_D19", "TDM_D19", "TDMB_OUT SEL" },
>>> +     { "TDM_D20", "TDM_D20", "TDMB_OUT SEL" },
>>> +     { "TDM_D21", "TDM_D21", "TDMB_OUT SEL" },
>>> +     { "TDM_D22", "TDM_D22", "TDMB_OUT SEL" },
>>> +     { "TDM_D23", "TDM_D23", "TDMB_OUT SEL" },
>>> +     { "TDM_D24", "TDM_D24", "TDMB_OUT SEL" },
>>> +     { "TDM_D25", "TDM_D25", "TDMB_OUT SEL" },
>>> +     { "TDM_D26", "TDM_D26", "TDMB_OUT SEL" },
>>> +     { "TDM_D27", "TDM_D27", "TDMB_OUT SEL" },
>>> +     { "TDM_D28", "TDM_D28", "TDMB_OUT SEL" },
>>> +     { "TDM_D29", "TDM_D29", "TDMB_OUT SEL" },
>>> +     { "TDM_D30", "TDM_D30", "TDMB_OUT SEL" },
>>> +     { "TDM_D31", "TDM_D31", "TDMB_OUT SEL" },
>>> +     { "TDM_D0", "TDM_D0", "TDMC_OUT SEL" },
>>> +     { "TDM_D1", "TDM_D1", "TDMC_OUT SEL" },
>>> +     { "TDM_D2", "TDM_D2", "TDMC_OUT SEL" },
>>> +     { "TDM_D3", "TDM_D3", "TDMC_OUT SEL" },
>>> +     { "TDM_D4", "TDM_D4", "TDMC_OUT SEL" },
>>> +     { "TDM_D5", "TDM_D5", "TDMC_OUT SEL" },
>>> +     { "TDM_D6", "TDM_D6", "TDMC_OUT SEL" },
>>> +     { "TDM_D7", "TDM_D7", "TDMC_OUT SEL" },
>>> +     { "TDM_D8", "TDM_D8", "TDMC_OUT SEL" },
>>> +     { "TDM_D9", "TDM_D9", "TDMC_OUT SEL" },
>>> +     { "TDM_D10", "TDM_D10", "TDMC_OUT SEL" },
>>> +     { "TDM_D11", "TDM_D11", "TDMC_OUT SEL" },
>>> +     { "TDM_D12", "TDM_D12", "TDMC_OUT SEL" },
>>> +     { "TDM_D13", "TDM_D13", "TDMC_OUT SEL" },
>>> +     { "TDM_D14", "TDM_D14", "TDMC_OUT SEL" },
>>> +     { "TDM_D15", "TDM_D15", "TDMC_OUT SEL" },
>>> +     { "TDM_D16", "TDM_D16", "TDMC_OUT SEL" },
>>> +     { "TDM_D17", "TDM_D17", "TDMC_OUT SEL" },
>>> +     { "TDM_D18", "TDM_D18", "TDMC_OUT SEL" },
>>> +     { "TDM_D19", "TDM_D19", "TDMC_OUT SEL" },
>>> +     { "TDM_D20", "TDM_D20", "TDMC_OUT SEL" },
>>> +     { "TDM_D21", "TDM_D21", "TDMC_OUT SEL" },
>>> +     { "TDM_D22", "TDM_D22", "TDMC_OUT SEL" },
>>> +     { "TDM_D23", "TDM_D23", "TDMC_OUT SEL" },
>>> +     { "TDM_D24", "TDM_D24", "TDMC_OUT SEL" },
>>> +     { "TDM_D25", "TDM_D25", "TDMC_OUT SEL" },
>>> +     { "TDM_D26", "TDM_D26", "TDMC_OUT SEL" },
>>> +     { "TDM_D27", "TDM_D27", "TDMC_OUT SEL" },
>>> +     { "TDM_D28", "TDM_D28", "TDMC_OUT SEL" },
>>> +     { "TDM_D29", "TDM_D29", "TDMC_OUT SEL" },
>>> +     { "TDM_D30", "TDM_D30", "TDMC_OUT SEL" },
>>> +     { "TDM_D31", "TDM_D31", "TDMC_OUT SEL" },
>>> +};
>>> +
>>> +static const struct snd_soc_component_driver 
>>> s4_tdmout_pad_component_drv = {
>>> +     .dapm_widgets           = s4_tdmout_pad_dapm_widgets,
>>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_tdmout_pad_dapm_widgets),
>>> +     .dapm_routes            = s4_tdmout_pad_dapm_routes,
>>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tdmout_pad_dapm_routes),
>>> +
>>> +};
>>> +
>>> +static const struct of_device_id s4_tdmout_pad_of_match[] = {
>>> +     {
>>> +             .compatible = "amlogic,s4-tdmout-pad",
>>> +     }, {}
>>> +};
>>> +
>>> +MODULE_DEVICE_TABLE(of, s4_tdmout_pad_of_match);
>>> +
>>> +static int tdm_pad_out_probe(struct platform_device *pdev)
>>> +{
>>> +     struct device *dev = &pdev->dev;
>>> +     struct regmap *map;
>>> +     void __iomem *regs;
>>> +
>>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>>> +     if (IS_ERR(regs))
>>> +             return PTR_ERR(regs);
>>> +
>>> +     map = devm_regmap_init_mmio(dev, regs, &tdmout_pad_regmap_cfg);
>>> +     if (IS_ERR(map))
>>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to 
>>> init regmap\n");
>>> +
>>> +     return devm_snd_soc_register_component(dev, 
>>> &s4_tdmout_pad_component_drv,
>>> +                                            NULL, 0);
>>> +}
>>> +
>>> +static struct platform_driver tdmout_pad_pdrv = {
>>> +     .probe = tdm_pad_out_probe,
>>> +     .driver = {
>>> +             .name = "s4-pad-out",
>>> +             .of_match_table = s4_tdmout_pad_of_match,
>>> +     },
>>> +};
>>> +
>>> +module_platform_driver(tdmout_pad_pdrv);
>>> +
>>> +MODULE_DESCRIPTION("Amlogic TDM PAD DRIVER");
>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>> +MODULE_LICENSE("GPL");
>>> diff --git a/sound/soc/meson/s4-tocodec-control.c 
>>> b/sound/soc/meson/s4-tocodec-control.c
>>> new file mode 100644
>>> index 
>>> 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
>>> --- /dev/null
>>> +++ b/sound/soc/meson/s4-tocodec-control.c
>> There is already a to-acodec driver a not reason has been provided as 
>> to why a
>> completly new driver is required.
>>
>> Please have look at the existing driver and do try to use it.
>> If you need to do things so differently, clear justification are 
>> necessary.
>
> for g12a-toacodec.c, we find the tocodec clock source can't get 
> the clock id from the tdm Be device,
>
> and set it by the kcontrol from user,  For different soc chips, The 
> kcontrol value maybe different, The kcontrol configuration doesn't 
> look very friendly for user
>
> so we use dapm route path to manage it, 
> fe(fddr)->be(tdm)->(tocodec)->(codec),  and use the aux-devs to 
> register,  and sound card only include the
>
> sound-dai = <&tdmif_a>
>
> codec-0 {
>                 sound-dai = <&acodec>;
>  };
>
> and not include
>
> codec-1 {
>                 sound-dai = <&toacodec>;
>  };
>
> when tdm work, only connect the tocodec path
>
>  "TDM_A Playback" ->"TOACODEC TDMA"->"TOACODEC INPUT SRC"
>
> iterate it find the be device ,and get the struct axg_tdm_stream, so 
> we can get the tdm clock id
>
> Take into account behavioral differences, we add new tocodec driver 
> for s4
>
>>> @@ -0,0 +1,376 @@
>>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>>> +/*
>>> + * Copyright (C) 2023 Amlogic, Inc. All rights reserved
>>> + */
>>> +
>>> +#include <linux/module.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/regmap.h>
>>> +#include <sound/soc.h>
>>> +#include <sound/soc-dai.h>
>>> +#include <linux/init.h>
>>> +#include <linux/kernel.h>
>>> +#include<linux/kstrtox.h>
>>> +#include <linux/clk-provider.h>
>>> +#include <linux/reset.h>
>>> +#include "axg-tdm.h"
>>> +
>>> +#define TOACODEC_CTRL0                       0x0
>>> +
>>> +#define CTRL0_ENABLE_SHIFT           31
>>> +#define CTRL0_BCLK_ENABLE_SHIFT              30
>>> +#define CTRL0_MCLK_ENABLE_SHIFT              29
>>> +#define CTRL0_BLK_CAP_INV_SHIFT              9
>>> +
>>> +#define TDM_IFACE 0
>>> +#define TDM_A_PAD 0
>>> +#define TDM_B_PAD 1
>>> +#define TDM_C_PAD 2
>>> +
>>> +struct toacodec {
>>> +     struct regmap_field *field_dat_sel;
>>> +     struct regmap_field *field_lrclk_sel;
>>> +     struct regmap_field *field_bclk_sel;
>>> +     struct regmap_field *field_mclk_sel;
>>> +};
>>> +
>>> +struct toacodec_match_data {
>>> +     const struct snd_soc_component_driver *component_drv;
>>> +     const struct reg_field field_dat_sel;
>>> +     const struct reg_field field_lrclk_sel;
>>> +     const struct reg_field field_bclk_sel;
>>> +     const struct reg_field field_mclk_sel;
>>> +};
>>> +
>>> +static const struct regmap_config tocodec_regmap_cfg = {
>>> +     .reg_bits       = 32,
>>> +     .val_bits       = 32,
>>> +     .reg_stride     = 4,
>>> +     .max_register   = 0x1,
>>> +};
>>> +
>>> +#define S4_LANE_OFFSET 8
>>> +
>>> +static const char * const s4_tocodec_lane_sel_texts[] = {
>>> +     "Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", 
>>> "Lane7"
>>> +};
>>> +
>>> +static const struct soc_enum s4_tocodec_lane_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 
>>> ARRAY_SIZE(s4_tocodec_lane_sel_texts),
>>> +                     s4_tocodec_lane_sel_texts);
>>> +
>>> +static const struct snd_kcontrol_new s4_tocodec_lane_sel =
>>> +     SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
>>> +
>>> +static const char * const s4_tocodec_src_sel_texts[] = {
>>> +     "TDMA", "TDMB", "TDMC"
>>> +};
>>> +
>>> +static const struct soc_enum s4_tocodec_src_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 
>>> ARRAY_SIZE(s4_tocodec_src_sel_texts),
>>> +                     s4_tocodec_src_sel_texts);
>>> +
>>> +static const struct snd_kcontrol_new s4_tocodec_src_sel =
>>> +     SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
>>> +
>>> +static const struct snd_kcontrol_new s4_toacodec_out_enable =
>>> +     SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
>>> +                                 CTRL0_ENABLE_SHIFT, 1, 0);
>>> +
>>> +static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct 
>>> snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dapm_path *p;
>>> +     struct snd_soc_dai *be;
>>> +
>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>> +             if (!p->connect)
>>> +                     continue;
>>> +             if (p->source->id == snd_soc_dapm_dai_in)
>>> +                     return (struct snd_soc_dai *)p->source->priv;
>>> +             be = tocodec_tdm_get_ahead_be(p->source);
>>> +             if (be && be->id == TDM_IFACE)
>>> +                     return be;
>>> +     }
>>> +     return NULL;
>>> +}
>>> +
>>> +static unsigned int aml_simple_strtoull(const char *cp)
>>> +{
>>> +     unsigned int result = 0;
>>> +     unsigned int value = 0;
>>> +     unsigned int len = strlen(cp);
>>> +
>>> +     while (len != 0) {
>>> +             len--;
>>> +             value = isdigit(*cp);
>>> +             if (value) {
>>> +                     value = *cp - '0';
>>> +             } else {
>>> +                     cp++;
>>> +                     continue;
>>> +             }
>>> +             cp++;
>>> +             result = result * 10 + value;
>>> +     }
>>> +     return result;
>>> +}
>>> +
>>> +static int aml_get_clk_id(const char *name)
>>> +{
>>> +     int clk_id = 0;
>>> +
>>> +     if (strstr(name, "mst_a"))
>>> +             clk_id = 0;
>>> +     else if (strstr(name, "mst_b"))
>>> +             clk_id = 1;
>>> +     else if (strstr(name, "mst_c"))
>>> +             clk_id = 2;
>>> +     else if (strstr(name, "mst_d"))
>>> +             clk_id = 3;
>>> +     else if (strstr(name, "mst_e"))
>>> +             clk_id = 4;
>>> +     else if (strstr(name, "mst_f"))
>>> +             clk_id = 5;
>>> +
>>> +     return clk_id;
>>> +}
>>> +
>>> +static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dai *be;
>>> +     struct axg_tdm_stream *stream;
>>> +     struct axg_tdm_iface *iface;
>>> +     struct snd_soc_component *component = 
>>> snd_soc_dapm_to_component(w->dapm);
>>> +     struct toacodec *priv = snd_soc_component_get_drvdata(component);
>>> +     unsigned int tdm_id = TDM_A_PAD;
>>> +     const char *dai_widget_name;
>>> +     struct snd_soc_dapm_path *p;
>>> +     unsigned int lane = 0;
>>> +     unsigned int val = 0;
>>> +     struct clk *sclk, *mclk;
>>> +     char *clk_name;
>>> +     int mclk_id, sclk_id;
>>> +
>>> +     be = tocodec_tdm_get_ahead_be(w);
>>> +     if (!be) {
>>> +             dev_err(component->dev, "%s not find the be\n", 
>>> __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>>> +     if (!stream) {
>>> +             dev_err(component->dev, "%s not find the stream\n", 
>>> __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     /*we like to use dai id, but it is fixed val*/
>>> +     dai_widget_name = 
>>> be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>>> +     if (strstr(dai_widget_name, "TDM_A"))
>>> +             tdm_id = TDM_A_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_B"))
>>> +             tdm_id = TDM_B_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_C"))
>>> +             tdm_id = TDM_C_PAD;
>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>> +             if (p->connect && p->name) {
>>> +                     lane = aml_simple_strtoull(p->name);
>>> +                     val = lane + tdm_id * S4_LANE_OFFSET;
>>> + regmap_field_write(priv->field_dat_sel, val);
>>> +             }
>>> +     }
>>> +     iface = stream->iface;
>>> +     mclk = iface->mclk;
>>> +     sclk = iface->sclk;
>>> +     mclk_id = aml_get_clk_id(__clk_get_name(mclk));
>>> +     sclk_id = aml_get_clk_id(__clk_get_name(sclk));
>>> +     regmap_field_write(priv->field_mclk_sel, mclk_id);
>>> +     regmap_field_write(priv->field_bclk_sel, sclk_id);
>>> +     regmap_field_write(priv->field_lrclk_sel, sclk_id);
>>> +
>>> +     return 0;
>>> +}
>>> +
>>> +static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
>>> +                          struct snd_kcontrol *control,
>>> +                          int event)
>>> +{
>>> +     struct snd_soc_component *component = 
>>> snd_soc_dapm_to_component(w->dapm);
>>> +     int ret = 0;
>>> +
>>> +     switch (event) {
>>> +     case SND_SOC_DAPM_PRE_PMU:
>>> +             ret = aml_tocodec_sel_set(w);
>>> +             break;
>>> +
>>> +     case SND_SOC_DAPM_PRE_PMD:
>>> +             break;
>>> +
>>> +     default:
>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>> +             return -EINVAL;
>>> +     }
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
>>> +                           struct snd_kcontrol *control,
>>> +                           int event)
>>> +{
>>> +     int ret = 0;
>>> +     unsigned int mask = 0, val = 0;
>>> +     struct snd_soc_component *component = 
>>> snd_soc_dapm_to_component(w->dapm);
>>> +
>>> +     snd_soc_component_update_bits(component, TOACODEC_CTRL0,
>>> +                                   1 << CTRL0_BLK_CAP_INV_SHIFT, 1 
>>> << CTRL0_BLK_CAP_INV_SHIFT);
>>> +     switch (event) {
>>> +     case SND_SOC_DAPM_PRE_PMU:
>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << 
>>> CTRL0_BCLK_ENABLE_SHIFT;
>>> +             val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << 
>>> CTRL0_BCLK_ENABLE_SHIFT;
>>> +             snd_soc_component_update_bits(component, 
>>> TOACODEC_CTRL0, mask, val);
>>> +             break;
>>> +     case SND_SOC_DAPM_PRE_PMD:
>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << 
>>> CTRL0_BCLK_ENABLE_SHIFT;
>>> +             val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << 
>>> CTRL0_BCLK_ENABLE_SHIFT;
>>> +             snd_soc_component_update_bits(component, 
>>> TOACODEC_CTRL0, mask, val);
>>> +             break;
>>> +     default:
>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>> +             return -EINVAL;
>>> +     }
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
>>> +     SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
>>> +                        &s4_tocodec_lane_sel, tocodec_sel_event,
>>> +                        (SND_SOC_DAPM_PRE_PMU | 
>>> SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, 
>>> &s4_tocodec_src_sel),
>>> +     SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
>>> +                           &s4_toacodec_out_enable, 
>>> tocodec_clk_enable,
>>> +                             (SND_SOC_DAPM_PRE_PMU | 
>>> SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
>>> +};
>>> +
>>> +static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
>>> +     { "INPUT SRC", "TDMA", "TDMA"},
>>> +     { "INPUT SRC", "TDMB", "TDMB"},
>>> +     { "INPUT SRC", "TDMC", "TDMC"},
>>> +     { "Lane0", NULL, "INPUT SRC" },
>>> +     { "Lane1", NULL, "INPUT SRC"},
>>> +     { "Lane2", NULL, "INPUT SRC"},
>>> +     { "Lane3", NULL, "INPUT SRC"},
>>> +     { "Lane4", NULL, "INPUT SRC"},
>>> +     { "Lane5", NULL, "INPUT SRC"},
>>> +     { "Lane6", NULL, "INPUT SRC"},
>>> +     { "Lane7", NULL, "INPUT SRC"},
>>> +     { "Lane SRC", "Lane0", "Lane0"},
>>> +     { "Lane SRC", "Lane1", "Lane1"},
>>> +     { "Lane SRC", "Lane2", "Lane2"},
>>> +     { "Lane SRC", "Lane3", "Lane3"},
>>> +     { "Lane SRC", "Lane4", "Lane4"},
>>> +     { "Lane SRC", "Lane5", "Lane5"},
>>> +     { "Lane SRC", "Lane6", "Lane6"},
>>> +     { "Lane SRC", "Lane7", "Lane7"},
>>> +     { "OUT EN", "Switch", "Lane SRC"},
>>> +     { "TDM_TO_ACODEC", NULL, "OUT EN"},
>>> +
>>> +};
>>> +
>>> +static const struct snd_soc_component_driver 
>>> s4_tocodec_component_drv = {
>>> +     .dapm_widgets           = s4_toacodec_widgets,
>>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_toacodec_widgets),
>>> +     .dapm_routes            = s4_tocodec_dapm_routes,
>>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tocodec_dapm_routes),
>>> +};
>>> +
>>> +static const struct toacodec_match_data s4_toacodec_match_data = {
>>> +     .component_drv  = &s4_tocodec_component_drv,
>>> +     .field_dat_sel  = REG_FIELD(TOACODEC_CTRL0, 16, 20),
>>> +     .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
>>> +     .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
>>> +     .field_mclk_sel = REG_FIELD(TOACODEC_CTRL0, 0, 2),
>>> +};
>>> +
>>> +static const struct of_device_id s4_tocodec_of_match[] = {
>>> +     {
>>> +             .compatible = "amlogic,s4-tocodec",
>>> +             .data = &s4_toacodec_match_data,
>>> +     }, {}
>>> +};
>>> +
>>> +MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
>>> +
>>> +static int tocodec_probe(struct platform_device *pdev)
>>> +{
>>> +     const struct toacodec_match_data *data;
>>> +     struct device *dev = &pdev->dev;
>>> +     struct toacodec *priv;
>>> +     void __iomem *regs;
>>> +     struct regmap *map;
>>> +     int ret;
>>> +
>>> +     data = device_get_match_data(dev);
>>> +     if (!data)
>>> +             return dev_err_probe(dev, -ENODEV, "failed to match 
>>> device\n");
>>> +     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>>> +     if (!priv)
>>> +             return -ENOMEM;
>>> +
>>> +     platform_set_drvdata(pdev, priv);
>>> +
>>> +     ret = device_reset(dev);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>>> +     if (IS_ERR(regs))
>>> +             return PTR_ERR(regs);
>>> +
>>> +     map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
>>> +     if (IS_ERR(map))
>>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to 
>>> init regmap\n");
>>> +
>>> +     priv->field_dat_sel = devm_regmap_field_alloc(dev, map, 
>>> data->field_dat_sel);
>>> +     if (IS_ERR(priv->field_dat_sel))
>>> +             return PTR_ERR(priv->field_dat_sel);
>>> +
>>> +     priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, 
>>> data->field_lrclk_sel);
>>> +     if (IS_ERR(priv->field_lrclk_sel))
>>> +             return PTR_ERR(priv->field_lrclk_sel);
>>> +
>>> +     priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, 
>>> data->field_bclk_sel);
>>> +     if (IS_ERR(priv->field_bclk_sel))
>>> +             return PTR_ERR(priv->field_bclk_sel);
>>> +
>>> +     priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, 
>>> data->field_mclk_sel);
>>> +     if (IS_ERR(priv->field_mclk_sel))
>>> +             return PTR_ERR(priv->field_mclk_sel);
>>> +
>>> +     return devm_snd_soc_register_component(dev,
>>> +                     data->component_drv, NULL, 0);
>>> +}
>>> +
>>> +static struct platform_driver tocodec_pdrv = {
>>> +     .probe = tocodec_probe,
>>> +     .driver = {
>>> +             .name = "s4-tocodec",
>>> +             .of_match_table = s4_tocodec_of_match,
>>> +     },
>>> +};
>>> +
>>> +module_platform_driver(tocodec_pdrv);
>>> +
>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>> +MODULE_LICENSE("GPL");
>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>> index 
>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 
>>> 100644
>>> --- a/sound/soc/meson/t9015.c
>>> +++ b/sound/soc/meson/t9015.c
>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>                .channels_min = 1,
>>>                .channels_max = 2,
>>>                .rates = SNDRV_PCM_RATE_8000_96000,
>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE | 
>>> SNDRV_PCM_FMTBIT_S32_LE),
>> Again, mixed up changes with zero justification.
>>
>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>> which is known to work and add S32 support on an HW documented as 24bits
>> only. Can you explain ?

for g12a, sm1 etc, it is use new audio ip, GXL is old ip, the new ip not 
support 24 bit,

usually support 16/32 bit for new audio ip , for 
SNDRV_PCM_FMTBIT_S24_LE, it width =24, phy =32

it was  treated as 32 bit to send for tdm, so we can only add the S32LE 
base on it , right ? but if the gxl not support the 32bit

we need add new snd_soc_dai_driver t9015_dai_s4 ?

>>
>>>        },
>>>        .ops = &t9015_dai_ops,
>>>   };
>> -- 
>> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-14  8:16     ` Jiebing Chen
  2025-01-14 11:20       ` Jiebing Chen
@ 2025-01-14 11:29       ` Jerome Brunet
  2025-01-14 12:41         ` Jiebing Chen
  1 sibling, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-14 11:29 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Tue 14 Jan 2025 at 16:16, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

>>> +static const char * const s4_tdmout_sel_texts[] = {
>>> +     "TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", "TDM_D6", "TDM_D7",
>>> +     "TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", "TDM_D13", "TDM_D14", "TDM_D15",
>>> +     "TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", "TDM_D21", "TDM_D22", "TDM_D23",
>>> +     "TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", "TDM_D29", "TDM_D30", "TDM_D31"
>>> +};
>> This thing does not belong in ASoC. This is clearly yet another layer of
>> pinctrl. Please deal with it there.
>
> Thanks for your suggestion, add audio pinctrl driver to control the which tdm_dx pin can map the which tdm lane_x
> for example
> 	tdm_d6_pin {
> 		mux {
> 			groups = "tdm_d6";
> 			function = "tdmoutb_lane0";
> 		};
> 	}
> tdm_d6 pin map the tdmoutb lane 0, right ?

possibly

>
>>> +
>>> +static const struct soc_enum tdmout_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
>>> +                     s4_tdmout_sel_texts);
>>> +

[...]

>>> diff --git a/sound/soc/meson/s4-tocodec-control.c b/sound/soc/meson/s4-tocodec-control.c
>>> new file mode 100644
>>> index 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
>>> --- /dev/null
>>> +++ b/sound/soc/meson/s4-tocodec-control.c
>> There is already a to-acodec driver a not reason has been provided as to why a
>> completly new driver is required.
>>
>> Please have look at the existing driver and do try to use it.
>> If you need to do things so differently, clear justification are necessary.
>
> for g12a-toacodec.c, we find the tocodec clock source can't get the clock
> id from the tdm Be device,

This is clearly documented limitation of the current to-acodec driver:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/meson/g12a-toacodec.c?h=v6.13-rc7#n91

While it is a limitation, it is a manageable one considering the amount
of master clocks available and the fact the master should be manually
assinged to the output pad, which you did not do.

See the u200:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts?h=v6.13-rc7#n569

You are more than welcome to help fix this limitation in the current
driver but just adding a fork is not OK

I would suggest to start with what is currently available and move on to
fixing this as a 2nd step, if you want to.

>
> and set it by the kcontrol from user,  For different soc chips, The
> kcontrol value maybe different, The kcontrol configuration doesn't look
> very friendly for user
>
> so we use dapm route path to manage it,
> fe(fddr)->be(tdm)->(tocodec)->(codec),  and use the aux-devs to register, 
> and sound card only include the
>
> sound-dai = <&tdmif_a>
>
> codec-0 {
>                 sound-dai = <&acodec>;
>  };
>
> and not include
>
> codec-1 {
>                 sound-dai = <&toacodec>;
>  };
>
> when tdm work, only connect the tocodec path
>
>  "TDM_A Playback" ->"TOACODEC TDMA"->"TOACODEC INPUT SRC"
>
> iterate it find the be device ,and get the struct axg_tdm_stream, so we can
> get the tdm clock id
>
> Take into account behavioral differences, we add new tocodec driver
> for s4

Still not seeing sufficient reason to make another driver.

>
>>> @@ -0,0 +1,376 @@
>>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>>> +/*
>>> + * Copyright (C) 2023 Amlogic, Inc. All rights reserved
>>> + */
>>> +
>>> +#include <linux/module.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/regmap.h>
>>> +#include <sound/soc.h>
>>> +#include <sound/soc-dai.h>
>>> +#include <linux/init.h>
>>> +#include <linux/kernel.h>
>>> +#include<linux/kstrtox.h>
>>> +#include <linux/clk-provider.h>
>>> +#include <linux/reset.h>
>>> +#include "axg-tdm.h"
>>> +
>>> +#define TOACODEC_CTRL0                       0x0
>>> +
>>> +#define CTRL0_ENABLE_SHIFT           31
>>> +#define CTRL0_BCLK_ENABLE_SHIFT              30
>>> +#define CTRL0_MCLK_ENABLE_SHIFT              29
>>> +#define CTRL0_BLK_CAP_INV_SHIFT              9
>>> +
>>> +#define TDM_IFACE 0
>>> +#define TDM_A_PAD 0
>>> +#define TDM_B_PAD 1
>>> +#define TDM_C_PAD 2
>>> +
>>> +struct toacodec {
>>> +     struct regmap_field *field_dat_sel;
>>> +     struct regmap_field *field_lrclk_sel;
>>> +     struct regmap_field *field_bclk_sel;
>>> +     struct regmap_field *field_mclk_sel;
>>> +};
>>> +
>>> +struct toacodec_match_data {
>>> +     const struct snd_soc_component_driver *component_drv;
>>> +     const struct reg_field field_dat_sel;
>>> +     const struct reg_field field_lrclk_sel;
>>> +     const struct reg_field field_bclk_sel;
>>> +     const struct reg_field field_mclk_sel;
>>> +};
>>> +
>>> +static const struct regmap_config tocodec_regmap_cfg = {
>>> +     .reg_bits       = 32,
>>> +     .val_bits       = 32,
>>> +     .reg_stride     = 4,
>>> +     .max_register   = 0x1,
>>> +};
>>> +
>>> +#define S4_LANE_OFFSET 8
>>> +
>>> +static const char * const s4_tocodec_lane_sel_texts[] = {
>>> +     "Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", "Lane7"
>>> +};
>>> +
>>> +static const struct soc_enum s4_tocodec_lane_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_lane_sel_texts),
>>> +                     s4_tocodec_lane_sel_texts);
>>> +
>>> +static const struct snd_kcontrol_new s4_tocodec_lane_sel =
>>> +     SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
>>> +
>>> +static const char * const s4_tocodec_src_sel_texts[] = {
>>> +     "TDMA", "TDMB", "TDMC"
>>> +};
>>> +
>>> +static const struct soc_enum s4_tocodec_src_sel_enum =
>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_src_sel_texts),
>>> +                     s4_tocodec_src_sel_texts);
>>> +
>>> +static const struct snd_kcontrol_new s4_tocodec_src_sel =
>>> +     SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
>>> +
>>> +static const struct snd_kcontrol_new s4_toacodec_out_enable =
>>> +     SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
>>> +                                 CTRL0_ENABLE_SHIFT, 1, 0);
>>> +
>>> +static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dapm_path *p;
>>> +     struct snd_soc_dai *be;
>>> +
>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>> +             if (!p->connect)
>>> +                     continue;
>>> +             if (p->source->id == snd_soc_dapm_dai_in)
>>> +                     return (struct snd_soc_dai *)p->source->priv;
>>> +             be = tocodec_tdm_get_ahead_be(p->source);
>>> +             if (be && be->id == TDM_IFACE)
>>> +                     return be;
>>> +     }
>>> +     return NULL;
>>> +}
>>> +
>>> +static unsigned int aml_simple_strtoull(const char *cp)
>>> +{
>>> +     unsigned int result = 0;
>>> +     unsigned int value = 0;
>>> +     unsigned int len = strlen(cp);
>>> +
>>> +     while (len != 0) {
>>> +             len--;
>>> +             value = isdigit(*cp);
>>> +             if (value) {
>>> +                     value = *cp - '0';
>>> +             } else {
>>> +                     cp++;
>>> +                     continue;
>>> +             }
>>> +             cp++;
>>> +             result = result * 10 + value;
>>> +     }
>>> +     return result;
>>> +}
>>> +
>>> +static int aml_get_clk_id(const char *name)
>>> +{
>>> +     int clk_id = 0;
>>> +
>>> +     if (strstr(name, "mst_a"))
>>> +             clk_id = 0;
>>> +     else if (strstr(name, "mst_b"))
>>> +             clk_id = 1;
>>> +     else if (strstr(name, "mst_c"))
>>> +             clk_id = 2;
>>> +     else if (strstr(name, "mst_d"))
>>> +             clk_id = 3;
>>> +     else if (strstr(name, "mst_e"))
>>> +             clk_id = 4;
>>> +     else if (strstr(name, "mst_f"))
>>> +             clk_id = 5;
>>> +
>>> +     return clk_id;
>>> +}
>>> +
>>> +static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
>>> +{
>>> +     struct snd_soc_dai *be;
>>> +     struct axg_tdm_stream *stream;
>>> +     struct axg_tdm_iface *iface;
>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>> +     struct toacodec *priv = snd_soc_component_get_drvdata(component);
>>> +     unsigned int tdm_id = TDM_A_PAD;
>>> +     const char *dai_widget_name;
>>> +     struct snd_soc_dapm_path *p;
>>> +     unsigned int lane = 0;
>>> +     unsigned int val = 0;
>>> +     struct clk *sclk, *mclk;
>>> +     char *clk_name;
>>> +     int mclk_id, sclk_id;
>>> +
>>> +     be = tocodec_tdm_get_ahead_be(w);
>>> +     if (!be) {
>>> +             dev_err(component->dev, "%s not find the be\n", __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>>> +     if (!stream) {
>>> +             dev_err(component->dev, "%s not find the stream\n", __func__);
>>> +             return -EINVAL;
>>> +     }
>>> +     /*we like to use dai id, but it is fixed val*/
>>> +     dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>>> +     if (strstr(dai_widget_name, "TDM_A"))
>>> +             tdm_id = TDM_A_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_B"))
>>> +             tdm_id = TDM_B_PAD;
>>> +     else if (strstr(dai_widget_name, "TDM_C"))
>>> +             tdm_id = TDM_C_PAD;
>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>> +             if (p->connect && p->name) {
>>> +                     lane = aml_simple_strtoull(p->name);
>>> +                     val = lane + tdm_id * S4_LANE_OFFSET;
>>> +                     regmap_field_write(priv->field_dat_sel, val);
>>> +             }
>>> +     }
>>> +     iface = stream->iface;
>>> +     mclk = iface->mclk;
>>> +     sclk = iface->sclk;
>>> +     mclk_id = aml_get_clk_id(__clk_get_name(mclk));
>>> +     sclk_id = aml_get_clk_id(__clk_get_name(sclk));
>>> +     regmap_field_write(priv->field_mclk_sel, mclk_id);
>>> +     regmap_field_write(priv->field_bclk_sel, sclk_id);
>>> +     regmap_field_write(priv->field_lrclk_sel, sclk_id);
>>> +
>>> +     return 0;
>>> +}
>>> +
>>> +static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
>>> +                          struct snd_kcontrol *control,
>>> +                          int event)
>>> +{
>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>> +     int ret = 0;
>>> +
>>> +     switch (event) {
>>> +     case SND_SOC_DAPM_PRE_PMU:
>>> +             ret = aml_tocodec_sel_set(w);
>>> +             break;
>>> +
>>> +     case SND_SOC_DAPM_PRE_PMD:
>>> +             break;
>>> +
>>> +     default:
>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>> +             return -EINVAL;
>>> +     }
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
>>> +                           struct snd_kcontrol *control,
>>> +                           int event)
>>> +{
>>> +     int ret = 0;
>>> +     unsigned int mask = 0, val = 0;
>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>> +
>>> +     snd_soc_component_update_bits(component, TOACODEC_CTRL0,
>>> +                                   1 << CTRL0_BLK_CAP_INV_SHIFT, 1 << CTRL0_BLK_CAP_INV_SHIFT);
>>> +     switch (event) {
>>> +     case SND_SOC_DAPM_PRE_PMU:
>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>> +             val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>>> +             break;
>>> +     case SND_SOC_DAPM_PRE_PMD:
>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>> +             val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << CTRL0_BCLK_ENABLE_SHIFT;
>>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>>> +             break;
>>> +     default:
>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>> +             return -EINVAL;
>>> +     }
>>> +
>>> +     return ret;
>>> +}
>>> +
>>> +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
>>> +     SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
>>> +                        &s4_tocodec_lane_sel, tocodec_sel_event,
>>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, &s4_tocodec_src_sel),
>>> +     SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
>>> +                           &s4_toacodec_out_enable, tocodec_clk_enable,
>>> +                             (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>>> +     SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
>>> +     SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
>>> +};
>>> +
>>> +static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
>>> +     { "INPUT SRC", "TDMA", "TDMA"},
>>> +     { "INPUT SRC", "TDMB", "TDMB"},
>>> +     { "INPUT SRC", "TDMC", "TDMC"},
>>> +     { "Lane0", NULL, "INPUT SRC" },
>>> +     { "Lane1", NULL, "INPUT SRC"},
>>> +     { "Lane2", NULL, "INPUT SRC"},
>>> +     { "Lane3", NULL, "INPUT SRC"},
>>> +     { "Lane4", NULL, "INPUT SRC"},
>>> +     { "Lane5", NULL, "INPUT SRC"},
>>> +     { "Lane6", NULL, "INPUT SRC"},
>>> +     { "Lane7", NULL, "INPUT SRC"},
>>> +     { "Lane SRC", "Lane0", "Lane0"},
>>> +     { "Lane SRC", "Lane1", "Lane1"},
>>> +     { "Lane SRC", "Lane2", "Lane2"},
>>> +     { "Lane SRC", "Lane3", "Lane3"},
>>> +     { "Lane SRC", "Lane4", "Lane4"},
>>> +     { "Lane SRC", "Lane5", "Lane5"},
>>> +     { "Lane SRC", "Lane6", "Lane6"},
>>> +     { "Lane SRC", "Lane7", "Lane7"},
>>> +     { "OUT EN", "Switch", "Lane SRC"},
>>> +     { "TDM_TO_ACODEC", NULL, "OUT EN"},
>>> +
>>> +};
>>> +
>>> +static const struct snd_soc_component_driver s4_tocodec_component_drv = {
>>> +     .dapm_widgets           = s4_toacodec_widgets,
>>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_toacodec_widgets),
>>> +     .dapm_routes            = s4_tocodec_dapm_routes,
>>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tocodec_dapm_routes),
>>> +};
>>> +
>>> +static const struct toacodec_match_data s4_toacodec_match_data = {
>>> +     .component_drv  = &s4_tocodec_component_drv,
>>> +     .field_dat_sel  = REG_FIELD(TOACODEC_CTRL0, 16, 20),
>>> +     .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
>>> +     .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
>>> +     .field_mclk_sel = REG_FIELD(TOACODEC_CTRL0, 0, 2),
>>> +};
>>> +
>>> +static const struct of_device_id s4_tocodec_of_match[] = {
>>> +     {
>>> +             .compatible = "amlogic,s4-tocodec",
>>> +             .data = &s4_toacodec_match_data,
>>> +     }, {}
>>> +};
>>> +
>>> +MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
>>> +
>>> +static int tocodec_probe(struct platform_device *pdev)
>>> +{
>>> +     const struct toacodec_match_data *data;
>>> +     struct device *dev = &pdev->dev;
>>> +     struct toacodec *priv;
>>> +     void __iomem *regs;
>>> +     struct regmap *map;
>>> +     int ret;
>>> +
>>> +     data = device_get_match_data(dev);
>>> +     if (!data)
>>> +             return dev_err_probe(dev, -ENODEV, "failed to match device\n");
>>> +     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>>> +     if (!priv)
>>> +             return -ENOMEM;
>>> +
>>> +     platform_set_drvdata(pdev, priv);
>>> +
>>> +     ret = device_reset(dev);
>>> +     if (ret)
>>> +             return ret;
>>> +
>>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>>> +     if (IS_ERR(regs))
>>> +             return PTR_ERR(regs);
>>> +
>>> +     map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
>>> +     if (IS_ERR(map))
>>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
>>> +
>>> +     priv->field_dat_sel = devm_regmap_field_alloc(dev, map, data->field_dat_sel);
>>> +     if (IS_ERR(priv->field_dat_sel))
>>> +             return PTR_ERR(priv->field_dat_sel);
>>> +
>>> +     priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, data->field_lrclk_sel);
>>> +     if (IS_ERR(priv->field_lrclk_sel))
>>> +             return PTR_ERR(priv->field_lrclk_sel);
>>> +
>>> +     priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, data->field_bclk_sel);
>>> +     if (IS_ERR(priv->field_bclk_sel))
>>> +             return PTR_ERR(priv->field_bclk_sel);
>>> +
>>> +     priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, data->field_mclk_sel);
>>> +     if (IS_ERR(priv->field_mclk_sel))
>>> +             return PTR_ERR(priv->field_mclk_sel);
>>> +
>>> +     return devm_snd_soc_register_component(dev,
>>> +                     data->component_drv, NULL, 0);
>>> +}
>>> +
>>> +static struct platform_driver tocodec_pdrv = {
>>> +     .probe = tocodec_probe,
>>> +     .driver = {
>>> +             .name = "s4-tocodec",
>>> +             .of_match_table = s4_tocodec_of_match,
>>> +     },
>>> +};
>>> +
>>> +module_platform_driver(tocodec_pdrv);
>>> +
>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>> +MODULE_LICENSE("GPL");
>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>> index 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 100644
>>> --- a/sound/soc/meson/t9015.c
>>> +++ b/sound/soc/meson/t9015.c
>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>                .channels_min = 1,
>>>                .channels_max = 2,
>>>                .rates = SNDRV_PCM_RATE_8000_96000,
>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE),
>> Again, mixed up changes with zero justification.
>>
>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>> which is known to work and add S32 support on an HW documented as 24bits
>> only. Can you explain ?
>>
>>>        },
>>>        .ops = &t9015_dai_ops,
>>>   };
>> --
>> Jerome

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-14 11:16       ` Jerome Brunet
@ 2025-01-14 12:34         ` Jiebing Chen
  2025-01-14 14:15           ` Jerome Brunet
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-14 12:34 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/14 19:16, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>> [ EXTERNAL EMAIL ]
>>>
>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>
>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>
>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>> AQ222 board.
>>>>
>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>> ---
>>>>    .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>>>>    arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>>>>    2 files changed, 610 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>                regulator-always-on;
>>>>         };
>>>>
>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>> +             compatible = "regulator-fixed";
>>>> +             vin-supply = <&main_12v>;
>>>> +             regulator-name = "VCC5V";
>>>> +             regulator-min-microvolt = <5000000>;
>>>> +             regulator-max-microvolt = <5000000>;
>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>> +             startup-delay-us = <7000>;
>>>> +             enable-active-high;
>>>> +             regulator-boot-on;
>>>> +             regulator-always-on;
>>>> +     };
>>>> +
>>>>         /* SY8120B1ABC DC/DC Regulator. */
>>>>         vddcpu: regulator-vddcpu {
>>>>                 compatible = "pwm-regulator";
>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>                                 <699000 98>,
>>>>                                 <689000 100>;
>>>>         };
>>>> +     dmics: audio-codec-1 {
>>>> +             compatible = "dmic-codec";
>>>> +             #sound-dai-cells = <0>;
>>>> +             num-channels = <2>;
>>>> +             wakeup-delay-ms = <50>;
>>>> +             sound-name-prefix = "MIC";
>>>> +     };
>>>> +
>>>> +     dioo2133: audio-amplifier-0 {
>>>> +             compatible = "simple-audio-amplifier";
>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>> +             VCC-supply = <&vcc5v_reg>;
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "10U2";
>>>> +     };
>>>> +
>>>> +     spdif_dir: audio-spdif-in {
>>>> +             compatible = "linux,spdif-dir";
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "DIR";
>>>> +     };
>>>> +
>>>> +     spdif_dit: audio-spdif-out {
>>>> +             compatible = "linux,spdif-dit";
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "DIT";
>>>> +     };
>>>> +
>>>> +     sound {
>>>> +             compatible = "amlogic,axg-sound-card";
>>>> +             model = "aq222";
>>>> +             audio-widgets = "Line", "Lineout";
>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>> +                              <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>> +                             "10U2 INR", "ACODEC LORP",
>>>> +                             "Lineout", "10U2 OUTL",
>>>> +                             "Lineout", "10U2 OUTR";
>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>> +             assigned-clock-rates = <491520000>,
>>>> +                                    <294912000>,
>>>> +                                    <270950400>,
>>>> +                                    <393216000>;
>>> Why do you need 4 base rates ? Which rate family does each provide ?
>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000, the
>> accuracy of hifipll
>>
>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if the
>> tdm and spdif work on
> It is fine to use the HiFi. I'm glad this clock finally got fixed
>
>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the same
>> pll, so spdif need use the mpll 0
>>
>> other pll , only set a default value, at the latest chip, we remove all
>> mpll for hardware, only two hifipll
> I'm not sure you understand how this works.
> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>
> Each family needs a PLL assigned, so you need 3, not 4, unless there is
> another specific rate family you want to support. If that's the case,
> document it.
>
> Setting the rate of the PLL should follow this principle:
> * Family rate
>    - multiplied by (32 x 24): to accomodate different sample sizes
>    - multiplied by 2 until you reach the maximum rate of selected PLLs
>      This allows to support rates such 192k or even 768k
>
> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
> poor choice.
>
> Have a look at the s400 for an example using the HiFi PLL. The axg was
> restricted to a 68 PLL multiplier but the S4 is not so you should be
> able to use a higher base rate (4 718 592 000 Hz), providing better
> accuracy in the end

for new soc audio ip, the hardware will not support the 24bit(include 
g12a, sm1,axg)

SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory

>>>> +
>>>> +             dai-link-0 {
>>>> +                     sound-dai = <&frddr_a>;
>>>> +             };
>>>> +
>>>> +             dai-link-1 {
>>>> +                     sound-dai = <&frddr_b>;
>>>> +             };
>>>> +
>>>> +             dai-link-2 {
>>>> +                     sound-dai = <&frddr_c>;
>>>> +             };
>>>> +
>>>> +             dai-link-3 {
>>>> +                     sound-dai = <&toddr_a>;
>>>> +             };
>>>> +
>>>> +             dai-link-4 {
>>>> +                     sound-dai = <&toddr_b>;
>>>> +             };
>>>> +
>>>> +             dai-link-5 {
>>>> +                     sound-dai = <&toddr_c>;
>>>> +             };
>>>> +
>>>> +             /* Connected to the WIFI/BT chip */
>>>> +             dai-link-6 {
>>>> +                     sound-dai = <&tdmif_a>;
>>>> +                     dai-format = "dsp_a";
>>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>>> +                     mclk-fs = <256>;
>>>> +                     codec-0 {
>>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_A>;
>>>> +                     };
>>>> +             };
>>>> +
>>>> +             /* Connected to the onboard AD82584F DAC */
>>>> +             dai-link-7 {
>>>> +                     sound-dai = <&tdmif_b>;
>>>> +                     dai-format = "i2s";
>>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>>> +                     mclk-fs = <256>;
>>>> +
>>>> +                     codec-0 {
>>>> +                             sound-dai = <&acodec>;
>>>> +                     };
>>>> +
>>>> +                     codec-1 {
>>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
>>>> +                     };
>>>> +             };
>>>> +
>>>> +             /* 8ch HDMI interface */
>>>> +             dai-link-8 {
>>>> +                     sound-dai = <&tdmif_c>;
>>>> +                     dai-format = "i2s";
>>>> +                     dai-tdm-slot-tx-mask-0 = <1 1>;
>>>> +                     dai-tdm-slot-tx-mask-1 = <1 1>;
>>>> +                     dai-tdm-slot-tx-mask-2 = <1 1>;
>>>> +                     dai-tdm-slot-tx-mask-3 = <1 1>;
>>>> +                     mclk-fs = <256>;
>>>> +
>>>> +                     codec-0 {
>>>> +                             sound-dai = <&acodec>;
>>>> +                     };
>>>> +
>>>> +                     codec-1 {
>>>> +                             sound-dai = <&tohdmitx TOHDMITX_I2S_IN_C>;
>>>> +                     };
>>>> +             };
>>>> +
>>>> +             /* spdif hdmi and coax output */
>>>> +             dai-link-9 {
>>>> +                     sound-dai = <&spdifout_a>;
>>>> +
>>>> +                     codec-0 {
>>>> +                             sound-dai = <&spdif_dit>;
>>>> +                     };
>>>> +
>>>> +                     codec-1 {
>>>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_A>;
>>>> +                     };
>>>> +             };
>>>> +
>>>> +             /* spdif hdmi interface */
>>>> +             dai-link-10 {
>>>> +                     sound-dai = <&spdifout_b>;
>>>> +
>>>> +                     codec {
>>>> +                             sound-dai = <&tohdmitx TOHDMITX_SPDIF_IN_B>;
>>>> +                     };
>>>> +             };
>>>> +
>>>> +             /* spdif coax input */
>>>> +             dai-link-11 {
>>>> +                     sound-dai = <&spdifin>;
>>>> +
>>>> +                     codec {
>>>> +                             sound-dai = <&spdif_dir>;
>>>> +                     };
>>>> +             };
>>>> +     };
>>>> +
>>>>    };
>>>>
>>>>    &pwm_ef {
>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>>> index 957577d986c0675a503115e1ccbc4387c2051620..87a00ace23131e31822bb43fbe956b8abcbaef40 100644
>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi
>>>> @@ -11,7 +11,11 @@
>>>>    #include <dt-bindings/clock/amlogic,s4-peripherals-clkc.h>
>>>>    #include <dt-bindings/power/meson-s4-power.h>
>>>>    #include <dt-bindings/reset/amlogic,meson-s4-reset.h>
>>>> -
>>>> +#include <dt-bindings/clock/axg-audio-clkc.h>
>>>> +#include <dt-bindings/reset/amlogic,meson-axg-audio-arb.h>
>>>> +#include <dt-bindings/reset/amlogic,meson-g12a-audio-reset.h>
>>>> +#include <dt-bindings/sound/meson-g12a-toacodec.h>
>>>> +#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
>>>>    / {
>>>>         cpus {
>>>>                 #address-cells = <2>;
>>>> @@ -46,6 +50,42 @@ cpu3: cpu@3 {
>>>>                 };
>>>>         };
>>>>
>>>> +     tdmif_a: audio-controller-0 {
>>>> +             compatible = "amlogic,axg-tdm-iface";
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "TDM_A";
>>>> +             clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_A_SCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
>>>> +             clock-names = "mclk", "sclk", "lrclk";
>>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK_SEL>;
>>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>>> Based on clock provider used, I doubt this is of any use.
>> if not set the mclk parent. we dump clk_summary, the default parent is mpll
>> 0
>>
>> we tend  to use hifipll
> Have you really tested this ? Master clocks do reparent to the appropriate PLL
> depending on the rate required, this is how it has always worked.

you are right, when boot up kernel, it is default, but when aplay

it auto switch the hifipll, it is a good skill, thanks

>>>> +     };
>>>> +
>>>> +     tdmif_b: audio-controller-1 {
>>>> +             compatible = "amlogic,axg-tdm-iface";
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "TDM_B";
>>>> +             clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_B_SCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_B_LRCLK>;
>>>> +             clock-names = "mclk", "sclk", "lrclk";
>>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_B_MCLK_SEL>;
>>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>>>> +     };
>>>> +
>>>> +     tdmif_c: audio-controller-2 {
>>>> +             compatible = "amlogic,axg-tdm-iface";
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "TDM_C";
>>>> +             clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_C_SCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_MST_C_LRCLK>;
>>>> +             clock-names = "mclk", "sclk", "lrclk";
>>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_MST_C_MCLK_SEL>;
>>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>;
>>>> +     };
>>>> +
>>>>         timer {
>>>>                 compatible = "arm,armv8-timer";
>>>>                 interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
>>>> @@ -850,3 +890,346 @@ emmc: mmc@fe08c000 {
>>>>                 };
>>>>         };
>>>>    };
>>>> +
>>>> +&apb4 {
>>>> +     audio: bus@330000 {
>>>> +             compatible = "simple-bus";
>>>> +             reg = <0x0 0x330000 0x0 0x1000>;
>>>> +             #address-cells = <2>;
>>>> +             #size-cells = <2>;
>>>> +             ranges = <0x0 0x0 0x0 0x330000 0x0 0x1000>;
>>>> +
>>>> +             clkc_audio: clock-controller@0 {
>>>> +                     compatible = "amlogic,sm1-audio-clkc";
>>> I suspect the DT folks would like having SoC specific compatible in
>>> addition to the fall back. In that case, I think that would be wise. I
>>> doubt the compatibility will hold in the long run.
>>>
>>> Same goes for the other HW components.
>> you are right, for s4 , some clock is different, we will add the
>> "amlogic,s4-audio-clkc"
>>
>> this is a base clk for tdm
>>
>>>> +                     reg = <0x0 0x0 0x0 0xb4>;
>>>> +                     #clock-cells = <1>;
>>>> +                     #reset-cells = <1>;
>>>> +                     power-domains = <&pwrc PWRC_S4_AUDIO_ID>;
>>>> +                     clocks = <&clkc_periphs CLKID_AUDIO>,
>>>> +                              <&clkc_pll CLKID_MPLL0>,
>>>> +                              <&clkc_pll CLKID_MPLL1>,
>>>> +                              <&clkc_pll CLKID_MPLL2>,
>>>> +                              <&clkc_pll CLKID_MPLL3>,
>>>> +                              <&clkc_pll CLKID_HIFI_PLL>,
>>>> +                              <&clkc_pll CLKID_FCLK_DIV3>,
>>>> +                              <&clkc_pll CLKID_FCLK_DIV4>,
>>>> +                              <&clkc_pll CLKID_FCLK_DIV5>;
>>>> +                     clock-names = "pclk",
>>>> +                                   "mst_in0",
>>>> +                                   "mst_in1",
>>>> +                                   "mst_in2",
>>>> +                                   "mst_in3",
>>>> +                                   "mst_in4",
>>>> +                                   "mst_in5",
>>>> +                                   "mst_in6",
>>>> +                                   "mst_in7";
>>>> +
>>>> +                     resets = <&reset RESET_AUDIO>;
>>>> +             };
>>>> +
>>>> +             toddr_a: audio-controller@100 {
>>>> +                     compatible = "amlogic,sm1-toddr",
>>>> +                                  "amlogic,axg-toddr";
>>>> +                     reg = <0x0 0x100 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "TODDR_A";
>>>> +                     interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_A>;
>>>> +                     resets = <&arb AXG_ARB_TODDR_A>,
>>>> +                              <&clkc_audio AUD_RESET_TODDR_A>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <8192>;
>>>> +             };
>>>> +
>>>> +             toddr_b: audio-controller@140 {
>>>> +                     compatible = "amlogic,sm1-toddr",
>>>> +                                  "amlogic,axg-toddr";
>>>> +                     reg = <0x0 0x140 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "TODDR_B";
>>>> +                     interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_B>;
>>>> +                     resets = <&arb AXG_ARB_TODDR_B>,
>>>> +                              <&clkc_audio AUD_RESET_TODDR_B>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             toddr_c: audio-controller@180 {
>>>> +                     compatible = "amlogic,sm1-toddr",
>>>> +                                  "amlogic,axg-toddr";
>>>> +                     reg = <0x0 0x180 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "TODDR_C";
>>>> +                     interrupts = <GIC_SPI 34 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_C>;
>>>> +                     resets = <&arb AXG_ARB_TODDR_C>,
>>>> +                              <&clkc_audio AUD_RESET_TODDR_C>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             frddr_a: audio-controller@1c0 {
>>>> +                     compatible = "amlogic,sm1-frddr",
>>>> +                                  "amlogic,axg-frddr";
>>>> +                     reg = <0x0 0x1c0 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "FRDDR_A";
>>>> +                     interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
>>>> +                     resets = <&arb AXG_ARB_FRDDR_A>,
>>>> +                              <&clkc_audio AUD_RESET_FRDDR_A>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <512>;
>>>> +             };
>>>> +
>>>> +             frddr_b: audio-controller@200 {
>>>> +                     compatible = "amlogic,sm1-frddr",
>>>> +                                  "amlogic,axg-frddr";
>>>> +                     reg = <0x0 0x200 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "FRDDR_B";
>>>> +                     interrupts = <GIC_SPI 37 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_B>;
>>>> +                     resets = <&arb AXG_ARB_FRDDR_B>,
>>>> +                              <&clkc_audio AUD_RESET_FRDDR_B>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             frddr_c: audio-controller@240 {
>>>> +                     compatible = "amlogic,sm1-frddr",
>>>> +                                  "amlogic,axg-frddr";
>>>> +                     reg = <0x0 0x240 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "FRDDR_C";
>>>> +                     interrupts = <GIC_SPI 38 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_C>;
>>>> +                     resets = <&arb AXG_ARB_FRDDR_C>,
>>>> +                              <&clkc_audio AUD_RESET_FRDDR_C>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             arb: reset-controller@280 {
>>>> +                     compatible = "amlogic,meson-sm1-audio-arb";
>>>> +                     reg = <0x0 0x280 0x0 0x4>;
>>>> +                     #reset-cells = <1>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_DDR_ARB>;
>>>> +             };
>>>> +
>>>> +             tdmin_a: audio-controller@300 {
>>>> +                     compatible = "amlogic,sm1-tdmin",
>>>> +                                  "amlogic,axg-tdmin";
>>>> +                     reg = <0x0 0x300 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMIN_A";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_A>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_A>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_A_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             tdmin_b: audio-controller@340 {
>>>> +                     compatible = "amlogic,sm1-tdmin",
>>>> +                                  "amlogic,axg-tdmin";
>>>> +                     reg = <0x0 0x340 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMIN_B";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_B>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_B>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_B_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             tdmin_c: audio-controller@380 {
>>>> +                     compatible = "amlogic,sm1-tdmin",
>>>> +                                  "amlogic,axg-tdmin";
>>>> +                     reg = <0x0 0x380 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMIN_C";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_C>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_C>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_C_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             tdmin_lb: audio-controller@3c0 {
>>>> +                     compatible = "amlogic,sm1-tdmin",
>>>> +                                  "amlogic,axg-tdmin";
>>>> +                     reg = <0x0 0x3c0 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMIN_LB";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMIN_LB>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMIN_LB>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMIN_LB_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             spdifin: audio-controller@400 {
>>>> +                     compatible = "amlogic,g12a-spdifin",
>>>> +                                  "amlogic,axg-spdifin";
>>>> +                     reg = <0x0 0x400 0x0 0x30>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "SPDIFIN";
>>>> +                     interrupts = <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFIN>,
>>>> +                     <&clkc_audio AUD_CLKID_SPDIFIN_CLK>;
>>>> +                     clock-names = "pclk", "refclk";
>>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFIN>;
>>>> +             };
>>>> +
>>>> +             spdifout_a: audio-controller@480 {
>>>> +                     compatible = "amlogic,g12a-spdifout",
>>>> +                                  "amlogic,axg-spdifout";
>>>> +                     reg = <0x0 0x480 0x0 0x50>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "SPDIFOUT_A";
>>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
>>>> +                     <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
>>>> +                     clock-names = "pclk", "mclk";
>>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT>;
>>>> +             };
>>>> +
>>>> +             tdmout_a: audio-controller@500 {
>>>> +                     compatible = "amlogic,sm1-tdmout";
>>>> +                     reg = <0x0 0x500 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMOUT_A";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_A>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             tdmout_b: audio-controller@540 {
>>>> +                     compatible = "amlogic,sm1-tdmout";
>>>> +                     reg = <0x0 0x540 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMOUT_B";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_B>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_B>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_B_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             tdmout_c: audio-controller@580 {
>>>> +                     compatible = "amlogic,sm1-tdmout";
>>>> +                     reg = <0x0 0x580 0x0 0x40>;
>>>> +                     sound-name-prefix = "TDMOUT_C";
>>>> +                     resets = <&clkc_audio AUD_RESET_TDMOUT_C>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TDMOUT_C>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_SCLK_SEL>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>,
>>>> +                              <&clkc_audio AUD_CLKID_TDMOUT_C_LRCLK>;
>>>> +                     clock-names = "pclk", "sclk", "sclk_sel",
>>>> +                                   "lrclk", "lrclk_sel";
>>>> +             };
>>>> +
>>>> +             spdifout_b: audio-controller@680 {
>>>> +                     compatible = "amlogic,g12a-spdifout",
>>>> +                                  "amlogic,axg-spdifout";
>>>> +                     reg = <0x0 0x680 0x0 0x50>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "SPDIFOUT_B";
>>>> +                     clocks = <&clkc_audio AUD_CLKID_SPDIFOUT_B>,
>>>> +                              <&clkc_audio AUD_CLKID_SPDIFOUT_B_CLK>;
>>>> +                     clock-names = "pclk", "mclk";
>>>> +                     resets = <&clkc_audio AUD_RESET_SPDIFOUT_B>;
>>>> +             };
>>>> +
>>>> +             toacodec: audio-controller@740 {
>>>> +                     compatible = "amlogic,s4-tocodec";
>>>> +                     reg = <0x0 0x740 0x0 0x4>;
>>>> +                     sound-name-prefix = "TOACODEC";
>>>> +                     resets = <&clkc_audio AUD_RESET_TOACODEC>;
>>>> +             };
>>>> +
>>>> +             tohdmitx: audio-controller@744 {
>>>> +                     compatible = "amlogic,sm1-tohdmitx",
>>>> +                                  "amlogic,g12a-tohdmitx";
>>>> +                     reg = <0x0 0x744 0x0 0x4>;
>>>> +                     #sound-dai-cells = <1>;
>>>> +                     sound-name-prefix = "TOHDMITX";
>>>> +                     resets = <&clkc_audio AUD_RESET_TOHDMITX>;
>>>> +             };
>>>> +
>>>> +             toddr_d: audio-controller@840 {
>>>> +                     compatible = "amlogic,sm1-toddr",
>>>> +                                  "amlogic,axg-toddr";
>>>> +                     reg = <0x0 0x840 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "TODDR_D";
>>>> +                     interrupts = <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_TODDR_D>;
>>>> +                     resets = <&arb AXG_ARB_TODDR_D>,
>>>> +                              <&clkc_audio AUD_RESET_TODDR_D>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             frddr_d: audio-controller@880 {
>>>> +                      compatible = "amlogic,sm1-frddr",
>>>> +                                   "amlogic,axg-frddr";
>>>> +                     reg = <0x0 0x880 0x0 0x2c>;
>>>> +                     #sound-dai-cells = <0>;
>>>> +                     sound-name-prefix = "FRDDR_D";
>>>> +                     interrupts = <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>;
>>>> +                     clocks = <&clkc_audio AUD_CLKID_FRDDR_D>;
>>>> +                     resets = <&arb AXG_ARB_FRDDR_D>,
>>>> +                              <&clkc_audio AUD_RESET_FRDDR_D>;
>>>> +                     reset-names = "arb", "rst";
>>>> +                     amlogic,fifo-depth = <256>;
>>>> +             };
>>>> +
>>>> +             tdmout_pad: audio-controller@E58 {
>>>> +                     compatible = "amlogic,s4-tdmout-pad";
>>>> +                     reg = <0x0 0xe58 0x0 0x28>;
>>>> +             };
>>>> +     };
>>>> +
>>>> +     pdm: audio-controller@331000 {
>>>> +             compatible = "amlogic,sm1-pdm",
>>>> +                          "amlogic,axg-pdm";
>>>> +             reg = <0x0 0x331000 0x0 0x34>;
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "PDM";
>>>> +             clocks = <&clkc_audio AUD_CLKID_PDM>,
>>>> +                      <&clkc_audio AUD_CLKID_PDM_DCLK>,
>>>> +                      <&clkc_audio AUD_CLKID_PDM_SYSCLK>;
>>>> +             clock-names = "pclk", "dclk", "sysclk";
>>>> +             resets = <&clkc_audio AUD_RESET_PDM>;
>>>> +             assigned-clocks = <&clkc_audio AUD_CLKID_PDM_DCLK_SEL>,
>>>> +                               <&clkc_audio AUD_CLKID_PDM_SYSCLK_SEL>;
>>>> +             assigned-clock-parents = <&clkc_pll CLKID_HIFI_PLL>,<&clkc_pll CLKID_HIFI_PLL>;
>>>> +     };
>>>> +      acodec: audio-controller@1A000 {
>>>> +             compatible = "amlogic,t9015";
>>>> +             reg = <0x0 0x1A000 0x0 0x14>;
>>>> +             #sound-dai-cells = <0>;
>>>> +             sound-name-prefix = "ACODEC";
>>>> +             clocks = <&clkc_periphs CLKID_ACODEC>;
>>>> +             clock-names = "pclk";
>>>> +             resets = <&reset RESET_ACODEC>;
>>>> +     };
>>>> +
>>>> +};
>>> --
>>> Jerome
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-14 11:29       ` Jerome Brunet
@ 2025-01-14 12:41         ` Jiebing Chen
  0 siblings, 0 replies; 27+ messages in thread
From: Jiebing Chen @ 2025-01-14 12:41 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/14 19:29, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Tue 14 Jan 2025 at 16:16, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>>>> +static const char * const s4_tdmout_sel_texts[] = {
>>>> +     "TDM_D0", "TDM_D1", "TDM_D2", "TDM_D3", "TDM_D4", "TDM_D5", "TDM_D6", "TDM_D7",
>>>> +     "TDM_D8", "TDM_D9", "TDM_D10", "TDM_D11", "TDM_D12", "TDM_D13", "TDM_D14", "TDM_D15",
>>>> +     "TDM_D16", "TDM_D17", "TDM_D18", "TDM_D19", "TDM_D20", "TDM_D21", "TDM_D22", "TDM_D23",
>>>> +     "TDM_D24", "TDM_D25", "TDM_D26", "TDM_D27", "TDM_D28", "TDM_D29", "TDM_D30", "TDM_D31"
>>>> +};
>>> This thing does not belong in ASoC. This is clearly yet another layer of
>>> pinctrl. Please deal with it there.
>> Thanks for your suggestion, add audio pinctrl driver to control the which tdm_dx pin can map the which tdm lane_x
>> for example
>>        tdm_d6_pin {
>>                mux {
>>                        groups = "tdm_d6";
>>                        function = "tdmoutb_lane0";
>>                };
>>        }
>> tdm_d6 pin map the tdmoutb lane 0, right ?
> possibly
>
>>>> +
>>>> +static const struct soc_enum tdmout_sel_enum =
>>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tdmout_sel_texts),
>>>> +                     s4_tdmout_sel_texts);
>>>> +
> [...]
>
>>>> diff --git a/sound/soc/meson/s4-tocodec-control.c b/sound/soc/meson/s4-tocodec-control.c
>>>> new file mode 100644
>>>> index 0000000000000000000000000000000000000000..e5d824fae0eba545d38dc36e2566e7cee590e7f5
>>>> --- /dev/null
>>>> +++ b/sound/soc/meson/s4-tocodec-control.c
>>> There is already a to-acodec driver a not reason has been provided as to why a
>>> completly new driver is required.
>>>
>>> Please have look at the existing driver and do try to use it.
>>> If you need to do things so differently, clear justification are necessary.
>> for g12a-toacodec.c, we find the tocodec clock source can't get the clock
>> id from the tdm Be device,
> This is clearly documented limitation of the current to-acodec driver:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/meson/g12a-toacodec.c?h=v6.13-rc7#n91
>
> While it is a limitation, it is a manageable one considering the amount
> of master clocks available and the fact the master should be manually
> assinged to the output pad, which you did not do.
>
> See the u200:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts?h=v6.13-rc7#n569
>
> You are more than welcome to help fix this limitation in the current
> driver but just adding a fork is not OK
>
> I would suggest to start with what is currently available and move on to
> fixing this as a 2nd step, if you want to.
>
>> and set it by the kcontrol from user,  For different soc chips, The
>> kcontrol value maybe different, The kcontrol configuration doesn't look
>> very friendly for user
>>
>> so we use dapm route path to manage it,
>> fe(fddr)->be(tdm)->(tocodec)->(codec),  and use the aux-devs to register,
>> and sound card only include the
>>
>> sound-dai = <&tdmif_a>
>>
>> codec-0 {
>>                  sound-dai = <&acodec>;
>>   };
>>
>> and not include
>>
>> codec-1 {
>>                  sound-dai = <&toacodec>;
>>   };
>>
>> when tdm work, only connect the tocodec path
>>
>>   "TDM_A Playback" ->"TOACODEC TDMA"->"TOACODEC INPUT SRC"
>>
>> iterate it find the be device ,and get the struct axg_tdm_stream, so we can
>> get the tdm clock id
>>
>> Take into account behavioral differences, we add new tocodec driver
>> for s4
> Still not seeing sufficient reason to make another driver.
it is a good idea, i will add the change for s4 base on g12a-toacodec.c
>
>>>> @@ -0,0 +1,376 @@
>>>> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
>>>> +/*
>>>> + * Copyright (C) 2023 Amlogic, Inc. All rights reserved
>>>> + */
>>>> +
>>>> +#include <linux/module.h>
>>>> +#include <linux/of_platform.h>
>>>> +#include <linux/regmap.h>
>>>> +#include <sound/soc.h>
>>>> +#include <sound/soc-dai.h>
>>>> +#include <linux/init.h>
>>>> +#include <linux/kernel.h>
>>>> +#include<linux/kstrtox.h>
>>>> +#include <linux/clk-provider.h>
>>>> +#include <linux/reset.h>
>>>> +#include "axg-tdm.h"
>>>> +
>>>> +#define TOACODEC_CTRL0                       0x0
>>>> +
>>>> +#define CTRL0_ENABLE_SHIFT           31
>>>> +#define CTRL0_BCLK_ENABLE_SHIFT              30
>>>> +#define CTRL0_MCLK_ENABLE_SHIFT              29
>>>> +#define CTRL0_BLK_CAP_INV_SHIFT              9
>>>> +
>>>> +#define TDM_IFACE 0
>>>> +#define TDM_A_PAD 0
>>>> +#define TDM_B_PAD 1
>>>> +#define TDM_C_PAD 2
>>>> +
>>>> +struct toacodec {
>>>> +     struct regmap_field *field_dat_sel;
>>>> +     struct regmap_field *field_lrclk_sel;
>>>> +     struct regmap_field *field_bclk_sel;
>>>> +     struct regmap_field *field_mclk_sel;
>>>> +};
>>>> +
>>>> +struct toacodec_match_data {
>>>> +     const struct snd_soc_component_driver *component_drv;
>>>> +     const struct reg_field field_dat_sel;
>>>> +     const struct reg_field field_lrclk_sel;
>>>> +     const struct reg_field field_bclk_sel;
>>>> +     const struct reg_field field_mclk_sel;
>>>> +};
>>>> +
>>>> +static const struct regmap_config tocodec_regmap_cfg = {
>>>> +     .reg_bits       = 32,
>>>> +     .val_bits       = 32,
>>>> +     .reg_stride     = 4,
>>>> +     .max_register   = 0x1,
>>>> +};
>>>> +
>>>> +#define S4_LANE_OFFSET 8
>>>> +
>>>> +static const char * const s4_tocodec_lane_sel_texts[] = {
>>>> +     "Lane0", "Lane1", "Lane2", "Lane3", "Lane4", "Lane5", "Lane6", "Lane7"
>>>> +};
>>>> +
>>>> +static const struct soc_enum s4_tocodec_lane_sel_enum =
>>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_lane_sel_texts),
>>>> +                     s4_tocodec_lane_sel_texts);
>>>> +
>>>> +static const struct snd_kcontrol_new s4_tocodec_lane_sel =
>>>> +     SOC_DAPM_ENUM("TOCODEC LANE SEL", s4_tocodec_lane_sel_enum);
>>>> +
>>>> +static const char * const s4_tocodec_src_sel_texts[] = {
>>>> +     "TDMA", "TDMB", "TDMC"
>>>> +};
>>>> +
>>>> +static const struct soc_enum s4_tocodec_src_sel_enum =
>>>> +     SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(s4_tocodec_src_sel_texts),
>>>> +                     s4_tocodec_src_sel_texts);
>>>> +
>>>> +static const struct snd_kcontrol_new s4_tocodec_src_sel =
>>>> +     SOC_DAPM_ENUM("TOCODEC SEL", s4_tocodec_src_sel_enum);
>>>> +
>>>> +static const struct snd_kcontrol_new s4_toacodec_out_enable =
>>>> +     SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
>>>> +                                 CTRL0_ENABLE_SHIFT, 1, 0);
>>>> +
>>>> +static struct snd_soc_dai *tocodec_tdm_get_ahead_be(struct snd_soc_dapm_widget *w)
>>>> +{
>>>> +     struct snd_soc_dapm_path *p;
>>>> +     struct snd_soc_dai *be;
>>>> +
>>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>>> +             if (!p->connect)
>>>> +                     continue;
>>>> +             if (p->source->id == snd_soc_dapm_dai_in)
>>>> +                     return (struct snd_soc_dai *)p->source->priv;
>>>> +             be = tocodec_tdm_get_ahead_be(p->source);
>>>> +             if (be && be->id == TDM_IFACE)
>>>> +                     return be;
>>>> +     }
>>>> +     return NULL;
>>>> +}
>>>> +
>>>> +static unsigned int aml_simple_strtoull(const char *cp)
>>>> +{
>>>> +     unsigned int result = 0;
>>>> +     unsigned int value = 0;
>>>> +     unsigned int len = strlen(cp);
>>>> +
>>>> +     while (len != 0) {
>>>> +             len--;
>>>> +             value = isdigit(*cp);
>>>> +             if (value) {
>>>> +                     value = *cp - '0';
>>>> +             } else {
>>>> +                     cp++;
>>>> +                     continue;
>>>> +             }
>>>> +             cp++;
>>>> +             result = result * 10 + value;
>>>> +     }
>>>> +     return result;
>>>> +}
>>>> +
>>>> +static int aml_get_clk_id(const char *name)
>>>> +{
>>>> +     int clk_id = 0;
>>>> +
>>>> +     if (strstr(name, "mst_a"))
>>>> +             clk_id = 0;
>>>> +     else if (strstr(name, "mst_b"))
>>>> +             clk_id = 1;
>>>> +     else if (strstr(name, "mst_c"))
>>>> +             clk_id = 2;
>>>> +     else if (strstr(name, "mst_d"))
>>>> +             clk_id = 3;
>>>> +     else if (strstr(name, "mst_e"))
>>>> +             clk_id = 4;
>>>> +     else if (strstr(name, "mst_f"))
>>>> +             clk_id = 5;
>>>> +
>>>> +     return clk_id;
>>>> +}
>>>> +
>>>> +static int aml_tocodec_sel_set(struct snd_soc_dapm_widget *w)
>>>> +{
>>>> +     struct snd_soc_dai *be;
>>>> +     struct axg_tdm_stream *stream;
>>>> +     struct axg_tdm_iface *iface;
>>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>>> +     struct toacodec *priv = snd_soc_component_get_drvdata(component);
>>>> +     unsigned int tdm_id = TDM_A_PAD;
>>>> +     const char *dai_widget_name;
>>>> +     struct snd_soc_dapm_path *p;
>>>> +     unsigned int lane = 0;
>>>> +     unsigned int val = 0;
>>>> +     struct clk *sclk, *mclk;
>>>> +     char *clk_name;
>>>> +     int mclk_id, sclk_id;
>>>> +
>>>> +     be = tocodec_tdm_get_ahead_be(w);
>>>> +     if (!be) {
>>>> +             dev_err(component->dev, "%s not find the be\n", __func__);
>>>> +             return -EINVAL;
>>>> +     }
>>>> +     stream = snd_soc_dai_dma_data_get_playback(be);
>>>> +     if (!stream) {
>>>> +             dev_err(component->dev, "%s not find the stream\n", __func__);
>>>> +             return -EINVAL;
>>>> +     }
>>>> +     /*we like to use dai id, but it is fixed val*/
>>>> +     dai_widget_name = be->stream[SNDRV_PCM_STREAM_PLAYBACK].widget->name;
>>>> +     if (strstr(dai_widget_name, "TDM_A"))
>>>> +             tdm_id = TDM_A_PAD;
>>>> +     else if (strstr(dai_widget_name, "TDM_B"))
>>>> +             tdm_id = TDM_B_PAD;
>>>> +     else if (strstr(dai_widget_name, "TDM_C"))
>>>> +             tdm_id = TDM_C_PAD;
>>>> +     snd_soc_dapm_widget_for_each_source_path(w, p) {
>>>> +             if (p->connect && p->name) {
>>>> +                     lane = aml_simple_strtoull(p->name);
>>>> +                     val = lane + tdm_id * S4_LANE_OFFSET;
>>>> +                     regmap_field_write(priv->field_dat_sel, val);
>>>> +             }
>>>> +     }
>>>> +     iface = stream->iface;
>>>> +     mclk = iface->mclk;
>>>> +     sclk = iface->sclk;
>>>> +     mclk_id = aml_get_clk_id(__clk_get_name(mclk));
>>>> +     sclk_id = aml_get_clk_id(__clk_get_name(sclk));
>>>> +     regmap_field_write(priv->field_mclk_sel, mclk_id);
>>>> +     regmap_field_write(priv->field_bclk_sel, sclk_id);
>>>> +     regmap_field_write(priv->field_lrclk_sel, sclk_id);
>>>> +
>>>> +     return 0;
>>>> +}
>>>> +
>>>> +static int tocodec_sel_event(struct snd_soc_dapm_widget *w,
>>>> +                          struct snd_kcontrol *control,
>>>> +                          int event)
>>>> +{
>>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>>> +     int ret = 0;
>>>> +
>>>> +     switch (event) {
>>>> +     case SND_SOC_DAPM_PRE_PMU:
>>>> +             ret = aml_tocodec_sel_set(w);
>>>> +             break;
>>>> +
>>>> +     case SND_SOC_DAPM_PRE_PMD:
>>>> +             break;
>>>> +
>>>> +     default:
>>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>>> +             return -EINVAL;
>>>> +     }
>>>> +
>>>> +     return ret;
>>>> +}
>>>> +
>>>> +static int tocodec_clk_enable(struct snd_soc_dapm_widget *w,
>>>> +                           struct snd_kcontrol *control,
>>>> +                           int event)
>>>> +{
>>>> +     int ret = 0;
>>>> +     unsigned int mask = 0, val = 0;
>>>> +     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
>>>> +
>>>> +     snd_soc_component_update_bits(component, TOACODEC_CTRL0,
>>>> +                                   1 << CTRL0_BLK_CAP_INV_SHIFT, 1 << CTRL0_BLK_CAP_INV_SHIFT);
>>>> +     switch (event) {
>>>> +     case SND_SOC_DAPM_PRE_PMU:
>>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>>> +             val = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>>>> +             break;
>>>> +     case SND_SOC_DAPM_PRE_PMD:
>>>> +             mask = 1 << CTRL0_MCLK_ENABLE_SHIFT | 1 << CTRL0_BCLK_ENABLE_SHIFT;
>>>> +             val = 0 << CTRL0_MCLK_ENABLE_SHIFT | 0 << CTRL0_BCLK_ENABLE_SHIFT;
>>>> +             snd_soc_component_update_bits(component, TOACODEC_CTRL0, mask, val);
>>>> +             break;
>>>> +     default:
>>>> +             dev_err(component->dev, "Unexpected event %d\n", event);
>>>> +             return -EINVAL;
>>>> +     }
>>>> +
>>>> +     return ret;
>>>> +}
>>>> +
>>>> +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
>>>> +     SND_SOC_DAPM_MUX_E("Lane SRC", SND_SOC_NOPM, 0, 0,
>>>> +                        &s4_tocodec_lane_sel, tocodec_sel_event,
>>>> +                        (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>>>> +     SND_SOC_DAPM_MUX("INPUT SRC", SND_SOC_NOPM, 0, 0, &s4_tocodec_src_sel),
>>>> +     SND_SOC_DAPM_SWITCH_E("OUT EN", SND_SOC_NOPM, 0, 0,
>>>> +                           &s4_toacodec_out_enable, tocodec_clk_enable,
>>>> +                             (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
>>>> +     SND_SOC_DAPM_AIF_IN("TDMA", NULL, 0, SND_SOC_NOPM, 0, 0),
>>>> +     SND_SOC_DAPM_AIF_IN("TDMB", NULL, 0, SND_SOC_NOPM, 0, 0),
>>>> +     SND_SOC_DAPM_AIF_IN("TDMC", NULL, 0, SND_SOC_NOPM, 0, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane0", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane1", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane2", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane3", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane4", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane5", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane6", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUT_DRV("Lane7", SND_SOC_NOPM, 0, 0, NULL, 0),
>>>> +     SND_SOC_DAPM_OUTPUT("TDM_TO_ACODEC"),
>>>> +};
>>>> +
>>>> +static const struct snd_soc_dapm_route s4_tocodec_dapm_routes[] = {
>>>> +     { "INPUT SRC", "TDMA", "TDMA"},
>>>> +     { "INPUT SRC", "TDMB", "TDMB"},
>>>> +     { "INPUT SRC", "TDMC", "TDMC"},
>>>> +     { "Lane0", NULL, "INPUT SRC" },
>>>> +     { "Lane1", NULL, "INPUT SRC"},
>>>> +     { "Lane2", NULL, "INPUT SRC"},
>>>> +     { "Lane3", NULL, "INPUT SRC"},
>>>> +     { "Lane4", NULL, "INPUT SRC"},
>>>> +     { "Lane5", NULL, "INPUT SRC"},
>>>> +     { "Lane6", NULL, "INPUT SRC"},
>>>> +     { "Lane7", NULL, "INPUT SRC"},
>>>> +     { "Lane SRC", "Lane0", "Lane0"},
>>>> +     { "Lane SRC", "Lane1", "Lane1"},
>>>> +     { "Lane SRC", "Lane2", "Lane2"},
>>>> +     { "Lane SRC", "Lane3", "Lane3"},
>>>> +     { "Lane SRC", "Lane4", "Lane4"},
>>>> +     { "Lane SRC", "Lane5", "Lane5"},
>>>> +     { "Lane SRC", "Lane6", "Lane6"},
>>>> +     { "Lane SRC", "Lane7", "Lane7"},
>>>> +     { "OUT EN", "Switch", "Lane SRC"},
>>>> +     { "TDM_TO_ACODEC", NULL, "OUT EN"},
>>>> +
>>>> +};
>>>> +
>>>> +static const struct snd_soc_component_driver s4_tocodec_component_drv = {
>>>> +     .dapm_widgets           = s4_toacodec_widgets,
>>>> +     .num_dapm_widgets       = ARRAY_SIZE(s4_toacodec_widgets),
>>>> +     .dapm_routes            = s4_tocodec_dapm_routes,
>>>> +     .num_dapm_routes        = ARRAY_SIZE(s4_tocodec_dapm_routes),
>>>> +};
>>>> +
>>>> +static const struct toacodec_match_data s4_toacodec_match_data = {
>>>> +     .component_drv  = &s4_tocodec_component_drv,
>>>> +     .field_dat_sel  = REG_FIELD(TOACODEC_CTRL0, 16, 20),
>>>> +     .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14),
>>>> +     .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6),
>>>> +     .field_mclk_sel = REG_FIELD(TOACODEC_CTRL0, 0, 2),
>>>> +};
>>>> +
>>>> +static const struct of_device_id s4_tocodec_of_match[] = {
>>>> +     {
>>>> +             .compatible = "amlogic,s4-tocodec",
>>>> +             .data = &s4_toacodec_match_data,
>>>> +     }, {}
>>>> +};
>>>> +
>>>> +MODULE_DEVICE_TABLE(of, s4_tocodec_of_match);
>>>> +
>>>> +static int tocodec_probe(struct platform_device *pdev)
>>>> +{
>>>> +     const struct toacodec_match_data *data;
>>>> +     struct device *dev = &pdev->dev;
>>>> +     struct toacodec *priv;
>>>> +     void __iomem *regs;
>>>> +     struct regmap *map;
>>>> +     int ret;
>>>> +
>>>> +     data = device_get_match_data(dev);
>>>> +     if (!data)
>>>> +             return dev_err_probe(dev, -ENODEV, "failed to match device\n");
>>>> +     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>>>> +     if (!priv)
>>>> +             return -ENOMEM;
>>>> +
>>>> +     platform_set_drvdata(pdev, priv);
>>>> +
>>>> +     ret = device_reset(dev);
>>>> +     if (ret)
>>>> +             return ret;
>>>> +
>>>> +     regs = devm_platform_ioremap_resource(pdev, 0);
>>>> +     if (IS_ERR(regs))
>>>> +             return PTR_ERR(regs);
>>>> +
>>>> +     map = devm_regmap_init_mmio(dev, regs, &tocodec_regmap_cfg);
>>>> +     if (IS_ERR(map))
>>>> +             return dev_err_probe(dev, PTR_ERR(map), "failed to init regmap\n");
>>>> +
>>>> +     priv->field_dat_sel = devm_regmap_field_alloc(dev, map, data->field_dat_sel);
>>>> +     if (IS_ERR(priv->field_dat_sel))
>>>> +             return PTR_ERR(priv->field_dat_sel);
>>>> +
>>>> +     priv->field_lrclk_sel = devm_regmap_field_alloc(dev, map, data->field_lrclk_sel);
>>>> +     if (IS_ERR(priv->field_lrclk_sel))
>>>> +             return PTR_ERR(priv->field_lrclk_sel);
>>>> +
>>>> +     priv->field_bclk_sel = devm_regmap_field_alloc(dev, map, data->field_bclk_sel);
>>>> +     if (IS_ERR(priv->field_bclk_sel))
>>>> +             return PTR_ERR(priv->field_bclk_sel);
>>>> +
>>>> +     priv->field_mclk_sel = devm_regmap_field_alloc(dev, map, data->field_mclk_sel);
>>>> +     if (IS_ERR(priv->field_mclk_sel))
>>>> +             return PTR_ERR(priv->field_mclk_sel);
>>>> +
>>>> +     return devm_snd_soc_register_component(dev,
>>>> +                     data->component_drv, NULL, 0);
>>>> +}
>>>> +
>>>> +static struct platform_driver tocodec_pdrv = {
>>>> +     .probe = tocodec_probe,
>>>> +     .driver = {
>>>> +             .name = "s4-tocodec",
>>>> +             .of_match_table = s4_tocodec_of_match,
>>>> +     },
>>>> +};
>>>> +
>>>> +module_platform_driver(tocodec_pdrv);
>>>> +
>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>> +MODULE_LICENSE("GPL");
>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>> index 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 100644
>>>> --- a/sound/soc/meson/t9015.c
>>>> +++ b/sound/soc/meson/t9015.c
>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>                 .channels_min = 1,
>>>>                 .channels_max = 2,
>>>>                 .rates = SNDRV_PCM_RATE_8000_96000,
>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE),
>>> Again, mixed up changes with zero justification.
>>>
>>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>>> which is known to work and add S32 support on an HW documented as 24bits
>>> only. Can you explain ?
>>>
>>>>         },
>>>>         .ops = &t9015_dai_ops,
>>>>    };
>>> --
>>> Jerome
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-14 11:20       ` Jiebing Chen
@ 2025-01-14 14:05         ` Jerome Brunet
  2025-01-15  2:56           ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-14 14:05 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Tue 14 Jan 2025 at 19:20, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

>>>> +
>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>> +MODULE_LICENSE("GPL");
>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>> index
>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648
>>>> 100644
>>>> --- a/sound/soc/meson/t9015.c
>>>> +++ b/sound/soc/meson/t9015.c
>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>                .channels_min = 1,
>>>>                .channels_max = 2,
>>>>                .rates = SNDRV_PCM_RATE_8000_96000,
>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>> Again, mixed up changes with zero justification.
>>>
>>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>>> which is known to work and add S32 support on an HW documented as 24bits
>>> only. Can you explain ?
>
> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,

If there are chips difference we did not know about, then you should
introduce those difference, without breaking existing support -
including for GXL, which is what you did IIUC.

> the new ip not support 24 bit,

Are sure about that ? that code has been there for a while.

If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix up patch for
that, with the proper "Fixes:" tag, how to reproduce the problem and
explaining the fix.

>
> usually support 16/32 bit for new audio ip , for SNDRV_PCM_FMTBIT_S24_LE,
> it width =24, phy =32

Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 32 bits
width would support this S24_LE, unless there is something odd.

>
> it was  treated as 32 bit to send for tdm, so we can only add the S32LE
> base on it , right ?

You are asking me ? How am I suppose to know ?

> but if the gxl not support the 32bit

I don't see a problem with a DAC taking input on 32bits physical
interface and ignoring some bit on processing.

If that's not the case, please send a proper fix change with some explanation

>
> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>

If I understood correctly format depends on the chip and needs to
adjusted including for sm1. 

>>>
>>>>        },
>>>>        .ops = &t9015_dai_ops,
>>>>   };
>>> -- Jerome

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-14 12:34         ` Jiebing Chen
@ 2025-01-14 14:15           ` Jerome Brunet
  2025-01-15  3:38             ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-14 14:15 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Tue 14 Jan 2025 at 20:34, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

> 在 2025/1/14 19:16, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>>
>>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>>> [ EXTERNAL EMAIL ]
>>>>
>>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>>
>>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>>
>>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>>> AQ222 board.
>>>>>
>>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>>> ---
>>>>>    .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>>>>>    arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>>>>>    2 files changed, 610 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
> b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
>>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>>                regulator-always-on;
>>>>>         };
>>>>>
>>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>>> +             compatible = "regulator-fixed";
>>>>> +             vin-supply = <&main_12v>;
>>>>> +             regulator-name = "VCC5V";
>>>>> +             regulator-min-microvolt = <5000000>;
>>>>> +             regulator-max-microvolt = <5000000>;
>>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>>> +             startup-delay-us = <7000>;
>>>>> +             enable-active-high;
>>>>> +             regulator-boot-on;
>>>>> +             regulator-always-on;
>>>>> +     };
>>>>> +
>>>>>         /* SY8120B1ABC DC/DC Regulator. */
>>>>>         vddcpu: regulator-vddcpu {
>>>>>                 compatible = "pwm-regulator";
>>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>>                                 <699000 98>,
>>>>>                                 <689000 100>;
>>>>>         };
>>>>> +     dmics: audio-codec-1 {
>>>>> +             compatible = "dmic-codec";
>>>>> +             #sound-dai-cells = <0>;
>>>>> +             num-channels = <2>;
>>>>> +             wakeup-delay-ms = <50>;
>>>>> +             sound-name-prefix = "MIC";
>>>>> +     };
>>>>> +
>>>>> +     dioo2133: audio-amplifier-0 {
>>>>> +             compatible = "simple-audio-amplifier";
>>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>>> +             VCC-supply = <&vcc5v_reg>;
>>>>> +             #sound-dai-cells = <0>;
>>>>> +             sound-name-prefix = "10U2";
>>>>> +     };
>>>>> +
>>>>> +     spdif_dir: audio-spdif-in {
>>>>> +             compatible = "linux,spdif-dir";
>>>>> +             #sound-dai-cells = <0>;
>>>>> +             sound-name-prefix = "DIR";
>>>>> +     };
>>>>> +
>>>>> +     spdif_dit: audio-spdif-out {
>>>>> +             compatible = "linux,spdif-dit";
>>>>> +             #sound-dai-cells = <0>;
>>>>> +             sound-name-prefix = "DIT";
>>>>> +     };
>>>>> +
>>>>> +     sound {
>>>>> +             compatible = "amlogic,axg-sound-card";
>>>>> +             model = "aq222";
>>>>> +             audio-widgets = "Line", "Lineout";
>>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
>>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>>> +                              <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
>>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>>> +                             "10U2 INR", "ACODEC LORP",
>>>>> +                             "Lineout", "10U2 OUTL",
>>>>> +                             "Lineout", "10U2 OUTR";
>>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>>> +             assigned-clock-rates = <491520000>,
>>>>> +                                    <294912000>,
>>>>> +                                    <270950400>,
>>>>> +                                    <393216000>;
>>>> Why do you need 4 base rates ? Which rate family does each provide ?
>>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000, the
>>> accuracy of hifipll
>>>
>>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if the
>>> tdm and spdif work on
>> It is fine to use the HiFi. I'm glad this clock finally got fixed
>>
>>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the same
>>> pll, so spdif need use the mpll 0
>>>
>>> other pll , only set a default value, at the latest chip, we remove all
>>> mpll for hardware, only two hifipll
>> I'm not sure you understand how this works.
>> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>>
>> Each family needs a PLL assigned, so you need 3, not 4, unless there is
>> another specific rate family you want to support. If that's the case,
>> document it.
>>
>> Setting the rate of the PLL should follow this principle:
>> * Family rate
>>    - multiplied by (32 x 24): to accomodate different sample sizes
>>    - multiplied by 2 until you reach the maximum rate of selected PLLs
>>      This allows to support rates such 192k or even 768k
>>
>> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
>> poor choice.
>>
>> Have a look at the s400 for an example using the HiFi PLL. The axg was
>> restricted to a 68 PLL multiplier but the S4 is not so you should be
>> able to use a higher base rate (4 718 592 000 Hz), providing better
>> accuracy in the end
>
> for new soc audio ip, the hardware will not support the 24bit(include g12a,
> sm1,axg)

That may be what you chose to support in your BSP but that not how it
works in mainline. 24bits slot width is supported and has been tested on
axg, g12 and sm1. This is not going away.

I would find extremely odd that 24 bits slot width is not supported on s4,
but as long you document this, it is fine by me.

>
> SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory

I think you are mixing up slot width and memory representation

>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-14 14:05         ` Jerome Brunet
@ 2025-01-15  2:56           ` Jiebing Chen
  2025-01-15  8:36             ` Jerome Brunet
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15  2:56 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/14 22:05, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Tue 14 Jan 2025 at 19:20, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>>>>> +
>>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>>> +MODULE_LICENSE("GPL");
>>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>>> index
>>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648
>>>>> 100644
>>>>> --- a/sound/soc/meson/t9015.c
>>>>> +++ b/sound/soc/meson/t9015.c
>>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>>                 .channels_min = 1,
>>>>>                 .channels_max = 2,
>>>>>                 .rates = SNDRV_PCM_RATE_8000_96000,
>>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>>> Again, mixed up changes with zero justification.
>>>>
>>>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>>>> which is known to work and add S32 support on an HW documented as 24bits
>>>> only. Can you explain ?
>> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,
> If there are chips difference we did not know about, then you should
> introduce those difference, without breaking existing support -
> including for GXL, which is what you did IIUC.
>
>> the new ip not support 24 bit,
> Are sure about that ? that code has been there for a while.
>
> If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix up patch for
> that, with the proper "Fixes:" tag, how to reproduce the problem and
> explaining the fix.

maybe there are some gap , we support SNDRV_PCM_FMTBIT_S24, not support the

SNDRV_PCM_FMTBIT_S24_3LE,  for SNDRV_PCM_FMTBIT_S24

it is  Signed, 24-bit (32-bit in memory), little endian , the audio dma 
busrt is 64bit

it can get the full data. we send the 32 bit data  mclk = 32bit* 48k 
*4,  use the clk to send

the  SNDRV_PCM_FMTBIT_S24,   the hadware always send the 32bit data

so, i think we only add the SNDRV_PCM_FMTBIT_S32 base on it

we think the 24 bit is the SNDRV_PCM_FMTBIT_S24_3LE, it is 24bit in memroy,

due to the dma busrt 64 bit limit, it can't align the sample bit, if it 
is 24 bit

so the clock configure can't 24bit clock, by the way, We discuss 
internally for gxl,

it also support the SNDRV_PCM_FMTBIT_S32


>
>> usually support 16/32 bit for new audio ip , for SNDRV_PCM_FMTBIT_S24_LE,
>> it width =24, phy =32
> Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 32 bits
> width would support this S24_LE, unless there is something odd.
>
>> it was  treated as 32 bit to send for tdm, so we can only add the S32LE
>> base on it , right ?
> You are asking me ? How am I suppose to know ?
>
>> but if the gxl not support the 32bit
> I don't see a problem with a DAC taking input on 32bits physical
> interface and ignoring some bit on processing.
>
> If that's not the case, please send a proper fix change with some explanation
>
>> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>>
> If I understood correctly format depends on the chip and needs to
> adjusted including for sm1.
>
>>>>>         },
>>>>>         .ops = &t9015_dai_ops,
>>>>>    };
>>>> -- Jerome
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-14 14:15           ` Jerome Brunet
@ 2025-01-15  3:38             ` Jiebing Chen
  2025-01-15  6:16               ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15  3:38 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/14 22:15, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Tue 14 Jan 2025 at 20:34, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>> 在 2025/1/14 19:16, Jerome Brunet 写道:
>>> [ EXTERNAL EMAIL ]
>>>
>>> On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>>>
>>>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>>>> [ EXTERNAL EMAIL ]
>>>>>
>>>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>>>
>>>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>
>>>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>>>> AQ222 board.
>>>>>>
>>>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>>>> ---
>>>>>>     .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts     | 226 ++++++++++++
>>>>>>     arch/arm64/boot/dts/amlogic/meson-s4.dtsi          | 385 ++++++++++++++++++++-
>>>>>>     2 files changed, 610 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>> b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>> index 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 100644
>>>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>>>                 regulator-always-on;
>>>>>>          };
>>>>>>
>>>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>>>> +             compatible = "regulator-fixed";
>>>>>> +             vin-supply = <&main_12v>;
>>>>>> +             regulator-name = "VCC5V";
>>>>>> +             regulator-min-microvolt = <5000000>;
>>>>>> +             regulator-max-microvolt = <5000000>;
>>>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>>>> +             startup-delay-us = <7000>;
>>>>>> +             enable-active-high;
>>>>>> +             regulator-boot-on;
>>>>>> +             regulator-always-on;
>>>>>> +     };
>>>>>> +
>>>>>>          /* SY8120B1ABC DC/DC Regulator. */
>>>>>>          vddcpu: regulator-vddcpu {
>>>>>>                  compatible = "pwm-regulator";
>>>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>>>                                  <699000 98>,
>>>>>>                                  <689000 100>;
>>>>>>          };
>>>>>> +     dmics: audio-codec-1 {
>>>>>> +             compatible = "dmic-codec";
>>>>>> +             #sound-dai-cells = <0>;
>>>>>> +             num-channels = <2>;
>>>>>> +             wakeup-delay-ms = <50>;
>>>>>> +             sound-name-prefix = "MIC";
>>>>>> +     };
>>>>>> +
>>>>>> +     dioo2133: audio-amplifier-0 {
>>>>>> +             compatible = "simple-audio-amplifier";
>>>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>>>> +             VCC-supply = <&vcc5v_reg>;
>>>>>> +             #sound-dai-cells = <0>;
>>>>>> +             sound-name-prefix = "10U2";
>>>>>> +     };
>>>>>> +
>>>>>> +     spdif_dir: audio-spdif-in {
>>>>>> +             compatible = "linux,spdif-dir";
>>>>>> +             #sound-dai-cells = <0>;
>>>>>> +             sound-name-prefix = "DIR";
>>>>>> +     };
>>>>>> +
>>>>>> +     spdif_dit: audio-spdif-out {
>>>>>> +             compatible = "linux,spdif-dit";
>>>>>> +             #sound-dai-cells = <0>;
>>>>>> +             sound-name-prefix = "DIT";
>>>>>> +     };
>>>>>> +
>>>>>> +     sound {
>>>>>> +             compatible = "amlogic,axg-sound-card";
>>>>>> +             model = "aq222";
>>>>>> +             audio-widgets = "Line", "Lineout";
>>>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, <&tdmout_c>,
>>>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>>>> +                              <&tdmin_lb>, <&dioo2133>, <&tdmout_pad>, <&toacodec>;
>>>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>>>> +                             "10U2 INR", "ACODEC LORP",
>>>>>> +                             "Lineout", "10U2 OUTL",
>>>>>> +                             "Lineout", "10U2 OUTR";
>>>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>>>> +             assigned-clock-rates = <491520000>,
>>>>>> +                                    <294912000>,
>>>>>> +                                    <270950400>,
>>>>>> +                                    <393216000>;
>>>>> Why do you need 4 base rates ? Which rate family does each provide ?
>>>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000, the
>>>> accuracy of hifipll
>>>>
>>>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if the
>>>> tdm and spdif work on
>>> It is fine to use the HiFi. I'm glad this clock finally got fixed
>>>
>>>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the same
>>>> pll, so spdif need use the mpll 0
>>>>
>>>> other pll , only set a default value, at the latest chip, we remove all
>>>> mpll for hardware, only two hifipll
>>> I'm not sure you understand how this works.
>>> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>>>
>>> Each family needs a PLL assigned, so you need 3, not 4, unless there is
>>> another specific rate family you want to support. If that's the case,
>>> document it.
>>>
>>> Setting the rate of the PLL should follow this principle:
>>> * Family rate
>>>     - multiplied by (32 x 24): to accomodate different sample sizes
>>>     - multiplied by 2 until you reach the maximum rate of selected PLLs
>>>       This allows to support rates such 192k or even 768k
>>>
>>> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
>>> poor choice.
>>>
>>> Have a look at the s400 for an example using the HiFi PLL. The axg was
>>> restricted to a 68 PLL multiplier but the S4 is not so you should be
>>> able to use a higher base rate (4 718 592 000 Hz), providing better
>>> accuracy in the end
>> for new soc audio ip, the hardware will not support the 24bit(include g12a,
>> sm1,axg)
> That may be what you chose to support in your BSP but that not how it
> works in mainline. 24bits slot width is supported and has been tested on
> axg, g12 and sm1. This is not going away.
>
> I would find extremely odd that 24 bits slot width is not supported on s4,
> but as long you document this, it is fine by me.

i understand your meaning, you sad we configure the slot width 24bit for 
tdmout control

if the format the SNDRV_PCM_FMTBIT_S24,  it send the 24bit data, for the 
format, and send the 24bit clock

if tdmout control can cut out [24:0] from the fddr, maybe your right, we 
can send the 24 bit accoring to the slot width

but it can't confirm by us, we are worried that there may be potential 
risks, so we don't use it thay way

so this why i sad can't support the 24bit slot clock, 16/32 sample bit 
is fully validated


>> SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory
> I think you are mixing up slot width and memory representation
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-15  3:38             ` Jiebing Chen
@ 2025-01-15  6:16               ` Jiebing Chen
  2025-01-15  8:43                 ` Jerome Brunet
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15  6:16 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/15 11:38, Jiebing Chen 写道:
>
> 在 2025/1/14 22:15, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Tue 14 Jan 2025 at 20:34, Jiebing Chen <jiebing.chen@amlogic.com> 
>> wrote:
>>
>>> 在 2025/1/14 19:16, Jerome Brunet 写道:
>>>> [ EXTERNAL EMAIL ]
>>>>
>>>> On Tue 14 Jan 2025 at 16:52, Jiebing Chen 
>>>> <jiebing.chen@amlogic.com> wrote:
>>>>
>>>>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>>>>> [ EXTERNAL EMAIL ]
>>>>>>
>>>>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay 
>>>>>> <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>>>>
>>>>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>>
>>>>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>>>>> AQ222 board.
>>>>>>>
>>>>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>> ---
>>>>>>>     .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts | 226 
>>>>>>> ++++++++++++
>>>>>>>     arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 385 
>>>>>>> ++++++++++++++++++++-
>>>>>>>     2 files changed, 610 insertions(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>> b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>> index 
>>>>>>> 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130 
>>>>>>> 100644
>>>>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>>>>                 regulator-always-on;
>>>>>>>          };
>>>>>>>
>>>>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>>>>> +             compatible = "regulator-fixed";
>>>>>>> +             vin-supply = <&main_12v>;
>>>>>>> +             regulator-name = "VCC5V";
>>>>>>> +             regulator-min-microvolt = <5000000>;
>>>>>>> +             regulator-max-microvolt = <5000000>;
>>>>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>>>>> +             startup-delay-us = <7000>;
>>>>>>> +             enable-active-high;
>>>>>>> +             regulator-boot-on;
>>>>>>> +             regulator-always-on;
>>>>>>> +     };
>>>>>>> +
>>>>>>>          /* SY8120B1ABC DC/DC Regulator. */
>>>>>>>          vddcpu: regulator-vddcpu {
>>>>>>>                  compatible = "pwm-regulator";
>>>>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>>>>                                  <699000 98>,
>>>>>>>                                  <689000 100>;
>>>>>>>          };
>>>>>>> +     dmics: audio-codec-1 {
>>>>>>> +             compatible = "dmic-codec";
>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>> +             num-channels = <2>;
>>>>>>> +             wakeup-delay-ms = <50>;
>>>>>>> +             sound-name-prefix = "MIC";
>>>>>>> +     };
>>>>>>> +
>>>>>>> +     dioo2133: audio-amplifier-0 {
>>>>>>> +             compatible = "simple-audio-amplifier";
>>>>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>>>>> +             VCC-supply = <&vcc5v_reg>;
>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>> +             sound-name-prefix = "10U2";
>>>>>>> +     };
>>>>>>> +
>>>>>>> +     spdif_dir: audio-spdif-in {
>>>>>>> +             compatible = "linux,spdif-dir";
>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>> +             sound-name-prefix = "DIR";
>>>>>>> +     };
>>>>>>> +
>>>>>>> +     spdif_dit: audio-spdif-out {
>>>>>>> +             compatible = "linux,spdif-dit";
>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>> +             sound-name-prefix = "DIT";
>>>>>>> +     };
>>>>>>> +
>>>>>>> +     sound {
>>>>>>> +             compatible = "amlogic,axg-sound-card";
>>>>>>> +             model = "aq222";
>>>>>>> +             audio-widgets = "Line", "Lineout";
>>>>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>, 
>>>>>>> <&tdmout_c>,
>>>>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>>>>> +                              <&tdmin_lb>, <&dioo2133>, 
>>>>>>> <&tdmout_pad>, <&toacodec>;
>>>>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>>>>> +                             "10U2 INR", "ACODEC LORP",
>>>>>>> +                             "Lineout", "10U2 OUTL",
>>>>>>> +                             "Lineout", "10U2 OUTR";
>>>>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>>>>> +             assigned-clock-rates = <491520000>,
>>>>>>> + <294912000>,
>>>>>>> + <270950400>,
>>>>>>> + <393216000>;
>>>>>> Why do you need 4 base rates ? Which rate family does each provide ?
>>>>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 
>>>>> 393216000, the
>>>>> accuracy of hifipll
>>>>>
>>>>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. 
>>>>> if the
>>>>> tdm and spdif work on
>>>> It is fine to use the HiFi. I'm glad this clock finally got fixed
>>>>
>>>>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the 
>>>>> same
>>>>> pll, so spdif need use the mpll 0
>>>>>
>>>>> other pll , only set a default value, at the latest chip, we 
>>>>> remove all
>>>>> mpll for hardware, only two hifipll
>>>> I'm not sure you understand how this works.
>>>> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>>>>
>>>> Each family needs a PLL assigned, so you need 3, not 4, unless 
>>>> there is
>>>> another specific rate family you want to support. If that's the case,
>>>> document it.
>>>>
>>>> Setting the rate of the PLL should follow this principle:
>>>> * Family rate
>>>>     - multiplied by (32 x 24): to accomodate different sample sizes
>>>>     - multiplied by 2 until you reach the maximum rate of selected 
>>>> PLLs
>>>>       This allows to support rates such 192k or even 768k
>>>>
>>>> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
>>>> poor choice.
>>>>
>>>> Have a look at the s400 for an example using the HiFi PLL. The axg was
>>>> restricted to a 68 PLL multiplier but the S4 is not so you should be
>>>> able to use a higher base rate (4 718 592 000 Hz), providing better
>>>> accuracy in the end
>>> for new soc audio ip, the hardware will not support the 
>>> 24bit(include g12a,
>>> sm1,axg)
>> That may be what you chose to support in your BSP but that not how it
>> works in mainline. 24bits slot width is supported and has been tested on
>> axg, g12 and sm1. This is not going away.
>>
>> I would find extremely odd that 24 bits slot width is not supported 
>> on s4,
>> but as long you document this, it is fine by me.
>
> i understand your meaning, you sad we configure the slot width 24bit 
> for tdmout control
>
> if the format the SNDRV_PCM_FMTBIT_S24,  it send the 24bit data, for 
> the format, and send the 24bit clock
>
> if tdmout control can cut out [24:0] from the fddr, maybe your right, 
> we can send the 24 bit accoring to the slot width
>
> but it can't confirm by us, we are worried that there may be potential 
> risks, so we don't use it thay way
>
> so this why i sad can't support the 24bit slot clock, 16/32 sample bit 
> is fully validated
>
>
i did some tests for the S24_LE format use the tdm base drvier

aplay -f S24_LE test.pcm -r48000 -c2

  # cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S24_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 6000
buffer_size: 24000

we dump the mclk

aud_mst_a_mclk       2       2        0        12288000 0          0     
50000      Y audio-controller-0              mclk

according to the base driver

in the api axg_tdm_set_tdm_slots function
switch (slot_width) {
     case 0:
         slot_width = 32;
         fallthrough;
         ...

if dts not configure "dai-tdm-slot-width"

it use the 32 bit slot width

the api -> axg_tdm_iface_set_sclk

srate = iface->slots * iface->slot_width * params_rate(params);

set mclk rate

we dump tdmout control register

# devmem 0xfe330500
0xB001003F

it set 32bit slot width to send

the base driver is the smae behavior that we wound expect,


>>> SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory
>> I think you are mixing up slot width and memory representation
>>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-15  2:56           ` Jiebing Chen
@ 2025-01-15  8:36             ` Jerome Brunet
  2025-01-15 10:36               ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-15  8:36 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Wed 15 Jan 2025 at 10:56, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

> 在 2025/1/14 22:05, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Tue 14 Jan 2025 at 19:20, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>>
>>>>>> +
>>>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>>>> +MODULE_LICENSE("GPL");
>>>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>>>> index
>>>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648
>>>>>> 100644
>>>>>> --- a/sound/soc/meson/t9015.c
>>>>>> +++ b/sound/soc/meson/t9015.c
>>>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>>>                 .channels_min = 1,
>>>>>>                 .channels_max = 2,
>>>>>>                 .rates = SNDRV_PCM_RATE_8000_96000,
>>>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>>>> Again, mixed up changes with zero justification.
>>>>>
>>>>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>>>>> which is known to work and add S32 support on an HW documented as 24bits
>>>>> only. Can you explain ?
>>> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,
>> If there are chips difference we did not know about, then you should
>> introduce those difference, without breaking existing support -
>> including for GXL, which is what you did IIUC.
>>
>>> the new ip not support 24 bit,
>> Are sure about that ? that code has been there for a while.
>>
>> If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix up patch for
>> that, with the proper "Fixes:" tag, how to reproduce the problem and
>> explaining the fix.
>
> maybe there are some gap , we support SNDRV_PCM_FMTBIT_S24, not support the
>
> SNDRV_PCM_FMTBIT_S24_3LE,  for SNDRV_PCM_FMTBIT_S24
>
> it is  Signed, 24-bit (32-bit in memory), little endian , the audio dma
> busrt is 64bit

It makes absolutely no sense to discuss memory layout for the codec.

>
> it can get the full data. we send the 32 bit data  mclk = 32bit* 48k *4, 
> use the clk to send
>
> the  SNDRV_PCM_FMTBIT_S24,   the hadware always send the 32bit data

No it does not. It send 24 bits of data over a 32 bits physical word with
8 bits ignored.

>
> so, i think we only add the SNDRV_PCM_FMTBIT_S32 base on it

That's wrong if the codec does not actually use the full 32bits ... and
I have clear indication that's what the codec is doing, on GXL at least.

>
> we think the 24 bit is the SNDRV_PCM_FMTBIT_S24_3LE, it is 24bit in memroy,
>
> due to the dma busrt 64 bit limit, it can't align the sample bit, if it is
> 24 bit

Again, memory layout makes no sense here.

>
> so the clock configure can't 24bit clock,

I disagree and this has been tested. If you have a test case showing
otherwise please share it.

> by the way, We discuss internally for gxl,
>
> it also support the SNDRV_PCM_FMTBIT_S32
>

Does it really ? If it is just to ignore the 8bits LSB, that not a support.

>
>>
>>> usually support 16/32 bit for new audio ip , for SNDRV_PCM_FMTBIT_S24_LE,
>>> it width =24, phy =32
>> Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 32 bits
>> width would support this S24_LE, unless there is something odd.
>>
>>> it was  treated as 32 bit to send for tdm, so we can only add the S32LE
>>> base on it , right ?
>> You are asking me ? How am I suppose to know ?
>>
>>> but if the gxl not support the 32bit
>> I don't see a problem with a DAC taking input on 32bits physical
>> interface and ignoring some bit on processing.
>>
>> If that's not the case, please send a proper fix change with some explanation
>>
>>> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>>>
>> If I understood correctly format depends on the chip and needs to
>> adjusted including for sm1.
>>
>>>>>>         },
>>>>>>         .ops = &t9015_dai_ops,
>>>>>>    };
>>>>> -- Jerome
>> --
>> Jerome

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-15  6:16               ` Jiebing Chen
@ 2025-01-15  8:43                 ` Jerome Brunet
  2025-01-15  9:56                   ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jerome Brunet @ 2025-01-15  8:43 UTC (permalink / raw)
  To: Jiebing Chen
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic

On Wed 15 Jan 2025 at 14:16, Jiebing Chen <jiebing.chen@amlogic.com> wrote:

> 在 2025/1/15 11:38, Jiebing Chen 写道:
>>
>> 在 2025/1/14 22:15, Jerome Brunet 写道:
>>> [ EXTERNAL EMAIL ]
>>>
>>> On Tue 14 Jan 2025 at 20:34, Jiebing Chen <jiebing.chen@amlogic.com>
>>> wrote:
>>>
>>>> 在 2025/1/14 19:16, Jerome Brunet 写道:
>>>>> [ EXTERNAL EMAIL ]
>>>>>
>>>>> On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com>
>>>>> wrote:
>>>>>
>>>>>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>>>>>> [ EXTERNAL EMAIL ]
>>>>>>>
>>>>>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay
>>>>>>> <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>>>>>
>>>>>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>>>
>>>>>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>>>>>> AQ222 board.
>>>>>>>>
>>>>>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>>> ---
>>>>>>>>     .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts | 226
>>>>>>>> ++++++++++++
>>>>>>>>     arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 385
>>>>>>>> ++++++++++++++++++++-
>>>>>>>>     2 files changed, 610 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>> b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>> index
>>>>>>>> 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130
>>>>>>>> 100644
>>>>>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>>>>>                 regulator-always-on;
>>>>>>>>          };
>>>>>>>>
>>>>>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>>>>>> +             compatible = "regulator-fixed";
>>>>>>>> +             vin-supply = <&main_12v>;
>>>>>>>> +             regulator-name = "VCC5V";
>>>>>>>> +             regulator-min-microvolt = <5000000>;
>>>>>>>> +             regulator-max-microvolt = <5000000>;
>>>>>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>>>>>> +             startup-delay-us = <7000>;
>>>>>>>> +             enable-active-high;
>>>>>>>> +             regulator-boot-on;
>>>>>>>> +             regulator-always-on;
>>>>>>>> +     };
>>>>>>>> +
>>>>>>>>          /* SY8120B1ABC DC/DC Regulator. */
>>>>>>>>          vddcpu: regulator-vddcpu {
>>>>>>>>                  compatible = "pwm-regulator";
>>>>>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>>>>>                                  <699000 98>,
>>>>>>>>                                  <689000 100>;
>>>>>>>>          };
>>>>>>>> +     dmics: audio-codec-1 {
>>>>>>>> +             compatible = "dmic-codec";
>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>> +             num-channels = <2>;
>>>>>>>> +             wakeup-delay-ms = <50>;
>>>>>>>> +             sound-name-prefix = "MIC";
>>>>>>>> +     };
>>>>>>>> +
>>>>>>>> +     dioo2133: audio-amplifier-0 {
>>>>>>>> +             compatible = "simple-audio-amplifier";
>>>>>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>>>>>> +             VCC-supply = <&vcc5v_reg>;
>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>> +             sound-name-prefix = "10U2";
>>>>>>>> +     };
>>>>>>>> +
>>>>>>>> +     spdif_dir: audio-spdif-in {
>>>>>>>> +             compatible = "linux,spdif-dir";
>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>> +             sound-name-prefix = "DIR";
>>>>>>>> +     };
>>>>>>>> +
>>>>>>>> +     spdif_dit: audio-spdif-out {
>>>>>>>> +             compatible = "linux,spdif-dit";
>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>> +             sound-name-prefix = "DIT";
>>>>>>>> +     };
>>>>>>>> +
>>>>>>>> +     sound {
>>>>>>>> +             compatible = "amlogic,axg-sound-card";
>>>>>>>> +             model = "aq222";
>>>>>>>> +             audio-widgets = "Line", "Lineout";
>>>>>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>,
>>>>>>>> <&tdmout_c>,
>>>>>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>>>>>> +                              <&tdmin_lb>, <&dioo2133>,
>>>>>>>> <&tdmout_pad>, <&toacodec>;
>>>>>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>>>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>>>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>>>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>>>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>>>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>>>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>>>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>>>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>>>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>>>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>>>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>>>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>>>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>>>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>>>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>>>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>>>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>>>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>>>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>>>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>>>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>>>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>>>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>>>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>>>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>>>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>>>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>>>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>>>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>>>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>>>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>>>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>>>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>>>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>>>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>>>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>>>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>>>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>>>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>>>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>>>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>>>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>>>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>>>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>>>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>>>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>>>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>>>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>>>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>>>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>>>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>>>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>>>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>>>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>>>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>>>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>>>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>>>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>>>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>>>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>>>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>>>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>>>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>>>>>> +                             "10U2 INR", "ACODEC LORP",
>>>>>>>> +                             "Lineout", "10U2 OUTL",
>>>>>>>> +                             "Lineout", "10U2 OUTR";
>>>>>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>>>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>>>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>>>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>>>>>> +             assigned-clock-rates = <491520000>,
>>>>>>>> + <294912000>,
>>>>>>>> + <270950400>,
>>>>>>>> + <393216000>;
>>>>>>> Why do you need 4 base rates ? Which rate family does each provide ?
>>>>>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000,
>>>>>> the
>>>>>> accuracy of hifipll
>>>>>>
>>>>>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if
>>>>>> the
>>>>>> tdm and spdif work on
>>>>> It is fine to use the HiFi. I'm glad this clock finally got fixed
>>>>>
>>>>>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the
>>>>>> same
>>>>>> pll, so spdif need use the mpll 0
>>>>>>
>>>>>> other pll , only set a default value, at the latest chip, we remove
>>>>>> all
>>>>>> mpll for hardware, only two hifipll
>>>>> I'm not sure you understand how this works.
>>>>> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>>>>>
>>>>> Each family needs a PLL assigned, so you need 3, not 4, unless there
>>>>> is
>>>>> another specific rate family you want to support. If that's the case,
>>>>> document it.
>>>>>
>>>>> Setting the rate of the PLL should follow this principle:
>>>>> * Family rate
>>>>>     - multiplied by (32 x 24): to accomodate different sample sizes
>>>>>     - multiplied by 2 until you reach the maximum rate of selected
>>>>> PLLs
>>>>>       This allows to support rates such 192k or even 768k
>>>>>
>>>>> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
>>>>> poor choice.
>>>>>
>>>>> Have a look at the s400 for an example using the HiFi PLL. The axg was
>>>>> restricted to a 68 PLL multiplier but the S4 is not so you should be
>>>>> able to use a higher base rate (4 718 592 000 Hz), providing better
>>>>> accuracy in the end
>>>> for new soc audio ip, the hardware will not support the 24bit(include
>>>> g12a,
>>>> sm1,axg)
>>> That may be what you chose to support in your BSP but that not how it
>>> works in mainline. 24bits slot width is supported and has been tested on
>>> axg, g12 and sm1. This is not going away.
>>>
>>> I would find extremely odd that 24 bits slot width is not supported on
>>> s4,
>>> but as long you document this, it is fine by me.
>>
>> i understand your meaning, you sad we configure the slot width 24bit for
>> tdmout control
>>
>> if the format the SNDRV_PCM_FMTBIT_S24,  it send the 24bit data, for the
>> format, and send the 24bit clock
>>
>> if tdmout control can cut out [24:0] from the fddr, maybe your right, we
>> can send the 24 bit accoring to the slot width
>>
>> but it can't confirm by us, we are worried that there may be potential
>> risks, so we don't use it thay way
>>
>> so this why i sad can't support the 24bit slot clock, 16/32 sample bit is
>> fully validated
>>
>>
> i did some tests for the S24_LE format use the tdm base drvier
>
> aplay -f S24_LE test.pcm -r48000 -c2
>
>  # cat /proc/asound/card0/pcm0p/sub0/hw_params
> access: RW_INTERLEAVED
> format: S24_LE
> subformat: STD
> channels: 2
> rate: 48000 (48000/1)
> period_size: 6000
> buffer_size: 24000
>
> we dump the mclk
>
> aud_mst_a_mclk       2       2        0        12288000 0          0    
> 50000      Y audio-controller-0              mclk
>
> according to the base driver
>
> in the api axg_tdm_set_tdm_slots function
> switch (slot_width) {
>     case 0:
>         slot_width = 32;

32 bits is the default slot width if none is specified, yes. So ?

>         fallthrough;
>         ...
>
> if dts not configure "dai-tdm-slot-width"
>
> it use the 32 bit slot width
>
> the api -> axg_tdm_iface_set_sclk
>
> srate = iface->slots * iface->slot_width * params_rate(params);
>
> set mclk rate
>
> we dump tdmout control register
>
> # devmem 0xfe330500
> 0xB001003F
>
> it set 32bit slot width to send
>
> the base driver is the smae behavior that we wound expect,

The driver set a slot width of 32 bits because you did choose any and
then behave as it should.

I don't get your point here or what such test is supposed to show.

You did not test 24bits slot width at all.

>
>
>>>> SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory
>>> I think you are mixing up slot width and memory representation
>>>

-- 
Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio
  2025-01-15  8:43                 ` Jerome Brunet
@ 2025-01-15  9:56                   ` Jiebing Chen
  0 siblings, 0 replies; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15  9:56 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/15 16:43, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Wed 15 Jan 2025 at 14:16, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>> 在 2025/1/15 11:38, Jiebing Chen 写道:
>>> 在 2025/1/14 22:15, Jerome Brunet 写道:
>>>> [ EXTERNAL EMAIL ]
>>>>
>>>> On Tue 14 Jan 2025 at 20:34, Jiebing Chen <jiebing.chen@amlogic.com>
>>>> wrote:
>>>>
>>>>> 在 2025/1/14 19:16, Jerome Brunet 写道:
>>>>>> [ EXTERNAL EMAIL ]
>>>>>>
>>>>>> On Tue 14 Jan 2025 at 16:52, Jiebing Chen <jiebing.chen@amlogic.com>
>>>>>> wrote:
>>>>>>
>>>>>>> 在 2025/1/13 22:50, Jerome Brunet 写道:
>>>>>>>> [ EXTERNAL EMAIL ]
>>>>>>>>
>>>>>>>> On Mon 13 Jan 2025 at 14:35, jiebing chen via B4 Relay
>>>>>>>> <devnull+jiebing.chen.amlogic.com@kernel.org> wrote:
>>>>>>>>
>>>>>>>>> From: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>>>>
>>>>>>>>> Add basic audio driver support for the Amlogic S4 based Amlogic
>>>>>>>>> AQ222 board.
>>>>>>>>>
>>>>>>>>> Signed-off-by: jiebing chen <jiebing.chen@amlogic.com>
>>>>>>>>> ---
>>>>>>>>>      .../boot/dts/amlogic/meson-s4-s805x2-aq222.dts | 226
>>>>>>>>> ++++++++++++
>>>>>>>>>      arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 385
>>>>>>>>> ++++++++++++++++++++-
>>>>>>>>>      2 files changed, 610 insertions(+), 1 deletion(-)
>>>>>>>>>
>>>>>>>>> diff --git a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>> b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>>> index
>>>>>>>>> 6730c44642d2910d42ec0c4adf49fefc3514dbec..32f50a5b860435d50d9c5528b43422b705b20130
>>>>>>>>> 100644
>>>>>>>>> --- a/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>>> +++ b/arch/arm64/boot/dts/amlogic/meson-s4-s805x2-aq222.dts
>>>>>>>>> @@ -75,6 +75,19 @@ vddio_ao1v8: regulator-vddio-ao1v8 {
>>>>>>>>>                  regulator-always-on;
>>>>>>>>>           };
>>>>>>>>>
>>>>>>>>> +     vcc5v_reg: regulator-vcc-5v {
>>>>>>>>> +             compatible = "regulator-fixed";
>>>>>>>>> +             vin-supply = <&main_12v>;
>>>>>>>>> +             regulator-name = "VCC5V";
>>>>>>>>> +             regulator-min-microvolt = <5000000>;
>>>>>>>>> +             regulator-max-microvolt = <5000000>;
>>>>>>>>> +             gpio = <&gpio GPIOH_7 GPIO_ACTIVE_HIGH>;
>>>>>>>>> +             startup-delay-us = <7000>;
>>>>>>>>> +             enable-active-high;
>>>>>>>>> +             regulator-boot-on;
>>>>>>>>> +             regulator-always-on;
>>>>>>>>> +     };
>>>>>>>>> +
>>>>>>>>>           /* SY8120B1ABC DC/DC Regulator. */
>>>>>>>>>           vddcpu: regulator-vddcpu {
>>>>>>>>>                   compatible = "pwm-regulator";
>>>>>>>>> @@ -129,6 +142,219 @@ vddcpu: regulator-vddcpu {
>>>>>>>>>                                   <699000 98>,
>>>>>>>>>                                   <689000 100>;
>>>>>>>>>           };
>>>>>>>>> +     dmics: audio-codec-1 {
>>>>>>>>> +             compatible = "dmic-codec";
>>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>>> +             num-channels = <2>;
>>>>>>>>> +             wakeup-delay-ms = <50>;
>>>>>>>>> +             sound-name-prefix = "MIC";
>>>>>>>>> +     };
>>>>>>>>> +
>>>>>>>>> +     dioo2133: audio-amplifier-0 {
>>>>>>>>> +             compatible = "simple-audio-amplifier";
>>>>>>>>> +             enable-gpios = <&gpio GPIOH_8 GPIO_ACTIVE_HIGH>;
>>>>>>>>> +             VCC-supply = <&vcc5v_reg>;
>>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>>> +             sound-name-prefix = "10U2";
>>>>>>>>> +     };
>>>>>>>>> +
>>>>>>>>> +     spdif_dir: audio-spdif-in {
>>>>>>>>> +             compatible = "linux,spdif-dir";
>>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>>> +             sound-name-prefix = "DIR";
>>>>>>>>> +     };
>>>>>>>>> +
>>>>>>>>> +     spdif_dit: audio-spdif-out {
>>>>>>>>> +             compatible = "linux,spdif-dit";
>>>>>>>>> +             #sound-dai-cells = <0>;
>>>>>>>>> +             sound-name-prefix = "DIT";
>>>>>>>>> +     };
>>>>>>>>> +
>>>>>>>>> +     sound {
>>>>>>>>> +             compatible = "amlogic,axg-sound-card";
>>>>>>>>> +             model = "aq222";
>>>>>>>>> +             audio-widgets = "Line", "Lineout";
>>>>>>>>> +             audio-aux-devs = <&tdmout_a>, <&tdmout_b>,
>>>>>>>>> <&tdmout_c>,
>>>>>>>>> +                              <&tdmin_a>, <&tdmin_b>, <&tdmin_c>,
>>>>>>>>> +                              <&tdmin_lb>, <&dioo2133>,
>>>>>>>>> <&tdmout_pad>, <&toacodec>;
>>>>>>>>> +             audio-routing = "TDMOUT_A IN 0", "FRDDR_A OUT 0",
>>>>>>>>> +                             "TDMOUT_A IN 1", "FRDDR_B OUT 0",
>>>>>>>>> +                             "TDMOUT_A IN 2", "FRDDR_C OUT 0",
>>>>>>>>> +                             "TDM_A Playback", "TDMOUT_A OUT",
>>>>>>>>> +                             "TDMA_OUT SEL",   "TDM_A Playback",
>>>>>>>>> +                             "TDMOUT_B IN 0", "FRDDR_A OUT 1",
>>>>>>>>> +                             "TDMOUT_B IN 1", "FRDDR_B OUT 1",
>>>>>>>>> +                             "TDMOUT_B IN 2", "FRDDR_C OUT 1",
>>>>>>>>> +                             "TDM_B Playback", "TDMOUT_B OUT",
>>>>>>>>> +                             "TDMB_OUT SEL",   "TDM_B Playback",
>>>>>>>>> +                             "TDMOUT_C IN 0", "FRDDR_A OUT 2",
>>>>>>>>> +                             "TDMOUT_C IN 1", "FRDDR_B OUT 2",
>>>>>>>>> +                             "TDMOUT_C IN 2", "FRDDR_C OUT 2",
>>>>>>>>> +                             "TDM_C Playback", "TDMOUT_C OUT",
>>>>>>>>> +                             "TDMC_OUT SEL",   "TDM_C Playback",
>>>>>>>>> +                             "TOACODEC TDMA", "TDM_A Playback",
>>>>>>>>> +                             "TOACODEC TDMB", "TDM_B Playback",
>>>>>>>>> +                             "TOACODEC TDMC", "TDM_C Playback",
>>>>>>>>> +                             "SPDIFOUT_A IN 0", "FRDDR_A OUT 3",
>>>>>>>>> +                             "SPDIFOUT_A IN 1", "FRDDR_B OUT 3",
>>>>>>>>> +                             "SPDIFOUT_A IN 2", "FRDDR_C OUT 3",
>>>>>>>>> +                             "SPDIFOUT_B IN 0", "FRDDR_A OUT 4",
>>>>>>>>> +                             "SPDIFOUT_B IN 1", "FRDDR_B OUT 4",
>>>>>>>>> +                             "SPDIFOUT_B IN 2", "FRDDR_C OUT 4",
>>>>>>>>> +                             "TDMIN_A IN 0", "TDM_A Capture",
>>>>>>>>> +                             "TDMIN_A IN 1", "TDM_B Capture",
>>>>>>>>> +                             "TDMIN_A IN 2", "TDM_C Capture",
>>>>>>>>> +                             "TDMIN_A IN 3", "TDM_A Loopback",
>>>>>>>>> +                             "TDMIN_A IN 4", "TDM_B Loopback",
>>>>>>>>> +                             "TDMIN_A IN 5", "TDM_C Loopback",
>>>>>>>>> +                             "TDMIN_B IN 0", "TDM_A Capture",
>>>>>>>>> +                             "TDMIN_B IN 1", "TDM_B Capture",
>>>>>>>>> +                             "TDMIN_B IN 2", "TDM_C Capture",
>>>>>>>>> +                             "TDMIN_B IN 3", "TDM_A Loopback",
>>>>>>>>> +                             "TDMIN_B IN 4", "TDM_B Loopback",
>>>>>>>>> +                             "TDMIN_B IN 5", "TDM_C Loopback",
>>>>>>>>> +                             "TDMIN_C IN 0", "TDM_A Capture",
>>>>>>>>> +                             "TDMIN_C IN 1", "TDM_B Capture",
>>>>>>>>> +                             "TDMIN_C IN 2", "TDM_C Capture",
>>>>>>>>> +                             "TDMIN_C IN 3", "TDM_A Loopback",
>>>>>>>>> +                             "TDMIN_C IN 4", "TDM_B Loopback",
>>>>>>>>> +                             "TDMIN_C IN 5", "TDM_C Loopback",
>>>>>>>>> +                             "TDMIN_LB IN 3", "TDM_A Capture",
>>>>>>>>> +                             "TDMIN_LB IN 4", "TDM_B Capture",
>>>>>>>>> +                             "TDMIN_LB IN 5", "TDM_C Capture",
>>>>>>>>> +                             "TDMIN_LB IN 0", "TDM_A Loopback",
>>>>>>>>> +                             "TDMIN_LB IN 1", "TDM_B Loopback",
>>>>>>>>> +                             "TDMIN_LB IN 2", "TDM_C Loopback",
>>>>>>>>> +                             "TODDR_A IN 0", "TDMIN_A OUT",
>>>>>>>>> +                             "TODDR_B IN 0", "TDMIN_A OUT",
>>>>>>>>> +                             "TODDR_C IN 0", "TDMIN_A OUT",
>>>>>>>>> +                             "TODDR_A IN 1", "TDMIN_B OUT",
>>>>>>>>> +                             "TODDR_B IN 1", "TDMIN_B OUT",
>>>>>>>>> +                             "TODDR_C IN 1", "TDMIN_B OUT",
>>>>>>>>> +                             "TODDR_A IN 2", "TDMIN_C OUT",
>>>>>>>>> +                             "TODDR_B IN 2", "TDMIN_C OUT",
>>>>>>>>> +                             "TODDR_C IN 2", "TDMIN_C OUT",
>>>>>>>>> +                             "TODDR_A IN 3", "SPDIFIN Capture",
>>>>>>>>> +                             "TODDR_B IN 3", "SPDIFIN Capture",
>>>>>>>>> +                             "TODDR_C IN 3", "SPDIFIN Capture",
>>>>>>>>> +                             "TODDR_A IN 6", "TDMIN_LB OUT",
>>>>>>>>> +                             "TODDR_B IN 6", "TDMIN_LB OUT",
>>>>>>>>> +                             "TODDR_C IN 6", "TDMIN_LB OUT",
>>>>>>>>> +                             "10U2 INL", "ACODEC LOLP",
>>>>>>>>> +                             "10U2 INR", "ACODEC LORP",
>>>>>>>>> +                             "Lineout", "10U2 OUTL",
>>>>>>>>> +                             "Lineout", "10U2 OUTR";
>>>>>>>>> +             assigned-clocks = <&clkc_pll CLKID_HIFI_PLL>,
>>>>>>>>> +                               <&clkc_pll CLKID_MPLL2>,
>>>>>>>>> +                               <&clkc_pll CLKID_MPLL0>,
>>>>>>>>> +                               <&clkc_pll CLKID_MPLL1>;
>>>>>>>>> +             assigned-clock-rates = <491520000>,
>>>>>>>>> + <294912000>,
>>>>>>>>> + <270950400>,
>>>>>>>>> + <393216000>;
>>>>>>>> Why do you need 4 base rates ? Which rate family does each provide ?
>>>>>>> hifipll 49152000, mpll2 294912000 mpll0 270950400, mpll1 393216000,
>>>>>>> the
>>>>>>> accuracy of hifipll
>>>>>>>
>>>>>>> is relatively high, for tdm/pdm/spdif 16/48/96/192k we can use it. if
>>>>>>> the
>>>>>>> tdm and spdif work on
>>>>>> It is fine to use the HiFi. I'm glad this clock finally got fixed
>>>>>>
>>>>>>> the same time, for example ,tdm 48k. spdif 44.1k, we can't use the
>>>>>>> same
>>>>>>> pll, so spdif need use the mpll 0
>>>>>>>
>>>>>>> other pll , only set a default value, at the latest chip, we remove
>>>>>>> all
>>>>>>> mpll for hardware, only two hifipll
>>>>>> I'm not sure you understand how this works.
>>>>>> There is 3 families of audio rate: 48kHz, 44.1kHz and 32kHz
>>>>>>
>>>>>> Each family needs a PLL assigned, so you need 3, not 4, unless there
>>>>>> is
>>>>>> another specific rate family you want to support. If that's the case,
>>>>>> document it.
>>>>>>
>>>>>> Setting the rate of the PLL should follow this principle:
>>>>>> * Family rate
>>>>>>      - multiplied by (32 x 24): to accomodate different sample sizes
>>>>>>      - multiplied by 2 until you reach the maximum rate of selected
>>>>>> PLLs
>>>>>>        This allows to support rates such 192k or even 768k
>>>>>>
>>>>>> 491520000 is not dividable by 3, it won't allow 24 bits words. It is a
>>>>>> poor choice.
>>>>>>
>>>>>> Have a look at the s400 for an example using the HiFi PLL. The axg was
>>>>>> restricted to a 68 PLL multiplier but the S4 is not so you should be
>>>>>> able to use a higher base rate (4 718 592 000 Hz), providing better
>>>>>> accuracy in the end
>>>>> for new soc audio ip, the hardware will not support the 24bit(include
>>>>> g12a,
>>>>> sm1,axg)
>>>> That may be what you chose to support in your BSP but that not how it
>>>> works in mainline. 24bits slot width is supported and has been tested on
>>>> axg, g12 and sm1. This is not going away.
>>>>
>>>> I would find extremely odd that 24 bits slot width is not supported on
>>>> s4,
>>>> but as long you document this, it is fine by me.
>>> i understand your meaning, you sad we configure the slot width 24bit for
>>> tdmout control
>>>
>>> if the format the SNDRV_PCM_FMTBIT_S24,  it send the 24bit data, for the
>>> format, and send the 24bit clock
>>>
>>> if tdmout control can cut out [24:0] from the fddr, maybe your right, we
>>> can send the 24 bit accoring to the slot width
>>>
>>> but it can't confirm by us, we are worried that there may be potential
>>> risks, so we don't use it thay way
>>>
>>> so this why i sad can't support the 24bit slot clock, 16/32 sample bit is
>>> fully validated
>>>
>>>
>> i did some tests for the S24_LE format use the tdm base drvier
>>
>> aplay -f S24_LE test.pcm -r48000 -c2
>>
>>   # cat /proc/asound/card0/pcm0p/sub0/hw_params
>> access: RW_INTERLEAVED
>> format: S24_LE
>> subformat: STD
>> channels: 2
>> rate: 48000 (48000/1)
>> period_size: 6000
>> buffer_size: 24000
>>
>> we dump the mclk
>>
>> aud_mst_a_mclk       2       2        0        12288000 0          0
>> 50000      Y audio-controller-0              mclk
>>
>> according to the base driver
>>
>> in the api axg_tdm_set_tdm_slots function
>> switch (slot_width) {
>>      case 0:
>>          slot_width = 32;
> 32 bits is the default slot width if none is specified, yes. So ?
>
>>          fallthrough;
>>          ...
>>
>> if dts not configure "dai-tdm-slot-width"
>>
>> it use the 32 bit slot width
>>
>> the api -> axg_tdm_iface_set_sclk
>>
>> srate = iface->slots * iface->slot_width * params_rate(params);
>>
>> set mclk rate
>>
>> we dump tdmout control register
>>
>> # devmem 0xfe330500
>> 0xB001003F
>>
>> it set 32bit slot width to send
>>
>> the base driver is the smae behavior that we wound expect,
> The driver set a slot width of 32 bits because you did choose any and
> then behave as it should.
>
> I don't get your point here or what such test is supposed to show.
>
> You did not test 24bits slot width at all.

we focus on why hifipll set 49152000 for S24_LE format, why not to  set 
the slot width = 24

we consider that 24-bit probably hasn't done a lot of testing, suggest  
slot width =32

tdmout cut out fddr[23:0], set slot width = 24, fddr msb = 23

we can support it, but can't sure the tdmout 24bit function can work for 
long time

it need to test for many time , so we just think it can send 24bit with 
8 bit zero for data lane,

if must be send 24 bit data with zero data

we need support the 24 bit clock pll

24 *32* 2 * 768k  = 1179.648M

4 718 592 000 Hz you suggested maybe is out of range hififpll

i think the 1179.648M is more suitable, Do you think so?

if you agree, we ask clk owner to add it




>
>>
>>>>> SNDRV_PCM_FMTBIT_S24_3LE, 24 bit in memory
>>>> I think you are mixing up slot width and memory representation
>>>>
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-15  8:36             ` Jerome Brunet
@ 2025-01-15 10:36               ` Jiebing Chen
  2025-01-15 11:47                 ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15 10:36 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/15 16:36, Jerome Brunet 写道:
> [ EXTERNAL EMAIL ]
>
> On Wed 15 Jan 2025 at 10:56, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>
>> 在 2025/1/14 22:05, Jerome Brunet 写道:
>>> [ EXTERNAL EMAIL ]
>>>
>>> On Tue 14 Jan 2025 at 19:20, Jiebing Chen <jiebing.chen@amlogic.com> wrote:
>>>
>>>>>>> +
>>>>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>>>>> +MODULE_LICENSE("GPL");
>>>>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>>>>> index
>>>>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648
>>>>>>> 100644
>>>>>>> --- a/sound/soc/meson/t9015.c
>>>>>>> +++ b/sound/soc/meson/t9015.c
>>>>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>>>>                  .channels_min = 1,
>>>>>>>                  .channels_max = 2,
>>>>>>>                  .rates = SNDRV_PCM_RATE_8000_96000,
>>>>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>>>>> Again, mixed up changes with zero justification.
>>>>>>
>>>>>> This drops S8 and S16 format support for the existing SoCs (such as GXL)
>>>>>> which is known to work and add S32 support on an HW documented as 24bits
>>>>>> only. Can you explain ?
>>>> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,
>>> If there are chips difference we did not know about, then you should
>>> introduce those difference, without breaking existing support -
>>> including for GXL, which is what you did IIUC.
>>>
>>>> the new ip not support 24 bit,
>>> Are sure about that ? that code has been there for a while.
>>>
>>> If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix up patch for
>>> that, with the proper "Fixes:" tag, how to reproduce the problem and
>>> explaining the fix.
>> maybe there are some gap , we support SNDRV_PCM_FMTBIT_S24, not support the
>>
>> SNDRV_PCM_FMTBIT_S24_3LE,  for SNDRV_PCM_FMTBIT_S24
>>
>> it is  Signed, 24-bit (32-bit in memory), little endian , the audio dma
>> busrt is 64bit
> It makes absolutely no sense to discuss memory layout for the codec.
>
>> it can get the full data. we send the 32 bit data  mclk = 32bit* 48k *4,
>> use the clk to send
>>
>> the  SNDRV_PCM_FMTBIT_S24,   the hadware always send the 32bit data
> No it does not. It send 24 bits of data over a 32 bits physical word with
> 8 bits ignored.

The original intention, we play 32bit data from tdmout, it play error, 
so we add the s32_le

for tdmouta ,it can bind Multiple codec, one codec is the internal codec,

other is external codec, tdmout can send the data to internal codec and 
external codec from the output pad

for example, tdmout send 4 ch, 2 ch is send the internal codec, 2 ch 
send the data pad

it aplay error, due to the internal codec fomat parameter limiting condition

There is a contradiction here,  Considering our internal can process 
this it, drop 8bit, 24bit valid

therefore software can set s24_le/s32_le, still  work ok for hardware, 
so Multiple ch can support for internal codec and external codec


>
>> so, i think we only add the SNDRV_PCM_FMTBIT_S32 base on it
> That's wrong if the codec does not actually use the full 32bits ... and
> I have clear indication that's what the codec is doing, on GXL at least.
>
>> we think the 24 bit is the SNDRV_PCM_FMTBIT_S24_3LE, it is 24bit in memroy,
>>
>> due to the dma busrt 64 bit limit, it can't align the sample bit, if it is
>> 24 bit
> Again, memory layout makes no sense here.
>
>> so the clock configure can't 24bit clock,
> I disagree and this has been tested. If you have a test case showing
> otherwise please share it.
>
>> by the way, We discuss internally for gxl,
>>
>> it also support the SNDRV_PCM_FMTBIT_S32
>>
> Does it really ? If it is just to ignore the 8bits LSB, that not a support.
>
>>>> usually support 16/32 bit for new audio ip , for SNDRV_PCM_FMTBIT_S24_LE,
>>>> it width =24, phy =32
>>> Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 32 bits
>>> width would support this S24_LE, unless there is something odd.
>>>
>>>> it was  treated as 32 bit to send for tdm, so we can only add the S32LE
>>>> base on it , right ?
>>> You are asking me ? How am I suppose to know ?
>>>
>>>> but if the gxl not support the 32bit
>>> I don't see a problem with a DAC taking input on 32bits physical
>>> interface and ignoring some bit on processing.
>>>
>>> If that's not the case, please send a proper fix change with some explanation
>>>
>>>> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>>>>
>>> If I understood correctly format depends on the chip and needs to
>>> adjusted including for sm1.
>>>
>>>>>>>          },
>>>>>>>          .ops = &t9015_dai_ops,
>>>>>>>     };
>>>>>> -- Jerome
>>> --
>>> Jerome
> --
> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-15 10:36               ` Jiebing Chen
@ 2025-01-15 11:47                 ` Jiebing Chen
  2025-01-15 12:09                   ` Jiebing Chen
  0 siblings, 1 reply; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15 11:47 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/15 18:36, Jiebing Chen 写道:
>
> 在 2025/1/15 16:36, Jerome Brunet 写道:
>> [ EXTERNAL EMAIL ]
>>
>> On Wed 15 Jan 2025 at 10:56, Jiebing Chen <jiebing.chen@amlogic.com> 
>> wrote:
>>
>>> 在 2025/1/14 22:05, Jerome Brunet 写道:
>>>> [ EXTERNAL EMAIL ]
>>>>
>>>> On Tue 14 Jan 2025 at 19:20, Jiebing Chen 
>>>> <jiebing.chen@amlogic.com> wrote:
>>>>
>>>>>>>> +
>>>>>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>>>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>>>>>> +MODULE_LICENSE("GPL");
>>>>>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>>>>>> index
>>>>>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 
>>>>>>>>
>>>>>>>> 100644
>>>>>>>> --- a/sound/soc/meson/t9015.c
>>>>>>>> +++ b/sound/soc/meson/t9015.c
>>>>>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>>>>>                  .channels_min = 1,
>>>>>>>>                  .channels_max = 2,
>>>>>>>>                  .rates = SNDRV_PCM_RATE_8000_96000,
>>>>>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>>>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>>>>>> -                         SNDRV_PCM_FMTBIT_S24_LE),
>>>>>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>>>>>> Again, mixed up changes with zero justification.
>>>>>>>
>>>>>>> This drops S8 and S16 format support for the existing SoCs (such 
>>>>>>> as GXL)
>>>>>>> which is known to work and add S32 support on an HW documented 
>>>>>>> as 24bits
>>>>>>> only. Can you explain ?
>>>>> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,
>>>> If there are chips difference we did not know about, then you should
>>>> introduce those difference, without breaking existing support -
>>>> including for GXL, which is what you did IIUC.
>>>>
>>>>> the new ip not support 24 bit,
>>>> Are sure about that ? that code has been there for a while.
>>>>
>>>> If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix 
>>>> up patch for
>>>> that, with the proper "Fixes:" tag, how to reproduce the problem and
>>>> explaining the fix.
>>> maybe there are some gap , we support SNDRV_PCM_FMTBIT_S24, not 
>>> support the
>>>
>>> SNDRV_PCM_FMTBIT_S24_3LE,  for SNDRV_PCM_FMTBIT_S24
>>>
>>> it is  Signed, 24-bit (32-bit in memory), little endian , the audio dma
>>> busrt is 64bit
>> It makes absolutely no sense to discuss memory layout for the codec.
>>
>>> it can get the full data. we send the 32 bit data  mclk = 32bit* 48k 
>>> *4,
>>> use the clk to send
>>>
>>> the  SNDRV_PCM_FMTBIT_S24,   the hadware always send the 32bit data
>> No it does not. It send 24 bits of data over a 32 bits physical word 
>> with
>> 8 bits ignored.
>
> The original intention, we play 32bit data from tdmout, it play error, 
> so we add the s32_le
>
> for tdmouta ,it can bind Multiple codec, one codec is the internal codec,
>
> other is external codec, tdmout can send the data to internal codec 
> and external codec from the output pad
>
> for example, tdmout send 4 ch, 2 ch is send the internal codec, 2 ch 
> send the data pad
>
> it aplay error, due to the internal codec fomat parameter limiting 
> condition
>
> There is a contradiction here,  Considering our internal codec can 
> process this it, drop 8bit, 24bit valid
>
> therefore software can set s24_le/s32_le, still  work ok for hardware, 
> so Multiple ch can support for internal codec and external codec
>
>
add the s32_le format for the t9015.c,  it can resovle Multiple codec 
s32_le format case,  although hardware only process 24bit of 32bit, but 
it can't affect the acodec hardware work, it still work fine

usually we add the s32_le format support, if not allow to do it, think 
of it as a limitation, we can  remove 32bit test for it

>>
>>> so, i think we only add the SNDRV_PCM_FMTBIT_S32 base on it
>> That's wrong if the codec does not actually use the full 32bits ... and
>> I have clear indication that's what the codec is doing, on GXL at least.
>>
>>> we think the 24 bit is the SNDRV_PCM_FMTBIT_S24_3LE, it is 24bit in 
>>> memroy,
>>>
>>> due to the dma busrt 64 bit limit, it can't align the sample bit, if 
>>> it is
>>> 24 bit
>> Again, memory layout makes no sense here.
>>
>>> so the clock configure can't 24bit clock,
>> I disagree and this has been tested. If you have a test case showing
>> otherwise please share it.
>>
>>> by the way, We discuss internally for gxl,
>>>
>>> it also support the SNDRV_PCM_FMTBIT_S32
>>>
>> Does it really ? If it is just to ignore the 8bits LSB, that not a 
>> support.
>>
>>>>> usually support 16/32 bit for new audio ip , for 
>>>>> SNDRV_PCM_FMTBIT_S24_LE,
>>>>> it width =24, phy =32
>>>> Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 32 
>>>> bits
>>>> width would support this S24_LE, unless there is something odd.
>>>>
>>>>> it was  treated as 32 bit to send for tdm, so we can only add the 
>>>>> S32LE
>>>>> base on it , right ?
>>>> You are asking me ? How am I suppose to know ?
>>>>
>>>>> but if the gxl not support the 32bit
>>>> I don't see a problem with a DAC taking input on 32bits physical
>>>> interface and ignoring some bit on processing.
>>>>
>>>> If that's not the case, please send a proper fix change with some 
>>>> explanation
>>>>
>>>>> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>>>>>
>>>> If I understood correctly format depends on the chip and needs to
>>>> adjusted including for sm1.
>>>>
>>>>>>>>          },
>>>>>>>>          .ops = &t9015_dai_ops,
>>>>>>>>     };
>>>>>>> -- Jerome
>>>> -- 
>>>> Jerome
>> -- 
>> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio
  2025-01-15 11:47                 ` Jiebing Chen
@ 2025-01-15 12:09                   ` Jiebing Chen
  0 siblings, 0 replies; 27+ messages in thread
From: Jiebing Chen @ 2025-01-15 12:09 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: jiebing chen via B4 Relay, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai,
	Neil Armstrong, Kevin Hilman, Martin Blumenstingl, linux-sound,
	devicetree, linux-kernel, linux-arm-kernel, linux-amlogic


在 2025/1/15 19:47, Jiebing Chen 写道:
>
> 在 2025/1/15 18:36, Jiebing Chen 写道:
>>
>> 在 2025/1/15 16:36, Jerome Brunet 写道:
>>> [ EXTERNAL EMAIL ]
>>>
>>> On Wed 15 Jan 2025 at 10:56, Jiebing Chen <jiebing.chen@amlogic.com> 
>>> wrote:
>>>
>>>> 在 2025/1/14 22:05, Jerome Brunet 写道:
>>>>> [ EXTERNAL EMAIL ]
>>>>>
>>>>> On Tue 14 Jan 2025 at 19:20, Jiebing Chen 
>>>>> <jiebing.chen@amlogic.com> wrote:
>>>>>
>>>>>>>>> +
>>>>>>>>> +MODULE_DESCRIPTION("Amlogic to codec driver");
>>>>>>>>> +MODULE_AUTHOR("jiebing.chen@amlogic.com");
>>>>>>>>> +MODULE_LICENSE("GPL");
>>>>>>>>> diff --git a/sound/soc/meson/t9015.c b/sound/soc/meson/t9015.c
>>>>>>>>> index
>>>>>>>>> 571f65788c592050abdca264f5656d4d1a9d99f6..2db1cd18cf2cea507f3d7282054e03d953586648 
>>>>>>>>>
>>>>>>>>> 100644
>>>>>>>>> --- a/sound/soc/meson/t9015.c
>>>>>>>>> +++ b/sound/soc/meson/t9015.c
>>>>>>>>> @@ -89,10 +89,7 @@ static struct snd_soc_dai_driver t9015_dai = {
>>>>>>>>>                  .channels_min = 1,
>>>>>>>>>                  .channels_max = 2,
>>>>>>>>>                  .rates = SNDRV_PCM_RATE_8000_96000,
>>>>>>>>> -             .formats = (SNDRV_PCM_FMTBIT_S8 |
>>>>>>>>> -                         SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>>>> -                         SNDRV_PCM_FMTBIT_S20_LE |
>>>>>>>>> - SNDRV_PCM_FMTBIT_S24_LE),
>>>>>>>>> +             .formats = (SNDRV_PCM_FMTBIT_S16_LE |
>>>>>>>>> SNDRV_PCM_FMTBIT_S32_LE),
>>>>>>>> Again, mixed up changes with zero justification.
>>>>>>>>
>>>>>>>> This drops S8 and S16 format support for the existing SoCs 
>>>>>>>> (such as GXL)
>>>>>>>> which is known to work and add S32 support on an HW documented 
>>>>>>>> as 24bits
>>>>>>>> only. Can you explain ?
>>>>>> for g12a, sm1 etc, it is use new audio ip, GXL is old ip,
>>>>> If there are chips difference we did not know about, then you should
>>>>> introduce those difference, without breaking existing support -
>>>>> including for GXL, which is what you did IIUC.
>>>>>
>>>>>> the new ip not support 24 bit,
>>>>> Are sure about that ? that code has been there for a while.
>>>>>
>>>>> If sm1 does not support SNDRV_PCM_FMTBIT_S24_LE, you should a fix 
>>>>> up patch for
>>>>> that, with the proper "Fixes:" tag, how to reproduce the problem and
>>>>> explaining the fix.

At first I thought you said 24bit is s24_3le, becasue of the fddr can't 
get it,

so  spend a lot of time trying to explain it

I think it may be because of this difference that we are not focused on 
the same problem

yes, we support s24_le,  the internal codec also process it 24 bit of 32 
bit,

if we send valid 32bit data, it only process 24bit, discard 8 bit data, 
if this behavior should be prohibit

we will follow this rule

>>>> maybe there are some gap , we support SNDRV_PCM_FMTBIT_S24, not 
>>>> support the
>>>>
>>>> SNDRV_PCM_FMTBIT_S24_3LE,  for SNDRV_PCM_FMTBIT_S24
>>>>
>>>> it is  Signed, 24-bit (32-bit in memory), little endian , the audio 
>>>> dma
>>>> busrt is 64bit
>>> It makes absolutely no sense to discuss memory layout for the codec.
>>>
>>>> it can get the full data. we send the 32 bit data  mclk = 32bit* 
>>>> 48k *4,
>>>> use the clk to send
>>>>
>>>> the  SNDRV_PCM_FMTBIT_S24,   the hadware always send the 32bit data
>>> No it does not. It send 24 bits of data over a 32 bits physical word 
>>> with
>>> 8 bits ignored.
>>
>> The original intention, we play 32bit data from tdmout, it play 
>> error, so we add the s32_le
>>
>> for tdmouta ,it can bind Multiple codec, one codec is the internal 
>> codec,
>>
>> other is external codec, tdmout can send the data to internal codec 
>> and external codec from the output pad
>>
>> for example, tdmout send 4 ch, 2 ch is send the internal codec, 2 ch 
>> send the data pad
>>
>> it aplay error, due to the internal codec fomat parameter limiting 
>> condition
>>
>> There is a contradiction here,  Considering our internal codec can 
>> process this it, drop 8bit, 24bit valid
>>
>> therefore software can set s24_le/s32_le, still  work ok for 
>> hardware, so Multiple ch can support for internal codec and external 
>> codec
>>
>>
> add the s32_le format for the t9015.c,  it can resovle Multiple codec 
> s32_le format case,  although hardware only process 24bit of 32bit, 
> but it can't affect the acodec hardware work, it still work fine
>
> usually we add the s32_le format support, if not allow to do it, think 
> of it as a limitation, we can  remove 32bit test for it
>
>>>
>>>> so, i think we only add the SNDRV_PCM_FMTBIT_S32 base on it
>>> That's wrong if the codec does not actually use the full 32bits ... and
>>> I have clear indication that's what the codec is doing, on GXL at 
>>> least.
>>>
>>>> we think the 24 bit is the SNDRV_PCM_FMTBIT_S24_3LE, it is 24bit in 
>>>> memroy,
>>>>
>>>> due to the dma busrt 64 bit limit, it can't align the sample bit, 
>>>> if it is
>>>> 24 bit
>>> Again, memory layout makes no sense here.
>>>
>>>> so the clock configure can't 24bit clock,
>>> I disagree and this has been tested. If you have a test case showing
>>> otherwise please share it.
>>>
>>>> by the way, We discuss internally for gxl,
>>>>
>>>> it also support the SNDRV_PCM_FMTBIT_S32
>>>>
>>> Does it really ? If it is just to ignore the 8bits LSB, that not a 
>>> support.
>>>
>>>>>> usually support 16/32 bit for new audio ip , for 
>>>>>> SNDRV_PCM_FMTBIT_S24_LE,
>>>>>> it width =24, phy =32
>>>>> Yes physical of SNDRV_PCM_FMTBIT_S24_LE, so most chip supporting 
>>>>> 32 bits
>>>>> width would support this S24_LE, unless there is something odd.
>>>>>
>>>>>> it was  treated as 32 bit to send for tdm, so we can only add the 
>>>>>> S32LE
>>>>>> base on it , right ?
>>>>> You are asking me ? How am I suppose to know ?
>>>>>
>>>>>> but if the gxl not support the 32bit
>>>>> I don't see a problem with a DAC taking input on 32bits physical
>>>>> interface and ignoring some bit on processing.
>>>>>
>>>>> If that's not the case, please send a proper fix change with some 
>>>>> explanation
>>>>>
>>>>>> we need add new snd_soc_dai_driver t9015_dai_s4 ?
>>>>>>
>>>>> If I understood correctly format depends on the chip and needs to
>>>>> adjusted including for sm1.
>>>>>
>>>>>>>>>          },
>>>>>>>>>          .ops = &t9015_dai_ops,
>>>>>>>>>     };
>>>>>>>> -- Jerome
>>>>> -- 
>>>>> Jerome
>>> -- 
>>> Jerome


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2025-01-15 12:10 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13  6:35 [PATCH 0/3] Add support for S4 audio jiebing chen via B4 Relay
2025-01-13  6:35 ` [PATCH 1/3] ASoC: dt-bindings: Add Amlogic " jiebing chen via B4 Relay
2025-01-13  7:19   ` Rob Herring (Arm)
2025-01-13  6:35 ` [PATCH 2/3] ASoC: meson: s4:support for the on-chip audio jiebing chen via B4 Relay
2025-01-13 14:31   ` Jerome Brunet
2025-01-14  8:16     ` Jiebing Chen
2025-01-14 11:20       ` Jiebing Chen
2025-01-14 14:05         ` Jerome Brunet
2025-01-15  2:56           ` Jiebing Chen
2025-01-15  8:36             ` Jerome Brunet
2025-01-15 10:36               ` Jiebing Chen
2025-01-15 11:47                 ` Jiebing Chen
2025-01-15 12:09                   ` Jiebing Chen
2025-01-14 11:29       ` Jerome Brunet
2025-01-14 12:41         ` Jiebing Chen
2025-01-14  9:09   ` kernel test robot
2025-01-13  6:35 ` [PATCH 3/3] arm64: dts: amlogic: Add Amlogic S4 Audio jiebing chen via B4 Relay
2025-01-13 14:50   ` Jerome Brunet
2025-01-14  8:52     ` Jiebing Chen
2025-01-14 11:16       ` Jerome Brunet
2025-01-14 12:34         ` Jiebing Chen
2025-01-14 14:15           ` Jerome Brunet
2025-01-15  3:38             ` Jiebing Chen
2025-01-15  6:16               ` Jiebing Chen
2025-01-15  8:43                 ` Jerome Brunet
2025-01-15  9:56                   ` Jiebing Chen
2025-01-13 15:26 ` [PATCH 0/3] Add support for S4 audio Rob Herring (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).