Commit 6746cc85 authored by Trevor Wu's avatar Trevor Wu Committed by Mark Brown

ASoC: mediatek: mt8195: add platform driver

This patch adds mt8195 platform and affiliated driver.
Signed-off-by: default avatarTrevor Wu <trevor.wu@mediatek.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20210819084144.18483-7-trevor.wu@mediatek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1f95c019
......@@ -184,3 +184,12 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682
with the MT6359 RT1015 RT5682 audio codec.
Select Y if you have such device.
If unsure select "N".
config SND_SOC_MT8195
tristate "ASoC support for Mediatek MT8195 chip"
select SND_SOC_MEDIATEK
help
This adds ASoC platform driver support for Mediatek MT8195 chip
that can be used with other codecs.
Select Y if you have such device.
If unsure select "N".
......@@ -5,3 +5,4 @@ obj-$(CONFIG_SND_SOC_MT6797) += mt6797/
obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
obj-$(CONFIG_SND_SOC_MT8183) += mt8183/
obj-$(CONFIG_SND_SOC_MT8192) += mt8192/
obj-$(CONFIG_SND_SOC_MT8195) += mt8195/
# SPDX-License-Identifier: GPL-2.0
# platform driver
snd-soc-mt8195-afe-objs := \
mt8195-audsys-clk.o \
mt8195-afe-clk.o \
mt8195-afe-pcm.o \
mt8195-dai-adda.o \
mt8195-dai-etdm.o \
mt8195-dai-pcm.o
obj-$(CONFIG_SND_SOC_MT8195) += snd-soc-mt8195-afe.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* mt8195-afe-clk.h -- Mediatek 8195 afe clock ctrl definition
*
* Copyright (c) 2021 MediaTek Inc.
* Author: Bicycle Tsai <bicycle.tsai@mediatek.com>
* Trevor Wu <trevor.wu@mediatek.com>
*/
#ifndef _MT8195_AFE_CLK_H_
#define _MT8195_AFE_CLK_H_
enum {
/* xtal */
MT8195_CLK_XTAL_26M,
/* divider */
MT8195_CLK_TOP_APLL1,
MT8195_CLK_TOP_APLL2,
MT8195_CLK_TOP_APLL12_DIV0,
MT8195_CLK_TOP_APLL12_DIV1,
MT8195_CLK_TOP_APLL12_DIV2,
MT8195_CLK_TOP_APLL12_DIV3,
MT8195_CLK_TOP_APLL12_DIV9,
/* mux */
MT8195_CLK_TOP_A1SYS_HP_SEL,
MT8195_CLK_TOP_AUD_INTBUS_SEL,
MT8195_CLK_TOP_AUDIO_H_SEL,
MT8195_CLK_TOP_AUDIO_LOCAL_BUS_SEL,
MT8195_CLK_TOP_DPTX_M_SEL,
MT8195_CLK_TOP_I2SO1_M_SEL,
MT8195_CLK_TOP_I2SO2_M_SEL,
MT8195_CLK_TOP_I2SI1_M_SEL,
MT8195_CLK_TOP_I2SI2_M_SEL,
/* clock gate */
MT8195_CLK_INFRA_AO_AUDIO_26M_B,
MT8195_CLK_SCP_ADSP_AUDIODSP,
MT8195_CLK_AUD_AFE,
MT8195_CLK_AUD_APLL,
MT8195_CLK_AUD_APLL2,
MT8195_CLK_AUD_DAC,
MT8195_CLK_AUD_ADC,
MT8195_CLK_AUD_DAC_HIRES,
MT8195_CLK_AUD_A1SYS_HP,
MT8195_CLK_AUD_ADC_HIRES,
MT8195_CLK_AUD_ADDA6_ADC,
MT8195_CLK_AUD_ADDA6_ADC_HIRES,
MT8195_CLK_AUD_I2SIN,
MT8195_CLK_AUD_TDM_IN,
MT8195_CLK_AUD_I2S_OUT,
MT8195_CLK_AUD_TDM_OUT,
MT8195_CLK_AUD_HDMI_OUT,
MT8195_CLK_AUD_ASRC11,
MT8195_CLK_AUD_ASRC12,
MT8195_CLK_AUD_A1SYS,
MT8195_CLK_AUD_A2SYS,
MT8195_CLK_AUD_PCMIF,
MT8195_CLK_AUD_MEMIF_UL1,
MT8195_CLK_AUD_MEMIF_UL2,
MT8195_CLK_AUD_MEMIF_UL3,
MT8195_CLK_AUD_MEMIF_UL4,
MT8195_CLK_AUD_MEMIF_UL5,
MT8195_CLK_AUD_MEMIF_UL6,
MT8195_CLK_AUD_MEMIF_UL8,
MT8195_CLK_AUD_MEMIF_UL9,
MT8195_CLK_AUD_MEMIF_UL10,
MT8195_CLK_AUD_MEMIF_DL2,
MT8195_CLK_AUD_MEMIF_DL3,
MT8195_CLK_AUD_MEMIF_DL6,
MT8195_CLK_AUD_MEMIF_DL7,
MT8195_CLK_AUD_MEMIF_DL8,
MT8195_CLK_AUD_MEMIF_DL10,
MT8195_CLK_AUD_MEMIF_DL11,
MT8195_CLK_NUM,
};
enum {
MT8195_MCK_SEL_26M,
MT8195_MCK_SEL_APLL1,
MT8195_MCK_SEL_APLL2,
MT8195_MCK_SEL_APLL3,
MT8195_MCK_SEL_APLL4,
MT8195_MCK_SEL_APLL5,
MT8195_MCK_SEL_HDMIRX_APLL,
MT8195_MCK_SEL_NUM,
};
struct mtk_base_afe;
int mt8195_afe_get_mclk_source_clk_id(int sel);
int mt8195_afe_get_mclk_source_rate(struct mtk_base_afe *afe, int apll);
int mt8195_afe_get_default_mclk_source_by_rate(int rate);
int mt8195_afe_init_clock(struct mtk_base_afe *afe);
void mt8195_afe_deinit_clock(struct mtk_base_afe *afe);
int mt8195_afe_enable_clk(struct mtk_base_afe *afe, struct clk *clk);
void mt8195_afe_disable_clk(struct mtk_base_afe *afe, struct clk *clk);
int mt8195_afe_prepare_clk(struct mtk_base_afe *afe, struct clk *clk);
void mt8195_afe_unprepare_clk(struct mtk_base_afe *afe, struct clk *clk);
int mt8195_afe_enable_clk_atomic(struct mtk_base_afe *afe, struct clk *clk);
void mt8195_afe_disable_clk_atomic(struct mtk_base_afe *afe, struct clk *clk);
int mt8195_afe_set_clk_rate(struct mtk_base_afe *afe, struct clk *clk,
unsigned int rate);
int mt8195_afe_set_clk_parent(struct mtk_base_afe *afe, struct clk *clk,
struct clk *parent);
int mt8195_afe_enable_main_clock(struct mtk_base_afe *afe);
int mt8195_afe_disable_main_clock(struct mtk_base_afe *afe);
int mt8195_afe_enable_reg_rw_clk(struct mtk_base_afe *afe);
int mt8195_afe_disable_reg_rw_clk(struct mtk_base_afe *afe);
#endif
/* SPDX-License-Identifier: GPL-2.0 */
/*
* mt8195-afe-common.h -- Mediatek 8195 audio driver definitions
*
* Copyright (c) 2021 MediaTek Inc.
* Author: Bicycle Tsai <bicycle.tsai@mediatek.com>
* Trevor Wu <trevor.wu@mediatek.com>
*/
#ifndef _MT_8195_AFE_COMMON_H_
#define _MT_8195_AFE_COMMON_H_
#include <sound/soc.h>
#include <linux/list.h>
#include <linux/regmap.h>
#include "../common/mtk-base-afe.h"
enum {
MT8195_DAI_START,
MT8195_AFE_MEMIF_START = MT8195_DAI_START,
MT8195_AFE_MEMIF_DL2 = MT8195_AFE_MEMIF_START,
MT8195_AFE_MEMIF_DL3,
MT8195_AFE_MEMIF_DL6,
MT8195_AFE_MEMIF_DL7,
MT8195_AFE_MEMIF_DL8,
MT8195_AFE_MEMIF_DL10,
MT8195_AFE_MEMIF_DL11,
MT8195_AFE_MEMIF_UL_START,
MT8195_AFE_MEMIF_UL1 = MT8195_AFE_MEMIF_UL_START,
MT8195_AFE_MEMIF_UL2,
MT8195_AFE_MEMIF_UL3,
MT8195_AFE_MEMIF_UL4,
MT8195_AFE_MEMIF_UL5,
MT8195_AFE_MEMIF_UL6,
MT8195_AFE_MEMIF_UL8,
MT8195_AFE_MEMIF_UL9,
MT8195_AFE_MEMIF_UL10,
MT8195_AFE_MEMIF_END,
MT8195_AFE_MEMIF_NUM = (MT8195_AFE_MEMIF_END - MT8195_AFE_MEMIF_START),
MT8195_AFE_IO_START = MT8195_AFE_MEMIF_END,
MT8195_AFE_IO_DL_SRC = MT8195_AFE_IO_START,
MT8195_AFE_IO_DPTX,
MT8195_AFE_IO_ETDM_START,
MT8195_AFE_IO_ETDM1_IN = MT8195_AFE_IO_ETDM_START,
MT8195_AFE_IO_ETDM2_IN,
MT8195_AFE_IO_ETDM1_OUT,
MT8195_AFE_IO_ETDM2_OUT,
MT8195_AFE_IO_ETDM3_OUT,
MT8195_AFE_IO_ETDM_END,
MT8195_AFE_IO_ETDM_NUM =
(MT8195_AFE_IO_ETDM_END - MT8195_AFE_IO_ETDM_START),
MT8195_AFE_IO_PCM = MT8195_AFE_IO_ETDM_END,
MT8195_AFE_IO_UL_SRC1,
MT8195_AFE_IO_UL_SRC2,
MT8195_AFE_IO_END,
MT8195_AFE_IO_NUM = (MT8195_AFE_IO_END - MT8195_AFE_IO_START),
MT8195_DAI_END = MT8195_AFE_IO_END,
MT8195_DAI_NUM = (MT8195_DAI_END - MT8195_DAI_START),
};
enum {
MT8195_TOP_CG_A1SYS_TIMING,
MT8195_TOP_CG_A2SYS_TIMING,
MT8195_TOP_CG_26M_TIMING,
MT8195_TOP_CG_NUM,
};
enum {
MT8195_AFE_IRQ_1,
MT8195_AFE_IRQ_2,
MT8195_AFE_IRQ_3,
MT8195_AFE_IRQ_8,
MT8195_AFE_IRQ_9,
MT8195_AFE_IRQ_10,
MT8195_AFE_IRQ_13,
MT8195_AFE_IRQ_14,
MT8195_AFE_IRQ_15,
MT8195_AFE_IRQ_16,
MT8195_AFE_IRQ_17,
MT8195_AFE_IRQ_18,
MT8195_AFE_IRQ_19,
MT8195_AFE_IRQ_20,
MT8195_AFE_IRQ_21,
MT8195_AFE_IRQ_22,
MT8195_AFE_IRQ_23,
MT8195_AFE_IRQ_24,
MT8195_AFE_IRQ_25,
MT8195_AFE_IRQ_26,
MT8195_AFE_IRQ_27,
MT8195_AFE_IRQ_28,
MT8195_AFE_IRQ_NUM,
};
enum {
MT8195_ETDM_OUT1_1X_EN = 9,
MT8195_ETDM_OUT2_1X_EN = 10,
MT8195_ETDM_OUT3_1X_EN = 11,
MT8195_ETDM_IN1_1X_EN = 12,
MT8195_ETDM_IN2_1X_EN = 13,
MT8195_ETDM_IN1_NX_EN = 25,
MT8195_ETDM_IN2_NX_EN = 26,
};
enum {
MT8195_MTKAIF_MISO_0,
MT8195_MTKAIF_MISO_1,
MT8195_MTKAIF_MISO_2,
MT8195_MTKAIF_MISO_NUM,
};
struct mtk_dai_memif_irq_priv {
unsigned int asys_timing_sel;
};
struct mtkaif_param {
bool mtkaif_calibration_ok;
int mtkaif_chosen_phase[MT8195_MTKAIF_MISO_NUM];
int mtkaif_phase_cycle[MT8195_MTKAIF_MISO_NUM];
int mtkaif_dmic_on;
int mtkaif_adda6_only;
};
struct clk;
struct mt8195_afe_private {
struct clk **clk;
struct clk_lookup **lookup;
struct regmap *topckgen;
int pm_runtime_bypass_reg_ctl;
#ifdef CONFIG_DEBUG_FS
struct dentry **debugfs_dentry;
#endif
int afe_on_ref_cnt;
int top_cg_ref_cnt[MT8195_TOP_CG_NUM];
spinlock_t afe_ctrl_lock; /* Lock for afe control */
struct mtk_dai_memif_irq_priv irq_priv[MT8195_AFE_IRQ_NUM];
struct mtkaif_param mtkaif_params;
/* dai */
void *dai_priv[MT8195_DAI_NUM];
};
int mt8195_afe_fs_timing(unsigned int rate);
/* dai register */
int mt8195_dai_adda_register(struct mtk_base_afe *afe);
int mt8195_dai_etdm_register(struct mtk_base_afe *afe);
int mt8195_dai_pcm_register(struct mtk_base_afe *afe);
#define MT8195_SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put, id) \
{ \
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_enum_double, \
.get = xhandler_get, .put = xhandler_put, \
.device = id, \
.private_value = (unsigned long)&xenum, \
}
#endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment