Linux 4.15.6
[linux/fpc-iii.git] / sound / soc / mediatek / mt2701 / mt2701-afe-clock-ctrl.c
blobaffa7fb25dd9080b853672d9669d0820205443cf
1 /*
2 * mt2701-afe-clock-ctrl.c -- Mediatek 2701 afe clock ctrl
4 * Copyright (c) 2016 MediaTek Inc.
5 * Author: Garlic Tseng <garlic.tseng@mediatek.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 and
9 * only version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <sound/soc.h>
18 #include <linux/regmap.h>
19 #include <linux/pm_runtime.h>
21 #include "mt2701-afe-common.h"
22 #include "mt2701-afe-clock-ctrl.h"
24 static const char *aud_clks[MT2701_CLOCK_NUM] = {
25 [MT2701_AUD_INFRA_SYS_AUDIO] = "infra_sys_audio_clk",
26 [MT2701_AUD_AUD_MUX1_SEL] = "top_audio_mux1_sel",
27 [MT2701_AUD_AUD_MUX2_SEL] = "top_audio_mux2_sel",
28 [MT2701_AUD_AUD_MUX1_DIV] = "top_audio_mux1_div",
29 [MT2701_AUD_AUD_MUX2_DIV] = "top_audio_mux2_div",
30 [MT2701_AUD_AUD_48K_TIMING] = "top_audio_48k_timing",
31 [MT2701_AUD_AUD_44K_TIMING] = "top_audio_44k_timing",
32 [MT2701_AUD_AUDPLL_MUX_SEL] = "top_audpll_mux_sel",
33 [MT2701_AUD_APLL_SEL] = "top_apll_sel",
34 [MT2701_AUD_AUD1PLL_98M] = "top_aud1_pll_98M",
35 [MT2701_AUD_AUD2PLL_90M] = "top_aud2_pll_90M",
36 [MT2701_AUD_HADDS2PLL_98M] = "top_hadds2_pll_98M",
37 [MT2701_AUD_HADDS2PLL_294M] = "top_hadds2_pll_294M",
38 [MT2701_AUD_AUDPLL] = "top_audpll",
39 [MT2701_AUD_AUDPLL_D4] = "top_audpll_d4",
40 [MT2701_AUD_AUDPLL_D8] = "top_audpll_d8",
41 [MT2701_AUD_AUDPLL_D16] = "top_audpll_d16",
42 [MT2701_AUD_AUDPLL_D24] = "top_audpll_d24",
43 [MT2701_AUD_AUDINTBUS] = "top_audintbus_sel",
44 [MT2701_AUD_CLK_26M] = "clk_26m",
45 [MT2701_AUD_SYSPLL1_D4] = "top_syspll1_d4",
46 [MT2701_AUD_AUD_K1_SRC_SEL] = "top_aud_k1_src_sel",
47 [MT2701_AUD_AUD_K2_SRC_SEL] = "top_aud_k2_src_sel",
48 [MT2701_AUD_AUD_K3_SRC_SEL] = "top_aud_k3_src_sel",
49 [MT2701_AUD_AUD_K4_SRC_SEL] = "top_aud_k4_src_sel",
50 [MT2701_AUD_AUD_K5_SRC_SEL] = "top_aud_k5_src_sel",
51 [MT2701_AUD_AUD_K6_SRC_SEL] = "top_aud_k6_src_sel",
52 [MT2701_AUD_AUD_K1_SRC_DIV] = "top_aud_k1_src_div",
53 [MT2701_AUD_AUD_K2_SRC_DIV] = "top_aud_k2_src_div",
54 [MT2701_AUD_AUD_K3_SRC_DIV] = "top_aud_k3_src_div",
55 [MT2701_AUD_AUD_K4_SRC_DIV] = "top_aud_k4_src_div",
56 [MT2701_AUD_AUD_K5_SRC_DIV] = "top_aud_k5_src_div",
57 [MT2701_AUD_AUD_K6_SRC_DIV] = "top_aud_k6_src_div",
58 [MT2701_AUD_AUD_I2S1_MCLK] = "top_aud_i2s1_mclk",
59 [MT2701_AUD_AUD_I2S2_MCLK] = "top_aud_i2s2_mclk",
60 [MT2701_AUD_AUD_I2S3_MCLK] = "top_aud_i2s3_mclk",
61 [MT2701_AUD_AUD_I2S4_MCLK] = "top_aud_i2s4_mclk",
62 [MT2701_AUD_AUD_I2S5_MCLK] = "top_aud_i2s5_mclk",
63 [MT2701_AUD_AUD_I2S6_MCLK] = "top_aud_i2s6_mclk",
64 [MT2701_AUD_ASM_M_SEL] = "top_asm_m_sel",
65 [MT2701_AUD_ASM_H_SEL] = "top_asm_h_sel",
66 [MT2701_AUD_UNIVPLL2_D4] = "top_univpll2_d4",
67 [MT2701_AUD_UNIVPLL2_D2] = "top_univpll2_d2",
68 [MT2701_AUD_SYSPLL_D5] = "top_syspll_d5",
71 int mt2701_init_clock(struct mtk_base_afe *afe)
73 struct mt2701_afe_private *afe_priv = afe->platform_priv;
74 int i = 0;
76 for (i = 0; i < MT2701_CLOCK_NUM; i++) {
77 afe_priv->clocks[i] = devm_clk_get(afe->dev, aud_clks[i]);
78 if (IS_ERR(afe_priv->clocks[i])) {
79 dev_warn(afe->dev, "%s devm_clk_get %s fail\n",
80 __func__, aud_clks[i]);
81 return PTR_ERR(aud_clks[i]);
85 return 0;
88 int mt2701_afe_enable_clock(struct mtk_base_afe *afe)
90 int ret = 0;
92 ret = mt2701_turn_on_a1sys_clock(afe);
93 if (ret) {
94 dev_err(afe->dev, "%s turn_on_a1sys_clock fail %d\n",
95 __func__, ret);
96 return ret;
99 ret = mt2701_turn_on_a2sys_clock(afe);
100 if (ret) {
101 dev_err(afe->dev, "%s turn_on_a2sys_clock fail %d\n",
102 __func__, ret);
103 mt2701_turn_off_a1sys_clock(afe);
104 return ret;
107 ret = mt2701_turn_on_afe_clock(afe);
108 if (ret) {
109 dev_err(afe->dev, "%s turn_on_afe_clock fail %d\n",
110 __func__, ret);
111 mt2701_turn_off_a1sys_clock(afe);
112 mt2701_turn_off_a2sys_clock(afe);
113 return ret;
116 regmap_update_bits(afe->regmap, ASYS_TOP_CON,
117 AUDIO_TOP_CON0_A1SYS_A2SYS_ON,
118 AUDIO_TOP_CON0_A1SYS_A2SYS_ON);
119 regmap_update_bits(afe->regmap, AFE_DAC_CON0,
120 AFE_DAC_CON0_AFE_ON,
121 AFE_DAC_CON0_AFE_ON);
122 regmap_write(afe->regmap, PWR2_TOP_CON,
123 PWR2_TOP_CON_INIT_VAL);
124 regmap_write(afe->regmap, PWR1_ASM_CON1,
125 PWR1_ASM_CON1_INIT_VAL);
126 regmap_write(afe->regmap, PWR2_ASM_CON1,
127 PWR2_ASM_CON1_INIT_VAL);
129 return 0;
132 void mt2701_afe_disable_clock(struct mtk_base_afe *afe)
134 mt2701_turn_off_afe_clock(afe);
135 mt2701_turn_off_a1sys_clock(afe);
136 mt2701_turn_off_a2sys_clock(afe);
137 regmap_update_bits(afe->regmap, ASYS_TOP_CON,
138 AUDIO_TOP_CON0_A1SYS_A2SYS_ON, 0);
139 regmap_update_bits(afe->regmap, AFE_DAC_CON0,
140 AFE_DAC_CON0_AFE_ON, 0);
143 int mt2701_turn_on_a1sys_clock(struct mtk_base_afe *afe)
145 struct mt2701_afe_private *afe_priv = afe->platform_priv;
146 int ret = 0;
148 /* Set Mux */
149 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
150 if (ret) {
151 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
152 __func__, aud_clks[MT2701_AUD_AUD_MUX1_SEL], ret);
153 goto A1SYS_CLK_AUD_MUX1_SEL_ERR;
156 ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL],
157 afe_priv->clocks[MT2701_AUD_AUD1PLL_98M]);
158 if (ret) {
159 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
160 aud_clks[MT2701_AUD_AUD_MUX1_SEL],
161 aud_clks[MT2701_AUD_AUD1PLL_98M], ret);
162 goto A1SYS_CLK_AUD_MUX1_SEL_ERR;
165 /* Set Divider */
166 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
167 if (ret) {
168 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
169 __func__,
170 aud_clks[MT2701_AUD_AUD_MUX1_DIV],
171 ret);
172 goto A1SYS_CLK_AUD_MUX1_DIV_ERR;
175 ret = clk_set_rate(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV],
176 MT2701_AUD_AUD_MUX1_DIV_RATE);
177 if (ret) {
178 dev_err(afe->dev, "%s clk_set_parent %s-%d fail %d\n", __func__,
179 aud_clks[MT2701_AUD_AUD_MUX1_DIV],
180 MT2701_AUD_AUD_MUX1_DIV_RATE, ret);
181 goto A1SYS_CLK_AUD_MUX1_DIV_ERR;
184 /* Enable clock gate */
185 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
186 if (ret) {
187 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
188 __func__, aud_clks[MT2701_AUD_AUD_48K_TIMING], ret);
189 goto A1SYS_CLK_AUD_48K_ERR;
192 /* Enable infra audio */
193 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
194 if (ret) {
195 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
196 __func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
197 goto A1SYS_CLK_INFRA_ERR;
200 return 0;
202 A1SYS_CLK_INFRA_ERR:
203 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
204 A1SYS_CLK_AUD_48K_ERR:
205 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
206 A1SYS_CLK_AUD_MUX1_DIV_ERR:
207 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
208 A1SYS_CLK_AUD_MUX1_SEL_ERR:
209 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
211 return ret;
214 void mt2701_turn_off_a1sys_clock(struct mtk_base_afe *afe)
216 struct mt2701_afe_private *afe_priv = afe->platform_priv;
218 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
219 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_48K_TIMING]);
220 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_DIV]);
221 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
224 int mt2701_turn_on_a2sys_clock(struct mtk_base_afe *afe)
226 struct mt2701_afe_private *afe_priv = afe->platform_priv;
227 int ret = 0;
229 /* Set Mux */
230 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
231 if (ret) {
232 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
233 __func__, aud_clks[MT2701_AUD_AUD_MUX2_SEL], ret);
234 goto A2SYS_CLK_AUD_MUX2_SEL_ERR;
237 ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL],
238 afe_priv->clocks[MT2701_AUD_AUD2PLL_90M]);
239 if (ret) {
240 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
241 aud_clks[MT2701_AUD_AUD_MUX2_SEL],
242 aud_clks[MT2701_AUD_AUD2PLL_90M], ret);
243 goto A2SYS_CLK_AUD_MUX2_SEL_ERR;
246 /* Set Divider */
247 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
248 if (ret) {
249 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
250 __func__, aud_clks[MT2701_AUD_AUD_MUX2_DIV], ret);
251 goto A2SYS_CLK_AUD_MUX2_DIV_ERR;
254 ret = clk_set_rate(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV],
255 MT2701_AUD_AUD_MUX2_DIV_RATE);
256 if (ret) {
257 dev_err(afe->dev, "%s clk_set_parent %s-%d fail %d\n", __func__,
258 aud_clks[MT2701_AUD_AUD_MUX2_DIV],
259 MT2701_AUD_AUD_MUX2_DIV_RATE, ret);
260 goto A2SYS_CLK_AUD_MUX2_DIV_ERR;
263 /* Enable clock gate */
264 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
265 if (ret) {
266 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
267 __func__, aud_clks[MT2701_AUD_AUD_44K_TIMING], ret);
268 goto A2SYS_CLK_AUD_44K_ERR;
271 /* Enable infra audio */
272 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
273 if (ret) {
274 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
275 __func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
276 goto A2SYS_CLK_INFRA_ERR;
279 return 0;
281 A2SYS_CLK_INFRA_ERR:
282 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
283 A2SYS_CLK_AUD_44K_ERR:
284 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
285 A2SYS_CLK_AUD_MUX2_DIV_ERR:
286 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
287 A2SYS_CLK_AUD_MUX2_SEL_ERR:
288 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
290 return ret;
293 void mt2701_turn_off_a2sys_clock(struct mtk_base_afe *afe)
295 struct mt2701_afe_private *afe_priv = afe->platform_priv;
297 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
298 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_44K_TIMING]);
299 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_DIV]);
300 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
303 int mt2701_turn_on_afe_clock(struct mtk_base_afe *afe)
305 struct mt2701_afe_private *afe_priv = afe->platform_priv;
306 int ret;
308 /* enable INFRA_SYS */
309 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
310 if (ret) {
311 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
312 __func__, aud_clks[MT2701_AUD_INFRA_SYS_AUDIO], ret);
313 goto AFE_AUD_INFRA_ERR;
316 /* Set MT2701_AUD_AUDINTBUS to MT2701_AUD_SYSPLL1_D4 */
317 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
318 if (ret) {
319 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
320 __func__, aud_clks[MT2701_AUD_AUDINTBUS], ret);
321 goto AFE_AUD_AUDINTBUS_ERR;
324 ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_AUDINTBUS],
325 afe_priv->clocks[MT2701_AUD_SYSPLL1_D4]);
326 if (ret) {
327 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
328 aud_clks[MT2701_AUD_AUDINTBUS],
329 aud_clks[MT2701_AUD_SYSPLL1_D4], ret);
330 goto AFE_AUD_AUDINTBUS_ERR;
333 /* Set MT2701_AUD_ASM_H_SEL to MT2701_AUD_UNIVPLL2_D2 */
334 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
335 if (ret) {
336 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
337 __func__, aud_clks[MT2701_AUD_ASM_H_SEL], ret);
338 goto AFE_AUD_ASM_H_ERR;
341 ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_ASM_H_SEL],
342 afe_priv->clocks[MT2701_AUD_UNIVPLL2_D2]);
343 if (ret) {
344 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
345 aud_clks[MT2701_AUD_ASM_H_SEL],
346 aud_clks[MT2701_AUD_UNIVPLL2_D2], ret);
347 goto AFE_AUD_ASM_H_ERR;
350 /* Set MT2701_AUD_ASM_M_SEL to MT2701_AUD_UNIVPLL2_D4 */
351 ret = clk_prepare_enable(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
352 if (ret) {
353 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
354 __func__, aud_clks[MT2701_AUD_ASM_M_SEL], ret);
355 goto AFE_AUD_ASM_M_ERR;
358 ret = clk_set_parent(afe_priv->clocks[MT2701_AUD_ASM_M_SEL],
359 afe_priv->clocks[MT2701_AUD_UNIVPLL2_D4]);
360 if (ret) {
361 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n", __func__,
362 aud_clks[MT2701_AUD_ASM_M_SEL],
363 aud_clks[MT2701_AUD_UNIVPLL2_D4], ret);
364 goto AFE_AUD_ASM_M_ERR;
367 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
368 AUDIO_TOP_CON0_PDN_AFE, 0);
369 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
370 AUDIO_TOP_CON0_PDN_APLL_CK, 0);
371 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
372 AUDIO_TOP_CON4_PDN_A1SYS, 0);
373 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
374 AUDIO_TOP_CON4_PDN_A2SYS, 0);
375 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
376 AUDIO_TOP_CON4_PDN_AFE_CONN, 0);
378 return 0;
380 AFE_AUD_ASM_M_ERR:
381 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
382 AFE_AUD_ASM_H_ERR:
383 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
384 AFE_AUD_AUDINTBUS_ERR:
385 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
386 AFE_AUD_INFRA_ERR:
387 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
389 return ret;
392 void mt2701_turn_off_afe_clock(struct mtk_base_afe *afe)
394 struct mt2701_afe_private *afe_priv = afe->platform_priv;
396 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_INFRA_SYS_AUDIO]);
398 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_AUDINTBUS]);
399 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_H_SEL]);
400 clk_disable_unprepare(afe_priv->clocks[MT2701_AUD_ASM_M_SEL]);
402 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
403 AUDIO_TOP_CON0_PDN_AFE, AUDIO_TOP_CON0_PDN_AFE);
404 regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
405 AUDIO_TOP_CON0_PDN_APLL_CK,
406 AUDIO_TOP_CON0_PDN_APLL_CK);
407 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
408 AUDIO_TOP_CON4_PDN_A1SYS,
409 AUDIO_TOP_CON4_PDN_A1SYS);
410 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
411 AUDIO_TOP_CON4_PDN_A2SYS,
412 AUDIO_TOP_CON4_PDN_A2SYS);
413 regmap_update_bits(afe->regmap, AUDIO_TOP_CON4,
414 AUDIO_TOP_CON4_PDN_AFE_CONN,
415 AUDIO_TOP_CON4_PDN_AFE_CONN);
418 void mt2701_mclk_configuration(struct mtk_base_afe *afe, int id, int domain,
419 int mclk)
421 struct mt2701_afe_private *afe_priv = afe->platform_priv;
422 int ret;
423 int aud_src_div_id = MT2701_AUD_AUD_K1_SRC_DIV + id;
424 int aud_src_clk_id = MT2701_AUD_AUD_K1_SRC_SEL + id;
426 /* Set MCLK Kx_SRC_SEL(domain) */
427 ret = clk_prepare_enable(afe_priv->clocks[aud_src_clk_id]);
428 if (ret)
429 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
430 __func__, aud_clks[aud_src_clk_id], ret);
432 if (domain == 0) {
433 ret = clk_set_parent(afe_priv->clocks[aud_src_clk_id],
434 afe_priv->clocks[MT2701_AUD_AUD_MUX1_SEL]);
435 if (ret)
436 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n",
437 __func__, aud_clks[aud_src_clk_id],
438 aud_clks[MT2701_AUD_AUD_MUX1_SEL], ret);
439 } else {
440 ret = clk_set_parent(afe_priv->clocks[aud_src_clk_id],
441 afe_priv->clocks[MT2701_AUD_AUD_MUX2_SEL]);
442 if (ret)
443 dev_err(afe->dev, "%s clk_set_parent %s-%s fail %d\n",
444 __func__, aud_clks[aud_src_clk_id],
445 aud_clks[MT2701_AUD_AUD_MUX2_SEL], ret);
447 clk_disable_unprepare(afe_priv->clocks[aud_src_clk_id]);
449 /* Set MCLK Kx_SRC_DIV(divider) */
450 ret = clk_prepare_enable(afe_priv->clocks[aud_src_div_id]);
451 if (ret)
452 dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
453 __func__, aud_clks[aud_src_div_id], ret);
455 ret = clk_set_rate(afe_priv->clocks[aud_src_div_id], mclk);
456 if (ret)
457 dev_err(afe->dev, "%s clk_set_rate %s-%d fail %d\n", __func__,
458 aud_clks[aud_src_div_id], mclk, ret);
459 clk_disable_unprepare(afe_priv->clocks[aud_src_div_id]);
462 MODULE_DESCRIPTION("MT2701 afe clock control");
463 MODULE_AUTHOR("Garlic Tseng <garlic.tseng@mediatek.com>");
464 MODULE_LICENSE("GPL v2");