Skip to content

Commit 6cbd290

Browse files
tinghan-shenplbossart
authored andcommitted
ASoC: SOF: mediatek: Add mt8186 sof fw loader and dsp ops
Add mt8186-loader module with ops callback to load and run firmware on mt8186 SoC. Signed-off-by: Allen-KH Cheng <allen-kh.cheng@mediatek.com> Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
1 parent 5d8730e commit 6cbd290

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2-
snd-sof-mt8186-objs := mt8186.o
2+
snd-sof-mt8186-objs := mt8186.o mt8186-loader.o
33
obj-$(CONFIG_SND_SOC_SOF_MT8186) += snd-sof-mt8186.o
44

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2+
//
3+
// Copyright (c) 2022 Mediatek Corporation. All rights reserved.
4+
//
5+
// Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
6+
// Tinghan Shen <tinghan.shen@mediatek.com>
7+
//
8+
// Hardware interface for mt8186 DSP code loader
9+
10+
#include <sound/sof.h>
11+
#include "mt8186.h"
12+
#include "../../ops.h"
13+
14+
void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)
15+
{
16+
/* set RUNSTALL to stop core */
17+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
18+
RUNSTALL, RUNSTALL);
19+
20+
/* set core boot address */
21+
snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVEC_C0, boot_addr);
22+
snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVECSEL, ADSP_ALTVECSEL_C0);
23+
24+
/* assert core reset */
25+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
26+
SW_RSTN_C0 | SW_DBG_RSTN_C0,
27+
SW_RSTN_C0 | SW_DBG_RSTN_C0);
28+
29+
/* hardware requirement */
30+
udelay(1);
31+
32+
/* release core reset */
33+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
34+
SW_RSTN_C0 | SW_DBG_RSTN_C0,
35+
0);
36+
37+
/* clear RUNSTALL (bit31) to start core */
38+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
39+
RUNSTALL, 0);
40+
}
41+
42+
void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev)
43+
{
44+
/* set RUNSTALL to stop core */
45+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
46+
RUNSTALL, RUNSTALL);
47+
48+
/* assert core reset */
49+
snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
50+
SW_RSTN_C0 | SW_DBG_RSTN_C0,
51+
SW_RSTN_C0 | SW_DBG_RSTN_C0);
52+
}
53+

sound/soc/sof/mediatek/mt8186/mt8186.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ static int adsp_shared_base_ioremap(struct platform_device *pdev, void *data)
204204
return 0;
205205
}
206206

207+
static int mt8186_run(struct snd_sof_dev *sdev)
208+
{
209+
u32 adsp_bootup_addr;
210+
211+
adsp_bootup_addr = SRAM_PHYS_BASE_FROM_DSP_VIEW;
212+
dev_dbg(sdev->dev, "HIFIxDSP boot from base : 0x%08X\n", adsp_bootup_addr);
213+
sof_hifixdsp_boot_sequence(sdev, adsp_bootup_addr);
214+
215+
return 0;
216+
}
217+
207218
static int mt8186_dsp_probe(struct snd_sof_dev *sdev)
208219
{
209220
struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
@@ -272,6 +283,7 @@ static int mt8186_dsp_probe(struct snd_sof_dev *sdev)
272283

273284
static int mt8186_dsp_remove(struct snd_sof_dev *sdev)
274285
{
286+
sof_hifixdsp_shutdown(sdev);
275287
adsp_sram_power_off(sdev);
276288

277289
return 0;
@@ -289,6 +301,9 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = {
289301
.probe = mt8186_dsp_probe,
290302
.remove = mt8186_dsp_remove,
291303

304+
/* DSP core boot */
305+
.run = mt8186_run,
306+
292307
/* Block IO */
293308
.block_read = sof_block_read,
294309
.block_write = sof_block_write,
@@ -302,6 +317,9 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = {
302317
/* misc */
303318
.get_bar_index = mt8186_get_bar_index,
304319

320+
/* firmware loading */
321+
.load_firmware = snd_sof_load_firmware_memcpy,
322+
305323
/* Firmware ops */
306324
.dsp_arch_ops = &sof_xtensa_arch_ops,
307325

sound/soc/sof/mediatek/mt8186/mt8186.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define __MT8186_H
1111

1212
struct mtk_adsp_chip_info;
13+
struct snd_sof_dev;
1314

1415
#define DSP_REG_BAR 4
1516
#define DSP_SECREG_BAR 5
@@ -74,4 +75,6 @@ struct mtk_adsp_chip_info;
7475
#define SIZE_SHARED_DRAM_UL 0x40000 /*Shared buffer for Uplink*/
7576
#define TOTAL_SIZE_SHARED_DRAM_FROM_TAIL (SIZE_SHARED_DRAM_DL + SIZE_SHARED_DRAM_UL)
7677

78+
void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr);
79+
void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev);
7780
#endif

0 commit comments

Comments
 (0)