Skip to content

Commit 62b6848

Browse files
andrew-mtklgirdwood
authored andcommitted
platform: mtk: Add platform driver for mt8365
Add mt8365 dai and dma platform driver. Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
1 parent 8b6044a commit 62b6848

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

src/platform/mt8365/lib/dai.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#include <sof/common.h>
9+
#include <sof/lib/dai.h>
10+
#include <sof/lib/memory.h>
11+
#include <rtos/sof.h>
12+
#include <rtos/spinlock.h>
13+
#include <ipc/dai.h>
14+
#include <ipc/stream.h>
15+
16+
#include <sof/drivers/afe-dai.h>
17+
#include <mt8365-afe-common.h>
18+
19+
/* MEMIF specified IRQs set in the Linux driver:
20+
*
21+
* [MT8365_AFE_MEMIF_DL1] = MT8365_AFE_IRQ1,
22+
* [MT8365_AFE_MEMIF_DL2] = MT8365_AFE_IRQ2,
23+
* [MT8365_AFE_MEMIF_TDM_OUT] = MT8365_AFE_IRQ5,
24+
* // [MT8365_AFE_MEMIF_SPDIF_OUT] = MT8365_AFE_IRQ6,
25+
* [MT8365_AFE_MEMIF_AWB] = MT8365_AFE_IRQ3,
26+
* [MT8365_AFE_MEMIF_VUL] = MT8365_AFE_IRQ4,
27+
* [MT8365_AFE_MEMIF_VUL2] = MT8365_AFE_IRQ7,
28+
* [MT8365_AFE_MEMIF_VUL3] = MT8365_AFE_IRQ8,
29+
* // [MT8365_AFE_MEMIF_SPDIF_IN] = MT8365_AFE_IRQ9,
30+
* [MT8365_AFE_MEMIF_TDM_IN] = MT8365_AFE_IRQ10,
31+
*/
32+
33+
static int afe_dai_handshake[MT8365_DAI_NUM] = {
34+
AFE_HANDSHAKE(MT8365_AFE_IO_INT_ADDA_OUT, MT8365_AFE_IRQ_1, MT8365_MEMIF_DL1),
35+
AFE_HANDSHAKE(MT8365_AFE_IO_2ND_I2S, MT8365_AFE_IRQ_2, MT8365_MEMIF_DL2),
36+
AFE_HANDSHAKE(MT8365_AFE_IO_INT_ADDA_IN, MT8365_AFE_IRQ_3, MT8365_MEMIF_AWB),
37+
AFE_HANDSHAKE(MT8365_AFE_IO_DMIC, MT8365_AFE_IRQ_4, MT8365_MEMIF_VUL),
38+
};
39+
40+
static SHARED_DATA struct dai afe_dai[MT8365_DAI_NUM];
41+
42+
const struct dai_type_info dti[] = {
43+
{
44+
.type = SOF_DAI_MEDIATEK_AFE,
45+
.dai_array = afe_dai,
46+
.num_dais = ARRAY_SIZE(afe_dai),
47+
},
48+
};
49+
50+
const struct dai_info lib_dai = {
51+
.dai_type_array = dti,
52+
.num_dai_types = ARRAY_SIZE(dti),
53+
};
54+
55+
int dai_init(struct sof *sof)
56+
{
57+
int i;
58+
59+
/* initialize spin locks early to enable ref counting */
60+
for (i = 0; i < ARRAY_SIZE(afe_dai); i++) {
61+
k_spinlock_init(&afe_dai[i].lock);
62+
afe_dai[i].index = AFE_HS_GET_DAI(afe_dai_handshake[i]);
63+
afe_dai[i].drv = &afe_dai_driver;
64+
/* TODO, fifo[0] change to target playback or capture */
65+
afe_dai[i].plat_data.fifo[0].handshake = afe_dai_handshake[i];
66+
}
67+
68+
sof->dai_info = &lib_dai;
69+
70+
return 0;
71+
}

src/platform/mt8365/lib/dma.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
*/
77

88
#include <sof/common.h>
9+
#include <sof/drivers/afe-memif.h>
910
#include <rtos/interrupt.h>
1011
#include <sof/lib/dma.h>
1112
#include <sof/lib/memory.h>
1213
#include <rtos/sof.h>
1314
#include <rtos/spinlock.h>
1415

16+
#include <mt8365-afe-regs.h>
17+
#include <mt8365-afe-common.h>
18+
1519
extern const struct dma_ops dummy_dma_ops;
1620

1721
static SHARED_DATA struct dma dma[PLATFORM_NUM_DMACS] = {
@@ -24,6 +28,16 @@ static SHARED_DATA struct dma dma[PLATFORM_NUM_DMACS] = {
2428
},
2529
.ops = &dummy_dma_ops,
2630
},
31+
{
32+
.plat_data = {
33+
.id = DMA_ID_AFE_MEMIF,
34+
.dir = DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM,
35+
.devs = DMA_DEV_AFE_MEMIF,
36+
.base = AFE_REG_BASE,
37+
.channels = MT8365_MEMIF_NUM,
38+
},
39+
.ops = &memif_ops,
40+
},
2741
};
2842

2943
static const struct dma_info lib_dma = {

0 commit comments

Comments
 (0)