firmware: mtk: add adsp ipc protocol for SOF
Subsystems (4)
v8 cover firmware: mtk: add adsp ipc protocol for SOF
This patch provides mediatek adsp ipc support for SOF. ADSP IPC protocol offers (send/recv) interfaces using mediatek-mailbox APIs.
This patch was tested and confirmed to work with SOF fw on MT8195 cherry board and MT8186 krabby board.
changes since v7:
- rebase to linux-next/next-22020504
- use EXPORT_SYMBOL_GPL instead of EXPORT_SYMBOL in mtk-adsp-ipc.c
- move mtk-adsp-ipc.c out from driver/firmware/mediatek
- add user of mtk-adsp-ipc.h in patchset 2 and 3.
changes since v6:
- rebase to matthias.bgg/linux.git, v5.18-next/soc
- Prefer "GPL" over "GPL v2" for MODULE_LICENSE
changes since v5:
- fix WARNING: modpost: missing MODULE_LICENSE() in drivers/mailbox /mtk-adsp-mailbox.o. Add MODULE_LICENSE in the last line.
- Due to WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 in checkpatch, we don't remove SPDX-License in line 1.
changes since v4:
- add error message for wrong mbox chan
changes since v3:
- rebase on v5.16-rc8
- update reviewers
changes since v2:
- add out tag for two memory free phases
changes since v1:
- add comments for mtk_adsp_ipc_send and mtk_adsp_ipc_recv
- remove useless MODULE_LICENSE
- change label name to out_free
Allen-KH Cheng (1):
ASoC: SOF: mediatek: Add ipc support for mt8195
TingHan Shen (1):
firmware: mediatek: add adsp ipc protocol interface
Tinghan Shen (1):
ASoC: SOF: mediatek: Add mt8186 ipc support
drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/mtk-adsp-ipc.c | 157 ++++++++++++++++++ .../linux/firmware/mediatek/mtk-adsp-ipc.h | 65 ++++++++ sound/soc/sof/mediatek/Kconfig | 1 + sound/soc/sof/mediatek/adsp_helper.h | 12 +- sound/soc/sof/mediatek/mt8186/mt8186-loader.c | 5 + sound/soc/sof/mediatek/mt8186/mt8186.c | 141 ++++++++++++++++ sound/soc/sof/mediatek/mt8195/mt8195.c | 138 ++++++++++++++- 9 files changed, 518 insertions(+), 11 deletions(-) create mode 100644 drivers/firmware/mtk-adsp-ipc.c create mode 100644 include/linux/firmware/mediatek/mtk-adsp-ipc.h
Signature · 1 line
2.18.0
PATCH v8 1/3 firmware: mediatek: add adsp ipc protocol interface
From: TingHan Shen <[email protected]>
Some of mediatek processors contain
the Tensilica HiFix DSP for audio processing.
The communication between Host CPU and DSP firmware is taking place using a shared memory area for message passing.
ADSP IPC protocol offers (send/recv) interfaces using mediatek-mailbox APIs.
We use two mbox channels to implement a request-reply protocol.
--- drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/mtk-adsp-ipc.c | 157 ++++++++++++++++++ .../linux/firmware/mediatek/mtk-adsp-ipc.h | 65 ++++++++ 4 files changed, 232 insertions(+) create mode 100644 drivers/firmware/mtk-adsp-ipc.c create mode 100644 include/linux/firmware/mediatek/mtk-adsp-ipc.h
drivers/firmware/Kconfig +9 -0
@@ -203,6 +203,15 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. +config MTK_ADSP_IPC + tristate "MTK ADSP IPC Protocol driver" + depends on MTK_ADSP_MBOX + help + Say yes here to add support for the MediaTek ADSP IPC + between host AP (Linux) and the firmware running on ADSP. + ADSP exists on some mtk processors. + Client might use shared memory to exchange information with ADSP. + config QCOM_SCM tristate
drivers/firmware/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_INTEL_STRATIX10_RSU) += stratix10-rsu.o obj-$(CONFIG_ISCSI_IBFT_FIND) += iscsi_ibft_find.o obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o +obj-$(CONFIG_MTK_ADSP_IPC) += mtk-adsp-ipc.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
drivers/firmware/mtk-adsp-ipc.c new file +157 -0
157 lines not on this page · raw message
include/linux/firmware/mediatek/mtk-adsp-ipc.h new file +65 -0
65 lines not on this page · raw message
Signature · 7 lines
2.18.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v8 2/3 ASoC: SOF: mediatek: Add ipc support for mt8195
In reply to Tinghan ShenFrom: Allen-KH Cheng <[email protected]>
This patch adds mt8195 IPC support by using mailbox.
On mt8195 resource, there are two mboxes used to handle ipc request and reply. We create a mtk-adsp-ipc client device to request mbox controllers.
--- sound/soc/sof/mediatek/Kconfig | 1 + sound/soc/sof/mediatek/adsp_helper.h | 12 +-- sound/soc/sof/mediatek/mt8195/mt8195.c | 138 ++++++++++++++++++++++++- 3 files changed, 140 insertions(+), 11 deletions(-)
sound/soc/sof/mediatek/Kconfig +1 -0
@@ -17,6 +17,7 @@ config SND_SOC_SOF_MTK_COMMON select SND_SOC_SOF select SND_SOC_SOF_XTENSA select SND_SOC_SOF_COMPRESS + depends on MTK_ADSP_IPC help This option is not user-selectable but automagically handled by 'select' statements at a higher level
sound/soc/sof/mediatek/adsp_helper.h +4 -8
@@ -7,24 +7,22 @@ #ifndef __MTK_ADSP_HELPER_H__ #define __MTK_ADSP_HELPER_H__ +#include <linux/firmware/mediatek/mtk-adsp-ipc.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;
@@ -42,10 +40,8 @@ struct mtk_adsp_chip_info {struct adsp_priv {struct device *dev;struct snd_sof_dev *sdev; - -/* DSP IPC handler */ -struct mbox_controller *adsp_mbox; - +struct mtk_adsp_ipc *dsp_ipc; +struct platform_device *ipc_dev;struct mtk_adsp_chip_info *adsp;struct clk **clk;u32 (*ap2adsp_addr)(u32 addr,void *data);
sound/soc/sof/mediatek/mt8195/mt8195.c +135 -3
181 lines not on this page · raw message
Signature · 1 line
2.18.0
kernel test robot
build botRe: [PATCH v8 2/3] ASoC: SOF: mediatek: Add ipc support for mt8195
Thank you for the patch! Yet something to improve:
Hi Tinghan,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on broonie-spi/for-next linus/master v5.18-rc6 next-20220511] [cannot apply to mbgg-mediatek/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Tinghan-Shen/firmware-mtk-add-adsp-ipc-protocol-for-SOF/20220511-122856 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: arm64-randconfig-r006-20220509 (https://download.01.org/0day-ci/archive/20220512/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 18dd123c56754edf62c7042dcf23185c3727610f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/d52363b968181a599c947b4fcd470b6ec634f735
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tinghan-Shen/firmware-mtk-add-adsp-ipc-protocol-for-SOF/20220511-122856 git checkout d52363b968181a599c947b4fcd470b6ec634f735
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "sof_of_pm" [sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.ko] undefined! >> ERROR: modpost: "sof_of_shutdown" [sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.ko] undefined! >> ERROR: modpost: "sof_of_remove" [sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.ko] undefined! >> ERROR: modpost: "sof_of_probe" [sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.ko] undefined! >> ERROR: modpost: "mtk_adsp_ipc_send" [sound/soc/sof/mediatek/mt8195/snd-sof-mt8195.ko] undefined!
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_SOC_SOF_MTK_COMMON
Depends on SOUND && !UML && SND && SND_SOC && SND_SOC_SOF_TOPLEVEL && SND_SOC_SOF_MTK_TOPLEVEL && MTK_ADSP_IPC Selected by
- SND_SOC_SOF_MT8195 && SOUND && !UML && SND && SND_SOC && SND_SOC_SOF_TOPLEVEL && SND_SOC_SOF_MTK_TOPLEVEL
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
PATCH v8 3/3 ASoC: SOF: mediatek: Add mt8186 ipc support
In reply to Tinghan Shenmt8186 DSP uses two hardware mailbox IP to communicate with AP. One mailbox is used for requests coming from AP, and the other one is for requests from DSP.
--- sound/soc/sof/mediatek/mt8186/mt8186-loader.c | 5 + sound/soc/sof/mediatek/mt8186/mt8186.c | 141 ++++++++++++++++++ 2 files changed, 146 insertions(+)
sound/soc/sof/mediatek/mt8186/mt8186-loader.c +5 -0
@@ -17,6 +17,11 @@ void mt8186_sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)snd_sof_dsp_update_bits (sdev,DSP_REG_BAR ,ADSP_HIFI_IO_CONFIG ,RUNSTALL ,RUNSTALL ); +/* enable mbox 0 & 1 IRQ */ +snd_sof_dsp_update_bits (sdev,DSP_REG_BAR ,ADSP_MBOX_IRQ_EN , +DSP_MBOX0_IRQ_EN |DSP_MBOX1_IRQ_EN , +DSP_MBOX0_IRQ_EN |DSP_MBOX1_IRQ_EN ); +/* set core boot address */ snd_sof_dsp_write (sdev,DSP_SECREG_BAR ,ADSP_ALTVEC_C0 , boot_addr);snd_sof_dsp_write (sdev,DSP_SECREG_BAR ,ADSP_ALTVECSEL ,ADSP_ALTVECSEL_C0 );
sound/soc/sof/mediatek/mt8186/mt8186.c +141 -0
176 lines not on this page · raw message
Signature · 1 line
2.18.0