Commit 626a3dfb authored by Mark Brown's avatar Mark Brown

ASoC: SOF: Add support for Mediatek MT8195

Merge series from Daniel Baluta <daniel.baluta@oss.nxp.com>:

This adds sound open firmware driver support for MT8915 platform.
parents b38892b5 163fa3a5
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/*
* Copyright(c) 2021 Mediatek Corporation. All rights reserved.
*
* Author: Bo Pan <bo.pan@mediatek.com>
*/
#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
......@@ -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;
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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/
# 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
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
obj-$(CONFIG_SND_SOC_SOF_MT8195) += mt8195/
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2021 MediaTek Corporation. All rights reserved.
*/
#ifndef __MTK_ADSP_HELPER_H__
#define __MTK_ADSP_HELPER_H__
/*
* Global important adsp data structure.
*/
#define DSP_MBOX_NUM 3
struct mtk_adsp_chip_info {
phys_addr_t pa_sram;
phys_addr_t pa_dram; /* adsp dram physical base */
phys_addr_t pa_shared_dram; /* adsp dram physical base */
phys_addr_t pa_cfgreg;
phys_addr_t pa_mboxreg[DSP_MBOX_NUM];
u32 sramsize;
u32 dramsize;
u32 cfgregsize;
void __iomem *va_sram; /* corresponding to pa_sram */
void __iomem *va_dram; /* corresponding to pa_dram */
void __iomem *va_cfgreg;
void __iomem *va_mboxreg[DSP_MBOX_NUM];
void __iomem *shared_sram; /* part of va_sram */
void __iomem *shared_dram; /* part of va_dram */
phys_addr_t adsp_bootup_addr;
int dram_offset; /*dram offset between system and dsp view*/
};
struct adsp_priv {
struct device *dev;
struct snd_sof_dev *sdev;
/* DSP IPC handler */
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);
void *private_data;
};
#endif
/* 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
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
snd-sof-mt8195-objs := mt8195.o mt8195-clk.o mt8195-loader.o
obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// Copyright(c) 2021 Mediatek Corporation. All rights reserved.
//
// Author: YC Hung <yc.hung@mediatek.com>
//
// Hardware interface for mt8195 DSP clock
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/io.h>
#include "mt8195.h"
#include "mt8195-clk.h"
#include "../adsp_helper.h"
#include "../../sof-audio.h"
static const char *adsp_clks[ADSP_CLK_MAX] = {
[CLK_TOP_ADSP] = "adsp_sel",
[CLK_TOP_CLK26M] = "clk26m_ck",
[CLK_TOP_AUDIO_LOCAL_BUS] = "audio_local_bus",
[CLK_TOP_MAINPLL_D7_D2] = "mainpll_d7_d2",
[CLK_SCP_ADSP_AUDIODSP] = "scp_adsp_audiodsp",
[CLK_TOP_AUDIO_H] = "audio_h",
};
int mt8195_adsp_init_clock(struct snd_sof_dev *sdev)
{
struct device *dev = sdev->dev;
struct adsp_priv *priv = sdev->pdata->hw_pdata;
int i;
priv->clk = devm_kcalloc(dev, ADSP_CLK_MAX, sizeof(*priv->clk), GFP_KERNEL);
if (!priv->clk)
return -ENOMEM;
for (i = 0; i < ADSP_CLK_MAX; i++) {
priv->clk[i] = devm_clk_get(dev, adsp_clks[i]);
if (IS_ERR(priv->clk[i]))
return PTR_ERR(priv->clk[i]);
}
return 0;
}
static int adsp_enable_all_clock(struct snd_sof_dev *sdev)
{
struct device *dev = sdev->dev;
struct adsp_priv *priv = sdev->pdata->hw_pdata;
int ret;
ret = clk_prepare_enable(priv->clk[CLK_TOP_MAINPLL_D7_D2]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(mainpll_d7_d2) fail %d\n",
__func__, ret);
return ret;
}
ret = clk_prepare_enable(priv->clk[CLK_TOP_ADSP]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(adsp_sel) fail %d\n",
__func__, ret);
goto disable_mainpll_d7_d2_clk;
}
ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(audio_local_bus) fail %d\n",
__func__, ret);
goto disable_dsp_sel_clk;
}
ret = clk_prepare_enable(priv->clk[CLK_SCP_ADSP_AUDIODSP]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(scp_adsp_audiodsp) fail %d\n",
__func__, ret);
goto disable_audio_local_bus_clk;
}
ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIO_H]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(audio_h) fail %d\n",
__func__, ret);
goto disable_scp_adsp_audiodsp_clk;
}
return 0;
disable_scp_adsp_audiodsp_clk:
clk_disable_unprepare(priv->clk[CLK_SCP_ADSP_AUDIODSP]);
disable_audio_local_bus_clk:
clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]);
disable_dsp_sel_clk:
clk_disable_unprepare(priv->clk[CLK_TOP_ADSP]);
disable_mainpll_d7_d2_clk:
clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D7_D2]);
return ret;
}
static void adsp_disable_all_clock(struct snd_sof_dev *sdev)
{
struct adsp_priv *priv = sdev->pdata->hw_pdata;
clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_H]);
clk_disable_unprepare(priv->clk[CLK_SCP_ADSP_AUDIODSP]);
clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]);
clk_disable_unprepare(priv->clk[CLK_TOP_ADSP]);
clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D7_D2]);
}
static int adsp_default_clk_init(struct snd_sof_dev *sdev, bool enable)
{
struct device *dev = sdev->dev;
struct adsp_priv *priv = sdev->pdata->hw_pdata;
int ret;
dev_dbg(dev, "%s: %s\n", __func__, enable ? "on" : "off");
if (enable) {
ret = clk_set_parent(priv->clk[CLK_TOP_ADSP],
priv->clk[CLK_TOP_CLK26M]);
if (ret) {
dev_err(dev, "failed to set dsp_sel to clk26m: %d\n", ret);
return ret;
}
ret = clk_set_parent(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS],
priv->clk[CLK_TOP_MAINPLL_D7_D2]);
if (ret) {
dev_err(dev, "set audio_local_bus failed %d\n", ret);
return ret;
}
ret = adsp_enable_all_clock(sdev);
if (ret) {
dev_err(dev, "failed to adsp_enable_clock: %d\n", ret);
return ret;
}
} else {
adsp_disable_all_clock(sdev);
}
return 0;
}
int adsp_clock_on(struct snd_sof_dev *sdev)
{
/* Open ADSP clock */
return adsp_default_clk_init(sdev, 1);
}
int adsp_clock_off(struct snd_sof_dev *sdev)
{
/* Close ADSP clock */
return adsp_default_clk_init(sdev, 0);
}
/* 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
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// Copyright (c) 2021 Mediatek Corporation. All rights reserved.
//
// Author: YC Hung <yc.hung@mediatek.com>
//
// Hardware interface for mt8195 DSP code loader
#include <sound/sof.h>
#include "mt8195.h"
#include "../../ops.h"
void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)
{
/* ADSP bootup base */
snd_sof_dsp_write(sdev, DSP_REG_BAR, DSP_ALTRESETVEC, boot_addr);
/* pull high RunStall (set bit3 to 1) */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
ADSP_RUNSTALL, ADSP_RUNSTALL);
/* pull high StatVectorSel to use AltResetVec (set bit4 to 1) */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
DSP_RESET_SW, DSP_RESET_SW);
/* toggle DReset & BReset */
/* pull high DReset & BReset */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
ADSP_BRESET_SW | ADSP_DRESET_SW,
ADSP_BRESET_SW | ADSP_DRESET_SW);
/* pull low DReset & BReset */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
ADSP_BRESET_SW | ADSP_DRESET_SW,
0);
/* Enable PDebug */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_PDEBUGBUS0,
PDEBUG_ENABLE,
PDEBUG_ENABLE);
/* release RunStall (set bit3 to 0) */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
ADSP_RUNSTALL, 0);
}
void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev)
{
/* Clear to 0 firstly */
snd_sof_dsp_write(sdev, DSP_REG_BAR, DSP_RESET_SW, 0x0);
/* RUN_STALL pull high again to reset */
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
ADSP_RUNSTALL, ADSP_RUNSTALL);
}
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2021 MediaTek Corporation. All rights reserved.
*
* Header file for the mt8195 DSP register definition
*/
#ifndef __MT8195_H
#define __MT8195_H
struct mtk_adsp_chip_info;
struct snd_sof_dev;
#define DSP_REG_BASE 0x10803000
#define SCP_CFGREG_BASE 0x10724000
#define DSP_SYSAO_BASE 0x1080C000
/*****************************************************************************
* R E G I S T E R TABLE
*****************************************************************************/
#define DSP_JTAGMUX 0x0000
#define DSP_ALTRESETVEC 0x0004
#define DSP_PDEBUGDATA 0x0008
#define DSP_PDEBUGBUS0 0x000c
#define PDEBUG_ENABLE BIT(0)
#define DSP_PDEBUGBUS1 0x0010
#define DSP_PDEBUGINST 0x0014
#define DSP_PDEBUGLS0STAT 0x0018
#define DSP_PDEBUGLS1STAT 0x001c
#define DSP_PDEBUGPC 0x0020
#define DSP_RESET_SW 0x0024 /*reset sw*/
#define ADSP_BRESET_SW BIT(0)
#define ADSP_DRESET_SW BIT(1)
#define ADSP_RUNSTALL BIT(3)
#define STATVECTOR_SEL BIT(4)
#define DSP_PFAULTBUS 0x0028
#define DSP_PFAULTINFO 0x002c
#define DSP_GPR00 0x0030
#define DSP_GPR01 0x0034
#define DSP_GPR02 0x0038
#define DSP_GPR03 0x003c
#define DSP_GPR04 0x0040
#define DSP_GPR05 0x0044
#define DSP_GPR06 0x0048
#define DSP_GPR07 0x004c
#define DSP_GPR08 0x0050
#define DSP_GPR09 0x0054
#define DSP_GPR0A 0x0058
#define DSP_GPR0B 0x005c
#define DSP_GPR0C 0x0060
#define DSP_GPR0D 0x0064
#define DSP_GPR0E 0x0068
#define DSP_GPR0F 0x006c
#define DSP_GPR10 0x0070
#define DSP_GPR11 0x0074
#define DSP_GPR12 0x0078
#define DSP_GPR13 0x007c
#define DSP_GPR14 0x0080
#define DSP_GPR15 0x0084
#define DSP_GPR16 0x0088
#define DSP_GPR17 0x008c
#define DSP_GPR18 0x0090
#define DSP_GPR19 0x0094
#define DSP_GPR1A 0x0098
#define DSP_GPR1B 0x009c
#define DSP_GPR1C 0x00a0
#define DSP_GPR1D 0x00a4
#define DSP_GPR1E 0x00a8
#define DSP_GPR1F 0x00ac
#define DSP_TCM_OFFSET 0x00b0 /* not used */
#define DSP_DDR_OFFSET 0x00b4 /* not used */
#define DSP_INTFDSP 0x00d0
#define DSP_INTFDSP_CLR 0x00d4
#define DSP_SRAM_PD_SW1 0x00d8
#define DSP_SRAM_PD_SW2 0x00dc
#define DSP_OCD 0x00e0
#define DSP_RG_DSP_IRQ_POL 0x00f0 /* not used */
#define DSP_DSP_IRQ_EN 0x00f4 /* not used */
#define DSP_DSP_IRQ_LEVEL 0x00f8 /* not used */
#define DSP_DSP_IRQ_STATUS 0x00fc /* not used */
#define DSP_RG_INT2CIRQ 0x0114
#define DSP_RG_INT_POL_CTL0 0x0120
#define DSP_RG_INT_EN_CTL0 0x0130
#define DSP_RG_INT_LV_CTL0 0x0140
#define DSP_RG_INT_STATUS0 0x0150
#define DSP_PDEBUGSTATUS0 0x0200
#define DSP_PDEBUGSTATUS1 0x0204
#define DSP_PDEBUGSTATUS2 0x0208
#define DSP_PDEBUGSTATUS3 0x020c
#define DSP_PDEBUGSTATUS4 0x0210
#define DSP_PDEBUGSTATUS5 0x0214
#define DSP_PDEBUGSTATUS6 0x0218
#define DSP_PDEBUGSTATUS7 0x021c
#define DSP_DSP2PSRAM_PRIORITY 0x0220 /* not used */
#define DSP_AUDIO_DSP2SPM_INT 0x0224
#define DSP_AUDIO_DSP2SPM_INT_ACK 0x0228
#define DSP_AUDIO_DSP_DEBUG_SEL 0x022C
#define DSP_AUDIO_DSP_EMI_BASE_ADDR 0x02E0 /* not used */
#define DSP_AUDIO_DSP_SHARED_IRAM 0x02E4
#define DSP_AUDIO_DSP_CKCTRL_P2P_CK_CON 0x02F0
#define DSP_RG_SEMAPHORE00 0x0300
#define DSP_RG_SEMAPHORE01 0x0304
#define DSP_RG_SEMAPHORE02 0x0308
#define DSP_RG_SEMAPHORE03 0x030C
#define DSP_RG_SEMAPHORE04 0x0310
#define DSP_RG_SEMAPHORE05 0x0314
#define DSP_RG_SEMAPHORE06 0x0318
#define DSP_RG_SEMAPHORE07 0x031C
#define DSP_RESERVED_0 0x03F0
#define DSP_RESERVED_1 0x03F4
/* dsp wdt */
#define DSP_WDT_MODE 0x0400
/* dsp mbox */
#define DSP_MBOX_IN_CMD 0x00
#define DSP_MBOX_IN_CMD_CLR 0x04
#define DSP_MBOX_OUT_CMD 0x1c
#define DSP_MBOX_OUT_CMD_CLR 0x20
#define DSP_MBOX_IN_MSG0 0x08
#define DSP_MBOX_IN_MSG1 0x0C
#define DSP_MBOX_OUT_MSG0 0x24
#define DSP_MBOX_OUT_MSG1 0x28
/*dsp sys ao*/
#define ADSP_SRAM_POOL_CON (DSP_SYSAO_BASE + 0x30)
#define DSP_SRAM_POOL_PD_MASK 0xf
#define DSP_EMI_MAP_ADDR (DSP_SYSAO_BASE + 0x81c)
/* DSP memories */
#define MBOX_OFFSET 0x800000 /* DRAM */
#define MBOX_SIZE 0x1000 /* consistent with which in memory.h of sof fw */
#define DSP_DRAM_SIZE 0x1000000 /* 16M */
#define DSP_REG_BAR 4
#define DSP_MBOX0_BAR 5
#define DSP_MBOX1_BAR 6
#define DSP_MBOX2_BAR 7
#define TOTAL_SIZE_SHARED_SRAM_FROM_TAIL 0x0
#define SIZE_SHARED_DRAM_DL 0x40000 /*Shared buffer for Downlink*/
#define SIZE_SHARED_DRAM_UL 0x40000 /*Shared buffer for Uplink*/
#define TOTAL_SIZE_SHARED_DRAM_FROM_TAIL \
(SIZE_SHARED_DRAM_DL + SIZE_SHARED_DRAM_UL)
#define SRAM_PHYS_BASE_FROM_DSP_VIEW 0x40000000 /* MT8195 DSP view */
#define DRAM_PHYS_BASE_FROM_DSP_VIEW 0x60000000 /* MT8195 DSP view */
/*remap dram between AP and DSP view, 4KB aligned*/
#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
......@@ -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,
......
......@@ -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
{ }
};
......
......@@ -379,6 +379,7 @@ static const struct sof_dai_types sof_dais[] = {
{"ACP", SOF_DAI_AMD_BT},
{"ACPSP", SOF_DAI_AMD_SP},
{"ACPDMIC", SOF_DAI_AMD_DMIC},
{"AFE", SOF_DAI_MEDIATEK_AFE},
};
static enum sof_ipc_dai_type find_dai(const char *name)
......@@ -806,6 +807,19 @@ static const struct sof_topology_token led_tokens[] = {
get_token_u32, offsetof(struct snd_sof_led_control, direction), 0},
};
/* AFE */
static const struct sof_topology_token afe_tokens[] = {
{SOF_TKN_MEDIATEK_AFE_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc_dai_mtk_afe_params, rate), 0},
{SOF_TKN_MEDIATEK_AFE_CH,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc_dai_mtk_afe_params, channels), 0},
{SOF_TKN_MEDIATEK_AFE_FORMAT,
SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format,
offsetof(struct sof_ipc_dai_mtk_afe_params, format), 0},
};
static int sof_parse_uuid_tokens(struct snd_soc_component *scomp,
void *object,
const struct sof_topology_token *tokens,
......@@ -3091,6 +3105,48 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, int index,
return ret;
}
static int sof_link_afe_load(struct snd_soc_component *scomp, int index,
struct snd_soc_dai_link *link,
struct snd_soc_tplg_link_config *cfg,
struct snd_soc_tplg_hw_config *hw_config,
struct sof_ipc_dai_config *config)
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv;
struct snd_soc_dai *dai;
u32 size = sizeof(*config);
int ret;
config->hdr.size = size;
/* get any bespoke DAI tokens */
ret = sof_parse_tokens(scomp, &config->afe, afe_tokens,
ARRAY_SIZE(afe_tokens), private->array,
le32_to_cpu(private->size));
if (ret != 0) {
dev_err(scomp->dev, "parse afe tokens failed %d\n",
le32_to_cpu(private->size));
return ret;
}
dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n",
config->afe.rate, config->afe.channels, config->afe.format);
dai = snd_soc_find_dai(link->cpus);
if (!dai) {
dev_err(scomp->dev, "%s: failed to find dai %s", __func__, link->cpus->dai_name);
return -EINVAL;
}
config->afe.stream_id = DMA_CHAN_INVALID;
ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0)
dev_err(scomp->dev, "failed to process afe dai link %s", link->name);
return ret;
}
static int sof_link_dmic_load(struct snd_soc_component *scomp, int index,
struct snd_soc_dai_link *link,
struct snd_soc_tplg_link_config *cfg,
......@@ -3386,6 +3442,9 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
ret = sof_link_acp_dmic_load(scomp, index, link, cfg, hw_config + curr_conf,
config);
break;
case SOF_DAI_MEDIATEK_AFE:
ret = sof_link_afe_load(scomp, index, link, cfg, hw_config + curr_conf, config);
break;
default:
dev_err(scomp->dev, "error: invalid DAI type %d\n", common_config.type);
ret = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment