Skip to contentSkip to conversation

ASoC: mediatek: mt2701: HDMI audio support

PATCH Superseded Daniel Golle 3 participants 14 messages Apr 15 – Apr 16

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: mediatek: mt2701: HDMI audio support

This series wires up on-chip HDMI audio on MT2701 and MT7623, from the DRM bridge down through the AFE into a small machine driver that binds the AFE HDMI BE to the HDMI TX codec already exposed by the mediatek-drm-hdmi driver. Bindings, DT and a BananaPi R2 board node are included.

In order to survive vblank or late hotplug of the monitor, the fix submitted separately [1] is required as well.

Everything here was developed for and tested on a BananaPi R2 (MT7623N), which turns ten years old this year -- a nice occasion to finally land native HDMI audio for a SoC which was truly ahead of its time.

[1]: https://patchwork.kernel.org/project/linux-mediatek/patch/a3e22cbae528c9a38d854a586d1736b860998d41.1776265222.git.daniel@makrotopia.org/

Daniel Golle (9):
dt-bindings: sound: mt2701-afe-pcm: add HDMI audio path clocks
dt-bindings: sound: add mediatek,mt2701-hdmi-audio machine binding
ASoC: mediatek: mt2701: add AFE HDMI register definitions
ASoC: mediatek: mt2701: add optional HDMI audio path clocks
ASoC: mediatek: mt2701: add HDMI audio memif, FE and BE DAIs
ASoC: mediatek: mt2701: add machine driver for on-chip HDMI codec
ARM: dts: mediatek: mt2701: wire HDMI audio path clocks into AFE
ARM: dts: mediatek: mt7623: wire HDMI audio path clocks into AFE
ARM: dts: mediatek: mt7623n-bananapi-bpi-r2: add HDMI audio machine
node

 .../bindings/sound/mediatek,mt2701-audio.yaml |  10 +
 .../sound/mediatek,mt2701-hdmi-audio.yaml     |  47 +++
 arch/arm/boot/dts/mediatek/mt2701.dtsi        |  21 +-
 arch/arm/boot/dts/mediatek/mt7623.dtsi        |  21 +-
 .../dts/mediatek/mt7623n-bananapi-bpi-r2.dts  |   7 +
 sound/soc/mediatek/Kconfig                    |  10 +
 sound/soc/mediatek/mt2701/Makefile            |   1 +
 .../mediatek/mt2701/mt2701-afe-clock-ctrl.c   |  22 ++
 sound/soc/mediatek/mt2701/mt2701-afe-common.h |   6 +
 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c    | 281 +++++++++++++++++-
 sound/soc/mediatek/mt2701/mt2701-hdmi.c       | 114 +++++++
 sound/soc/mediatek/mt2701/mt2701-reg.h        |  35 +++
 12 files changed, 564 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml
 create mode 100644 sound/soc/mediatek/mt2701/mt2701-hdmi.c
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/9 dt-bindings: sound: mt2701-afe-pcm: add HDMI audio path clocks

Document four additional optional clocks feeding the HDMI audio output path on MT2701 and MT7623N: the HADDS2 PLL (root of the HDMI audio clock tree), the HDMI audio and S/PDIF interface power gates, and the audio APLL root gate. Older device trees that do not wire these up remain valid via minItems.

---
 .../bindings/sound/mediatek,mt2701-audio.yaml          | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/sound/mediatek,mt2701-audio.yaml +10 -0
index 45382c4d86aa3..9d4fc542cd72c 100644
@@ -32,6 +32,7 @@ properties:
     maxItems: 1
 
   clocks:
+    minItems: 34
     items:
       - description: audio infra sys clock
       - description: top audio mux 1
@@ -67,8 +68,13 @@ properties:
       - description: top audio a1 sys pd
       - description: top audio a2 sys pd
       - description: audio merge interface pd
+      - description: HADDS2 PLL 294 MHz (HDMI audio path root)
+      - description: HDMI audio interface pd
+      - description: S/PDIF interface pd
+      - description: audio APLL root pd
 
   clock-names:
+    minItems: 34
     items:
       - const: infra_sys_audio_clk
       - const: top_audio_mux1_sel
@@ -104,6 +110,10 @@ properties:
       - const: audio_a1sys_pd
       - const: audio_a2sys_pd
       - const: audio_mrgif_pd
