Skip to contentSkip to conversation

ASoC: SOF: Add support for Mediatek MT8195

PATCH In review Daniel Baluta 3 participants 18 messages Nov 18, 2021 – Nov 26, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover ASoC: SOF: Add support for Mediatek MT8195

From: Daniel Baluta <[email protected]>

This adds sound open firmware driver support for MT8915 platform.

Changes since v1:
- removed AMD patches since they were already applied
- fixed compilation error reported by Mark, generated by the fact that mt8195_run was declared too early in the series.

YC Hung (8):
ASoC: SOF: mediatek: Add mt8195 hardware support
ASoC: SOF: tokens: add token for Mediatek AFE
ASoC: SOF: topology: Add support for Mediatek AFE DAI
ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware
ASoC: SOF: Add mt8195 device descriptor
ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195
ASoC: SOF: mediatek: Add mt8195 dsp clock support
ASoC: SOF: mediatek: Add DSP system PM callback for mt8195

 include/sound/sof/dai-mediatek.h              |  23 +
 include/sound/sof/dai.h                       |   3 +
 include/uapi/sound/sof/tokens.h               |   5 +
 sound/soc/sof/Kconfig                         |   3 +-
 sound/soc/sof/Makefile                        |   1 +
 sound/soc/sof/mediatek/Kconfig                |  33 ++
 sound/soc/sof/mediatek/Makefile               |   2 +
 sound/soc/sof/mediatek/adsp_helper.h          |  49 ++
 sound/soc/sof/mediatek/mediatek-ops.h         |   8 +
 sound/soc/sof/mediatek/mt8195/Makefile        |   3 +
 sound/soc/sof/mediatek/mt8195/mt8195-clk.c    | 158 +++++++
 sound/soc/sof/mediatek/mt8195/mt8195-clk.h    |  28 ++
 sound/soc/sof/mediatek/mt8195/mt8195-loader.c |  56 +++
 sound/soc/sof/mediatek/mt8195/mt8195.c        | 437 ++++++++++++++++++
 sound/soc/sof/mediatek/mt8195/mt8195.h        | 158 +++++++
 sound/soc/sof/pcm.c                           |  12 +
 sound/soc/sof/sof-of-dev.c                    |  13 +
 sound/soc/sof/topology.c                      |  59 +++
 18 files changed, 1050 insertions(+), 1 deletion(-)
 create mode 100644 include/sound/sof/dai-mediatek.h
 create mode 100644 sound/soc/sof/mediatek/Kconfig
 create mode 100644 sound/soc/sof/mediatek/Makefile
 create mode 100644 sound/soc/sof/mediatek/adsp_helper.h
 create mode 100644 sound/soc/sof/mediatek/mediatek-ops.h
 create mode 100644 sound/soc/sof/mediatek/mt8195/Makefile
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.c
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.h
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-loader.c
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.c
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.h
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#1 lore raw

PATCH v2 1/8 ASoC: SOF: mediatek: Add mt8195 hardware support

From: YC Hung <[email protected]>

This patch initialize to support SOF on Mediatek mt8195 platform. MT8195 has four Cortex A78 cores paired with four Cortex A55 cores. It also has Cadence HiFi-4 DSP single core. There are shared DRAM and mailbox interrupt between AP and DSP to use for IPC communication.

---
 sound/soc/sof/Kconfig                  |   1 +
 sound/soc/sof/Makefile                 |   1 +
 sound/soc/sof/mediatek/Kconfig         |  33 +++
 sound/soc/sof/mediatek/Makefile        |   2 +
 sound/soc/sof/mediatek/adsp_helper.h   |  49 ++++
 sound/soc/sof/mediatek/mediatek-ops.h  |   8 +
 sound/soc/sof/mediatek/mt8195/Makefile |   3 +
 sound/soc/sof/mediatek/mt8195/mt8195.c | 323 +++++++++++++++++++++++++
 sound/soc/sof/mediatek/mt8195/mt8195.h | 155 ++++++++++++
 9 files changed, 575 insertions(+)
 create mode 100644 sound/soc/sof/mediatek/Kconfig
 create mode 100644 sound/soc/sof/mediatek/Makefile
 create mode 100644 sound/soc/sof/mediatek/adsp_helper.h
 create mode 100644 sound/soc/sof/mediatek/mediatek-ops.h
 create mode 100644 sound/soc/sof/mediatek/mt8195/Makefile
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.c
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.h
sound/soc/sof/Kconfig +1 -0
index 0e5473e899cd..b0cdabcfdde7 100644
@@ -236,6 +236,7 @@ config SND_SOC_SOF_PROBE_WORK_QUEUE
 source "sound/soc/sof/amd/Kconfig"
 source "sound/soc/sof/imx/Kconfig"
 source "sound/soc/sof/intel/Kconfig"
