forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
18 changed files
with
1,050 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) | ||
obj-$(CONFIG_SND_SOC_SOF_MT8195) += mt8195/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
// 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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.