Skip to contentSkip to conversation

ASoC: mediatek: Add support for MT7986 SoC

PATCH Superseded Maso Huang 5 participants 33 messages Jul 28, 2023 – Aug 8, 2023

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Maso Huang

author
#0 lore raw

v3 cover ASoC: mediatek: Add support for MT7986 SoC

Changes in v3:
- merge clk api to mt7986-afe-pcm.c, remove [2/7] in v2
- refine based on reviewer's suggestions [1/6] [2/6]
- fix the comment format, move in clk api, and simplify based on reviewer's suggestions [3/6]
- remove redundant prefix in dt-binding [6/6]

Changes in v2:
- v1 title: [PATCH 0/7] ASoC: mediatek: Add support for MT79xx SoC
- add missing maintainers
- rename mt79xx to mt7986 in all files
- use clk bulk api in mt7986-afe-clk.c [2/7]
- refine mt79xx-afe-pcm.c based on reviewer's suggestions [4/7]
- refine dt-binding files based on reviewer's suggestions [6/7] [7/7]
- transpose [3/7] and [4/7] in v1 to fix test build errors

Maso Huang (6):
ASoC: mediatek: mt7986: add common header
ASoC: mediatek: mt7986: support etdm in platform driver
ASoC: mediatek: mt7986: add platform driver
ASoC: mediatek: mt7986: add machine driver with wm8960
ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document
ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

 .../bindings/sound/mediatek,mt7986-afe.yaml   |  89 +++
 .../sound/mediatek,mt7986-wm8960.yaml         |  53 ++
 sound/soc/mediatek/Kconfig                    |  20 +
 sound/soc/mediatek/Makefile                   |   1 +
 sound/soc/mediatek/mt7986/Makefile            |   9 +
 sound/soc/mediatek/mt7986/mt7986-afe-common.h |  49 ++
 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c    | 622 ++++++++++++++++++
 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c   | 420 ++++++++++++
 sound/soc/mediatek/mt7986/mt7986-reg.h        | 206 ++++++
 sound/soc/mediatek/mt7986/mt7986-wm8960.c     | 184 ++++++
 10 files changed, 1653 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml
 create mode 100644 sound/soc/mediatek/mt7986/Makefile
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v3 1/6 ASoC: mediatek: mt7986: add common header

Add header files for register definition and structure.

---
 sound/soc/mediatek/mt7986/mt7986-afe-common.h |  49 +++++
 sound/soc/mediatek/mt7986/mt7986-reg.h        | 206 ++++++++++++++++++
 2 files changed, 255 insertions(+)
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +49 -0
new file mode 100644
index 000000000000..1c59549d91b4
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt7986-afe-common.h  --  MediaTek 7986 audio driver definitions
+ *
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Vic Wu <[email protected]>
+ *         Maso Huang <[email protected]>
+ */
+
+#ifndef _MT_7986_AFE_COMMON_H_
+#define _MT_7986_AFE_COMMON_H_
+
+#include <sound/soc.h>
+#include <linux/clk.h>
+#include <linux/list.h>
+#include <linux/regmap.h>
+#include "../common/mtk-base-afe.h"
+
+enum {
+	MT7986_MEMIF_DL1,
+	MT7986_MEMIF_VUL12,
+	MT7986_MEMIF_NUM,
+	MT7986_DAI_ETDM = MT7986_MEMIF_NUM,
+	MT7986_DAI_NUM,
+};
+
+enum {
+	MT7986_IRQ_0,
+	MT7986_IRQ_1,
+	MT7986_IRQ_2,
+	MT7986_IRQ_NUM,
+};
+
+struct mt7986_afe_private {
+	struct clk_bulk_data *clks;
+	int num_clks;
+
+	int pm_runtime_bypass_reg_ctl;
+
+	/* dai */
+	void *dai_priv[MT7986_DAI_NUM];
+};
+
+unsigned int mt7986_afe_rate_transform(struct device *dev,
+				       unsigned int rate);
+
+/* dai register */
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe);
+#endif
sound/soc/mediatek/mt7986/mt7986-reg.h new file +206 -0

206 lines not on this page · raw message

Signature · 1 line
2.18.0
#2 lore raw

Re: [PATCH v3 1/6] ASoC: mediatek: mt7986: add common header

Quoted 17 lines · Maso Huang

Add header files for register definition and structure.

---
  sound/soc/mediatek/mt7986/mt7986-afe-common.h |  49 +++++
  sound/soc/mediatek/mt7986/mt7986-reg.h        | 206 ++++++++++++++++++
  2 files changed, 255 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h

sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +0 -0
new file mode 100644
index 000000000000..1c59549d91b4

sound/soc/mediatek/mt7986/mt7986-afe-common.h line 5

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +5 -0
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt7986-afe-common.h  --  MediaTek 7986 audio driver definitions
+ *
+ * Copyright (c) 2021 MediaTek Inc.

2023

sound/soc/mediatek/mt7986/mt7986-afe-common.h line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +1 -0
+ * Author: Vic Wu <[email protected]>

Authors

Quoted 49 lines
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +43 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#ifndef _MT_7986_AFE_COMMON_H_
+#define _MT_7986_AFE_COMMON_H_
+
+#include <sound/soc.h>
+#include <linux/clk.h>
+#include <linux/list.h>
+#include <linux/regmap.h>
+#include "../common/mtk-base-afe.h"
+
+enum {
+	MT7986_MEMIF_DL1,
+	MT7986_MEMIF_VUL12,
+	MT7986_MEMIF_NUM,
+	MT7986_DAI_ETDM = MT7986_MEMIF_NUM,
+	MT7986_DAI_NUM,
+};
+
+enum {
+	MT7986_IRQ_0,
+	MT7986_IRQ_1,
+	MT7986_IRQ_2,
+	MT7986_IRQ_NUM,
+};
+
+struct mt7986_afe_private {
+	struct clk_bulk_data *clks;
+	int num_clks;
+
+	int pm_runtime_bypass_reg_ctl;
+
+	/* dai */
+	void *dai_priv[MT7986_DAI_NUM];
+};
+
+unsigned int mt7986_afe_rate_transform(struct device *dev,
+				       unsigned int rate);
+
+/* dai register */
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe);
+#endif
sound/soc/mediatek/mt7986/mt7986-reg.h new file +0 -0
new file mode 100644
index 000000000000..88861f81890f

sound/soc/mediatek/mt7986/mt7986-reg.h line 5

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-reg.h new file +5 -0
@@ -0,0 +1,206 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt7986-reg.h  --  MediaTek 7986 audio driver reg definition
+ *
+ * Copyright (c) 2021 MediaTek Inc.

Ditto

sound/soc/mediatek/mt7986/mt7986-reg.h line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-reg.h new file +1 -0
+ * Author: Vic Wu <[email protected]>

Ditto

Quoted 200 lines
sound/soc/mediatek/mt7986/mt7986-reg.h new file +200 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#ifndef _MT7986_REG_H_
+#define _MT7986_REG_H_
+
+#define AUDIO_TOP_CON2                  0x0008
+#define AUDIO_TOP_CON4                  0x0010
+#define AUDIO_ENGEN_CON0                0x0014
+#define AFE_IRQ_MCU_EN                  0x0100
+#define AFE_IRQ_MCU_STATUS              0x0120
+#define AFE_IRQ_MCU_CLR                 0x0128
+#define AFE_IRQ0_MCU_CFG0               0x0140
+#define AFE_IRQ0_MCU_CFG1               0x0144
+#define AFE_IRQ1_MCU_CFG0               0x0148
+#define AFE_IRQ1_MCU_CFG1               0x014c
+#define AFE_IRQ2_MCU_CFG0               0x0150
+#define AFE_IRQ2_MCU_CFG1               0x0154
+#define ETDM_IN5_CON0                   0x13f0
+#define ETDM_IN5_CON1                   0x13f4
+#define ETDM_IN5_CON2                   0x13f8
+#define ETDM_IN5_CON3                   0x13fc
+#define ETDM_IN5_CON4                   0x1400
+#define ETDM_OUT5_CON0                  0x1570
+#define ETDM_OUT5_CON4                  0x1580
+#define ETDM_OUT5_CON5                  0x1584
+#define ETDM_4_7_COWORK_CON0            0x15e0
+#define ETDM_4_7_COWORK_CON1            0x15e4
+#define AFE_CONN018_1                   0x1b44
+#define AFE_CONN018_4                   0x1b50
+#define AFE_CONN019_1                   0x1b64
+#define AFE_CONN019_4                   0x1b70
+#define AFE_CONN124_1                   0x2884
+#define AFE_CONN124_4                   0x2890
+#define AFE_CONN125_1                   0x28a4
+#define AFE_CONN125_4                   0x28b0
+#define AFE_CONN_RS_0                   0x3920
+#define AFE_CONN_RS_3                   0x392c
+#define AFE_CONN_16BIT_0                0x3960
+#define AFE_CONN_16BIT_3                0x396c
+#define AFE_CONN_24BIT_0                0x3980
+#define AFE_CONN_24BIT_3                0x398c
+#define AFE_MEMIF_CON0                  0x3d98
+#define AFE_MEMIF_RD_MON                0x3da0
+#define AFE_MEMIF_WR_MON                0x3da4
+#define AFE_DL0_BASE_MSB                0x3e40
+#define AFE_DL0_BASE                    0x3e44
+#define AFE_DL0_CUR_MSB                 0x3e48
+#define AFE_DL0_CUR                     0x3e4c
+#define AFE_DL0_END_MSB                 0x3e50
+#define AFE_DL0_END                     0x3e54
+#define AFE_DL0_RCH_MON                 0x3e58
+#define AFE_DL0_LCH_MON                 0x3e5c
+#define AFE_DL0_CON0                    0x3e60
+#define AFE_VUL0_BASE_MSB               0x4220
+#define AFE_VUL0_BASE                   0x4224
+#define AFE_VUL0_CUR_MSB                0x4228
+#define AFE_VUL0_CUR                    0x422c
+#define AFE_VUL0_END_MSB                0x4230
+#define AFE_VUL0_END                    0x4234
+#define AFE_VUL0_CON0                   0x4238
+
+#define AFE_MAX_REGISTER AFE_VUL0_CON0
+#define AFE_IRQ_STATUS_BITS             0x7
+#define AFE_IRQ_CNT_SHIFT               0
+#define AFE_IRQ_CNT_MASK	        0xffffff
+
+/* AUDIO_TOP_CON2 */
+#define CLK_OUT5_PDN                    BIT(14)
+#define CLK_OUT5_PDN_MASK               BIT(14)
+#define CLK_IN5_PDN                     BIT(7)
+#define CLK_IN5_PDN_MASK                BIT(7)
+
+/* AUDIO_TOP_CON4 */
+#define PDN_APLL_TUNER2                 BIT(12)
+#define PDN_APLL_TUNER2_MASK            BIT(12)
+
+/* AUDIO_ENGEN_CON0 */
+#define AUD_APLL2_EN                    BIT(3)
+#define AUD_APLL2_EN_MASK               BIT(3)
+#define AUD_26M_EN                      BIT(0)
+#define AUD_26M_EN_MASK                 BIT(0)
+
+/* AFE_DL0_CON0 */
+#define DL0_ON_SFT                      28
+#define DL0_ON_MASK                     0x1
+#define DL0_ON_MASK_SFT                 BIT(28)
+#define DL0_MINLEN_SFT                  20
+#define DL0_MINLEN_MASK                 0xf
+#define DL0_MINLEN_MASK_SFT             (0xf << 20)
+#define DL0_MODE_SFT                    8
+#define DL0_MODE_MASK                   0x1f
+#define DL0_MODE_MASK_SFT               (0x1f << 8)
+#define DL0_PBUF_SIZE_SFT               5
+#define DL0_PBUF_SIZE_MASK              0x3
+#define DL0_PBUF_SIZE_MASK_SFT          (0x3 << 5)
+#define DL0_MONO_SFT                    4
+#define DL0_MONO_MASK                   0x1
+#define DL0_MONO_MASK_SFT               BIT(4)
+#define DL0_HALIGN_SFT                  2
+#define DL0_HALIGN_MASK                 0x1
+#define DL0_HALIGN_MASK_SFT             BIT(2)
+#define DL0_HD_MODE_SFT                 0
+#define DL0_HD_MODE_MASK                0x3
+#define DL0_HD_MODE_MASK_SFT            (0x3 << 0)
+
+/* AFE_VUL0_CON0 */
+#define VUL0_ON_SFT                     28
+#define VUL0_ON_MASK                    0x1
+#define VUL0_ON_MASK_SFT                BIT(28)
+#define VUL0_MODE_SFT                   8
+#define VUL0_MODE_MASK                  0x1f
+#define VUL0_MODE_MASK_SFT              (0x1f << 8)
+#define VUL0_MONO_SFT                   4
+#define VUL0_MONO_MASK                  0x1
+#define VUL0_MONO_MASK_SFT              BIT(4)
+#define VUL0_HALIGN_SFT                 2
+#define VUL0_HALIGN_MASK                0x1
+#define VUL0_HALIGN_MASK_SFT            BIT(2)
+#define VUL0_HD_MODE_SFT                0
+#define VUL0_HD_MODE_MASK               0x3
+#define VUL0_HD_MODE_MASK_SFT           (0x3 << 0)
+
+/* AFE_IRQ_MCU_CON */
+#define IRQ_MCU_MODE_SFT                4
+#define IRQ_MCU_MODE_MASK               0x1f
+#define IRQ_MCU_MODE_MASK_SFT           (0x1f << 4)
+#define IRQ_MCU_ON_SFT                  0
+#define IRQ_MCU_ON_MASK                 0x1
+#define IRQ_MCU_ON_MASK_SFT             BIT(0)
+#define IRQ0_MCU_CLR_SFT                0
+#define IRQ0_MCU_CLR_MASK               0x1
+#define IRQ0_MCU_CLR_MASK_SFT           BIT(0)
+#define IRQ1_MCU_CLR_SFT                1
+#define IRQ1_MCU_CLR_MASK               0x1
+#define IRQ1_MCU_CLR_MASK_SFT           BIT(1)
+#define IRQ2_MCU_CLR_SFT                2
+#define IRQ2_MCU_CLR_MASK               0x1
+#define IRQ2_MCU_CLR_MASK_SFT           BIT(2)
+
+/* ETDM_IN5_CON2 */
+#define IN_CLK_SRC(x)                   ((x) << 10)
+#define IN_CLK_SRC_SFT                  10
+#define IN_CLK_SRC_MASK                 GENMASK(12, 10)
+
+/* ETDM_IN5_CON3 */
+#define IN_SEL_FS(x)                    ((x) << 26)
+#define IN_SEL_FS_SFT                   26
+#define IN_SEL_FS_MASK                  GENMASK(30, 26)
+
+/* ETDM_IN5_CON4 */
+#define IN_RELATCH(x)                   ((x) << 20)
+#define IN_RELATCH_SFT                  20
+#define IN_RELATCH_MASK                 GENMASK(24, 20)
+#define IN_CLK_INV                      BIT(18)
+#define IN_CLK_INV_MASK                 BIT(18)
+
+/* ETDM_IN5_CON0 & ETDM_OUT5_CON0 */
+#define RELATCH_SRC(x)                  ((x) << 28)
+#define RELATCH_SRC_SFT                 28
+#define RELATCH_SRC_MASK                GENMASK(30, 28)
+#define ETDM_CH_NUM(x)                  (((x) - 1) << 23)
+#define ETDM_CH_NUM_SFT                 23
+#define ETDM_CH_NUM_MASK                GENMASK(27, 23)
+#define ETDM_WRD_LEN(x)                 (((x) - 1) << 16)
+#define ETDM_WRD_LEN_SFT                16
+#define ETDM_WRD_LEN_MASK               GENMASK(20, 16)
+#define ETDM_BIT_LEN(x)                 (((x) - 1) << 11)
+#define ETDM_BIT_LEN_SFT                11
+#define ETDM_BIT_LEN_MASK               GENMASK(15, 11)
+#define ETDM_FMT(x)                     ((x) << 6)
+#define ETDM_FMT_SFT                    6
+#define ETDM_FMT_MASK                   GENMASK(8, 6)
+#define ETDM_SYNC                       BIT(1)
+#define ETDM_SYNC_MASK                  BIT(1)
+#define ETDM_EN                         BIT(0)
+#define ETDM_EN_MASK                    BIT(0)
+
+/* ETDM_OUT5_CON4 */
+#define OUT_RELATCH(x)                  ((x) << 24)
+#define OUT_RELATCH_SFT                 24
+#define OUT_RELATCH_MASK                GENMASK(28, 24)
+#define OUT_CLK_SRC(x)                  ((x) << 6)
+#define OUT_CLK_SRC_SFT                 6
+#define OUT_CLK_SRC_MASK                GENMASK(8, 6)
+#define OUT_SEL_FS(x)                   (x)
+#define OUT_SEL_FS_SFT                  0
+#define OUT_SEL_FS_MASK                 GENMASK(4, 0)
+
+/* ETDM_OUT5_CON5 */
+#define ETDM_CLK_DIV                    BIT(12)
+#define ETDM_CLK_DIV_MASK               BIT(12)
+#define OUT_CLK_INV                     BIT(9)
+#define OUT_CLK_INV_MASK                BIT(9)
+
+/* ETDM_4_7_COWORK_CON0 */
+#define OUT_SEL(x)                      ((x) << 12)
+#define OUT_SEL_SFT                     12
+#define OUT_SEL_MASK                    GENMASK(15, 12)
+#endif
Signature · 2 lines
Regards,
Alexandre
#3 lore raw

Re: [PATCH v3 1/6] ASoC: mediatek: mt7986: add common header

Quoted 292 lines · Alexandre Mergnat

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 4 lines · Maso Huang

Add header files for register definition and structure.

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

Quoted 3 lines
---
  sound/soc/mediatek/mt7986/mt7986-afe-common.h |  49 +++++
  sound/soc/mediatek/mt7986/mt7986-reg.h        | 206

++++++++++++++++++

Review

Quoted 5 lines
  2 files changed, 255 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h

(quoted diff) +0 -0

b/sound/soc/mediatek/mt7986/mt7986-afe-common.h

sound/soc/mediatek/mt7986/mt7986-afe-common.h line 5

Quoted 10 lines

new file mode 100644
index 000000000000..1c59549d91b4

sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +5 -0
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt7986-afe-common.h  --  MediaTek 7986 audio driver definitions
+ *
+ * Copyright (c) 2021 MediaTek Inc.

2023

sound/soc/mediatek/mt7986/mt7986-afe-common.h line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +1 -0
+ * Author: Vic Wu <[email protected]>

Authors

Review

Quoted 44 lines
sound/soc/mediatek/mt7986/mt7986-afe-common.h new file +43 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#ifndef _MT_7986_AFE_COMMON_H_
+#define _MT_7986_AFE_COMMON_H_
+
+#include <sound/soc.h>
+#include <linux/clk.h>
+#include <linux/list.h>
+#include <linux/regmap.h>
+#include "../common/mtk-base-afe.h"
+
+enum {
+MT7986_MEMIF_DL1,
+MT7986_MEMIF_VUL12,
+MT7986_MEMIF_NUM,
+MT7986_DAI_ETDM = MT7986_MEMIF_NUM,
+MT7986_DAI_NUM,
+};
+
+enum {
+MT7986_IRQ_0,
+MT7986_IRQ_1,
+MT7986_IRQ_2,
+MT7986_IRQ_NUM,
+};
+
+struct mt7986_afe_private {
+struct clk_bulk_data *clks;
+int num_clks;
+
+int pm_runtime_bypass_reg_ctl;
+
+/* dai */
+void *dai_priv[MT7986_DAI_NUM];
+};
+
+unsigned int mt7986_afe_rate_transform(struct device *dev,
+       unsigned int rate);
+
+/* dai register */
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe);
+#endif
(quoted diff) +0 -0

b/sound/soc/mediatek/mt7986/mt7986-reg.h

sound/soc/mediatek/mt7986/mt7986-reg.h line 5

Quoted 10 lines

new file mode 100644
index 000000000000..88861f81890f

sound/soc/mediatek/mt7986/mt7986-reg.h new file +5 -0
@@ -0,0 +1,206 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * mt7986-reg.h  --  MediaTek 7986 audio driver reg definition
+ *
+ * Copyright (c) 2021 MediaTek Inc.

Ditto

sound/soc/mediatek/mt7986/mt7986-reg.h line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-reg.h new file +1 -0
+ * Author: Vic Wu <[email protected]>

Ditto

Quoted 192 lines
sound/soc/mediatek/mt7986/mt7986-reg.h new file +192 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#ifndef _MT7986_REG_H_
+#define _MT7986_REG_H_
+
+#define AUDIO_TOP_CON2                  0x0008
+#define AUDIO_TOP_CON4                  0x0010
+#define AUDIO_ENGEN_CON0                0x0014
+#define AFE_IRQ_MCU_EN                  0x0100
+#define AFE_IRQ_MCU_STATUS              0x0120
+#define AFE_IRQ_MCU_CLR                 0x0128
+#define AFE_IRQ0_MCU_CFG0               0x0140
+#define AFE_IRQ0_MCU_CFG1               0x0144
+#define AFE_IRQ1_MCU_CFG0               0x0148
+#define AFE_IRQ1_MCU_CFG1               0x014c
+#define AFE_IRQ2_MCU_CFG0               0x0150
+#define AFE_IRQ2_MCU_CFG1               0x0154
+#define ETDM_IN5_CON0                   0x13f0
+#define ETDM_IN5_CON1                   0x13f4
+#define ETDM_IN5_CON2                   0x13f8
+#define ETDM_IN5_CON3                   0x13fc
+#define ETDM_IN5_CON4                   0x1400
+#define ETDM_OUT5_CON0                  0x1570
+#define ETDM_OUT5_CON4                  0x1580
+#define ETDM_OUT5_CON5                  0x1584
+#define ETDM_4_7_COWORK_CON0            0x15e0
+#define ETDM_4_7_COWORK_CON1            0x15e4
+#define AFE_CONN018_1                   0x1b44
+#define AFE_CONN018_4                   0x1b50
+#define AFE_CONN019_1                   0x1b64
+#define AFE_CONN019_4                   0x1b70
+#define AFE_CONN124_1                   0x2884
+#define AFE_CONN124_4                   0x2890
+#define AFE_CONN125_1                   0x28a4
+#define AFE_CONN125_4                   0x28b0
+#define AFE_CONN_RS_0                   0x3920
+#define AFE_CONN_RS_3                   0x392c
+#define AFE_CONN_16BIT_0                0x3960
+#define AFE_CONN_16BIT_3                0x396c
+#define AFE_CONN_24BIT_0                0x3980
+#define AFE_CONN_24BIT_3                0x398c
+#define AFE_MEMIF_CON0                  0x3d98
+#define AFE_MEMIF_RD_MON                0x3da0
+#define AFE_MEMIF_WR_MON                0x3da4
+#define AFE_DL0_BASE_MSB                0x3e40
+#define AFE_DL0_BASE                    0x3e44
+#define AFE_DL0_CUR_MSB                 0x3e48
+#define AFE_DL0_CUR                     0x3e4c
+#define AFE_DL0_END_MSB                 0x3e50
+#define AFE_DL0_END                     0x3e54
+#define AFE_DL0_RCH_MON                 0x3e58
+#define AFE_DL0_LCH_MON                 0x3e5c
+#define AFE_DL0_CON0                    0x3e60
+#define AFE_VUL0_BASE_MSB               0x4220
+#define AFE_VUL0_BASE                   0x4224
+#define AFE_VUL0_CUR_MSB                0x4228
+#define AFE_VUL0_CUR                    0x422c
+#define AFE_VUL0_END_MSB                0x4230
+#define AFE_VUL0_END                    0x4234
+#define AFE_VUL0_CON0                   0x4238
+
+#define AFE_MAX_REGISTER AFE_VUL0_CON0
+#define AFE_IRQ_STATUS_BITS             0x7
+#define AFE_IRQ_CNT_SHIFT               0
+#define AFE_IRQ_CNT_MASK        0xffffff
+
+/* AUDIO_TOP_CON2 */
+#define CLK_OUT5_PDN                    BIT(14)
+#define CLK_OUT5_PDN_MASK               BIT(14)
+#define CLK_IN5_PDN                     BIT(7)
+#define CLK_IN5_PDN_MASK                BIT(7)
+
+/* AUDIO_TOP_CON4 */
+#define PDN_APLL_TUNER2                 BIT(12)
+#define PDN_APLL_TUNER2_MASK            BIT(12)
+
+/* AUDIO_ENGEN_CON0 */
+#define AUD_APLL2_EN                    BIT(3)
+#define AUD_APLL2_EN_MASK               BIT(3)
+#define AUD_26M_EN                      BIT(0)
+#define AUD_26M_EN_MASK                 BIT(0)
+
+/* AFE_DL0_CON0 */
+#define DL0_ON_SFT                      28
+#define DL0_ON_MASK                     0x1
+#define DL0_ON_MASK_SFT                 BIT(28)
+#define DL0_MINLEN_SFT                  20
+#define DL0_MINLEN_MASK                 0xf
+#define DL0_MINLEN_MASK_SFT             (0xf << 20)
+#define DL0_MODE_SFT                    8
+#define DL0_MODE_MASK                   0x1f
+#define DL0_MODE_MASK_SFT               (0x1f << 8)
+#define DL0_PBUF_SIZE_SFT               5
+#define DL0_PBUF_SIZE_MASK              0x3
+#define DL0_PBUF_SIZE_MASK_SFT          (0x3 << 5)
+#define DL0_MONO_SFT                    4
+#define DL0_MONO_MASK                   0x1
+#define DL0_MONO_MASK_SFT               BIT(4)
+#define DL0_HALIGN_SFT                  2
+#define DL0_HALIGN_MASK                 0x1
+#define DL0_HALIGN_MASK_SFT             BIT(2)
+#define DL0_HD_MODE_SFT                 0
+#define DL0_HD_MODE_MASK                0x3
+#define DL0_HD_MODE_MASK_SFT            (0x3 << 0)
+
+/* AFE_VUL0_CON0 */
+#define VUL0_ON_SFT                     28
+#define VUL0_ON_MASK                    0x1
+#define VUL0_ON_MASK_SFT                BIT(28)
+#define VUL0_MODE_SFT                   8
+#define VUL0_MODE_MASK                  0x1f
+#define VUL0_MODE_MASK_SFT              (0x1f << 8)
+#define VUL0_MONO_SFT                   4
+#define VUL0_MONO_MASK                  0x1
+#define VUL0_MONO_MASK_SFT              BIT(4)
+#define VUL0_HALIGN_SFT                 2
+#define VUL0_HALIGN_MASK                0x1
+#define VUL0_HALIGN_MASK_SFT            BIT(2)
+#define VUL0_HD_MODE_SFT                0
+#define VUL0_HD_MODE_MASK               0x3
+#define VUL0_HD_MODE_MASK_SFT           (0x3 << 0)
+
+/* AFE_IRQ_MCU_CON */
+#define IRQ_MCU_MODE_SFT                4
+#define IRQ_MCU_MODE_MASK               0x1f
+#define IRQ_MCU_MODE_MASK_SFT           (0x1f << 4)
+#define IRQ_MCU_ON_SFT                  0
+#define IRQ_MCU_ON_MASK                 0x1
+#define IRQ_MCU_ON_MASK_SFT             BIT(0)
+#define IRQ0_MCU_CLR_SFT                0
+#define IRQ0_MCU_CLR_MASK               0x1
+#define IRQ0_MCU_CLR_MASK_SFT           BIT(0)
+#define IRQ1_MCU_CLR_SFT                1
+#define IRQ1_MCU_CLR_MASK               0x1
+#define IRQ1_MCU_CLR_MASK_SFT           BIT(1)
+#define IRQ2_MCU_CLR_SFT                2
+#define IRQ2_MCU_CLR_MASK               0x1
+#define IRQ2_MCU_CLR_MASK_SFT           BIT(2)
+
+/* ETDM_IN5_CON2 */
+#define IN_CLK_SRC(x)                   ((x) << 10)
+#define IN_CLK_SRC_SFT                  10
+#define IN_CLK_SRC_MASK                 GENMASK(12, 10)
+
+/* ETDM_IN5_CON3 */
+#define IN_SEL_FS(x)                    ((x) << 26)
+#define IN_SEL_FS_SFT                   26
+#define IN_SEL_FS_MASK                  GENMASK(30, 26)
+
+/* ETDM_IN5_CON4 */
+#define IN_RELATCH(x)                   ((x) << 20)
+#define IN_RELATCH_SFT                  20
+#define IN_RELATCH_MASK                 GENMASK(24, 20)
+#define IN_CLK_INV                      BIT(18)
+#define IN_CLK_INV_MASK                 BIT(18)
+
+/* ETDM_IN5_CON0 & ETDM_OUT5_CON0 */
+#define RELATCH_SRC(x)                  ((x) << 28)
+#define RELATCH_SRC_SFT                 28
+#define RELATCH_SRC_MASK                GENMASK(30, 28)
+#define ETDM_CH_NUM(x)                  (((x) - 1) << 23)
+#define ETDM_CH_NUM_SFT                 23
+#define ETDM_CH_NUM_MASK                GENMASK(27, 23)
+#define ETDM_WRD_LEN(x)                 (((x) - 1) << 16)
+#define ETDM_WRD_LEN_SFT                16
+#define ETDM_WRD_LEN_MASK               GENMASK(20, 16)
+#define ETDM_BIT_LEN(x)                 (((x) - 1) << 11)
+#define ETDM_BIT_LEN_SFT                11
+#define ETDM_BIT_LEN_MASK               GENMASK(15, 11)
+#define ETDM_FMT(x)                     ((x) << 6)
+#define ETDM_FMT_SFT                    6
+#define ETDM_FMT_MASK                   GENMASK(8, 6)
+#define ETDM_SYNC                       BIT(1)
+#define ETDM_SYNC_MASK                  BIT(1)
+#define ETDM_EN                         BIT(0)
+#define ETDM_EN_MASK                    BIT(0)
+
+/* ETDM_OUT5_CON4 */
+#define OUT_RELATCH(x)                  ((x) << 24)
+#define OUT_RELATCH_SFT                 24
+#define OUT_RELATCH_MASK                GENMASK(28, 24)
+#define OUT_CLK_SRC(x)                  ((x) << 6)
+#define OUT_CLK_SRC_SFT                 6
+#define OUT_CLK_SRC_MASK                GENMASK(8, 6)
+#define OUT_SEL_FS(x)                   (x)
+#define OUT_SEL_FS_SFT                  0
+#define OUT_SEL_FS_MASK                 GENMASK(4, 0)
+
+/* ETDM_OUT5_CON5 */
+#define ETDM_CLK_DIV                    BIT(12)
+#define ETDM_CLK_DIV_MASK               BIT(12)
Quoted 12 lines
Quoted 8 lines
sound/soc/mediatek/mt7986/mt7986-reg.h new file +8 -0
+#define OUT_CLK_INV                     BIT(9)
+#define OUT_CLK_INV_MASK                BIT(9)
+
+/* ETDM_4_7_COWORK_CON0 */
+#define OUT_SEL(x)                      ((x) << 12)
+#define OUT_SEL_SFT                     12
+#define OUT_SEL_MASK                    GENMASK(15, 12)
+#endif
Signature · 2 lines
Regards,
Alexandre

Hi Alexandre,

Thanks for your review.
I'll fix them in v4 patch.

Best regards,
Maso

author
#4 lore raw

PATCH v3 2/6 ASoC: mediatek: mt7986: support etdm in platform driver

In reply to Maso Huang

Add mt7986 etdm dai driver support.

---
 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 420 ++++++++++++++++++++
 1 file changed, 420 insertions(+)
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +420 -0
new file mode 100644
index 000000000000..dc094e25ddb4
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek ALSA SoC Audio DAI eTDM Control
+ *
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Vic Wu <[email protected]>
+ *         Maso Huang <[email protected]>
+ */
+
+#include <linux/bitops.h>
+#include <linux/regmap.h>
+#include <sound/pcm_params.h>
+#include "mt7986-afe-common.h"
+#include "mt7986-reg.h"
+
+enum {
+	HOPPING_CLK = 0,
+	APLL_CLK = 1,
+};
+
+enum {
+	MTK_DAI_ETDM_FORMAT_I2S = 0,
+	MTK_DAI_ETDM_FORMAT_DSPA = 4,
+	MTK_DAI_ETDM_FORMAT_DSPB = 5,
+};
+
+enum {
+	ETDM_IN5 = 2,
+	ETDM_OUT5 = 10,
+};
+
+enum {
+	MTK_ETDM_RATE_8K = 0,
+	MTK_ETDM_RATE_12K = 1,
+	MTK_ETDM_RATE_16K = 2,
+	MTK_ETDM_RATE_24K = 3,
+	MTK_ETDM_RATE_32K = 4,
+	MTK_ETDM_RATE_48K = 5,
+	MTK_ETDM_RATE_96K = 7,
+	MTK_ETDM_RATE_192K = 9,
+	MTK_ETDM_RATE_11K = 16,
+	MTK_ETDM_RATE_22K = 17,
+	MTK_ETDM_RATE_44K = 18,
+	MTK_ETDM_RATE_88K = 19,
+	MTK_ETDM_RATE_176K = 20,
+};
+
+struct mtk_dai_etdm_priv {
+	bool bck_inv;
+	bool lrck_inv;
+	bool slave_mode;
+	unsigned int format;
+};
+
+static unsigned int mt7986_etdm_rate_transform(struct device *dev, unsigned int rate)
+{
+	switch (rate) {
+	case 8000:
+		return MTK_ETDM_RATE_8K;
+	case 11025:
+		return MTK_ETDM_RATE_11K;
+	case 12000:
+		return MTK_ETDM_RATE_12K;
+	case 16000:
+		return MTK_ETDM_RATE_16K;
+	case 22050:
+		return MTK_ETDM_RATE_22K;
+	case 24000:
+		return MTK_ETDM_RATE_24K;
+	case 32000:
+		return MTK_ETDM_RATE_32K;
+	case 44100:
+		return MTK_ETDM_RATE_44K;
+	case 48000:
+		return MTK_ETDM_RATE_48K;
+	case 88200:
+		return MTK_ETDM_RATE_88K;
+	case 96000:
+		return MTK_ETDM_RATE_96K;
+	case 176400:
+		return MTK_ETDM_RATE_176K;
+	case 192000:
+		return MTK_ETDM_RATE_192K;
+	default:
+		dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n",
+			 __func__, rate, MTK_ETDM_RATE_48K);
+		return MTK_ETDM_RATE_48K;
+	}
+}
+
+static int get_etdm_wlen(unsigned int bitwidth)
+{
+	return bitwidth <= 16 ? 16 : 32;
+}
+
+/* dai component */
+/* interconnection */
+
+static const struct snd_kcontrol_new o124_mix[] = {
+	SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1, 0),
+};
+
+static const struct snd_kcontrol_new o125_mix[] = {
+	SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1, 0),
+};
+
+static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = {
+
+	/* DL */
+	SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0),
+	/* UL */
+	SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix, ARRAY_SIZE(o124_mix)),
+	SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix, ARRAY_SIZE(o125_mix)),
+};
+
+static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = {
+	{"I150", NULL, "ETDM Capture"},
+	{"I151", NULL, "ETDM Capture"},
+	{"ETDM Playback", NULL, "O124"},
+	{"ETDM Playback", NULL, "O125"},
+	{"O124", "I032_Switch", "I032"},
+	{"O125", "I033_Switch", "I033"},
+};
+
+/* dai ops */
+static int mtk_dai_etdm_startup(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	int ret;
+
+	ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks);
+	if (ret)
+		return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n");
+
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0);
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0);
+
+	return 0;
+}
+
+static void mtk_dai_etdm_shutdown(struct snd_pcm_substream *substream,
+				  struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK,
+			   CLK_OUT5_PDN);
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK,
+			   CLK_IN5_PDN);
+
+	clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks);
+}
+
+static unsigned int get_etdm_ch_fixup(unsigned int channels)
+{
+	if (channels > 16)
+		return 24;
+	else if (channels > 8)
+		return 16;
+	else if (channels > 4)
+		return 8;
+	else if (channels > 2)
+		return 4;
+	else
+		return 2;
+}
+
+static int mtk_dai_etdm_config(struct mtk_base_afe *afe,
+			       struct snd_pcm_hw_params *params,
+			       struct snd_soc_dai *dai,
+			       int stream)
+{
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id];
+	unsigned int rate = params_rate(params);
+	unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate);
+	unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate);
+	unsigned int channels = params_channels(params);
+	unsigned int bit_width = params_width(params);
+	unsigned int wlen = get_etdm_wlen(bit_width);
+	unsigned int val = 0;
+	unsigned int mask = 0;
+
+	dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n",
+		 __func__, stream, rate, bit_width);
+
+	/* CON0 */
+	mask |= ETDM_BIT_LEN_MASK;
+	val |= ETDM_BIT_LEN(bit_width);
+	mask |= ETDM_WRD_LEN_MASK;
+	val |= ETDM_WRD_LEN(wlen);
+	mask |= ETDM_FMT_MASK;
+	val |= ETDM_FMT(etdm_data->format);
+	mask |= ETDM_CH_NUM_MASK;
+	val |= ETDM_CH_NUM(get_etdm_ch_fixup(channels));
+	mask |= RELATCH_SRC_MASK;
+	val |= RELATCH_SRC(APLL_CLK);
+
+	switch (stream) {
+	case SNDRV_PCM_STREAM_PLAYBACK:
+		/* set ETDM_OUT5_CON0 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val);
+
+		/* set ETDM_OUT5_CON4 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_RELATCH_MASK, OUT_RELATCH(afe_rate));
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK));
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate));
+
+		/* set ETDM_OUT5_CON5 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON5,
+				   ETDM_CLK_DIV_MASK, ETDM_CLK_DIV);
+		break;
+	case SNDRV_PCM_STREAM_CAPTURE:
+		/* set ETDM_IN5_CON0 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val);
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0,
+				   ETDM_SYNC_MASK, ETDM_SYNC);
+
+		/* set ETDM_IN5_CON2 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON2,
+				   IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK));
+
+		/* set ETDM_IN5_CON3 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON3,
+				   IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate));
+
+		/* set ETDM_IN5_CON4 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON4,
+				   IN_RELATCH_MASK, IN_RELATCH(afe_rate));
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
+				  struct snd_pcm_hw_params *params,
+				  struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+	mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK);
+	mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE);
+
+	return 0;
+}
+
+static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd,
+				struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+	dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id);
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+				   ETDM_EN);
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
+				   ETDM_EN);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+				   0);
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
+				   0);
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	struct mtk_dai_etdm_priv *etdm_data;
+	void *priv_data;
+
+	switch (dai->id) {
+	case MT7986_DAI_ETDM:
+		break;
+	default:
+		dev_warn(afe->dev, "%s(), id %d not support\n",
+			 __func__, dai->id);
+		return -EINVAL;
+	}
+
+	priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv),
+				 GFP_KERNEL);
+	if (!priv_data)
+		return -ENOMEM;
+
+	afe_priv->dai_priv[dai->id] = priv_data;
+	etdm_data = afe_priv->dai_priv[dai->id];
+
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_I2S:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S;
+		break;
+	case SND_SOC_DAIFMT_DSP_A:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA;
+		break;
+	case SND_SOC_DAIFMT_DSP_B:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+	case SND_SOC_DAIFMT_NB_NF:
+		etdm_data->bck_inv = false;
+		etdm_data->lrck_inv = false;
+		break;
+	case SND_SOC_DAIFMT_NB_IF:
+		etdm_data->bck_inv = false;
+		etdm_data->lrck_inv = true;
+		break;
+	case SND_SOC_DAIFMT_IB_NF:
+		etdm_data->bck_inv = true;
+		etdm_data->lrck_inv = false;
+		break;
+	case SND_SOC_DAIFMT_IB_IF:
+		etdm_data->bck_inv = true;
+		etdm_data->lrck_inv = true;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBM_CFM:
+		etdm_data->slave_mode = true;
+		break;
+	case SND_SOC_DAIFMT_CBS_CFS:
+		etdm_data->slave_mode = false;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct snd_soc_dai_ops mtk_dai_etdm_ops = {
+	.startup = mtk_dai_etdm_startup,
+	.shutdown = mtk_dai_etdm_shutdown,
+	.hw_params = mtk_dai_etdm_hw_params,
+	.trigger = mtk_dai_etdm_trigger,
+	.set_fmt = mtk_dai_etdm_set_fmt,
+};
+
+/* dai driver */
+#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\
+			SNDRV_PCM_RATE_88200 |\
+			SNDRV_PCM_RATE_96000 |\
+			SNDRV_PCM_RATE_176400 |\
+			SNDRV_PCM_RATE_192000)
+
+#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
+			  SNDRV_PCM_FMTBIT_S24_LE |\
+			  SNDRV_PCM_FMTBIT_S32_LE)
+
+static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = {
+	{
+		.name = "ETDM",
+		.id = MT7986_DAI_ETDM,
+		.capture = {
+			.stream_name = "ETDM Capture",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = MTK_ETDM_RATES,
+			.formats = MTK_ETDM_FORMATS,
+		},
+		.playback = {
+			.stream_name = "ETDM Playback",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = MTK_ETDM_RATES,
+			.formats = MTK_ETDM_FORMATS,
+		},
+		.ops = &mtk_dai_etdm_ops,
+		.symmetric_rate = 1,
+		.symmetric_sample_bits = 1,
+	},
+};
+
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe)
+{
+	struct mtk_base_afe_dai *dai;
+
+	dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
+	if (!dai)
+		return -ENOMEM;
+
+	list_add(&dai->list, &afe->sub_dais);
+
+	dai->dai_drivers = mtk_dai_etdm_driver;
+	dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver);
+
+	dai->dapm_widgets = mtk_dai_etdm_widgets;
+	dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets);
+	dai->dapm_routes = mtk_dai_etdm_routes;
+	dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes);
+
+	return 0;
+}
Signature · 1 line
2.18.0
#5 lore raw

Re: [PATCH v3 2/6] ASoC: mediatek: mt7986: support etdm in platform driver

Hi Maso,

Quoted 15 lines · Maso Huang

Add mt7986 etdm dai driver support.

---
  sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 420 ++++++++++++++++++++
  1 file changed, 420 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +0 -0
new file mode 100644
index 000000000000..dc094e25ddb4

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 5

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek ALSA SoC Audio DAI eTDM Control
+ *
+ * Copyright (c) 2021 MediaTek Inc.

2023

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +1 -0
+ * Author: Vic Wu <[email protected]>

Authors

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 19

Quoted 13 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +13 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#include <linux/bitops.h>
+#include <linux/regmap.h>
+#include <sound/pcm_params.h>
+#include "mt7986-afe-common.h"
+#include "mt7986-reg.h"
+
+enum {
+	HOPPING_CLK = 0,
+	APLL_CLK = 1,
+};

Is there a reason to use enum instead of define ?

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 25

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +6 -0
+
+enum {
+	MTK_DAI_ETDM_FORMAT_I2S = 0,
+	MTK_DAI_ETDM_FORMAT_DSPA = 4,
+	MTK_DAI_ETDM_FORMAT_DSPB = 5,
+};

Same question here.

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 30

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
+
+enum {
+	ETDM_IN5 = 2,
+	ETDM_OUT5 = 10,
+};

I don't find where these enum are used.
If there aren't used, please remove them.

Quoted 161 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +161 -0
+
+enum {
+	MTK_ETDM_RATE_8K = 0,
+	MTK_ETDM_RATE_12K = 1,
+	MTK_ETDM_RATE_16K = 2,
+	MTK_ETDM_RATE_24K = 3,
+	MTK_ETDM_RATE_32K = 4,
+	MTK_ETDM_RATE_48K = 5,
+	MTK_ETDM_RATE_96K = 7,
+	MTK_ETDM_RATE_192K = 9,
+	MTK_ETDM_RATE_11K = 16,
+	MTK_ETDM_RATE_22K = 17,
+	MTK_ETDM_RATE_44K = 18,
+	MTK_ETDM_RATE_88K = 19,
+	MTK_ETDM_RATE_176K = 20,
+};
+
+struct mtk_dai_etdm_priv {
+	bool bck_inv;
+	bool lrck_inv;
+	bool slave_mode;
+	unsigned int format;
+};
+
+static unsigned int mt7986_etdm_rate_transform(struct device *dev, unsigned int rate)
+{
+	switch (rate) {
+	case 8000:
+		return MTK_ETDM_RATE_8K;
+	case 11025:
+		return MTK_ETDM_RATE_11K;
+	case 12000:
+		return MTK_ETDM_RATE_12K;
+	case 16000:
+		return MTK_ETDM_RATE_16K;
+	case 22050:
+		return MTK_ETDM_RATE_22K;
+	case 24000:
+		return MTK_ETDM_RATE_24K;
+	case 32000:
+		return MTK_ETDM_RATE_32K;
+	case 44100:
+		return MTK_ETDM_RATE_44K;
+	case 48000:
+		return MTK_ETDM_RATE_48K;
+	case 88200:
+		return MTK_ETDM_RATE_88K;
+	case 96000:
+		return MTK_ETDM_RATE_96K;
+	case 176400:
+		return MTK_ETDM_RATE_176K;
+	case 192000:
+		return MTK_ETDM_RATE_192K;
+	default:
+		dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n",
+			 __func__, rate, MTK_ETDM_RATE_48K);
+		return MTK_ETDM_RATE_48K;
+	}
+}
+
+static int get_etdm_wlen(unsigned int bitwidth)
+{
+	return bitwidth <= 16 ? 16 : 32;
+}
+
+/* dai component */
+/* interconnection */
+
+static const struct snd_kcontrol_new o124_mix[] = {
+	SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1, 0),
+};
+
+static const struct snd_kcontrol_new o125_mix[] = {
+	SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1, 0),
+};
+
+static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = {
+
+	/* DL */
+	SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0),
+	SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0),
+	/* UL */
+	SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix, ARRAY_SIZE(o124_mix)),
+	SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix, ARRAY_SIZE(o125_mix)),
+};
+
+static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = {
+	{"I150", NULL, "ETDM Capture"},
+	{"I151", NULL, "ETDM Capture"},
+	{"ETDM Playback", NULL, "O124"},
+	{"ETDM Playback", NULL, "O125"},
+	{"O124", "I032_Switch", "I032"},
+	{"O125", "I033_Switch", "I033"},
+};
+
+/* dai ops */
+static int mtk_dai_etdm_startup(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	int ret;
+
+	ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks);
+	if (ret)
+		return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n");
+
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0);
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0);
+
+	return 0;
+}
+
+static void mtk_dai_etdm_shutdown(struct snd_pcm_substream *substream,
+				  struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK,
+			   CLK_OUT5_PDN);
+	regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK,
+			   CLK_IN5_PDN);
+
+	clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks);
+}
+
+static unsigned int get_etdm_ch_fixup(unsigned int channels)
+{
+	if (channels > 16)
+		return 24;
+	else if (channels > 8)
+		return 16;
+	else if (channels > 4)
+		return 8;
+	else if (channels > 2)
+		return 4;
+	else
+		return 2;
+}
+
+static int mtk_dai_etdm_config(struct mtk_base_afe *afe,
+			       struct snd_pcm_hw_params *params,
+			       struct snd_soc_dai *dai,
+			       int stream)
+{
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id];
+	unsigned int rate = params_rate(params);
+	unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate);
+	unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate);
+	unsigned int channels = params_channels(params);
+	unsigned int bit_width = params_width(params);
+	unsigned int wlen = get_etdm_wlen(bit_width);
+	unsigned int val = 0;
+	unsigned int mask = 0;
+
+	dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n",
+		 __func__, stream, rate, bit_width);
+
+	/* CON0 */

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 201

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+	mask |= ETDM_BIT_LEN_MASK;
+	val |= ETDM_BIT_LEN(bit_width);
+	mask |= ETDM_WRD_LEN_MASK;
+	val |= ETDM_WRD_LEN(wlen);
+	mask |= ETDM_FMT_MASK;
+	val |= ETDM_FMT(etdm_data->format);
+	mask |= ETDM_CH_NUM_MASK;
+	val |= ETDM_CH_NUM(get_etdm_ch_fixup(channels));
+	mask |= RELATCH_SRC_MASK;
+	val |= RELATCH_SRC(APLL_CLK);

Why don't use bitfield helper to increase readability and reduce the number of define from mt7986-reg.h ?
val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width-1) ;

Then you can remove all ETDM_*****(x) and ETDM_*****_SFT these from your header file for all field:
#define ETDM_BIT_LEN(x) (((x) - 1) << 11)
#define ETDM_BIT_LEN_SFT 11

Please, do it for all bit operations in all your commits.

Quoted 219 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +219 -0
+
+	switch (stream) {
+	case SNDRV_PCM_STREAM_PLAYBACK:
+		/* set ETDM_OUT5_CON0 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val);
+
+		/* set ETDM_OUT5_CON4 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_RELATCH_MASK, OUT_RELATCH(afe_rate));
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK));
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+				   OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate));
+
+		/* set ETDM_OUT5_CON5 */
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON5,
+				   ETDM_CLK_DIV_MASK, ETDM_CLK_DIV);
+		break;
+	case SNDRV_PCM_STREAM_CAPTURE:
+		/* set ETDM_IN5_CON0 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val);
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0,
+				   ETDM_SYNC_MASK, ETDM_SYNC);
+
+		/* set ETDM_IN5_CON2 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON2,
+				   IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK));
+
+		/* set ETDM_IN5_CON3 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON3,
+				   IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate));
+
+		/* set ETDM_IN5_CON4 */
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON4,
+				   IN_RELATCH_MASK, IN_RELATCH(afe_rate));
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
+				  struct snd_pcm_hw_params *params,
+				  struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+	mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK);
+	mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE);
+
+	return 0;
+}
+
+static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd,
+				struct snd_soc_dai *dai)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+	dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id);
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+				   ETDM_EN);
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
+				   ETDM_EN);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+				   0);
+		regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
+				   0);
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+	struct mt7986_afe_private *afe_priv = afe->platform_priv;
+	struct mtk_dai_etdm_priv *etdm_data;
+	void *priv_data;
+
+	switch (dai->id) {
+	case MT7986_DAI_ETDM:
+		break;
+	default:
+		dev_warn(afe->dev, "%s(), id %d not support\n",
+			 __func__, dai->id);
+		return -EINVAL;
+	}
+
+	priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv),
+				 GFP_KERNEL);
+	if (!priv_data)
+		return -ENOMEM;
+
+	afe_priv->dai_priv[dai->id] = priv_data;
+	etdm_data = afe_priv->dai_priv[dai->id];
+
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_I2S:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S;
+		break;
+	case SND_SOC_DAIFMT_DSP_A:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA;
+		break;
+	case SND_SOC_DAIFMT_DSP_B:
+		etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+	case SND_SOC_DAIFMT_NB_NF:
+		etdm_data->bck_inv = false;
+		etdm_data->lrck_inv = false;
+		break;
+	case SND_SOC_DAIFMT_NB_IF:
+		etdm_data->bck_inv = false;
+		etdm_data->lrck_inv = true;
+		break;
+	case SND_SOC_DAIFMT_IB_NF:
+		etdm_data->bck_inv = true;
+		etdm_data->lrck_inv = false;
+		break;
+	case SND_SOC_DAIFMT_IB_IF:
+		etdm_data->bck_inv = true;
+		etdm_data->lrck_inv = true;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBM_CFM:
+		etdm_data->slave_mode = true;
+		break;
+	case SND_SOC_DAIFMT_CBS_CFS:
+		etdm_data->slave_mode = false;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct snd_soc_dai_ops mtk_dai_etdm_ops = {
+	.startup = mtk_dai_etdm_startup,
+	.shutdown = mtk_dai_etdm_shutdown,
+	.hw_params = mtk_dai_etdm_hw_params,
+	.trigger = mtk_dai_etdm_trigger,
+	.set_fmt = mtk_dai_etdm_set_fmt,
+};
+
+/* dai driver */
+#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\
+			SNDRV_PCM_RATE_88200 |\
+			SNDRV_PCM_RATE_96000 |\
+			SNDRV_PCM_RATE_176400 |\
+			SNDRV_PCM_RATE_192000)
+
+#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
+			  SNDRV_PCM_FMTBIT_S24_LE |\
+			  SNDRV_PCM_FMTBIT_S32_LE)
+
+static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = {
+	{
+		.name = "ETDM",
+		.id = MT7986_DAI_ETDM,
+		.capture = {
+			.stream_name = "ETDM Capture",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = MTK_ETDM_RATES,
+			.formats = MTK_ETDM_FORMATS,
+		},
+		.playback = {
+			.stream_name = "ETDM Playback",
+			.channels_min = 1,
+			.channels_max = 2,
+			.rates = MTK_ETDM_RATES,
+			.formats = MTK_ETDM_FORMATS,
+		},
+		.ops = &mtk_dai_etdm_ops,
+		.symmetric_rate = 1,
+		.symmetric_sample_bits = 1,
+	},
+};
+
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe)
+{
+	struct mtk_base_afe_dai *dai;
+
+	dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
+	if (!dai)
+		return -ENOMEM;
+
+	list_add(&dai->list, &afe->sub_dais);
+
+	dai->dai_drivers = mtk_dai_etdm_driver;
+	dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver);
+
+	dai->dapm_widgets = mtk_dai_etdm_widgets;
+	dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets);
+	dai->dapm_routes = mtk_dai_etdm_routes;
+	dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes);
+
+	return 0;
+}
Signature · 2 lines
Regards,
Alexandre
#6 lore raw

Re: [PATCH v3 2/6] ASoC: mediatek: mt7986: support etdm in platform driver

Quoted 19 lines · Alexandre Mergnat

External email : Please do not click links or open attachments until you have verified the sender or the content.
Hi Maso,

Quoted 4 lines · Maso Huang

Add mt7986 etdm dai driver support.

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

Quoted 2 lines
---
  sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 420

++++++++++++++++++++

Review

Quoted 4 lines
  1 file changed, 420 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

(quoted diff) +0 -0

b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 13 lines

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 5

Quoted 10 lines

new file mode 100644
index 000000000000..dc094e25ddb4

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek ALSA SoC Audio DAI eTDM Control
+ *
+ * Copyright (c) 2021 MediaTek Inc.

2023

OK.

Quoted 4 lines

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 6

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +1 -0
+ * Author: Vic Wu <[email protected]>

Authors

OK.

Quoted 7 lines
Quoted 7 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +7 -0
+ *         Maso Huang <[email protected]>
+ */
+
+#include <linux/bitops.h>
+#include <linux/regmap.h>
+#include <sound/pcm_params.h>
+#include "mt7986-afe-common.h"
Quoted 9 lines

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 19

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +6 -0
+#include "mt7986-reg.h"
+
+enum {
+HOPPING_CLK = 0,
+APLL_CLK = 1,
+};

Is there a reason to use enum instead of define ?

I'll refine with define in v4 patch.

Quoted 9 lines

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 25

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +6 -0
+
+enum {
+MTK_DAI_ETDM_FORMAT_I2S = 0,
+MTK_DAI_ETDM_FORMAT_DSPA = 4,
+MTK_DAI_ETDM_FORMAT_DSPB = 5,
+};

Same question here.

I'll refine with define in v4 patch.

Quoted 9 lines

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 30

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
+
+enum {
+ETDM_IN5 = 2,
+ETDM_OUT5 = 10,
+};

I don't find where these enum are used.
If there aren't used, please remove them.

I'll remove them in v4 patch.

Quoted 186 lines
Quoted 15 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +15 -0
+
+enum {
+MTK_ETDM_RATE_8K = 0,
+MTK_ETDM_RATE_12K = 1,
+MTK_ETDM_RATE_16K = 2,
+MTK_ETDM_RATE_24K = 3,
+MTK_ETDM_RATE_32K = 4,
+MTK_ETDM_RATE_48K = 5,
+MTK_ETDM_RATE_96K = 7,
+MTK_ETDM_RATE_192K = 9,
+MTK_ETDM_RATE_11K = 16,
+MTK_ETDM_RATE_22K = 17,
+MTK_ETDM_RATE_44K = 18,
+MTK_ETDM_RATE_88K = 19,
+MTK_ETDM_RATE_176K = 20,

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+};
+
+struct mtk_dai_etdm_priv {
+bool bck_inv;
+bool lrck_inv;
+bool slave_mode;
+unsigned int format;
+};
+
+static unsigned int mt7986_etdm_rate_transform(struct device *dev,

unsigned int rate)