+      - const: hadds2pll_294m
+      - const: audio_hdmi_pd
+      - const: audio_spdf_pd
+      - const: audio_apll_pd
 
 required:
   - compatible
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/9] dt-bindings: sound: mt2701-afe-pcm: add HDMI audio path clocks

Quoted 2 lines · Daniel Golle

Document four additional optional clocks feeding the HDMI audio output path on MT2701 and MT7623N: the HADDS2 PLL (root of the

There is no MT7623N compatible in this file, so that's confusing. Does mt7622 have it? If not, then it should be restricted per variant. If yet, the model name is confusing.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/9] dt-bindings: sound: mt2701-afe-pcm: add HDMI audio path clocks

Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Daniel Golle

Document four additional optional clocks feeding the HDMI audio output path on MT2701 and MT7623N: the HADDS2 PLL (root of the

There is no MT7623N compatible in this file, so that's confusing. Does mt7622 have it? If not, then it should be restricted per variant. If yet, the model name is confusing.

Only MT7623N (which is apparently identical with MT2701) has all the multimedia features (ie. HDMI, a Mali-450 GPU, ...). Neither MT7623A nor any of the other MediaTek router SoCs got any of that. So it should be restricted to that variant. I'll fix this in v2.

Thanks for the review!

Daniel

#4 lore raw

PATCH 2/9 dt-bindings: sound: add mediatek,mt2701-hdmi-audio machine binding

In reply to Daniel Golle

Describe the ASoC machine compatible used to wire the MT2701/MT7623N AFE HDMI playback path to the on-chip HDMI transmitter acting as the generic HDMI audio codec. MT7623N boards carry the same IP and use the mt7623n- compatible as a fallback to mt2701-.

---
 .../sound/mediatek,mt2701-hdmi-audio.yaml     | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml
Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml new file +47 -0
new file mode 100644
index 0000000000000..d08aee447b471
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt2701-hdmi-audio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT2701 HDMI audio machine driver
+
+maintainers:
+  - Daniel Golle <[email protected]>
+
+description:
+  ASoC machine driver binding the MT2701 AFE HDMI playback path to
+  the on-chip HDMI transmitter via the generic HDMI audio codec.
+  The same HDMI audio IP is present on MT7623N.
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt2701-hdmi-audio
+      - items:
+          - const: mediatek,mt7623n-hdmi-audio
+          - const: mediatek,mt2701-hdmi-audio
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: Phandle of the MT2701/MT7623N AFE platform node.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: Phandle of the HDMI transmitter acting as audio codec.
+
+required:
+  - compatible
+  - mediatek,platform
+  - mediatek,audio-codec
+
+additionalProperties: false
+
+examples:
+  - |
+    sound-hdmi {
+        compatible = "mediatek,mt7623n-hdmi-audio",
+                     "mediatek,mt2701-hdmi-audio";
+        mediatek,platform = <&afe>;
+        mediatek,audio-codec = <&hdmi0>;
+    };
Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH 2/9] dt-bindings: sound: add mediatek,mt2701-hdmi-audio machine binding

Quoted 4 lines · Daniel Golle

Describe the ASoC machine compatible used to wire the MT2701/MT7623N AFE HDMI playback path to the on-chip HDMI transmitter acting as the generic HDMI audio codec. MT7623N boards carry the same IP and use the mt7623n- compatible as a fallback to mt2701-.

subject: sound:
Please use subject prefixes matching the subsystem. You can get them for example with 'git log --oneline -- DIRECTORY_OR_FILE' on the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters

Quoted 13 lines
---
 .../sound/mediatek,mt2701-hdmi-audio.yaml     | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml
Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml new file +0 -0
new file mode 100644
index 0000000000000..d08aee447b471

Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml new file +7 -0
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt2701-hdmi-audio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT2701 HDMI audio machine driver

1. Don't describe drivers. Descirbe the hardware.

2. There is already audio for mt2701: mediatek,mt2701-audio. Why HDMI is not part of existing audio machine bindings? Or maybe this is not sound card driver?

Quoted 14 lines
Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml new file +14 -0
+
+maintainers:
+  - Daniel Golle <[email protected]>
+
+description:
+  ASoC machine driver binding the MT2701 AFE HDMI playback path to
+  the on-chip HDMI transmitter via the generic HDMI audio codec.
+  The same HDMI audio IP is present on MT7623N.
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt2701-hdmi-audio
+      - items:

Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt2701-hdmi-audio.yaml new file +10 -0
+          - const: mediatek,mt7623n-hdmi-audio
+          - const: mediatek,mt2701-hdmi-audio
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: Phandle of the MT2701/MT7623N AFE platform node.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: Phandle of the HDMI transmitter acting as audio codec.

But these suggest it is sound card driver...

Best regards,
Krzysztof

#6 lore raw

PATCH 3/9 ASoC: mediatek: mt2701: add AFE HDMI register definitions

In reply to Daniel Golle

Add register offsets and bit defines for the MT2701/MT7623N AFE HDMI audio output path: the HDMI BCK divider in AUDIO_TOP_CON3, the HDMI output memif control and descriptor registers, the 8-bit AFE_HDMI_CONN0 interconnect, and the AFE_8CH_I2S_OUT_CON engine that drives the HDMI TX serial link. These are a prerequisite for adding an HDMI playback path to the mt2701 AFE driver and have no behavioural effect on their own.

---
 sound/soc/mediatek/mt2701/mt2701-reg.h | 35 ++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
sound/soc/mediatek/mt2701/mt2701-reg.h +35 -0
index c84d14cdd7ae8..b7a25bfb58662 100644
@@ -10,10 +10,17 @@
 #define _MT2701_REG_H_
 
 #define AUDIO_TOP_CON0 0x0000
+#define AUDIO_TOP_CON3 0x000c
 #define AUDIO_TOP_CON4 0x0010
 #define AUDIO_TOP_CON5 0x0014
 #define AFE_DAIBT_CON0 0x001c
 #define AFE_MRGIF_CON 0x003c
+#define AFE_HDMI_OUT_CON0 0x0370
+#define AFE_HDMI_OUT_BASE 0x0374
+#define AFE_HDMI_OUT_CUR  0x0378
+#define AFE_HDMI_OUT_END  0x037c
+#define AFE_HDMI_CONN0    0x0390
+#define AFE_8CH_I2S_OUT_CON 0x0394
 #define ASMI_TIMING_CON1 0x0100
 #define ASMO_TIMING_CON1 0x0104
 #define PWR1_ASM_CON1 0x0108
@@ -125,6 +132,34 @@
 #define AFE_MEMIF_PBUF_SIZE_DLM_BYTE_MASK	(0x3 << 12)
 #define AFE_MEMIF_PBUF_SIZE_DLM_32BYTES		(0x1 << 12)
 
+/* AUDIO_TOP_CON0 (0x0000) -- HDMI audio clock gating */
+#define AUDIO_TOP_CON0_PDN_HDMI_CK		(0x1 << 20)
+#define AUDIO_TOP_CON0_PDN_SPDIF_CK		(0x1 << 21)
+#define AUDIO_TOP_CON0_PDN_SPDIF2_CK		(0x1 << 22)
+#define AUDIO_TOP_CON0_PDN_APLL_CK		(0x1 << 23)
+
+/* AUDIO_TOP_CON3 (0x000c) -- HDMI BCK divider */
+#define AUDIO_TOP_CON3_HDMI_BCK_DIV_MASK	(0x3f << 8)
+#define AUDIO_TOP_CON3_HDMI_BCK_DIV(x)		(((x) & 0x3f) << 8)
+
+/* AFE_HDMI_OUT_CON0 (0x0370) */
+#define AFE_HDMI_OUT_CON0_OUT_ON		(0x1 << 0)
+#define AFE_HDMI_OUT_CON0_BIT_WIDTH_MASK	(0x1 << 1)
+#define AFE_HDMI_OUT_CON0_BIT_WIDTH_16		(0x0 << 1)
+#define AFE_HDMI_OUT_CON0_BIT_WIDTH_32		(0x1 << 1)
+#define AFE_HDMI_OUT_CON0_CH_NUM_MASK		(0xf << 4)
+#define AFE_HDMI_OUT_CON0_CH_NUM(x)		(((x) & 0xf) << 4)
+
+/* AFE_8CH_I2S_OUT_CON (0x0394) -- on-SoC 8-channel I2S that feeds HDMI TX */
+#define AFE_8CH_I2S_OUT_CON_EN			(0x1 << 0)
+#define AFE_8CH_I2S_OUT_CON_BCK_INV		(0x1 << 1)
+#define AFE_8CH_I2S_OUT_CON_LRCK_INV		(0x1 << 2)
+#define AFE_8CH_I2S_OUT_CON_I2S_DELAY		(0x1 << 3)
+#define AFE_8CH_I2S_OUT_CON_WLEN_MASK		(0x3 << 4)
+#define AFE_8CH_I2S_OUT_CON_WLEN_16BIT		(0x1 << 4)
+#define AFE_8CH_I2S_OUT_CON_WLEN_24BIT		(0x2 << 4)
+#define AFE_8CH_I2S_OUT_CON_WLEN_32BIT		(0x3 << 4)
+
 /* I2S in/out register bit control */
 #define ASYS_I2S_CON_FS			(0x1f << 8)
 #define ASYS_I2S_CON_FS_SET(x)		((x) << 8)
Signature · 1 line
2.53.0
#7 lore raw

PATCH 4/9 ASoC: mediatek: mt2701: add optional HDMI audio path clocks

In reply to Daniel Golle

The HDMI audio output path on MT2701/MT7623N is rooted in HADDS2PLL and gated by the audio_hdmi, audio_spdf and audio_apll power gates. Acquire these four clocks from device tree using devm_clk_get_optional so that existing platforms which do not wire up HDMI audio keep probing unchanged. Actual clock enable/prepare is deferred to the upcoming HDMI DAI startup path.

---
 .../mediatek/mt2701/mt2701-afe-clock-ctrl.c   | 22 +++++++++++++++++++
 sound/soc/mediatek/mt2701/mt2701-afe-common.h |  4 ++++
 2 files changed, 26 insertions(+)
sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c +22 -0
index ae620890bb3ac..5a2bcf027b4fb 100644
@@ -95,6 +95,28 @@ int mt2701_init_clock(struct mtk_base_afe *afe)
 		afe_priv->mrgif_ck = NULL;
 	}
 
