Skip to content

Commit 764162b

Browse files
andrew-mtkkv2019i
authored andcommitted
platform: mtk: Add AFE buffer address translation
Add AFE buffer address translation between CPU and ADSP for MT818X and MT8195 platforms. AFE buffer is allocated in heap located in ADSP SRAM. SRAM base address is not the same for CPU and ADSP address space. AFE hardware accept buffer base address in CPU address space only. Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
1 parent a85551e commit 764162b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

src/platform/mtk/dai.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@
1212
*/
1313
#if defined(CONFIG_SOC_MT8186)
1414
#define MTK_AFE_BASE 0x11210000
15+
#define SRAM_CPU_START 0x10800000
1516
#elif defined(CONFIG_SOC_SERIES_MT818X)
1617
#define MTK_AFE_BASE 0x10b10000
18+
#define SRAM_CPU_START 0x10d00000
1719
#elif defined(CONFIG_SOC_MT8195)
1820
#define MTK_AFE_BASE 0x10890000
21+
#define SRAM_CPU_START 0x10840000
1922
#elif defined(CONFIG_SOC_MT8196)
2023
#define MTK_AFE_BASE 0x1a110000
24+
#define SRAM_CPU_START 0x1a210000
2125
#else
2226
#error Unrecognized device
2327
#endif
2428

29+
#define SRAM_ADSP_START DT_REG_ADDR(DT_NODELABEL(sram0))
30+
#define SRAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram0))
31+
#define SRAM_ADSP_END (SRAM_ADSP_START + SRAM_SIZE)
32+
#define SRAM_CPU_END (SRAM_CPU_START + SRAM_SIZE)
33+
2534
/* Bitfield register: address, left shift amount, and number of bits */
2635
struct afe_bitfld {
2736
uint32_t reg;
@@ -199,6 +208,28 @@ static const struct dai_info mtk_dai_info = {
199208
.num_dai_types = ARRAY_SIZE(mtk_dai_types),
200209
};
201210

211+
#if defined(CONFIG_SOC_SERIES_MT818X) || defined(CONFIG_SOC_MT8195)
212+
static unsigned int mtk_afe2adsp_addr(unsigned int addr)
213+
{
214+
/* CPU -> ADSP address remap */
215+
if ((addr >= SRAM_CPU_START) && (addr < SRAM_CPU_END)) {
216+
addr = SRAM_ADSP_START + (addr - SRAM_CPU_START);
217+
}
218+
219+
return addr;
220+
}
221+
222+
static unsigned int mtk_adsp2afe_addr(unsigned int addr)
223+
{
224+
/* ADSP -> CPU address remap */
225+
if ((addr >= SRAM_ADSP_START) && (addr < SRAM_ADSP_END)) {
226+
addr = SRAM_CPU_START + (addr - SRAM_ADSP_START);
227+
}
228+
229+
return addr;
230+
}
231+
#endif
232+
202233
/* Static table of fs register values. TODO: binary search */
203234
static unsigned int mtk_afe_fs_timing(unsigned int rate)
204235
{
@@ -279,6 +310,10 @@ struct mtk_base_afe_platform mtk_afe_platform = {
279310
.dais_size = ARRAY_SIZE(mtk_dais),
280311
.afe_fs = mtk_afe_fs,
281312
.irq_fs = mtk_afe_fs_timing,
313+
#if defined(CONFIG_SOC_SERIES_MT818X) || defined(CONFIG_SOC_MT8195)
314+
.afe2adsp_addr = mtk_afe2adsp_addr,
315+
.adsp2afe_addr = mtk_adsp2afe_addr,
316+
#endif
282317
};
283318

284319
int mtk_dai_init(struct sof *sof)

0 commit comments

Comments
 (0)