1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * mt8195-afe-clk.h  --  Mediatek 8195 afe clock ctrl definition
4  *
5  * Copyright (c) 2021 MediaTek Inc.
6  * Author: Bicycle Tsai <bicycle.tsai@mediatek.com>
7  *         Trevor Wu <trevor.wu@mediatek.com>
8  */
9 
10 #ifndef _MT8195_AFE_CLK_H_
11 #define _MT8195_AFE_CLK_H_
12 
13 enum {
14 	/* xtal */
15 	MT8195_CLK_XTAL_26M,
16 	/* divider */
17 	MT8195_CLK_TOP_APLL1,
18 	MT8195_CLK_TOP_APLL2,
19 	MT8195_CLK_TOP_APLL12_DIV0,
20 	MT8195_CLK_TOP_APLL12_DIV1,
21 	MT8195_CLK_TOP_APLL12_DIV2,
22 	MT8195_CLK_TOP_APLL12_DIV3,
23 	MT8195_CLK_TOP_APLL12_DIV9,
24 	/* mux */
25 	MT8195_CLK_TOP_A1SYS_HP_SEL,
26 	MT8195_CLK_TOP_AUD_INTBUS_SEL,
27 	MT8195_CLK_TOP_AUDIO_H_SEL,
28 	MT8195_CLK_TOP_AUDIO_LOCAL_BUS_SEL,
29 	MT8195_CLK_TOP_DPTX_M_SEL,
30 	MT8195_CLK_TOP_I2SO1_M_SEL,
31 	MT8195_CLK_TOP_I2SO2_M_SEL,
32 	MT8195_CLK_TOP_I2SI1_M_SEL,
33 	MT8195_CLK_TOP_I2SI2_M_SEL,
34 	/* clock gate */
35 	MT8195_CLK_INFRA_AO_AUDIO_26M_B,
36 	MT8195_CLK_SCP_ADSP_AUDIODSP,
37 	MT8195_CLK_AUD_AFE,
38 	MT8195_CLK_AUD_APLL,
39 	MT8195_CLK_AUD_APLL2,
40 	MT8195_CLK_AUD_DAC,
41 	MT8195_CLK_AUD_ADC,
42 	MT8195_CLK_AUD_DAC_HIRES,
43 	MT8195_CLK_AUD_A1SYS_HP,
44 	MT8195_CLK_AUD_ADC_HIRES,
45 	MT8195_CLK_AUD_ADDA6_ADC,
46 	MT8195_CLK_AUD_ADDA6_ADC_HIRES,
47 	MT8195_CLK_AUD_I2SIN,
48 	MT8195_CLK_AUD_TDM_IN,
49 	MT8195_CLK_AUD_I2S_OUT,
50 	MT8195_CLK_AUD_TDM_OUT,
51 	MT8195_CLK_AUD_HDMI_OUT,
52 	MT8195_CLK_AUD_ASRC11,
53 	MT8195_CLK_AUD_ASRC12,
54 	MT8195_CLK_AUD_A1SYS,
55 	MT8195_CLK_AUD_A2SYS,
56 	MT8195_CLK_AUD_PCMIF,
57 	MT8195_CLK_AUD_MEMIF_UL1,
58 	MT8195_CLK_AUD_MEMIF_UL2,
59 	MT8195_CLK_AUD_MEMIF_UL3,
60 	MT8195_CLK_AUD_MEMIF_UL4,
61 	MT8195_CLK_AUD_MEMIF_UL5,
62 	MT8195_CLK_AUD_MEMIF_UL6,
63 	MT8195_CLK_AUD_MEMIF_UL8,
64 	MT8195_CLK_AUD_MEMIF_UL9,
65 	MT8195_CLK_AUD_MEMIF_UL10,
66 	MT8195_CLK_AUD_MEMIF_DL2,
67 	MT8195_CLK_AUD_MEMIF_DL3,
68 	MT8195_CLK_AUD_MEMIF_DL6,
69 	MT8195_CLK_AUD_MEMIF_DL7,
70 	MT8195_CLK_AUD_MEMIF_DL8,
71 	MT8195_CLK_AUD_MEMIF_DL10,
72 	MT8195_CLK_AUD_MEMIF_DL11,
73 	MT8195_CLK_NUM,
74 };
75 
76 enum {
77 	MT8195_MCK_SEL_26M,
78 	MT8195_MCK_SEL_APLL1,
79 	MT8195_MCK_SEL_APLL2,
80 	MT8195_MCK_SEL_APLL3,
81 	MT8195_MCK_SEL_APLL4,
82 	MT8195_MCK_SEL_APLL5,
83 	MT8195_MCK_SEL_HDMIRX_APLL,
84 	MT8195_MCK_SEL_NUM,
85 };
86 
87 struct mtk_base_afe;
88 
89 int mt8195_afe_get_mclk_source_clk_id(int sel);
90 int mt8195_afe_get_mclk_source_rate(struct mtk_base_afe *afe, int apll);
91 int mt8195_afe_get_default_mclk_source_by_rate(int rate);
92 int mt8195_afe_init_clock(struct mtk_base_afe *afe);
93 void mt8195_afe_deinit_clock(struct mtk_base_afe *afe);
94 int mt8195_afe_enable_clk(struct mtk_base_afe *afe, struct clk *clk);
95 void mt8195_afe_disable_clk(struct mtk_base_afe *afe, struct clk *clk);
96 int mt8195_afe_prepare_clk(struct mtk_base_afe *afe, struct clk *clk);
97 void mt8195_afe_unprepare_clk(struct mtk_base_afe *afe, struct clk *clk);
98 int mt8195_afe_enable_clk_atomic(struct mtk_base_afe *afe, struct clk *clk);
99 void mt8195_afe_disable_clk_atomic(struct mtk_base_afe *afe, struct clk *clk);
100 int mt8195_afe_set_clk_rate(struct mtk_base_afe *afe, struct clk *clk,
101 			    unsigned int rate);
102 int mt8195_afe_set_clk_parent(struct mtk_base_afe *afe, struct clk *clk,
103 			      struct clk *parent);
104 int mt8195_afe_enable_main_clock(struct mtk_base_afe *afe);
105 int mt8195_afe_disable_main_clock(struct mtk_base_afe *afe);
106 int mt8195_afe_enable_reg_rw_clk(struct mtk_base_afe *afe);
107 int mt8195_afe_disable_reg_rw_clk(struct mtk_base_afe *afe);
108 
109 #endif
110