+	/*
+	 * Optional HDMI audio clocks. Platforms that do not wire up the
+	 * HDMI output (e.g. MT2701 devkits using only the I2S BE DAIs)
+	 * may omit these; in that case the HDMI BE DAI simply cannot be
+	 * enabled, but the rest of the AFE still probes.
+	 */
+	afe_priv->hadds2pll_ck = devm_clk_get_optional(afe->dev, "hadds2pll_294m");
+	if (IS_ERR(afe_priv->hadds2pll_ck))
+		return PTR_ERR(afe_priv->hadds2pll_ck);
+
+	afe_priv->audio_hdmi_ck = devm_clk_get_optional(afe->dev, "audio_hdmi_pd");
+	if (IS_ERR(afe_priv->audio_hdmi_ck))
+		return PTR_ERR(afe_priv->audio_hdmi_ck);
+
+	afe_priv->audio_spdf_ck = devm_clk_get_optional(afe->dev, "audio_spdf_pd");
+	if (IS_ERR(afe_priv->audio_spdf_ck))
+		return PTR_ERR(afe_priv->audio_spdf_ck);
+
+	afe_priv->audio_apll_ck = devm_clk_get_optional(afe->dev, "audio_apll_pd");
+	if (IS_ERR(afe_priv->audio_apll_ck))
+		return PTR_ERR(afe_priv->audio_apll_ck);
+
 	return 0;
 }
 
sound/soc/mediatek/mt2701/mt2701-afe-common.h +4 -0
index 32bef5e2a56d9..7b15283d6351e 100644
@@ -90,6 +90,10 @@ struct mt2701_afe_private {
 	struct mt2701_i2s_path *i2s_path;
 	struct clk *base_ck[MT2701_BASE_CLK_NUM];
 	struct clk *mrgif_ck;
+	struct clk *hadds2pll_ck;
+	struct clk *audio_hdmi_ck;
+	struct clk *audio_spdf_ck;
+	struct clk *audio_apll_ck;
 	bool mrg_enable[MTK_STREAM_NUM];
 
 	const struct mt2701_soc_variants *soc;
Signature · 1 line
2.53.0
#8 lore raw

PATCH 5/9 ASoC: mediatek: mt2701: add HDMI audio memif, FE and BE DAIs

In reply to Daniel Golle

Extend the MT2701/MT7623N AFE driver with the HDMI playback path:

- a new HDMI DMA memif (MT2701_MEMIF_HDMI) mapped to the

    AFE_HDMI_OUT_{CON0,BASE,CUR,END} registers;
  - a PCM_HDMI front-end DAI (S16_LE only, 44.1k/48k) which feeds
    the memif via DPCM;

- an HDMI BE DAI wrapping the AFE_8CH_I2S_OUT_CON engine that serialises L/R samples towards the on-chip HDMI transmitter.

Sample-rate programming uses the empirically determined HDMI_BCK_DIV = 45 * 48000 / rate - 1 formula in AUDIO_TOP_CON3, which covers 44.1 kHz and 48 kHz within the 6-bit divider range. The AFE_HDMI_CONN0 interconnect is programmed to route memif output pairs to the serializer inputs with L/R in the right order for hdmi-audio-codec.

The existing I2S engine helpers (mt2701_mclk_configuration, mt2701_i2s_path_enable, mt2701_afe_i2s_path_disable) are reused for the HDMI BE so that MCLK at 128*fs and the ASYS I2S3 FS field are programmed and cleanly released across open/close cycles.

Only S16_LE and 44.1k/48k are exposed to userspace. Other rates fall outside the 6-bit BCK divider range, and wider sample formats require DMA BIT_WIDTH programming that the current memif setup does not handle. These limits match what the MT8173 AFE driver exposes for its HDMI path.

---
 sound/soc/mediatek/mt2701/mt2701-afe-common.h |   2 +
 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c    | 281 +++++++++++++++++-
 2 files changed, 282 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt2701/mt2701-afe-common.h +2 -0
index 7b15283d6351e..8b6f3a200048a 100644
@@ -33,6 +33,7 @@ enum {
 	MT2701_MEMIF_UL5,
 	MT2701_MEMIF_DLBT,
 	MT2701_MEMIF_ULBT,
+	MT2701_MEMIF_HDMI,
 	MT2701_MEMIF_NUM,
 	MT2701_IO_I2S = MT2701_MEMIF_NUM,
 	MT2701_IO_2ND_I2S,
@@ -41,6 +42,7 @@ enum {
 	MT2701_IO_5TH_I2S,
 	MT2701_IO_6TH_I2S,
 	MT2701_IO_MRG,
+	MT2701_IO_HDMI,
 };
 
 enum {
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +280 -1

317 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer
#9 lore raw

Re: [PATCH 5/9] ASoC: mediatek: mt2701: add HDMI audio memif, FE and BE DAIs

sound/soc/mediatek/mt2701/mt2701-afe-pcm.c static const struct snd_soc_dai_ops mt2701_btmrg_ops = { · line 678

Quoted 10 lines · Daniel Golle

Extend the MT2701/MT7623N AFE driver with the HDMI playback path:

sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +7 -0
+static int mt2701_afe_hdmi_hw_params(struct snd_pcm_substream *substream,
+				     struct snd_pcm_hw_params *params,
+				     struct snd_soc_dai *dai)
+{
 
+	/* Channel count into the HDMI output memif (bits [7:4]). */
+	regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0,
+			   0x000000f0, channels << 4);

Are the other fields guaranteed to be already set up properly?

sound/soc/mediatek/mt2701/mt2701-afe-pcm.c static const struct snd_soc_dai_ops mt2701_btmrg_ops = { · line 703

Quoted 13 lines
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +13 -0
+	/*
+	 * 8-channel I2S framing: standard I2S, 32-bit slots,
+	 * LRCK/BCK inverted. The wire protocol is fixed.
+	 */
+	regmap_update_bits(afe->regmap, AFE_8CH_I2S_OUT_CON,
+			   AFE_8CH_I2S_OUT_CON_WLEN_MASK |
+			   AFE_8CH_I2S_OUT_CON_I2S_DELAY |
+			   AFE_8CH_I2S_OUT_CON_LRCK_INV |
+			   AFE_8CH_I2S_OUT_CON_BCK_INV,
+			   AFE_8CH_I2S_OUT_CON_WLEN_32BIT |
+			   AFE_8CH_I2S_OUT_CON_I2S_DELAY |
+			   AFE_8CH_I2S_OUT_CON_LRCK_INV |
+			   AFE_8CH_I2S_OUT_CON_BCK_INV);

Does this need suspend/resume handling?

#10 lore raw

PATCH 6/9 ASoC: mediatek: mt2701: add machine driver for on-chip HDMI codec

In reply to Daniel Golle

Add a simple ASoC machine driver that wires the MT2701/MT7623N AFE HDMI playback path to the on-chip HDMI transmitter exposed as a generic hdmi-audio-codec "i2s-hifi" DAI.

The driver binds to "mediatek,mt2701-hdmi-audio". MT7623N device trees carry "mediatek,mt7623n-hdmi-audio" as a board-specific fallback, matching the dt-binding.

---
 sound/soc/mediatek/Kconfig              |  10 +++
 sound/soc/mediatek/mt2701/Makefile      |   1 +
 sound/soc/mediatek/mt2701/mt2701-hdmi.c | 114 ++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 sound/soc/mediatek/mt2701/mt2701-hdmi.c
sound/soc/mediatek/Kconfig +10 -0
index 3a1e1fa3fe5cc..fa076e7854adc 100644
@@ -26,6 +26,16 @@ config SND_SOC_MT2701_CS42448
 	  Select Y if you have such device.
 	  If unsure select "N".
 
+config SND_SOC_MT2701_HDMI
+	tristate "ASoC Audio driver for MT2701 with on-chip HDMI codec"
+	depends on SND_SOC_MT2701
+	select SND_SOC_HDMI_CODEC
+	help
+	  This adds the ASoC machine driver for MediaTek MT2701 and
+	  MT7623N boards routing the AFE I2S back-end to the on-chip
+	  HDMI transmitter via the generic HDMI codec.
+	  If unsure select "N".
+
 config SND_SOC_MT2701_WM8960
 	tristate "ASoc Audio driver for MT2701 with WM8960 codec"
 	depends on SND_SOC_MT2701 && I2C
sound/soc/mediatek/mt2701/Makefile +1 -0
index 507fa26c39452..59623d3d3a038 100644
@@ -5,4 +5,5 @@ obj-$(CONFIG_SND_SOC_MT2701) += snd-soc-mt2701-afe.o
 
 # machine driver
 obj-$(CONFIG_SND_SOC_MT2701_CS42448) += mt2701-cs42448.o
+obj-$(CONFIG_SND_SOC_MT2701_HDMI) += mt2701-hdmi.o
 obj-$(CONFIG_SND_SOC_MT2701_WM8960) += mt2701-wm8960.o
sound/soc/mediatek/mt2701/mt2701-hdmi.c new file +114 -0

114 lines not on this page · raw message

Signature · 1 line
2.53.0
#11 lore raw

PATCH 7/9 ARM: dts: mediatek: mt2701: wire HDMI audio path clocks into AFE

In reply to Daniel Golle

Add the HADDS2 PLL 294 MHz root, the audio_hdmi and audio_spdf interface gates and the audio_apll gate to the MT2701 AFE node, and reparent the AUDPLL mux to HADDS2PLL_98M so the HDMI audio serial clock path has a stable 294.912 MHz source. The clock names match the updated mediatek,mt2701-audio binding.

---
 arch/arm/boot/dts/mediatek/mt2701.dtsi | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
arch/arm/boot/dts/mediatek/mt2701.dtsi +16 -5
index 128b87229f3d5..80c8c7e6a422a 100644
@@ -464,7 +464,11 @@ afe: audio-controller {
 				 <&audsys CLK_AUD_AFE_CONN>,
 				 <&audsys CLK_AUD_A1SYS>,
 				 <&audsys CLK_AUD_A2SYS>,
-				 <&audsys CLK_AUD_AFE_MRGIF>;
+				 <&audsys CLK_AUD_AFE_MRGIF>,
+				 <&topckgen CLK_TOP_HADDS2PLL_294M>,
+				 <&audsys CLK_AUD_HDMI>,
+				 <&audsys CLK_AUD_SPDF>,
+				 <&audsys CLK_AUD_APLL>;
 
 			clock-names = "infra_sys_audio_clk",
 				      "top_audio_mux1_sel",
@@ -499,15 +503,22 @@ afe: audio-controller {
 				      "audio_afe_conn_pd",
 				      "audio_a1sys_pd",
 				      "audio_a2sys_pd",
-				      "audio_mrgif_pd";
+				      "audio_mrgif_pd",
+				      "hadds2pll_294m",
+				      "audio_hdmi_pd",
+				      "audio_spdf_pd",
+				      "audio_apll_pd";
 
 			assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 					  <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 					  <&topckgen CLK_TOP_AUD_MUX1_DIV>,
-					  <&topckgen CLK_TOP_AUD_MUX2_DIV>;
+					  <&topckgen CLK_TOP_AUD_MUX2_DIV>,
+					  <&topckgen CLK_TOP_AUDPLL_MUX_SEL>;
 			assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
-						 <&topckgen CLK_TOP_AUD2PLL_90M>;
-			assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
+						 <&topckgen CLK_TOP_AUD2PLL_90M>,
+						 <0>, <0>,
+						 <&topckgen CLK_TOP_HADDS2PLL_98M>;
+			assigned-clock-rates = <0>, <0>, <49152000>, <45158400>, <0>;
 		};
 	};
 
Signature · 1 line
2.53.0
#12 lore raw

PATCH 8/9 ARM: dts: mediatek: mt7623: wire HDMI audio path clocks into AFE

In reply to Daniel Golle

Mirror the MT2701 change for the MT7623 SoC dtsi: add HADDS2PLL, audio_hdmi, audio_spdf and audio_apll to the AFE clocks list and reparent the AUDPLL mux to HADDS2PLL_98M. Required for HDMI audio on MT7623N boards via the shared mt2701 AFE driver.

---
 arch/arm/boot/dts/mediatek/mt7623.dtsi | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
arch/arm/boot/dts/mediatek/mt7623.dtsi +16 -5
index 71ac2b94c6ba3..4eb028ffee6f5 100644
@@ -665,7 +665,11 @@ afe: audio-controller {
 				 <&audsys CLK_AUD_AFE_CONN>,
 				 <&audsys CLK_AUD_A1SYS>,
 				 <&audsys CLK_AUD_A2SYS>,
-				 <&audsys CLK_AUD_AFE_MRGIF>;
+				 <&audsys CLK_AUD_AFE_MRGIF>,
+				 <&topckgen CLK_TOP_HADDS2PLL_294M>,
+				 <&audsys CLK_AUD_HDMI>,
+				 <&audsys CLK_AUD_SPDF>,
+				 <&audsys CLK_AUD_APLL>;
 
 			clock-names = "infra_sys_audio_clk",
 				      "top_audio_mux1_sel",
@@ -700,15 +704,22 @@ afe: audio-controller {
 				      "audio_afe_conn_pd",
 				      "audio_a1sys_pd",
 				      "audio_a2sys_pd",
-				      "audio_mrgif_pd";
+				      "audio_mrgif_pd",
+				      "hadds2pll_294m",
+				      "audio_hdmi_pd",
+				      "audio_spdf_pd",
+				      "audio_apll_pd";
 
 			assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
 					  <&topckgen CLK_TOP_AUD_MUX2_SEL>,
 					  <&topckgen CLK_TOP_AUD_MUX1_DIV>,
-					  <&topckgen CLK_TOP_AUD_MUX2_DIV>;
+					  <&topckgen CLK_TOP_AUD_MUX2_DIV>,
+					  <&topckgen CLK_TOP_AUDPLL_MUX_SEL>;
 			assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
-						 <&topckgen CLK_TOP_AUD2PLL_90M>;
-			assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
+						 <&topckgen CLK_TOP_AUD2PLL_90M>,
+						 <0>, <0>,
+						 <&topckgen CLK_TOP_HADDS2PLL_98M>;
+			assigned-clock-rates = <0>, <0>, <49152000>, <45158400>, <0>;
 		};
 	};
 
Signature · 1 line
2.53.0
#13 lore raw

PATCH 9/9 ARM: dts: mediatek: mt7623n-bananapi-bpi-r2: add HDMI audio machine node

In reply to Daniel Golle

Instantiate the mediatek,mt2701-hdmi-audio machine on the BananaPi BPI-R2, binding the AFE HDMI playback path to the on-chip HDMI transmitter acting as the generic HDMI codec.

---
 arch/arm/boot/dts/mediatek/mt7623n-bananapi-bpi-r2.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/mediatek/mt7623n-bananapi-bpi-r2.dts +7 -0
index a37f3fa223c72..139a76764faa0 100644
@@ -132,6 +132,13 @@ memory@80000000 {
 		device_type = "memory";
 		reg = <0 0x80000000 0 0x80000000>;
 	};
+
+	sound-hdmi {
+		compatible = "mediatek,mt7623n-hdmi-audio",
+			     "mediatek,mt2701-hdmi-audio";
+		mediatek,platform = <&afe>;
+		mediatek,audio-codec = <&hdmi0>;
+	};
 };
 
 &bls {
Signature · 1 line
2.53.0