+source "sound/soc/sof/mediatek/Kconfig"
 source "sound/soc/sof/xtensa/Kconfig"
 
 endif
sound/soc/sof/Makefile +1 -0
index 81ad8cb666e3..964b429146be 100644
@@ -24,3 +24,4 @@ obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
 obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/
 obj-$(CONFIG_SND_SOC_SOF_AMD_TOPLEVEL) += amd/
 obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/
+obj-$(CONFIG_SND_SOC_SOF_MTK_TOPLEVEL) += mediatek/
sound/soc/sof/mediatek/Kconfig new file +33 -0
new file mode 100644
index 000000000000..aeacf0e5bfbb
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+
+config SND_SOC_SOF_MTK_TOPLEVEL
+	bool "SOF support for MTK audio DSPs"
+	depends on ARM64 || COMPILE_TEST
+	depends on SND_SOC_SOF_OF
+	help
+	  This adds support for Sound Open Firmware for Mediatek platforms.
+	  It is top level for all mediatek platforms.
+	  Say Y if you have such a device.
+	  If unsure select "N".
+
+if SND_SOC_SOF_MTK_TOPLEVEL
+config SND_SOC_SOF_MTK_COMMON
+	tristate
+	select SND_SOC_SOF_OF_DEV
+	select SND_SOC_SOF
+	select SND_SOC_SOF_XTENSA
+	select SND_SOC_SOF_COMPRESS
+	help
+	  This option is not user-selectable but automagically handled by
+	  'select' statements at a higher level
+
+config SND_SOC_SOF_MT8195
+	tristate "SOF support for MT8195 audio DSP"
+	select SND_SOC_SOF_MTK_COMMON
+	help
+	  This adds support for Sound Open Firmware for Mediatek platforms
+	  using the mt8195 processors.
+	  Say Y if you have such a device.
+	  If unsure select "N".
+
+endif ## SND_SOC_SOF_MTK_TOPLEVEL
sound/soc/sof/mediatek/Makefile new file +2 -0
new file mode 100644
index 000000000000..e8ec6da981de
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+obj-$(CONFIG_SND_SOC_SOF_MT8195) += mt8195/
sound/soc/sof/mediatek/adsp_helper.h new file +49 -0

49 lines not on this page · raw message

sound/soc/sof/mediatek/mediatek-ops.h new file +8 -0
new file mode 100644
index 000000000000..e0ffa69ecb0c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+
+#ifndef __MEDIATEK_OPS_H__
+#define __MEDIATEK_OPS_H__
+
+extern const struct snd_sof_dsp_ops sof_mt8195_ops;
+
+#endif
sound/soc/sof/mediatek/mt8195/Makefile new file +3 -0
new file mode 100644
index 000000000000..dd2b6e4affc9
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+snd-sof-mt8195-objs := mt8195.o
+obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o
sound/soc/sof/mediatek/mt8195/mt8195.c new file +323 -0

323 lines not on this page · raw message

sound/soc/sof/mediatek/mt8195/mt8195.h new file +155 -0

155 lines not on this page · raw message

Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 1/8
#2 lore raw

Re: [PATCH v2 1/8] ASoC: SOF: mediatek: Add mt8195 hardware support

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 7 lines

From: YC Hung <[email protected]>

This patch initialize to support SOF on Mediatek mt8195 platform. MT8195 has four Cortex A78 cores paired with four Cortex A55 cores. It also has Cadence HiFi-4 DSP single core. There are shared DRAM and mailbox interrupt between AP and DSP to use for IPC communication.

Quoted 8 lines
#3 lore raw

PATCH v2 2/8 ASoC: SOF: tokens: add token for Mediatek AFE

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add the definition for Mediatek audio front end(AFE) tokens,include AFE sampling rate, channels, and format.

---
 include/uapi/sound/sof/tokens.h | 5 +++++
 1 file changed, 5 insertions(+)
include/uapi/sound/sof/tokens.h +5 -0
index 02b71a8deea4..b72fa385bebf 100644
@@ -140,4 +140,9 @@
 #define SOF_TKN_INTEL_HDA_RATE			1500
 #define SOF_TKN_INTEL_HDA_CH			1501
 
+/* AFE */
+#define SOF_TKN_MEDIATEK_AFE_RATE		1600
+#define SOF_TKN_MEDIATEK_AFE_CH			1601
+#define SOF_TKN_MEDIATEK_AFE_FORMAT		1602
+
 #endif
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 2/8
#4 lore raw

Re: [PATCH v2 2/8] ASoC: SOF: tokens: add token for Mediatek AFE

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 5 lines

From: YC Hung <[email protected]>

Add the definition for Mediatek audio front end(AFE) tokens,include AFE sampling rate, channels, and format.

Quoted 8 lines
#5 lore raw

PATCH v2 3/8 ASoC: SOF: topology: Add support for Mediatek AFE DAI

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add new sof dai and config to pass topology file configuration to SOF firmware running on Mediatek platform DSP core. Add mediatek audio front end(AFE) to the list of supported sof_dais

---
 include/sound/sof/dai-mediatek.h | 23 +++++++++++++
 include/sound/sof/dai.h          |  3 ++
 sound/soc/sof/pcm.c              | 12 +++++++
 sound/soc/sof/topology.c         | 59 ++++++++++++++++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 include/sound/sof/dai-mediatek.h
include/sound/sof/dai-mediatek.h new file +23 -0
new file mode 100644
index 000000000000..62dd4720558d
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+/*
+ * Copyright(c) 2021 Mediatek Corporation. All rights reserved.
+ *
+ * Author: Bo Pan <[email protected]>
+ */
+
+#ifndef __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__
+#define __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__
+
+#include <sound/sof/header.h>
+
+struct sof_ipc_dai_mtk_afe_params {
+	struct sof_ipc_hdr hdr;
+	u32 channels;
+	u32 rate;
+	u32 format;
+	u32 stream_id;
+	u32 reserved[4]; /* reserve for future */
+} __packed;
+
+#endif
+
include/sound/sof/dai.h +3 -0
index 3782127a7095..5132bc60f54b 100644
@@ -13,6 +13,7 @@
 #include <sound/sof/dai-intel.h>
 #include <sound/sof/dai-imx.h>
 #include <sound/sof/dai-amd.h>
+#include <sound/sof/dai-mediatek.h>
 
 /*
  * DAI Configuration.
@@ -70,6 +71,7 @@ enum sof_ipc_dai_type {
 	SOF_DAI_AMD_BT,			/**< AMD ACP BT*/
 	SOF_DAI_AMD_SP,			/**< AMD ACP SP */
 	SOF_DAI_AMD_DMIC,		/**< AMD ACP DMIC */
+	SOF_DAI_MEDIATEK_AFE,		/**< Mediatek AFE */
 };
 
 /* general purpose DAI configuration */
@@ -97,6 +99,7 @@ struct sof_ipc_dai_config {
 		struct sof_ipc_dai_acp_params acpbt;
 		struct sof_ipc_dai_acp_params acpsp;
 		struct sof_ipc_dai_acp_params acpdmic;
+		struct sof_ipc_dai_mtk_afe_params afe;
 	};
 } __packed;
 
sound/soc/sof/pcm.c +12 -0
index 8d313c9862cb..31dd79b794f1 100644
@@ -808,6 +808,18 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
 		channels->min = dai->dai_config->esai.tdm_slots;
 		channels->max = dai->dai_config->esai.tdm_slots;
 
+		dev_dbg(component->dev,
+			"rate_min: %d rate_max: %d\n", rate->min, rate->max);
+		dev_dbg(component->dev,
+			"channels_min: %d channels_max: %d\n",
+			channels->min, channels->max);
+		break;
+	case SOF_DAI_MEDIATEK_AFE:
+		rate->min = dai->dai_config->afe.rate;
+		rate->max = dai->dai_config->afe.rate;
+		channels->min = dai->dai_config->afe.channels;
+		channels->max = dai->dai_config->afe.channels;
+
 		dev_dbg(component->dev,
 			"rate_min: %d rate_max: %d\n", rate->min, rate->max);
 		dev_dbg(component->dev,
sound/soc/sof/topology.c +59 -0

83 lines not on this page · raw message

Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 3/8
#6 lore raw

Re: [PATCH v2 3/8] ASoC: SOF: topology: Add support for Mediatek AFE DAI

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 6 lines

From: YC Hung <[email protected]>

Add new sof dai and config to pass topology file configuration to SOF firmware running on Mediatek platform DSP core. Add mediatek audio front end(AFE) to the list of supported sof_dais

Quoted 8 lines
#7 lore raw

PATCH v2 4/8 ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add mt8195-loader module with ops callback to load and run firmware on mt8195 platform.

---
 sound/soc/sof/mediatek/mt8195/Makefile        |  2 +-
 sound/soc/sof/mediatek/mt8195/mt8195-loader.c | 56 +++++++++++++++++++
 sound/soc/sof/mediatek/mt8195/mt8195.c        | 19 +++++++
 sound/soc/sof/mediatek/mt8195/mt8195.h        |  3 +
 4 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-loader.c
sound/soc/sof/mediatek/mt8195/Makefile +1 -1
index dd2b6e4affc9..66cdc0e7bf3c 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
-snd-sof-mt8195-objs := mt8195.o
+snd-sof-mt8195-objs := mt8195.o mt8195-loader.o
 obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o
sound/soc/sof/mediatek/mt8195/mt8195-loader.c new file +56 -0

56 lines not on this page · raw message

sound/soc/sof/mediatek/mt8195/mt8195.c +19 -0
index 966b8660e21c..88da6c2de070 100644
@@ -198,6 +198,17 @@ static int adsp_shared_base_ioremap(struct platform_device *pdev, void *data)
 	return 0;
 }
 
+static int mt8195_run(struct snd_sof_dev *sdev)
+{
+	u32 adsp_bootup_addr;
+
+	adsp_bootup_addr = SRAM_PHYS_BASE_FROM_DSP_VIEW;
+	dev_dbg(sdev->dev, "HIFIxDSP boot from base : 0x%08X\n", adsp_bootup_addr);
+	sof_hifixdsp_boot_sequence(sdev, adsp_bootup_addr);
+
+	return 0;
+}
+
 static int mt8195_dsp_probe(struct snd_sof_dev *sdev)
 {
 	struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
@@ -294,6 +305,9 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	.probe		= mt8195_dsp_probe,
 	.remove		= mt8195_dsp_remove,
 
+	/* DSP core boot */
+	.run		= mt8195_run,
+
 	/* Block IO */
 	.block_read	= sof_block_read,
 	.block_write	= sof_block_write,
@@ -307,6 +321,11 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	/* misc */
 	.get_bar_index	= mt8195_get_bar_index,
 
+	/* module loading */
+	.load_module	= snd_sof_parse_module_memcpy,
+	/* firmware loading */
+	.load_firmware	= snd_sof_load_firmware_memcpy,
+
 	/* Firmware ops */
 	.dsp_arch_ops = &sof_xtensa_arch_ops,
 
sound/soc/sof/mediatek/mt8195/mt8195.h +3 -0
index 48cbbb5aacb5..929424182357 100644
@@ -10,6 +10,7 @@
 #define __MT8195_H
 
 struct mtk_adsp_chip_info;
+struct snd_sof_dev;
 
 #define DSP_REG_BASE			0x10803000
 #define SCP_CFGREG_BASE			0x10724000
@@ -152,4 +153,6 @@ struct mtk_adsp_chip_info;
 #define DRAM_REMAP_SHIFT	12
 #define DRAM_REMAP_MASK		(BIT(DRAM_REMAP_SHIFT) - 1)
 
+void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr);
+void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev);
 #endif
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 4/8
#8 lore raw

Re: [PATCH v2 4/8] ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 5 lines

From: YC Hung <[email protected]>

Add mt8195-loader module with ops callback to load and run firmware on mt8195 platform.

Quoted 8 lines
#9 lore raw

PATCH v2 5/8 ASoC: SOF: Add mt8195 device descriptor

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add SOF device and DT descriptor for Mediatek mt8195 platform.

---
 sound/soc/sof/Kconfig      |  2 +-
 sound/soc/sof/sof-of-dev.c | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
sound/soc/sof/Kconfig +1 -1
index b0cdabcfdde7..ac34c330cf0c 100644
@@ -42,7 +42,7 @@ config SND_SOC_SOF_OF
 	depends on OF || COMPILE_TEST
 	help
 	  This adds support for Device Tree enumeration. This option is
-	  required to enable i.MX8 devices.
+	  required to enable i.MX8 or Mediatek devices.
 	  Say Y if you need this option. If unsure select "N".
 
 config SND_SOC_SOF_OF_DEV
sound/soc/sof/sof-of-dev.c +13 -0
index 885430a42226..412cbb824b84 100644
@@ -13,6 +13,7 @@
 
 #include "ops.h"
 #include "imx/imx-ops.h"
+#include "mediatek/mediatek-ops.h"
 
 static char *fw_path;
 module_param(fw_path, charp, 0444);
@@ -50,6 +51,15 @@ static struct sof_dev_desc sof_of_imx8mp_desc = {
 	.ops = &sof_imx8m_ops,
 };
 #endif
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195)
+static const struct sof_dev_desc sof_of_mt8195_desc = {
+	.default_fw_path = "mediatek/sof",
+	.default_tplg_path = "mediatek/sof-tplg",
+	.default_fw_filename = "sof-mt8195.ri",
+	.nocodec_tplg_filename = "sof-mt8195-nocodec.tplg",
+	.ops = &sof_mt8195_ops,
+};
+#endif
 
 static const struct dev_pm_ops sof_of_pm = {
 	.prepare = snd_sof_prepare,
@@ -130,6 +140,9 @@ static const struct of_device_id sof_of_ids[] = {
 #endif
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8M)
 	{ .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195)
+	{ .compatible = "mediatek,mt8195-dsp", .data = &sof_of_mt8195_desc},
 #endif
 	{ }
 };
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 5/8
#10 lore raw

Re: [PATCH v2 5/8] ASoC: SOF: Add mt8195 device descriptor

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 4 lines

From: YC Hung <[email protected]>

Add SOF device and DT descriptor for Mediatek mt8195 platform.

Quoted 8 lines
#11 lore raw

PATCH v2 6/8 ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add dsp ops callback to register AFE DL2/DL3/UL4/UL5 sof dai's with ALSA

---
 sound/soc/sof/mediatek/mt8195/mt8195.c | 35 ++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
sound/soc/sof/mediatek/mt8195/mt8195.c +35 -0
index 88da6c2de070..99075598a35a 100644
@@ -299,6 +299,37 @@ static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 	return type;
 }
 
+static struct snd_soc_dai_driver mt8195_dai[] = {
+{
+	.name = "SOF_DL2",
+	.playback = {
+		.channels_min = 1,
+		.channels_max = 2,
+	},
+},
+{
+	.name = "SOF_DL3",
+	.playback = {
+		.channels_min = 1,
+		.channels_max = 2,
+	},
+},
+{
+	.name = "SOF_UL4",
+	.capture = {
+		.channels_min = 1,
+		.channels_max = 2,
+	},
+},
+{
+	.name = "SOF_UL5",
+	.capture = {
+		.channels_min = 1,
+		.channels_max = 2,
+	},
+},
+};
+
 /* mt8195 ops */
 const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	/* probe and remove */
@@ -329,6 +360,10 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	/* Firmware ops */
 	.dsp_arch_ops = &sof_xtensa_arch_ops,
 
+	/* DAI drivers */
+	.drv = mt8195_dai,
+	.num_drv = ARRAY_SIZE(mt8195_dai),
+
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
 			SNDRV_PCM_INFO_MMAP_VALID |
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 6/8
#12 lore raw

Re: [PATCH v2 6/8] ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 4 lines

From: YC Hung <[email protected]>

Add dsp ops callback to register AFE DL2/DL3/UL4/UL5 sof dai's with ALSA

Quoted 8 lines
#13 lore raw

PATCH v2 7/8 ASoC: SOF: mediatek: Add mt8195 dsp clock support

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add adsp clock on/off support on mt8195 platform.

---
 sound/soc/sof/mediatek/adsp_helper.h       |   2 +-
 sound/soc/sof/mediatek/mt8195/Makefile     |   2 +-
 sound/soc/sof/mediatek/mt8195/mt8195-clk.c | 158 +++++++++++++++++++++
 sound/soc/sof/mediatek/mt8195/mt8195-clk.h |  28 ++++
 sound/soc/sof/mediatek/mt8195/mt8195.c     |  22 ++-
 5 files changed, 208 insertions(+), 4 deletions(-)
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.c
 create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.h
sound/soc/sof/mediatek/adsp_helper.h +1 -1
index 346953dd22db..6734e2c0c6b1 100644
@@ -39,7 +39,7 @@ struct adsp_priv {
 	struct mbox_controller *adsp_mbox;
 
 	struct mtk_adsp_chip_info *adsp;
-
+	struct clk **clk;
 	u32 (*ap2adsp_addr)(u32 addr, void *data);
 	u32 (*adsp2ap_addr)(u32 addr, void *data);
 
sound/soc/sof/mediatek/mt8195/Makefile +1 -1
index 66cdc0e7bf3c..afc4f21fccc5 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
-snd-sof-mt8195-objs := mt8195.o mt8195-loader.o
+snd-sof-mt8195-objs := mt8195.o mt8195-clk.o mt8195-loader.o
 obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o
sound/soc/sof/mediatek/mt8195/mt8195-clk.c new file +158 -0

158 lines not on this page · raw message

sound/soc/sof/mediatek/mt8195/mt8195-clk.h new file +28 -0
new file mode 100644
index 000000000000..9cc0573d5cd2
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/*
+ * Copyright (c) 2021 MediaTek Corporation. All rights reserved.
+ *
+ *  Header file for the mt8195 DSP clock  definition
+ */
+
+#ifndef __MT8195_CLK_H
+#define __MT8195_CLK_H
+
+struct snd_sof_dev;
+
+/*DSP clock*/
+enum adsp_clk_id {
+	CLK_TOP_ADSP,
+	CLK_TOP_CLK26M,
+	CLK_TOP_AUDIO_LOCAL_BUS,
+	CLK_TOP_MAINPLL_D7_D2,
+	CLK_SCP_ADSP_AUDIODSP,
+	CLK_TOP_AUDIO_H,
+	ADSP_CLK_MAX
+};
+
+int mt8195_adsp_init_clock(struct snd_sof_dev *sdev);
+int adsp_clock_on(struct snd_sof_dev *sdev);
+int adsp_clock_off(struct snd_sof_dev *sdev);
+#endif
sound/soc/sof/mediatek/mt8195/mt8195.c +20 -2
index 99075598a35a..5bfae9379ac8 100644
@@ -25,6 +25,7 @@
 #include "../adsp_helper.h"
 #include "../mediatek-ops.h"
 #include "mt8195.h"
+#include "mt8195-clk.h"
 
 static int platform_parse_resource(struct platform_device *pdev, void *data)
 {
@@ -231,10 +232,22 @@ static int mt8195_dsp_probe(struct snd_sof_dev *sdev)
 	if (ret)
 		return ret;
 
+	ret = mt8195_adsp_init_clock(sdev);
+	if (ret) {
+		dev_err(sdev->dev, "mt8195_adsp_init_clock failed\n");
+		return -EINVAL;
+	}
+
+	ret = adsp_clock_on(sdev);
+	if (ret) {
+		dev_err(sdev->dev, "adsp_clock_on fail!\n");
+		return -EINVAL;
+	}
+
 	ret = adsp_sram_power_on(sdev->dev, true);
 	if (ret) {
 		dev_err(sdev->dev, "adsp_sram_power_on fail!\n");
-		return ret;
+		goto exit_clk_disable;
 	}
 
 	ret = adsp_memory_remap_init(&pdev->dev, priv->adsp);
@@ -282,6 +295,8 @@ static int mt8195_dsp_probe(struct snd_sof_dev *sdev)
 
 err_adsp_sram_power_off:
 	adsp_sram_power_on(&pdev->dev, false);
+exit_clk_disable:
+	adsp_clock_off(sdev);
 
 	return ret;
 }
@@ -290,7 +305,10 @@ static int mt8195_dsp_remove(struct snd_sof_dev *sdev)
 {
 	struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
 
-	return adsp_sram_power_on(&pdev->dev, false);
+	adsp_sram_power_on(&pdev->dev, false);
+	adsp_clock_off(sdev);
+
+	return 0;
 }
 
 /* on mt8195 there is 1 to 1 match between type and BAR idx */
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 7/8
#14 lore raw

Re: [PATCH v2 7/8] ASoC: SOF: mediatek: Add mt8195 dsp clock support

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 15 lines

From: YC Hung <[email protected]>

Add adsp clock on/off support on mt8195 platform.

---
  sound/soc/sof/mediatek/adsp_helper.h       |   2 +-
  sound/soc/sof/mediatek/mt8195/Makefile     |   2 +-
  sound/soc/sof/mediatek/mt8195/mt8195-clk.c | 158 +++++++++++++++++++++
  sound/soc/sof/mediatek/mt8195/mt8195-clk.h |  28 ++++
  sound/soc/sof/mediatek/mt8195/mt8195.c     |  22 ++-
  5 files changed, 208 insertions(+), 4 deletions(-)
Quoted 3 lines

create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.c create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.h

#15 lore raw

PATCH v2 8/8 ASoC: SOF: mediatek: Add DSP system PM callback for mt8195

In reply to Daniel Baluta

From: YC Hung <[email protected]>

Add DSP system PM callback for suspend and resume

---
 sound/soc/sof/mediatek/mt8195/mt8195.c | 42 ++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
sound/soc/sof/mediatek/mt8195/mt8195.c +42 -0
index 5bfae9379ac8..40e5a25875a6 100644
@@ -311,6 +311,44 @@ static int mt8195_dsp_remove(struct snd_sof_dev *sdev)
 	return 0;
 }
 
+static int mt8195_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
+{
+	struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+	int ret;
+
+	/* stall and reset dsp */
+	sof_hifixdsp_shutdown(sdev);
+
+	/* power down adsp sram */
+	ret = adsp_sram_power_on(&pdev->dev, false);
+	if (ret) {
+		dev_err(sdev->dev, "adsp_sram_power_off fail!\n");
+		return ret;
+	}
+
+	/* turn off adsp clock */
+	return adsp_clock_off(sdev);
+}
+
+static int mt8195_dsp_resume(struct snd_sof_dev *sdev)
+{
+	int ret;
+
+	/* turn on adsp clock */
+	ret = adsp_clock_on(sdev);
+	if (ret) {
+		dev_err(sdev->dev, "adsp_clock_on fail!\n");
+		return ret;
+	}
+
+	/* power on adsp sram */
+	ret = adsp_sram_power_on(sdev->dev, true);
+	if (ret)
+		dev_err(sdev->dev, "adsp_sram_power_on fail!\n");
+
+	return ret;
+}
+
 /* on mt8195 there is 1 to 1 match between type and BAR idx */
 static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 {
@@ -382,6 +420,10 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
 	.drv = mt8195_dai,
 	.num_drv = ARRAY_SIZE(mt8195_dai),
 
+	/* PM */
+	.suspend	= mt8195_dsp_suspend,
+	.resume		= mt8195_dsp_resume,
+
 	/* ALSA HW info flags */
 	.hw_info =	SNDRV_PCM_INFO_MMAP |
 			SNDRV_PCM_INFO_MMAP_VALID |
Signature · 7 lines
2.27.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
maintainer Acked-by on v2 8/8
#16 lore raw

Re: [PATCH v2 8/8] ASoC: SOF: mediatek: Add DSP system PM callback for mt8195

Il 18/11/21 11:07, Daniel Baluta ha scritto:

Quoted 8 lines

From: YC Hung <[email protected]>

Add DSP system PM callback for suspend and resume

maintainer
#17 lore raw
In reply to Daniel Baluta
Quoted 10 lines · Daniel Baluta

From: Daniel Baluta <[email protected]>

This adds sound open firmware driver support for MT8915 platform.

Changes since v1:
- removed AMD patches since they were already applied
- fixed compilation error reported by Mark, generated by the fact that mt8195_run was declared too early in the series.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/8] ASoC: SOF: mediatek: Add mt8195 hardware support

      commit: 32d7e03d26fd93187c87ed0fbf59ec7023a61404
[2/8] ASoC: SOF: tokens: add token for Mediatek AFE
      commit: e6feefa541f309afed8aa54431681261bc57bcde
[3/8] ASoC: SOF: topology: Add support for Mediatek AFE DAI
      commit: b72bfcffcfc11858a8fc92998733372606db485e
[4/8] ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware
      commit: b7f6503830cd8f3f7076635409460861b5ff6310
[5/8] ASoC: SOF: Add mt8195 device descriptor
      commit: 24281bc2bf1884e665dfbcd17aaaabbc5872e501
[6/8] ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195
      commit: 24d75049c5ed5193bd12ce0d43c355c4ef74a7fa
[7/8] ASoC: SOF: mediatek: Add mt8195 dsp clock support
      commit: 424d6d1a9a51b7e6ab397132700a237082d64cf4
[8/8] ASoC: SOF: mediatek: Add DSP system PM callback for mt8195
      commit: 163fa3a5927e1d8f948ea1fc16c897944933a06a

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark