18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * mt8183-afe-common.h  --  Mediatek 8183 audio driver definitions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2018 MediaTek Inc.
68c2ecf20Sopenharmony_ci * Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _MT_8183_AFE_COMMON_H_
108c2ecf20Sopenharmony_ci#define _MT_8183_AFE_COMMON_H_
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <sound/soc.h>
138c2ecf20Sopenharmony_ci#include <linux/list.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include "../common/mtk-base-afe.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum {
188c2ecf20Sopenharmony_ci	MT8183_MEMIF_DL1,
198c2ecf20Sopenharmony_ci	MT8183_MEMIF_DL2,
208c2ecf20Sopenharmony_ci	MT8183_MEMIF_DL3,
218c2ecf20Sopenharmony_ci	MT8183_MEMIF_VUL12,
228c2ecf20Sopenharmony_ci	MT8183_MEMIF_VUL2,
238c2ecf20Sopenharmony_ci	MT8183_MEMIF_AWB,
248c2ecf20Sopenharmony_ci	MT8183_MEMIF_AWB2,
258c2ecf20Sopenharmony_ci	MT8183_MEMIF_MOD_DAI,
268c2ecf20Sopenharmony_ci	MT8183_MEMIF_HDMI,
278c2ecf20Sopenharmony_ci	MT8183_MEMIF_NUM,
288c2ecf20Sopenharmony_ci	MT8183_DAI_ADDA = MT8183_MEMIF_NUM,
298c2ecf20Sopenharmony_ci	MT8183_DAI_PCM_1,
308c2ecf20Sopenharmony_ci	MT8183_DAI_PCM_2,
318c2ecf20Sopenharmony_ci	MT8183_DAI_I2S_0,
328c2ecf20Sopenharmony_ci	MT8183_DAI_I2S_1,
338c2ecf20Sopenharmony_ci	MT8183_DAI_I2S_2,
348c2ecf20Sopenharmony_ci	MT8183_DAI_I2S_3,
358c2ecf20Sopenharmony_ci	MT8183_DAI_I2S_5,
368c2ecf20Sopenharmony_ci	MT8183_DAI_TDM,
378c2ecf20Sopenharmony_ci	MT8183_DAI_HOSTLESS_LPBK,
388c2ecf20Sopenharmony_ci	MT8183_DAI_HOSTLESS_SPEECH,
398c2ecf20Sopenharmony_ci	MT8183_DAI_NUM,
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cienum {
438c2ecf20Sopenharmony_ci	MT8183_IRQ_0,
448c2ecf20Sopenharmony_ci	MT8183_IRQ_1,
458c2ecf20Sopenharmony_ci	MT8183_IRQ_2,
468c2ecf20Sopenharmony_ci	MT8183_IRQ_3,
478c2ecf20Sopenharmony_ci	MT8183_IRQ_4,
488c2ecf20Sopenharmony_ci	MT8183_IRQ_5,
498c2ecf20Sopenharmony_ci	MT8183_IRQ_6,
508c2ecf20Sopenharmony_ci	MT8183_IRQ_7,
518c2ecf20Sopenharmony_ci	MT8183_IRQ_8,	/* hw bundle to TDM */
528c2ecf20Sopenharmony_ci	MT8183_IRQ_11,
538c2ecf20Sopenharmony_ci	MT8183_IRQ_12,
548c2ecf20Sopenharmony_ci	MT8183_IRQ_NUM,
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cienum {
588c2ecf20Sopenharmony_ci	MT8183_MTKAIF_PROTOCOL_1 = 0,
598c2ecf20Sopenharmony_ci	MT8183_MTKAIF_PROTOCOL_2,
608c2ecf20Sopenharmony_ci	MT8183_MTKAIF_PROTOCOL_2_CLK_P2,
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* MCLK */
648c2ecf20Sopenharmony_cienum {
658c2ecf20Sopenharmony_ci	MT8183_I2S0_MCK = 0,
668c2ecf20Sopenharmony_ci	MT8183_I2S1_MCK,
678c2ecf20Sopenharmony_ci	MT8183_I2S2_MCK,
688c2ecf20Sopenharmony_ci	MT8183_I2S3_MCK,
698c2ecf20Sopenharmony_ci	MT8183_I2S4_MCK,
708c2ecf20Sopenharmony_ci	MT8183_I2S4_BCK,
718c2ecf20Sopenharmony_ci	MT8183_I2S5_MCK,
728c2ecf20Sopenharmony_ci	MT8183_MCK_NUM,
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistruct clk;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistruct mt8183_afe_private {
788c2ecf20Sopenharmony_ci	struct clk **clk;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	int pm_runtime_bypass_reg_ctl;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	/* dai */
838c2ecf20Sopenharmony_ci	void *dai_priv[MT8183_DAI_NUM];
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	/* adda */
868c2ecf20Sopenharmony_ci	int mtkaif_protocol;
878c2ecf20Sopenharmony_ci	int mtkaif_calibration_ok;
888c2ecf20Sopenharmony_ci	int mtkaif_chosen_phase[4];
898c2ecf20Sopenharmony_ci	int mtkaif_phase_cycle[4];
908c2ecf20Sopenharmony_ci	int mtkaif_calibration_num_phase;
918c2ecf20Sopenharmony_ci	int mtkaif_dmic;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	/* mck */
948c2ecf20Sopenharmony_ci	int mck_rate[MT8183_MCK_NUM];
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ciunsigned int mt8183_general_rate_transform(struct device *dev,
988c2ecf20Sopenharmony_ci					   unsigned int rate);
998c2ecf20Sopenharmony_ciunsigned int mt8183_rate_transform(struct device *dev,
1008c2ecf20Sopenharmony_ci				   unsigned int rate, int aud_blk);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/* dai register */
1038c2ecf20Sopenharmony_ciint mt8183_dai_adda_register(struct mtk_base_afe *afe);
1048c2ecf20Sopenharmony_ciint mt8183_dai_pcm_register(struct mtk_base_afe *afe);
1058c2ecf20Sopenharmony_ciint mt8183_dai_i2s_register(struct mtk_base_afe *afe);
1068c2ecf20Sopenharmony_ciint mt8183_dai_tdm_register(struct mtk_base_afe *afe);
1078c2ecf20Sopenharmony_ciint mt8183_dai_hostless_register(struct mtk_base_afe *afe);
1088c2ecf20Sopenharmony_ci#endif
109