Quoted 35 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +35 -0
+{
+switch (rate) {
+case 8000:
+return MTK_ETDM_RATE_8K;
+case 11025:
+return MTK_ETDM_RATE_11K;
+case 12000:
+return MTK_ETDM_RATE_12K;
+case 16000:
+return MTK_ETDM_RATE_16K;
+case 22050:
+return MTK_ETDM_RATE_22K;
+case 24000:
+return MTK_ETDM_RATE_24K;
+case 32000:
+return MTK_ETDM_RATE_32K;
+case 44100:
+return MTK_ETDM_RATE_44K;
+case 48000:
+return MTK_ETDM_RATE_48K;
+case 88200:
+return MTK_ETDM_RATE_88K;
+case 96000:
+return MTK_ETDM_RATE_96K;
+case 176400:
+return MTK_ETDM_RATE_176K;
+case 192000:
+return MTK_ETDM_RATE_192K;
+default:
+dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n",
+ __func__, rate, MTK_ETDM_RATE_48K);
+return MTK_ETDM_RATE_48K;
+}
+}
+

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+static int get_etdm_wlen(unsigned int bitwidth)
+{
+return bitwidth <= 16 ? 16 : 32;
+}
+
+/* dai component */
+/* interconnection */
+
+static const struct snd_kcontrol_new o124_mix[] = {
+SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1,

0),

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 4 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +4 -0
+};
+
+static const struct snd_kcontrol_new o125_mix[] = {
+SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1,

0),

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 9 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +9 -0
+};
+
+static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = {
+
+/* DL */
+SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0),
+SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0),
+/* UL */
+SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix,

ARRAY_SIZE(o124_mix)),

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 114

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +1 -0
+SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix,

ARRAY_SIZE(o125_mix)),

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 13 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +13 -0
+};
+
+static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = {
+{"I150", NULL, "ETDM Capture"},
+{"I151", NULL, "ETDM Capture"},
+{"ETDM Playback", NULL, "O124"},
+{"ETDM Playback", NULL, "O125"},
+{"O124", "I032_Switch", "I032"},
+{"O125", "I033_Switch", "I033"},
+};
+
+/* dai ops */
+static int mtk_dai_etdm_startup(struct snd_pcm_substream

*substream,

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 150

Quoted 11 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +11 -0
+struct snd_soc_dai *dai)
+{
+struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+struct mt7986_afe_private *afe_priv = afe->platform_priv;
+int ret;
+
+ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks);
+if (ret)
+return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n");
+
+regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK,

0);

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 152

Quoted 1 line
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +1 -0
+regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK,

0);

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 5 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
+
+return 0;
+}
+
+static void mtk_dai_etdm_shutdown(struct snd_pcm_substream

*substream,

Quoted 26 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +26 -0
+  struct snd_soc_dai *dai)
+{
+struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+struct mt7986_afe_private *afe_priv = afe->platform_priv;
+
+regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK,
+   CLK_OUT5_PDN);
+regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK,
+   CLK_IN5_PDN);
+
+clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks);
+}
+
+static unsigned int get_etdm_ch_fixup(unsigned int channels)
+{
+if (channels > 16)
+return 24;
+else if (channels > 8)
+return 16;
+else if (channels > 4)
+return 8;
+else if (channels > 2)
+return 4;
+else
+return 2;
+}

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+
+static int mtk_dai_etdm_config(struct mtk_base_afe *afe,
+       struct snd_pcm_hw_params *params,
+       struct snd_soc_dai *dai,
+       int stream)
+{
+struct mt7986_afe_private *afe_priv = afe->platform_priv;
+struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id];
+unsigned int rate = params_rate(params);
+unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev,

rate);

Quoted 11 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +11 -0
+unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate);
+unsigned int channels = params_channels(params);
+unsigned int bit_width = params_width(params);
+unsigned int wlen = get_etdm_wlen(bit_width);
+unsigned int val = 0;
+unsigned int mask = 0;
+
+dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n",
+ __func__, stream, rate, bit_width);
+
+/* CON0 */

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c line 201

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+mask |= ETDM_BIT_LEN_MASK;
+val |= ETDM_BIT_LEN(bit_width);
+mask |= ETDM_WRD_LEN_MASK;
+val |= ETDM_WRD_LEN(wlen);
+mask |= ETDM_FMT_MASK;
+val |= ETDM_FMT(etdm_data->format);
+mask |= ETDM_CH_NUM_MASK;
+val |= ETDM_CH_NUM(get_etdm_ch_fixup(channels));
+mask |= RELATCH_SRC_MASK;
+val |= RELATCH_SRC(APLL_CLK);

Why don't use bitfield helper to increase readability and reduce the number of define from mt7986-reg.h ?
val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width-1);

Quoted 8 lines

Then you can remove all ETDM_*****(x) and ETDM_*****_SFT these from your
header file for all field:
#define ETDM_BIT_LEN(x) (((x) - 1) << 11)
#define ETDM_BIT_LEN_SFT 11

Please, do it for all bit operations in all your commits.

OK, I'll refine them in v4 patch.

Quoted 216 lines
Quoted 34 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +34 -0
+
+switch (stream) {
+case SNDRV_PCM_STREAM_PLAYBACK:
+/* set ETDM_OUT5_CON0 */
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val);
+
+/* set ETDM_OUT5_CON4 */
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+   OUT_RELATCH_MASK, OUT_RELATCH(afe_rate));
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+   OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK));
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
+   OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate));
+
+/* set ETDM_OUT5_CON5 */
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON5,
+   ETDM_CLK_DIV_MASK, ETDM_CLK_DIV);
+break;
+case SNDRV_PCM_STREAM_CAPTURE:
+/* set ETDM_IN5_CON0 */
+regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val);
+regmap_update_bits(afe->regmap, ETDM_IN5_CON0,
+   ETDM_SYNC_MASK, ETDM_SYNC);
+
+/* set ETDM_IN5_CON2 */
+regmap_update_bits(afe->regmap, ETDM_IN5_CON2,
+   IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK));
+
+/* set ETDM_IN5_CON3 */
+regmap_update_bits(afe->regmap, ETDM_IN5_CON3,
+   IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate));
+
+/* set ETDM_IN5_CON4 */
+regmap_update_bits(afe->regmap, ETDM_IN5_CON4,

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+   IN_RELATCH_MASK, IN_RELATCH(afe_rate));
+break;
+default:
+break;
+}
+
+return 0;
+}
+
+static int mtk_dai_etdm_hw_params(struct snd_pcm_substream

*substream,

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 12 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +12 -0
+  struct snd_pcm_hw_params *params,
+  struct snd_soc_dai *dai)
+{
+struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK);
+mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE);
+
+return 0;
+}
+
+static int mtk_dai_etdm_trigger(struct snd_pcm_substream

*substream, int cmd,

Quoted 19 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +5 -0
+struct snd_soc_dai *dai)
+{
+struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+
+dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai-

id);

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +13 -0
+switch (cmd) {
+case SNDRV_PCM_TRIGGER_START:
+case SNDRV_PCM_TRIGGER_RESUME:
+regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+   ETDM_EN);
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
+   ETDM_EN);
+break;
+case SNDRV_PCM_TRIGGER_STOP:
+case SNDRV_PCM_TRIGGER_SUSPEND:
+regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
+   0);
+regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+   0);
+break;
+default:
+break;
+}
+
+return 0;
+}
+
+static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned

int fmt)

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +6 -0
+{
+struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+struct mt7986_afe_private *afe_priv = afe->platform_priv;
+struct mtk_dai_etdm_priv *etdm_data;
+void *priv_data;
+

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +10 -0
+switch (dai->id) {
+case MT7986_DAI_ETDM:
+break;
+default:
+dev_warn(afe->dev, "%s(), id %d not support\n",
+ __func__, dai->id);
+return -EINVAL;
+}
+
+priv_data = devm_kzalloc(afe->dev, sizeof(struct

mtk_dai_etdm_priv),

Quoted 111 lines

+ GFP_KERNEL);

sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +110 -0
+if (!priv_data)
+return -ENOMEM;
+
+afe_priv->dai_priv[dai->id] = priv_data;
+etdm_data = afe_priv->dai_priv[dai->id];
+
+switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+case SND_SOC_DAIFMT_I2S:
+etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S;
+break;
+case SND_SOC_DAIFMT_DSP_A:
+etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA;
+break;
+case SND_SOC_DAIFMT_DSP_B:
+etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB;
+break;
+default:
+return -EINVAL;
+}
+
+switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+case SND_SOC_DAIFMT_NB_NF:
+etdm_data->bck_inv = false;
+etdm_data->lrck_inv = false;
+break;
+case SND_SOC_DAIFMT_NB_IF:
+etdm_data->bck_inv = false;
+etdm_data->lrck_inv = true;
+break;
+case SND_SOC_DAIFMT_IB_NF:
+etdm_data->bck_inv = true;
+etdm_data->lrck_inv = false;
+break;
+case SND_SOC_DAIFMT_IB_IF:
+etdm_data->bck_inv = true;
+etdm_data->lrck_inv = true;
+break;
+default:
+return -EINVAL;
+}
+
+switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+case SND_SOC_DAIFMT_CBM_CFM:
+etdm_data->slave_mode = true;
+break;
+case SND_SOC_DAIFMT_CBS_CFS:
+etdm_data->slave_mode = false;
+break;
+default:
+return -EINVAL;
+}
+
+return 0;
+}
+
+static const struct snd_soc_dai_ops mtk_dai_etdm_ops = {
+.startup = mtk_dai_etdm_startup,
+.shutdown = mtk_dai_etdm_shutdown,
+.hw_params = mtk_dai_etdm_hw_params,
+.trigger = mtk_dai_etdm_trigger,
+.set_fmt = mtk_dai_etdm_set_fmt,
+};
+
+/* dai driver */
+#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\
+SNDRV_PCM_RATE_88200 |\
+SNDRV_PCM_RATE_96000 |\
+SNDRV_PCM_RATE_176400 |\
+SNDRV_PCM_RATE_192000)
+
+#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
+  SNDRV_PCM_FMTBIT_S24_LE |\
+  SNDRV_PCM_FMTBIT_S32_LE)
+
+static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = {
+{
+.name = "ETDM",
+.id = MT7986_DAI_ETDM,
+.capture = {
+.stream_name = "ETDM Capture",
+.channels_min = 1,
+.channels_max = 2,
+.rates = MTK_ETDM_RATES,
+.formats = MTK_ETDM_FORMATS,
+},
+.playback = {
+.stream_name = "ETDM Playback",
+.channels_min = 1,
+.channels_max = 2,
+.rates = MTK_ETDM_RATES,
+.formats = MTK_ETDM_FORMATS,
+},
+.ops = &mtk_dai_etdm_ops,
+.symmetric_rate = 1,
+.symmetric_sample_bits = 1,
+},
+};
+
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe)
+{
+struct mtk_base_afe_dai *dai;
+
+dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
+if (!dai)
+return -ENOMEM;
+
+list_add(&dai->list, &afe->sub_dais);
+
+dai->dai_drivers = mtk_dai_etdm_driver;
+dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver);
Quoted 12 lines
Quoted 8 lines
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c new file +8 -0
+
+dai->dapm_widgets = mtk_dai_etdm_widgets;
+dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets);
+dai->dapm_routes = mtk_dai_etdm_routes;
+dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes);
+
+return 0;
+}
Signature · 2 lines
Regards,
Alexandre

Hi Alexandre,

Thanks for your review.
I'll refine all of them in v4 patch :)

Best regards,
Maso

author
#7 lore raw

PATCH v3 3/6 ASoC: mediatek: mt7986: add platform driver

In reply to Maso Huang

Add mt7986 platform driver.

---
 sound/soc/mediatek/Kconfig                 |  10 +
 sound/soc/mediatek/Makefile                |   1 +
 sound/soc/mediatek/mt7986/Makefile         |   8 +
 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622 +++++++++++++++++++++
 4 files changed, 641 insertions(+)
 create mode 100644 sound/soc/mediatek/mt7986/Makefile
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c
sound/soc/mediatek/Kconfig +10 -0
index 90db67e0ce4f..558827755a8d 100644
@@ -54,6 +54,16 @@ config SND_SOC_MT6797_MT6351
 	  Select Y if you have such device.
 	  If unsure select "N".
 
+config SND_SOC_MT7986
+	tristate "ASoC support for Mediatek MT7986 chip"
+	depends on ARCH_MEDIATEK
+	select SND_SOC_MEDIATEK
+	help
+	  This adds ASoC platform driver support for MediaTek MT7986 chip
+	  that can be used with other codecs.
+	  Select Y if you have such device.
+	  If unsure select "N".
+
 config SND_SOC_MT8173
 	tristate "ASoC support for Mediatek MT8173 chip"
 	depends on ARCH_MEDIATEK
sound/soc/mediatek/Makefile +1 -0
index 3de38cfc69e5..3938e7f75c2e 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SND_SOC_MEDIATEK) += common/
 obj-$(CONFIG_SND_SOC_MT2701) += mt2701/
 obj-$(CONFIG_SND_SOC_MT6797) += mt6797/
+obj-$(CONFIG_SND_SOC_MT7986) += mt7986/
 obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
 obj-$(CONFIG_SND_SOC_MT8183) += mt8183/
 obj-$(CONFIG_SND_SOC_MT8186) += mt8186/
sound/soc/mediatek/mt7986/Makefile new file +8 -0
new file mode 100644
index 000000000000..de0742a67cae
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# platform driver
+snd-soc-mt7986-afe-objs := \
+	mt7986-afe-pcm.o \
+	mt7986-dai-etdm.o
+
+obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +622 -0

622 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 3/6
#8 lore raw

Re: [PATCH v3 3/6] ASoC: mediatek: mt7986: add platform driver

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 12 lines

Add mt7986 platform driver.

---
  sound/soc/mediatek/Kconfig                 |  10 +
  sound/soc/mediatek/Makefile                |   1 +
  sound/soc/mediatek/mt7986/Makefile         |   8 +
  sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622 +++++++++++++++++++++
  4 files changed, 641 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/Makefile create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c

..snip..

sound/soc/mediatek/mt7986/mt7986-afe-pcm.c line 579

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +6 -0
+	/* register component */
+	ret = devm_snd_soc_register_component(&pdev->dev,
+					      &mt7986_afe_component,
+					      NULL, 0);
+	if (ret)
+		return dev_err_probe(dev, ret, "err_platform\n");

I know I only said about using dev_err_probe(), but "err_platform" doesn't mean anything!

Please write a human readable error message, like "Cannot register AFE component\n"

sound/soc/mediatek/mt7986/mt7986-afe-pcm.c line 586

Quoted 7 lines
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +7 -0
+
+	ret = devm_snd_soc_register_component(afe->dev,
+					      &mt7986_afe_pcm_dai_component,
+					      afe->dai_drivers,
+					      afe->num_dai_drivers);
+	if (ret)
+		return dev_err_probe(dev, ret, "err_dai_component\n");

And the same here, "Cannot register PCM DAI component\n"

After which:

#9 lore raw

Re: [PATCH v3 3/6] ASoC: mediatek: mt7986: add platform driver

Quoted 42 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 13 lines

Add mt7986 platform driver.

---
  sound/soc/mediatek/Kconfig                 |  10 +
  sound/soc/mediatek/Makefile                |   1 +
  sound/soc/mediatek/mt7986/Makefile         |   8 +
  sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622
+++++++++++++++++++++
  4 files changed, 641 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/Makefile create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c

..snip..

sound/soc/mediatek/mt7986/mt7986-afe-pcm.c line 579

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +6 -0
+	/* register component */
+	ret = devm_snd_soc_register_component(&pdev->dev,
+					      &mt7986_afe_component,
+					      NULL, 0);
+	if (ret)
+		return dev_err_probe(dev, ret, "err_platform\n");

I know I only said about using dev_err_probe(), but "err_platform" doesn't
mean anything!

Please write a human readable error message, like "Cannot register AFE component\n"

sound/soc/mediatek/mt7986/mt7986-afe-pcm.c line 586

Quoted 8 lines
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +3 -0
+
+	ret = devm_snd_soc_register_component(afe->dev,
+					      &mt7986_afe_pcm_dai_compo

nent,

sound/soc/mediatek/mt7986/mt7986-afe-pcm.c new file +4 -0
+					      afe->dai_drivers,
+					      afe->num_dai_drivers);
+	if (ret)
+		return dev_err_probe(dev, ret, "err_dai_component\n");

And the same here, "Cannot register PCM DAI component\n"

Quoted 4 lines

After which:

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Hi Angelo,

Thanks for your review.
I'll refine it with human readable message!

Best regards,
Maso

author
#10 lore raw

PATCH v3 4/6 ASoC: mediatek: mt7986: add machine driver with wm8960

In reply to Maso Huang

Add support for mt7986 board with wm8960.

---
 sound/soc/mediatek/Kconfig                |  10 ++
 sound/soc/mediatek/mt7986/Makefile        |   1 +
 sound/soc/mediatek/mt7986/mt7986-wm8960.c | 184 ++++++++++++++++++++++
 3 files changed, 195 insertions(+)
 create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c
sound/soc/mediatek/Kconfig +10 -0
index 558827755a8d..8d1bc8814486 100644
@@ -64,6 +64,16 @@ config SND_SOC_MT7986
 	  Select Y if you have such device.
 	  If unsure select "N".
 
+config SND_SOC_MT7986_WM8960
+	tristate "ASoc Audio driver for MT7986 with WM8960 codec"
+	depends on SND_SOC_MT7986 && I2C
+	select SND_SOC_WM8960
+	help
+	  This adds support for ASoC machine driver for MediaTek MT7986
+	  boards with the WM8960 codecs.
+	  Select Y if you have such device.
+	  If unsure select "N".
+
 config SND_SOC_MT8173
 	tristate "ASoC support for Mediatek MT8173 chip"
 	depends on ARCH_MEDIATEK
sound/soc/mediatek/mt7986/Makefile +1 -0
index de0742a67cae..fc4c82559b29 100644
@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \
 	mt7986-dai-etdm.o
 
 obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
+obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +184 -0

184 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 4/6
#11 lore raw

Re: [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 45 lines

Add support for mt7986 board with wm8960.

---
  sound/soc/mediatek/Kconfig                |  10 ++
  sound/soc/mediatek/mt7986/Makefile        |   1 +
  sound/soc/mediatek/mt7986/mt7986-wm8960.c | 184 ++++++++++++++++++++++
  3 files changed, 195 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c

sound/soc/mediatek/Kconfig +10 -0
index 558827755a8d..8d1bc8814486 100644
@@ -64,6 +64,16 @@ config SND_SOC_MT7986
  	  Select Y if you have such device.
  	  If unsure select "N".
 
+config SND_SOC_MT7986_WM8960
+	tristate "ASoc Audio driver for MT7986 with WM8960 codec"
+	depends on SND_SOC_MT7986 && I2C
+	select SND_SOC_WM8960
+	help
+	  This adds support for ASoC machine driver for MediaTek MT7986
+	  boards with the WM8960 codecs.
+	  Select Y if you have such device.
+	  If unsure select "N".
+
  config SND_SOC_MT8173
  	tristate "ASoC support for Mediatek MT8173 chip"
  	depends on ARCH_MEDIATEK
sound/soc/mediatek/mt7986/Makefile +1 -0
index de0742a67cae..fc4c82559b29 100644
@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \
  	mt7986-dai-etdm.o
 
  obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
+obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +0 -0
new file mode 100644
index 000000000000..a880fcb8662e

..snip..

Quoted 60 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +60 -0
+static int mt7986_wm8960_machine_probe(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = &mt7986_wm8960_card;
+	struct snd_soc_dai_link *dai_link;
+	struct mt7986_wm8960_priv *priv;
+	int ret, i;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->platform_node = of_parse_phandle(pdev->dev.of_node,
+					       "mediatek,platform", 0);
+	if (!priv->platform_node) {
+		dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
+		return -EINVAL;
+	}
+
+	for_each_card_prelinks(card, i, dai_link) {
+		if (dai_link->platforms->name)
+			continue;
+		dai_link->platforms->of_node = priv->platform_node;
+	}
+
+	card->dev = &pdev->dev;
+
+	priv->codec_node = of_parse_phandle(pdev->dev.of_node,
+					    "mediatek,audio-codec", 0);
+	if (!priv->codec_node) {
+		dev_err(&pdev->dev,
+			"Property 'audio-codec' missing or invalid\n");
+		of_node_put(priv->platform_node);
+		return -EINVAL;
+	}
+
+	for_each_card_prelinks(card, i, dai_link) {
+		if (dai_link->codecs->name)
+			continue;
+		dai_link->codecs->of_node = priv->codec_node;
+	}
+
+	ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
+	if (ret) {
+		dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
+		goto err_of_node_put;
+	}
+
+	ret = devm_snd_soc_register_card(&pdev->dev, card);
+	if (ret) {
+		dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
+			__func__, ret);
+		goto err_of_node_put;
+	}
+
+err_of_node_put:
+	of_node_put(priv->codec_node);
+	of_node_put(priv->platform_node);
+	return ret;
+}
+

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 159

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +10 -0
+static void mt7986_wm8960_machine_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card);
+
+	of_node_put(priv->codec_node);
+	of_node_put(priv->platform_node);
+}
+
+#ifdef CONFIG_OF

Your probe function *relies on* devicetree, and you're adding an ifdef for CONFIG_OF? That wouldn't make sense, would it? ;-)

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 161

Quoted 2 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +2 -0
+static const struct of_device_id mt7986_wm8960_machine_dt_match[] = {
+	{.compatible = "mediatek,mt7986-wm8960-machine",},

please...

{ .compatible = "mediatek,mt7986-wm8960-machine" },

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 170

Quoted 9 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +9 -0
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match);
+#endif
+
+static struct platform_driver mt7986_wm8960_machine = {
+	.driver = {
+		.name = "mt7986-wm8960",
+#ifdef CONFIG_OF

Check struct device_driver: const struct of_device_id *of_match_table is always present, there's no ifdef.... and that's done in order to avoid seeing a bunch of ifdefs in drivers...

...so, why is this callback enclosed in an ifdef?

Please drop all those ifdefs.

After addressing those last comments, you can get my

Regards,
Angelo

#12 lore raw

Re: [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960

Il 28/07/23 11:49, AngeloGioacchino Del Regno ha scritto:

Quoted 121 lines

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 43 lines

Add support for mt7986 board with wm8960.

---
  sound/soc/mediatek/Kconfig                |  10 ++ sound/soc/mediatek/mt7986/Makefile        |   1 + sound/soc/mediatek/mt7986/mt7986-wm8960.c | 184 ++++++++++++++++++++++

  3 files changed, 195 insertions(+)

  create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c

sound/soc/mediatek/Kconfig +0 -0
index 558827755a8d..8d1bc8814486 100644
@@ -64,6 +64,16 @@ config SND_SOC_MT7986

        Select Y if you have such device.
        If unsure select "N".

sound/soc/mediatek/Kconfig +10 -0
+config SND_SOC_MT7986_WM8960
+    tristate "ASoc Audio driver for MT7986 with WM8960 codec"
+    depends on SND_SOC_MT7986 && I2C
+    select SND_SOC_WM8960
+    help
+      This adds support for ASoC machine driver for MediaTek MT7986
+      boards with the WM8960 codecs.
+      Select Y if you have such device.
+      If unsure select "N".
+

  config SND_SOC_MT8173
      tristate "ASoC support for Mediatek MT8173 chip" depends on ARCH_MEDIATEK

sound/soc/mediatek/mt7986/Makefile +0 -0
index de0742a67cae..fc4c82559b29 100644
@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \

      mt7986-dai-etdm.o obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o

sound/soc/mediatek/mt7986/Makefile +1 -0
+obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +0 -0
new file mode 100644
index 000000000000..a880fcb8662e

..snip..

Quoted 60 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +60 -0
+static int mt7986_wm8960_machine_probe(struct platform_device *pdev)
+{
+    struct snd_soc_card *card = &mt7986_wm8960_card;
+    struct snd_soc_dai_link *dai_link;
+    struct mt7986_wm8960_priv *priv;
+    int ret, i;
+
+    priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+    if (!priv)
+        return -ENOMEM;
+
+    priv->platform_node = of_parse_phandle(pdev->dev.of_node,
+                           "mediatek,platform", 0);
+    if (!priv->platform_node) {
+        dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
+        return -EINVAL;
+    }
+
+    for_each_card_prelinks(card, i, dai_link) {
+        if (dai_link->platforms->name)
+            continue;
+        dai_link->platforms->of_node = priv->platform_node;
+    }
+
+    card->dev = &pdev->dev;
+
+    priv->codec_node = of_parse_phandle(pdev->dev.of_node,
+                        "mediatek,audio-codec", 0);
+    if (!priv->codec_node) {
+        dev_err(&pdev->dev,
+            "Property 'audio-codec' missing or invalid\n");
+        of_node_put(priv->platform_node);
+        return -EINVAL;
+    }
+
+    for_each_card_prelinks(card, i, dai_link) {
+        if (dai_link->codecs->name)
+            continue;
+        dai_link->codecs->of_node = priv->codec_node;
+    }
+
+    ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
+    if (ret) {
+        dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
+        goto err_of_node_put;
+    }
+
+    ret = devm_snd_soc_register_card(&pdev->dev, card);
+    if (ret) {
+        dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
+            __func__, ret);
+        goto err_of_node_put;
+    }
+
+err_of_node_put:
+    of_node_put(priv->codec_node);
+    of_node_put(priv->platform_node);
+    return ret;
+}
+

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 159

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +10 -0
+static void mt7986_wm8960_machine_remove(struct platform_device *pdev)
+{
+    struct snd_soc_card *card = platform_get_drvdata(pdev);
+    struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card);
+
+    of_node_put(priv->codec_node);
+    of_node_put(priv->platform_node);
+}
+
+#ifdef CONFIG_OF

Your probe function *relies on* devicetree, and you're adding an ifdef for CONFIG_OF? That wouldn't make sense, would it? ;-)

Quoted 6 lines
Quoted 2 lines

+static const struct of_device_id mt7986_wm8960_machine_dt_match[] = { +    {.compatible = "mediatek,mt7986-wm8960-machine",},

please...

{ .compatible = "mediatek,mt7986-wm8960-machine" },

Actually, I noticed that just after sending the review.

Can you also please change the compatible, as "machine" doesn't really mean "sound"? :-)

.compatible = "mediatek,mt7986-wm8960-sound"

Thanks!

Quoted 26 lines

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 170

Quoted 10 lines

+    { /* sentinel */ }

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +8 -0
+};
+MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match);
+#endif
+
+static struct platform_driver mt7986_wm8960_machine = {
+    .driver = {
+        .name = "mt7986-wm8960",
+#ifdef CONFIG_OF

Check struct device_driver: const struct of_device_id *of_match_table is always present, there's no ifdef.... and that's done in order to avoid seeing a bunch of ifdefs in drivers...

...so, why is this callback enclosed in an ifdef?

Please drop all those ifdefs.

After addressing those last comments, you can get my

Regards,
Angelo

#13 lore raw

Re: [PATCH v3 4/6] ASoC: mediatek: mt7986: add machine driver with wm8960

Quoted 134 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:49, AngeloGioacchino Del Regno ha scritto:

Quoted 133 lines

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 48 lines

Add support for mt7986 board with wm8960.

---
  sound/soc/mediatek/Kconfig                |  10 ++
  sound/soc/mediatek/mt7986/Makefile        |   1 +
  sound/soc/mediatek/mt7986/mt7986-wm8960.c | 184
++++++++++++++++++++++
  3 files changed, 195 insertions(+)

create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c

sound/soc/mediatek/Kconfig +6 -0
index 558827755a8d..8d1bc8814486 100644
@@ -64,6 +64,16 @@ config SND_SOC_MT7986
        Select Y if you have such device.
        If unsure select "N".
+config SND_SOC_MT7986_WM8960
+    tristate "ASoc Audio driver for MT7986 with WM8960 codec"
+    depends on SND_SOC_MT7986 && I2C
+    select SND_SOC_WM8960
+    help
+      This adds support for ASoC machine driver for MediaTek

MT7986

sound/soc/mediatek/Kconfig +4 -0
+      boards with the WM8960 codecs.
+      Select Y if you have such device.
+      If unsure select "N".
+
  config SND_SOC_MT8173
      tristate "ASoC support for Mediatek MT8173 chip"
      depends on ARCH_MEDIATEK
sound/soc/mediatek/mt7986/Makefile +1 -0
index de0742a67cae..fc4c82559b29 100644
@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \
      mt7986-dai-etdm.o
  obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
+obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +0 -0
new file mode 100644
index 000000000000..a880fcb8662e

..snip..

Quoted 70 lines

+static int mt7986_wm8960_machine_probe(struct platform_device *pdev)

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +14 -0
+{
+    struct snd_soc_card *card = &mt7986_wm8960_card;
+    struct snd_soc_dai_link *dai_link;
+    struct mt7986_wm8960_priv *priv;
+    int ret, i;
+
+    priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+    if (!priv)
+        return -ENOMEM;
+
+    priv->platform_node = of_parse_phandle(pdev->dev.of_node,
+                           "mediatek,platform", 0);
+    if (!priv->platform_node) {
+        dev_err(&pdev->dev, "Property 'platform' missing or

invalid\n");

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +29 -0
+        return -EINVAL;
+    }
+
+    for_each_card_prelinks(card, i, dai_link) {
+        if (dai_link->platforms->name)
+            continue;
+        dai_link->platforms->of_node = priv->platform_node;
+    }
+
+    card->dev = &pdev->dev;
+
+    priv->codec_node = of_parse_phandle(pdev->dev.of_node,
+                        "mediatek,audio-codec", 0);
+    if (!priv->codec_node) {
+        dev_err(&pdev->dev,
+            "Property 'audio-codec' missing or invalid\n");
+        of_node_put(priv->platform_node);
+        return -EINVAL;
+    }
+
+    for_each_card_prelinks(card, i, dai_link) {
+        if (dai_link->codecs->name)
+            continue;
+        dai_link->codecs->of_node = priv->codec_node;
+    }
+
+    ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
+    if (ret) {
+        dev_err(&pdev->dev, "failed to parse audio-routing:

%d\n", ret);

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +6 -0
+        goto err_of_node_put;
+    }
+
+    ret = devm_snd_soc_register_card(&pdev->dev, card);
+    if (ret) {
+        dev_err(&pdev->dev, "%s snd_soc_register_card fail

%d\n",

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +11 -0
+            __func__, ret);
+        goto err_of_node_put;
+    }
+
+err_of_node_put:
+    of_node_put(priv->codec_node);
+    of_node_put(priv->platform_node);
+    return ret;
+}
+
+static void mt7986_wm8960_machine_remove(struct platform_device

*pdev)

sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +3 -0
+{
+    struct snd_soc_card *card = platform_get_drvdata(pdev);
+    struct mt7986_wm8960_priv *priv =

snd_soc_card_get_drvdata(card);

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 159

Quoted 6 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +6 -0
+
+    of_node_put(priv->codec_node);
+    of_node_put(priv->platform_node);
+}
+
+#ifdef CONFIG_OF

Your probe function *relies on* devicetree, and you're adding an ifdef for
CONFIG_OF? That wouldn't make sense, would it? ;-)

Hi Angelo,

Thanks for your review.

It seems we don't need CONFIG_OF here, so I'll remove it in v4 patch.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

+static const struct of_device_id
mt7986_wm8960_machine_dt_match[] = {
+ {.compatible = "mediatek,mt7986-wm8960-machine",},

please...

{ .compatible = "mediatek,mt7986-wm8960-machine" },

Actually, I noticed that just after sending the review.

Quoted 8 lines

Can you also please change the compatible, as "machine" doesn't really
mean "sound"? :-)

.compatible = "mediatek,mt7986-wm8960-sound"

Thanks!

For compatible suffix, I'll discuss with you in PATCH v3[5/6] mail, and will refine this with [5/6] mail conclusion :)

Quoted 22 lines
Quoted 22 lines

sound/soc/mediatek/mt7986/mt7986-wm8960.c line 170

Quoted 10 lines
sound/soc/mediatek/mt7986/mt7986-wm8960.c new file +9 -0
+    { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match);
+#endif
+
+static struct platform_driver mt7986_wm8960_machine = {
+    .driver = {
+        .name = "mt7986-wm8960",
+#ifdef CONFIG_OF

Check struct device_driver: const struct of_device_id *of_match_table is
always present, there's no ifdef.... and that's done in order to avoid seeing
a bunch of ifdefs in drivers...

...so, why is this callback enclosed in an ifdef?

Please drop all those ifdefs.

Quoted 9 lines
Quoted 7 lines

After addressing those last comments, you can get my

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Regards,
Angelo

No more needed for the ifdef, so I'll drop them in v4 patch :)

Best regards,
Maso

author
#14 lore raw

PATCH v3 5/6 ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

In reply to Maso Huang

Add document for mt7986 board with wm8960.

---
 .../sound/mediatek,mt7986-wm8960.yaml         | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +53 -0
new file mode 100644
index 000000000000..76394f7e5502
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of MT7986 platform.
+
+  audio-routing:
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+    description:
+      A list of the connections between audio components. Each entry is a
+      sink/source pair of strings. Valid names could be the input or output
+      widgets of audio components, power supplies, MicBias of codec and the
+      software switch.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - mediatek,platform
+  - audio-routing
+  - mediatek,audio-codec
+
+examples:
+  - |
+    sound {
+        compatible = "mediatek,mt7986-wm8960-machine";
+        mediatek,platform = <&afe>;
+        audio-routing =
+            "Headphone", "HP_L",
+            "Headphone", "HP_R",
+            "LINPUT1", "AMIC",
+            "RINPUT1", "AMIC";
+        mediatek,audio-codec = <&wm8960>;
+    };
+
+...
Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 5/6
#15 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 18 lines

Add document for mt7986 board with wm8960.

---
  .../sound/mediatek,mt7986-wm8960.yaml         | 53 +++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
new file mode 100644
index 000000000000..76394f7e5502
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 14

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +10 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine

mediatek,mt7986-wm8960-sound looks better.

After which,

#16 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 43 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 30 lines

Add document for mt7986 board with wm8960.

---
  .../sound/mediatek,mt7986-wm8960.yaml         | 53
+++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml
new file mode 100644
index 000000000000..76394f7e5502

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +0 -0

wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPPRaROt0$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPttZILAo$

Documentation/devicetree/bindings/sound/mediatek,mt7986-

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +9 -0
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine

mediatek,mt7986-wm8960-sound looks better.

Quoted 6 lines

After which,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Hi Angelo,

Thanks for your review.
I'll change the compatible to "mediatek,mt7986-wm8960-sound" in v4 patch.

Best regards,
Maso

#17 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 13 lines · Maso Huang
Quoted 12 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 11 lines

Add document for mt7986 board with wm8960.

---
  .../sound/mediatek,mt7986-wm8960.yaml         | 53
+++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml
new file mode 100644
index 000000000000..76394f7e5502
--- /dev/null

Quoted 8 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPPRaROt0$

Quoted 4 lines
Quoted 4 lines

Review line 5

Quoted 4 lines
(quoted diff) +1 -0
+$schema: 

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPttZILAo$

Quoted 21 lines
Quoted 14 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 14

Quoted 11 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +9 -0
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine

mediatek,mt7986-wm8960-sound looks better.

Quoted 6 lines

After which,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Quoted 9 lines

Hi Angelo,

Thanks for your review.
I'll change the compatible to "mediatek,mt7986-wm8960-sound" in v4 patch.

Best regards,
Maso

Hi Angelo,

One more question for this compatible.

The suffix "machine" means alsa machine driver for mt7986-wm8960. It might be better to use "machine" here.

Or you prefer "sound" than "machine"?

Best regards,
Maso

#18 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Il 31/07/23 08:42, Maso Huang (黃加竹) ha scritto:

Quoted 71 lines · Maso Huang
Quoted 13 lines · AngeloGioacchino Del Regno
Quoted 12 lines

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 11 lines

Add document for mt7986 board with wm8960.

---
   .../sound/mediatek,mt7986-wm8960.yaml         | 53
+++++++++++++++++++
   1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml
new file mode 100644
index 000000000000..76394f7e5502
--- /dev/null

Quoted 8 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPPRaROt0$

Quoted 4 lines
Quoted 4 lines

Review line 5

Quoted 4 lines
(quoted diff) +1 -0
+$schema:

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPttZILAo$

Quoted 21 lines
Quoted 14 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 14

Quoted 11 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +9 -0
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine

mediatek,mt7986-wm8960-sound looks better.

Quoted 6 lines

After which,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Quoted 9 lines

Hi Angelo,

Thanks for your review.
I'll change the compatible to "mediatek,mt7986-wm8960-sound" in v4 patch.

Best regards,
Maso

Hi Angelo,

One more question for this compatible.

Quoted 7 lines

The suffix "machine" means alsa machine driver for mt7986-wm8960. It might be better to use "machine" here.

Or you prefer "sound" than "machine"?

Best regards,
Maso

I prefer "sound" because of consistency with other MediaTek machine driver compatible strings.

Regards,
Angelo

#19 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 35 lines · AngeloGioacchino Del Regno

Il 31/07/23 08:42, Maso Huang (黃加竹) ha scritto:

Quoted 34 lines · Maso Huang
Quoted 31 lines
Quoted 29 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 28 lines

Add document for mt7986 board with wm8960.

---
   .../sound/mediatek,mt7986-wm8960.yaml         | 53
+++++++++++++++++++
   1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml
new file mode 100644
index 000000000000..76394f7e5502
--- /dev/null
+++
b/Documentation/devicetree/bindings/sound/mediatek,mt7986- wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPPRaROt0$

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Review line 5

Quoted 4 lines
(quoted diff) +1 -0
+$schema:

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!lu4Z6pJeRiL7-8l4T3ptqUCM54FnHTBiyh5KWBNqSjl6mOOI7WmzHpWEd-ZSZ-2NJ4Cs9PPaAF_75ywo2SKW16MPttZILAo$

Quoted 45 lines
Quoted 36 lines
Quoted 23 lines
Quoted 14 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 14

Quoted 11 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +9 -0
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine

mediatek,mt7986-wm8960-sound looks better.

Quoted 6 lines

After which,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Hi Angelo,

Quoted 8 lines

Thanks for your review.
I'll change the compatible to "mediatek,mt7986-wm8960-sound" in v4
patch.

Best regards,
Maso

Hi Angelo,

One more question for this compatible.

Quoted 8 lines

The suffix "machine" means alsa machine driver for mt7986-wm8960. It
might be better to use "machine" here.

Or you prefer "sound" than "machine"?

Best regards,
Maso

Quoted 6 lines

I prefer "sound" because of consistency with other MediaTek machine driver
compatible strings.

Regards,
Angelo

Hi Angelo,

No problem, I'll use "mediatek,mt7986-wm8960-sound" as compatible in v4 patch :)

Best regards,
Maso

#20 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

In reply to Maso Huang
Quoted 35 lines · Maso Huang

Add document for mt7986 board with wm8960.

---
 .../sound/mediatek,mt7986-wm8960.yaml         | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +21 -0
new file mode 100644
index 000000000000..76394f7e5502
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    const: mediatek,mt7986-wm8960-machine
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of MT7986 platform.
+
+  audio-routing:
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +10 -0
+    description:
+      A list of the connections between audio components. Each entry is a
+      sink/source pair of strings. Valid names could be the input or output
+      widgets of audio components, power supplies, MicBias of codec and the
+      software switch.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+

How did you implement Rob's comment? Or did you just ignore it?

Best regards,
Krzysztof

#21 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 61 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 5 lines · Maso Huang

Add document for mt7986 board with wm8960.

---
 .../sound/mediatek,mt7986-wm8960.yaml         | 53

+++++++++++++++++++

Quoted 2 lines
 1 file changed, 53 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

Quoted 2 lines

diff --git

a/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-

Quoted 4 lines

new file mode 100644
index 000000000000..76394f7e5502

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +0 -0

wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 4

Quoted 5 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +9 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 23

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +10 -0
+    const: mediatek,mt7986-wm8960-machine
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of MT7986 platform.
+
+  audio-routing:
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+    description:
+      A list of the connections between audio components. Each

entry is a

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 24

Quoted 1 line
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +1 -0
+      sink/source pair of strings. Valid names could be the input

or output

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 25

Quoted 1 line
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +1 -0
+      widgets of audio components, power supplies, MicBias of

codec and the

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 31

Quoted 6 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +6 -0
+      software switch.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+

How did you implement Rob's comment? Or did you just ignore it?

Quoted 3 lines

Best regards,
Krzysztof

Hi Krzysztof,

Sorry, I did not mean to ignore Rob's comment.
I waited for some suggestion in mail below, but it seems Rob was a little busy.

https://lore.kernel.org/lkml/[email protected]/

After gentle ping last week and receiving your advice, I thought that means to send the v3 patch and might discuss dtbingding in v3 series.

So sorry for misunderstanding it, I'll check the details with Rob in v3 series then refine it in v4.

Best regards,
Maso

#22 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 72 lines · Maso Huang (黃加竹)
Quoted 61 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 5 lines · Maso Huang

Add document for mt7986 board with wm8960.

---
 .../sound/mediatek,mt7986-wm8960.yaml         | 53

+++++++++++++++++++

Quoted 2 lines
 1 file changed, 53 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

Quoted 2 lines

diff --git

a/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-

Quoted 4 lines

new file mode 100644
index 000000000000..76394f7e5502

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +0 -0

wm8960.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 4

Quoted 5 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +9 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7986 sound card with WM8960 codec
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 23

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +10 -0
+    const: mediatek,mt7986-wm8960-machine
+
+  mediatek,platform:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of MT7986 platform.
+
+  audio-routing:
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+    description:
+      A list of the connections between audio components. Each

entry is a

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 24

Quoted 1 line
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +1 -0
+      sink/source pair of strings. Valid names could be the input

or output

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 25

Quoted 1 line
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +1 -0
+      widgets of audio components, power supplies, MicBias of

codec and the

Documentation/devicetree/bindings/sound/mediatek,mt7986- line 31

Quoted 6 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +6 -0
+      software switch.
+
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+

How did you implement Rob's comment? Or did you just ignore it?

Quoted 3 lines

Best regards,
Krzysztof

Hi Krzysztof,

Sorry, I did not mean to ignore Rob's comment.
I waited for some suggestion in mail below, but it seems Rob was a little busy.

Quoted 7 lines

https://lore.kernel.org/lkml/[email protected]/

After gentle ping last week and receiving your advice, I thought that means to send the v3 patch and might discuss dtbingding in v3 series.

So sorry for misunderstanding it, I'll check the details with Rob in v3 series then refine it in v4.

The problem is that you did not reference in this patch any ongoing discussion and further questions, so comment looks like addressed, while it was not.

Rob said:
"in a common schema and reference them "
You said:
"common part yaml and reference to it"
so I think you both agreed on the same.

The advice would be to create common binding which is then referenced by other and your bindings. However if you start doing it, you will notice that it is impossible, because you have conflicting types for "audio-codec", so you cannot have one definition.

This leads to the point - property is probably wrong and you need dai-link with sound-dai property, just like most cards are doing.

Best regards,
Krzysztof

#23 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 35 lines · Krzysztof Kozlowski
Quoted 17 lines
Quoted 10 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 31

Quoted 4 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+

How did you implement Rob's comment? Or did you just ignore it?

Best regards,
Krzysztof

Hi Krzysztof,

Sorry, I did not mean to ignore Rob's comment.
I waited for some suggestion in mail below, but it seems Rob was a little busy.

Quoted 7 lines

https://lore.kernel.org/lkml/[email protected]/

After gentle ping last week and receiving your advice, I thought that means to send the v3 patch and might discuss dtbingding in v3 series.

So sorry for misunderstanding it, I'll check the details with Rob in v3 series then refine it in v4.

The problem is that you did not reference in this patch any ongoing discussion and further questions, so comment looks like addressed, while it was not.

Rob said:
"in a common schema and reference them "
You said:
"common part yaml and reference to it"
so I think you both agreed on the same.

Quoted 7 lines

The advice would be to create common binding which is then referenced by other and your bindings. However if you start doing it, you will notice that it is impossible, because you have conflicting types for "audio-codec", so you cannot have one definition.

This leads to the point - property is probably wrong and you need dai-link with sound-dai property, just like most cards are doing.

BTW, might be useful for you, just sent:
https://lore.kernel.org/linux-devicetree/[email protected]/T/#t

Anyway you need dai-links, I think.

Best regards,
Krzysztof

#24 lore raw

Re: [PATCH v3 5/6] ASoC: dt-bindings: mediatek,mt7986-wm8960: add mt7986-wm8960 document

Quoted 47 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 11 lines · Krzysztof Kozlowski
Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml line 31

Quoted 4 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml new file +4 -0
+  mediatek,audio-codec:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: The phandle of wm8960 codec.
+

How did you implement Rob's comment? Or did you just ignore it?

Best regards,
Krzysztof

Quoted 7 lines
Quoted 7 lines

Hi Krzysztof,

Sorry, I did not mean to ignore Rob's comment.
I waited for some suggestion in mail below, but it seems Rob was a little busy.

https://lore.kernel.org/lkml/[email protected]/

Quoted 2 lines
Quoted 2 lines

After gentle ping last week and receiving your advice, I thought

that

Quoted 1 line
Quoted 1 line

means to send the v3 patch and might discuss dtbingding in v3

series.

Quoted 2 lines
Quoted 2 lines

So sorry for misunderstanding it, I'll check the details with Rob

in v3

Quoted 4 lines
Quoted 1 line

series then refine it in v4.

The problem is that you did not reference in this patch any ongoing discussion and further questions, so comment looks like addressed,

while

Quoted 9 lines

it was not.

Rob said:
"in a common schema and reference them "
You said:
"common part yaml and reference to it"
so I think you both agreed on the same.

The advice would be to create common binding which is then

referenced by

Quoted 1 line

other and your bindings. However if you start doing it, you will

Quoted 9 lines

notice

Quoted 5 lines

that it is impossible, because you have conflicting types for "audio-codec", so you cannot have one definition.

This leads to the point - property is probably wrong and you need dai-link with sound-dai property, just like most cards are doing.

BTW, might be useful for you, just sent:

https://lore.kernel.org/linux-devicetree/[email protected]/T/#t

Quoted 6 lines

Anyway you need dai-links, I think.

Best regards,
Krzysztof

Hi Krzysztof,

Thanks for your useful info!
I'll reference to sound-card-common.yaml for audio-routing.

For mediatek,platform and mediatek,audio-codec, I would like to replace them with cpu and codec as properties directly like below.

cpu {
    sound-dai <&ate>;
};
codec {
    sound-dai <&wm8960>;
};

Is that OK?

Best regards,
Maso

author
#25 lore raw

PATCH v3 6/6 ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

In reply to Maso Huang

Add mt7986 audio afe document.

---
 .../bindings/sound/mediatek,mt7986-afe.yaml   | 89 +++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +89 -0
new file mode 100644
index 000000000000..ebb151c6400f
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek AFE PCM controller for MT7986
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt7986-afe
+      - items:
+          - enum:
+              - mediatek,mt7981-afe
+              - mediatek,mt7988-afe
+          - const: mediatek,mt7986-afe
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    minItems: 5
+    items:
+      - description: audio bus clock
+      - description: audio 26M clock
+      - description: audio intbus clock
+      - description: audio hopping clock
+      - description: audio pll clock
+      - description: mux for pcm_mck
+      - description: audio i2s/pcm mck
+
+  clock-names:
+    minItems: 5
+    items:
+      - const: bus_ck
+      - const: 26m_ck
+      - const: l_ck
+      - const: aud_ck
+      - const: eg2_ck
+      - const: sel
+      - const: i2s_m
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/mt7986-clk.h>
+
+    afe@11210000 {
+        compatible = "mediatek,mt7986-afe";
+        reg = <0x11210000 0x9000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_26M_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_L_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_AUD_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_EG2_CK>;
+        clock-names = "bus_ck",
+                      "26m_ck",
+                      "l_ck",
+                      "aud_ck",
+                      "eg2_ck";
+        assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>,
+                          <&topckgen CLK_TOP_AUD_L_SEL>,
+                          <&topckgen CLK_TOP_A_TUNER_SEL>;
+        assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>,
+                                 <&apmixedsys CLK_APMIXED_APLL2>,
+                                 <&topckgen CLK_TOP_APLL2_D4>;
+    };
+
+...
Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 6/6
#26 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 61 lines

Add mt7986 audio afe document.

---
  .../bindings/sound/mediatek,mt7986-afe.yaml   | 89 +++++++++++++++++++
  1 file changed, 89 insertions(+)

create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +47 -0
new file mode 100644
index 000000000000..ebb151c6400f
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek AFE PCM controller for MT7986
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt7986-afe
+      - items:
+          - enum:
+              - mediatek,mt7981-afe
+              - mediatek,mt7988-afe
+          - const: mediatek,mt7986-afe
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    minItems: 5
+    items:
+      - description: audio bus clock
+      - description: audio 26M clock
+      - description: audio intbus clock
+      - description: audio hopping clock
+      - description: audio pll clock
+      - description: mux for pcm_mck
+      - description: audio i2s/pcm mck
+
+  clock-names:
+    minItems: 5
+    items:
+      - const: bus_ck
+      - const: 26m_ck
+      - const: l_ck
+      - const: aud_ck
+      - const: eg2_ck
+      - const: sel

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +10 -0
+      - const: i2s_m
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents

assigned-clocks and assigned-clock-parents are not a *required* property, as that depends on a number of things and someone *may* want to omit it.

Besides, that's related to how the drivers interact with / setup the hardware and not with the hardware itself... you can keep the assigned-clocks and assigned-clock-parents in your examples, but again they're definitely not required properties.

After fixing,

Regards,
Angelo

Quoted 32 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +32 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/mt7986-clk.h>
+
+    afe@11210000 {
+        compatible = "mediatek,mt7986-afe";
+        reg = <0x11210000 0x9000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_26M_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_L_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_AUD_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_EG2_CK>;
+        clock-names = "bus_ck",
+                      "26m_ck",
+                      "l_ck",
+                      "aud_ck",
+                      "eg2_ck";
+        assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>,
+                          <&topckgen CLK_TOP_AUD_L_SEL>,
+                          <&topckgen CLK_TOP_A_TUNER_SEL>;
+        assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>,
+                                 <&apmixedsys CLK_APMIXED_APLL2>,
+                                 <&topckgen CLK_TOP_APLL2_D4>;
+    };
+
+...
#27 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

Quoted 95 lines · AngeloGioacchino Del Regno

Il 28/07/23 11:08, Maso Huang ha scritto:

Quoted 70 lines

Add mt7986 audio afe document.

---
  .../bindings/sound/mediatek,mt7986-afe.yaml   | 89
+++++++++++++++++++
  1 file changed, 89 insertions(+)

create mode 100644
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml

diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file mode 100644
index 000000000000..ebb151c6400f

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +0 -0

afe.yaml

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +4 -0
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml*__;Iw!!CTRNKA9wMg0ARbw!nwtJIMuoaT5RiUlFU-0ExLhvWHgz9nyXm0Jxk9RfoaKqIKzS8_JTvdIW9AhOkTIpVjN9Jv3L7Aj4nXzTEeuHK2-Wdq69mo0$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!nwtJIMuoaT5RiUlFU-0ExLhvWHgz9nyXm0Jxk9RfoaKqIKzS8_JTvdIW9AhOkTIpVjN9Jv3L7Aj4nXzTEeuHK2-Wo1ebvx8$

Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +42 -0
+
+title: MediaTek AFE PCM controller for MT7986
+
+maintainers:
+  - Maso Huang <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt7986-afe
+      - items:
+          - enum:
+              - mediatek,mt7981-afe
+              - mediatek,mt7988-afe
+          - const: mediatek,mt7986-afe
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    minItems: 5
+    items:
+      - description: audio bus clock
+      - description: audio 26M clock
+      - description: audio intbus clock
+      - description: audio hopping clock
+      - description: audio pll clock
+      - description: mux for pcm_mck
+      - description: audio i2s/pcm mck
+
+  clock-names:
+    minItems: 5
+    items:
+      - const: bus_ck
+      - const: 26m_ck
+      - const: l_ck
+      - const: aud_ck
+      - const: eg2_ck
+      - const: sel

Documentation/devicetree/bindings/sound/mediatek,mt7986-

Quoted 10 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +10 -0
+      - const: i2s_m
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents

assigned-clocks and assigned-clock-parents are not a *required* property,
as that depends on a number of things and someone *may* want to omit it.

Besides, that's related to how the drivers interact with / setup the hardware
and not with the hardware itself... you can keep the assigned-clocks and
assigned-clock-parents in your examples, but again they're definitely not
required properties.

Quoted 8 lines

After fixing,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Regards,
Angelo

Hi Angelo,

Thanks for your review.
I'll remove these in v4 patch!

Best regards,
Maso

Quoted 34 lines
Quoted 32 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986- new file +32 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/mt7986-clk.h>
+
+    afe@11210000 {
+        compatible = "mediatek,mt7986-afe";
+        reg = <0x11210000 0x9000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_26M_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_L_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_AUD_CK>,
+                 <&infracfg_ao CLK_INFRA_AUD_EG2_CK>;
+        clock-names = "bus_ck",
+                      "26m_ck",
+                      "l_ck",
+                      "aud_ck",
+                      "eg2_ck";
+        assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>,
+                          <&topckgen CLK_TOP_AUD_L_SEL>,
+                          <&topckgen CLK_TOP_A_TUNER_SEL>;
+        assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>,
+                                 <&apmixedsys CLK_APMIXED_APLL2>,
+                                 <&topckgen CLK_TOP_APLL2_D4>;
+    };
+
+...
#28 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

In reply to Maso Huang
Quoted 3 lines · Maso Huang

Add mt7986 audio afe document.

Thank you for your patch. There is something to discuss/improve.

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents

You should constrain your clocks per variants. I doubt that they are really so flexible/optional on each SoC... or maybe missing clocks are result of unimplemented parts in the driver? But then this should not really affect bindings. Bindings still should require such clocks. Your DTS can always provide a <0>, if needed.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+additionalProperties: false

Best regards,
Krzysztof

maintainer
#29 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 2 lines · Maso Huang
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +2 -0
+  - assigned-clocks
+  - assigned-clock-parents

You should constrain your clocks per variants. I doubt that they are really so flexible/optional on each SoC... or maybe missing clocks are result of unimplemented parts in the driver? But then this should not really affect bindings. Bindings still should require such clocks. Your DTS can always provide a <0>, if needed.

Depending on what the clocks are some of them might genuinely be optional, it's fairly common for audio devices to have multiple clock inputs and be able to select between them depending on system requirements or to have bidirectional clock pins which may be either a provider or consumer depending on system configuration. No idea how that applies with this specific device.

#30 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

In reply to Krzysztof Kozlowski
Quoted 20 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 3 lines · Maso Huang

Add mt7986 audio afe document.

Thank you for your patch. There is something to discuss/improve.

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
Quoted 9 lines

You should constrain your clocks per variants. I doubt that they are really so flexible/optional on each SoC... or maybe missing clocks are
result of unimplemented parts in the driver? But then this should not really affect bindings. Bindings still should require such clocks. Your
DTS can always provide a <0>, if needed.

Hi Krzysztof,

After internal check, assigned-clocks and assigned-clock-parents are not required on this SoC.
Maybe we can just drop these two options?

Best regards,
Maso

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+additionalProperties: false

Best regards,
Krzysztof

#31 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

Quoted 31 lines · Maso Huang (黃加竹)
Quoted 20 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 3 lines · Maso Huang

Add mt7986 audio afe document.

Thank you for your patch. There is something to discuss/improve.

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
Quoted 9 lines

You should constrain your clocks per variants. I doubt that they are really so flexible/optional on each SoC... or maybe missing clocks are
result of unimplemented parts in the driver? But then this should not really affect bindings. Bindings still should require such clocks. Your
DTS can always provide a <0>, if needed.

Quoted 5 lines

Hi Krzysztof,

After internal check, assigned-clocks and assigned-clock-parents are not required on this SoC.
Maybe we can just drop these two options?

It's separate issue, but yes - why requiring them?

I wrote about missing constraints for your clocks in the bindings.

Best regards,
Krzysztof

#32 lore raw

Re: [PATCH v3 6/6] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe document

Quoted 45 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 3 lines · Maso Huang (黃加竹)
Quoted 2 lines · Krzysztof Kozlowski

External email : Please do not click links or open attachments

until

Quoted 8 lines
Quoted 8 lines

you have verified the sender or the content.

Quoted 3 lines · Maso Huang

Add mt7986 audio afe document.

Thank you for your patch. There is something to discuss/improve.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml line 57

Quoted 9 lines
Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents

You should constrain your clocks per variants. I doubt that they

are

Quoted 3 lines
Quoted 3 lines

really so flexible/optional on each SoC... or maybe missing clocks are
result of unimplemented parts in the driver? But then this should

not

Quoted 9 lines
Quoted 5 lines

really affect bindings. Bindings still should require such clocks. Your
DTS can always provide a <0>, if needed.

Hi Krzysztof,

After internal check, assigned-clocks and assigned-clock-parents

are

Quoted 2 lines

not required on this SoC.
Maybe we can just drop these two options?

Quoted 7 lines

It's separate issue, but yes - why requiring them?

I wrote about missing constraints for your clocks in the bindings.

Best regards,
Krzysztof

Hi Krzysztof,

OK, I'll remove assigned-clock and assigned-clock-parents. And constrain the clocks for different SoC in the binding in v4 patch.

Best regards,
Maso