platform: mtk: add platform driver for mt8188

Add mt8188 dai and dma platform driver.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
This commit is contained in:
Trevor Wu 2022-11-14 09:52:29 +08:00 committed by Liam Girdwood
parent 81bcc8999f
commit d340f72f39
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,57 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright(c) 2023 MediaTek. All rights reserved.
*
* Author: Trevor Wu <trevor.wu@mediatek.com>
*/
#include <sof/common.h>
#include <sof/lib/dai.h>
#include <sof/lib/memory.h>
#include <sof/sof.h>
#include <rtos/spinlock.h>
#include <ipc/dai.h>
#include <ipc/stream.h>
#include <sof/drivers/afe-dai.h>
#include <mt8188-afe-common.h>
static int afe_dai_handshake[MT8188_DAI_NUM] = {
AFE_HANDSHAKE(MT8188_AFE_IO_ETDM2_OUT, MT8188_IRQ_13, MT8188_MEMIF_DL2),
AFE_HANDSHAKE(MT8188_AFE_IO_ETDM1_OUT, MT8188_IRQ_14, MT8188_MEMIF_DL3),
AFE_HANDSHAKE(MT8188_AFE_IO_ADDA, MT8188_IRQ_21, MT8188_MEMIF_UL4),
AFE_HANDSHAKE(MT8188_AFE_IO_ETDM2_IN, MT8188_IRQ_22, MT8188_MEMIF_UL5),
};
static SHARED_DATA struct dai afe_dai[MT8188_DAI_NUM];
const struct dai_type_info dti[] = {
{
.type = SOF_DAI_MEDIATEK_AFE,
.dai_array = afe_dai,
.num_dais = ARRAY_SIZE(afe_dai),
},
};
const struct dai_info lib_dai = {
.dai_type_array = dti,
.num_dai_types = ARRAY_SIZE(dti),
};
int dai_init(struct sof *sof)
{
int i;
/* initialize spin locks early to enable ref counting */
for (i = 0; i < ARRAY_SIZE(afe_dai); i++) {
k_spinlock_init(&afe_dai[i].lock);
afe_dai[i].index = AFE_HS_GET_DAI(afe_dai_handshake[i]);
afe_dai[i].drv = &afe_dai_driver;
/* TODO, fifo[0] change to target playback or capture */
afe_dai[i].plat_data.fifo[0].handshake = afe_dai_handshake[i];
}
sof->dai_info = &lib_dai;
return 0;
}

View File

@ -9,10 +9,14 @@
#include <rtos/interrupt.h>
#include <rtos/spinlock.h>
#include <sof/common.h>
#include <sof/drivers/afe-memif.h>
#include <sof/lib/dma.h>
#include <sof/lib/memory.h>
#include <sof/sof.h>
#include <mt8188-afe-reg.h>
#include <mt8188-afe-common.h>
extern const struct dma_ops dummy_dma_ops;
static SHARED_DATA struct dma dma[PLATFORM_NUM_DMACS] = {
@ -25,6 +29,17 @@ static SHARED_DATA struct dma dma[PLATFORM_NUM_DMACS] = {
},
.ops = &dummy_dma_ops,
},
{
.plat_data = {
.id = DMA_ID_AFE_MEMIF,
.dir = DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM,
.devs = DMA_DEV_AFE_MEMIF,
.base = AFE_BASE_ADDR,
.channels = MT8188_MEMIF_NUM,
},
.ops = &memif_ops,
},
};
static const struct dma_info lib_dma = {