162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * mt8188-afe-clk.h  --  MediaTek 8188 afe clock ctrl definition
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2022 MediaTek Inc.
662306a36Sopenharmony_ci * Author: Bicycle Tsai <bicycle.tsai@mediatek.com>
762306a36Sopenharmony_ci *         Trevor Wu <trevor.wu@mediatek.com>
862306a36Sopenharmony_ci *         Chun-Chia Chiu <chun-chia.chiu@mediatek.com>
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef _MT8188_AFE_CLK_H_
1262306a36Sopenharmony_ci#define _MT8188_AFE_CLK_H_
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* APLL */
1562306a36Sopenharmony_ci#define APLL1_W_NAME "APLL1"
1662306a36Sopenharmony_ci#define APLL2_W_NAME "APLL2"
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cienum {
1962306a36Sopenharmony_ci	/* xtal */
2062306a36Sopenharmony_ci	MT8188_CLK_XTAL_26M,
2162306a36Sopenharmony_ci	/* pll */
2262306a36Sopenharmony_ci	MT8188_CLK_APMIXED_APLL1,
2362306a36Sopenharmony_ci	MT8188_CLK_APMIXED_APLL2,
2462306a36Sopenharmony_ci	/* divider */
2562306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL1_D4,
2662306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL2_D4,
2762306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV0,
2862306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV1,
2962306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV2,
3062306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV3,
3162306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV4,
3262306a36Sopenharmony_ci	MT8188_CLK_TOP_APLL12_DIV9,
3362306a36Sopenharmony_ci	/* mux */
3462306a36Sopenharmony_ci	MT8188_CLK_TOP_A1SYS_HP_SEL,
3562306a36Sopenharmony_ci	MT8188_CLK_TOP_A2SYS_SEL,
3662306a36Sopenharmony_ci	MT8188_CLK_TOP_AUD_IEC_SEL,
3762306a36Sopenharmony_ci	MT8188_CLK_TOP_AUD_INTBUS_SEL,
3862306a36Sopenharmony_ci	MT8188_CLK_TOP_AUDIO_H_SEL,
3962306a36Sopenharmony_ci	MT8188_CLK_TOP_AUDIO_LOCAL_BUS_SEL,
4062306a36Sopenharmony_ci	MT8188_CLK_TOP_DPTX_M_SEL,
4162306a36Sopenharmony_ci	MT8188_CLK_TOP_I2SO1_M_SEL,
4262306a36Sopenharmony_ci	MT8188_CLK_TOP_I2SO2_M_SEL,
4362306a36Sopenharmony_ci	MT8188_CLK_TOP_I2SI1_M_SEL,
4462306a36Sopenharmony_ci	MT8188_CLK_TOP_I2SI2_M_SEL,
4562306a36Sopenharmony_ci	/* clock gate */
4662306a36Sopenharmony_ci	MT8188_CLK_ADSP_AUDIO_26M,
4762306a36Sopenharmony_ci	MT8188_CLK_AUD_AFE,
4862306a36Sopenharmony_ci	MT8188_CLK_AUD_APLL1_TUNER,
4962306a36Sopenharmony_ci	MT8188_CLK_AUD_APLL2_TUNER,
5062306a36Sopenharmony_ci	MT8188_CLK_AUD_TOP0_SPDF,
5162306a36Sopenharmony_ci	MT8188_CLK_AUD_APLL,
5262306a36Sopenharmony_ci	MT8188_CLK_AUD_APLL2,
5362306a36Sopenharmony_ci	MT8188_CLK_AUD_DAC,
5462306a36Sopenharmony_ci	MT8188_CLK_AUD_ADC,
5562306a36Sopenharmony_ci	MT8188_CLK_AUD_DAC_HIRES,
5662306a36Sopenharmony_ci	MT8188_CLK_AUD_A1SYS_HP,
5762306a36Sopenharmony_ci	MT8188_CLK_AUD_ADC_HIRES,
5862306a36Sopenharmony_ci	MT8188_CLK_AUD_I2SIN,
5962306a36Sopenharmony_ci	MT8188_CLK_AUD_TDM_IN,
6062306a36Sopenharmony_ci	MT8188_CLK_AUD_I2S_OUT,
6162306a36Sopenharmony_ci	MT8188_CLK_AUD_TDM_OUT,
6262306a36Sopenharmony_ci	MT8188_CLK_AUD_HDMI_OUT,
6362306a36Sopenharmony_ci	MT8188_CLK_AUD_ASRC11,
6462306a36Sopenharmony_ci	MT8188_CLK_AUD_ASRC12,
6562306a36Sopenharmony_ci	MT8188_CLK_AUD_A1SYS,
6662306a36Sopenharmony_ci	MT8188_CLK_AUD_A2SYS,
6762306a36Sopenharmony_ci	MT8188_CLK_AUD_PCMIF,
6862306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL1,
6962306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL2,
7062306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL3,
7162306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL4,
7262306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL5,
7362306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL6,
7462306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL8,
7562306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL9,
7662306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_UL10,
7762306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL2,
7862306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL3,
7962306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL6,
8062306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL7,
8162306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL8,
8262306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL10,
8362306a36Sopenharmony_ci	MT8188_CLK_AUD_MEMIF_DL11,
8462306a36Sopenharmony_ci	MT8188_CLK_NUM,
8562306a36Sopenharmony_ci};
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cienum {
8862306a36Sopenharmony_ci	MT8188_AUD_PLL1,
8962306a36Sopenharmony_ci	MT8188_AUD_PLL2,
9062306a36Sopenharmony_ci	MT8188_AUD_PLL3,
9162306a36Sopenharmony_ci	MT8188_AUD_PLL4,
9262306a36Sopenharmony_ci	MT8188_AUD_PLL5,
9362306a36Sopenharmony_ci	MT8188_AUD_PLL_NUM,
9462306a36Sopenharmony_ci};
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_cienum {
9762306a36Sopenharmony_ci	MT8188_MCK_SEL_26M,
9862306a36Sopenharmony_ci	MT8188_MCK_SEL_APLL1,
9962306a36Sopenharmony_ci	MT8188_MCK_SEL_APLL2,
10062306a36Sopenharmony_ci	MT8188_MCK_SEL_APLL3,
10162306a36Sopenharmony_ci	MT8188_MCK_SEL_APLL4,
10262306a36Sopenharmony_ci	MT8188_MCK_SEL_APLL5,
10362306a36Sopenharmony_ci	MT8188_MCK_SEL_NUM,
10462306a36Sopenharmony_ci};
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cistruct mtk_base_afe;
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ciint mt8188_afe_get_mclk_source_clk_id(int sel);
10962306a36Sopenharmony_ciint mt8188_afe_get_mclk_source_rate(struct mtk_base_afe *afe, int apll);
11062306a36Sopenharmony_ciint mt8188_afe_get_default_mclk_source_by_rate(int rate);
11162306a36Sopenharmony_ciint mt8188_get_apll_by_rate(struct mtk_base_afe *afe, int rate);
11262306a36Sopenharmony_ciint mt8188_get_apll_by_name(struct mtk_base_afe *afe, const char *name);
11362306a36Sopenharmony_ciint mt8188_afe_init_clock(struct mtk_base_afe *afe);
11462306a36Sopenharmony_ciint mt8188_afe_enable_clk(struct mtk_base_afe *afe, struct clk *clk);
11562306a36Sopenharmony_civoid mt8188_afe_disable_clk(struct mtk_base_afe *afe, struct clk *clk);
11662306a36Sopenharmony_ciint mt8188_afe_set_clk_rate(struct mtk_base_afe *afe, struct clk *clk,
11762306a36Sopenharmony_ci			    unsigned int rate);
11862306a36Sopenharmony_ciint mt8188_afe_set_clk_parent(struct mtk_base_afe *afe, struct clk *clk,
11962306a36Sopenharmony_ci			      struct clk *parent);
12062306a36Sopenharmony_ciint mt8188_apll1_enable(struct mtk_base_afe *afe);
12162306a36Sopenharmony_ciint mt8188_apll1_disable(struct mtk_base_afe *afe);
12262306a36Sopenharmony_ciint mt8188_apll2_enable(struct mtk_base_afe *afe);
12362306a36Sopenharmony_ciint mt8188_apll2_disable(struct mtk_base_afe *afe);
12462306a36Sopenharmony_ciint mt8188_afe_enable_main_clock(struct mtk_base_afe *afe);
12562306a36Sopenharmony_ciint mt8188_afe_disable_main_clock(struct mtk_base_afe *afe);
12662306a36Sopenharmony_ciint mt8188_afe_enable_reg_rw_clk(struct mtk_base_afe *afe);
12762306a36Sopenharmony_ciint mt8188_afe_disable_reg_rw_clk(struct mtk_base_afe *afe);
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#endif
130