1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2018 MediaTek Inc. 4 * Author: Owen Chen <owen.chen@mediatek.com> 5 */ 6 7 #include <linux/clk-provider.h> 8 #include <linux/platform_device.h> 9 10 #include "clk-mtk.h" 11 #include "clk-gate.h" 12 13 #include <dt-bindings/clock/mt6765-clk.h> 14 15 static const struct mtk_gate_regs audio0_cg_regs = { 16 .set_ofs = 0x0, 17 .clr_ofs = 0x0, 18 .sta_ofs = 0x0, 19 }; 20 21 static const struct mtk_gate_regs audio1_cg_regs = { 22 .set_ofs = 0x4, 23 .clr_ofs = 0x4, 24 .sta_ofs = 0x4, 25 }; 26 27 #define GATE_AUDIO0(_id, _name, _parent, _shift) \ 28 GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 29 30 #define GATE_AUDIO1(_id, _name, _parent, _shift) \ 31 GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 32 33 static const struct mtk_gate audio_clks[] = { 34 /* AUDIO0 */ 35 GATE_AUDIO0(CLK_AUDIO_AFE, "aud_afe", "audio_ck", 2), 36 GATE_AUDIO0(CLK_AUDIO_22M, "aud_22m", "aud_engen1_ck", 8), 37 GATE_AUDIO0(CLK_AUDIO_APLL_TUNER, "aud_apll_tuner", 38 "aud_engen1_ck", 19), 39 GATE_AUDIO0(CLK_AUDIO_ADC, "aud_adc", "audio_ck", 24), 40 GATE_AUDIO0(CLK_AUDIO_DAC, "aud_dac", "audio_ck", 25), 41 GATE_AUDIO0(CLK_AUDIO_DAC_PREDIS, "aud_dac_predis", 42 "audio_ck", 26), 43 GATE_AUDIO0(CLK_AUDIO_TML, "aud_tml", "audio_ck", 27), 44 /* AUDIO1 */ 45 GATE_AUDIO1(CLK_AUDIO_I2S1_BCLK, "aud_i2s1_bclk", 46 "audio_ck", 4), 47 GATE_AUDIO1(CLK_AUDIO_I2S2_BCLK, "aud_i2s2_bclk", 48 "audio_ck", 5), 49 GATE_AUDIO1(CLK_AUDIO_I2S3_BCLK, "aud_i2s3_bclk", 50 "audio_ck", 6), 51 GATE_AUDIO1(CLK_AUDIO_I2S4_BCLK, "aud_i2s4_bclk", 52 "audio_ck", 7), 53 }; 54 55 static const struct mtk_clk_desc audio_desc = { 56 .clks = audio_clks, 57 .num_clks = ARRAY_SIZE(audio_clks), 58 }; 59 60 static const struct of_device_id of_match_clk_mt6765_audio[] = { 61 { 62 .compatible = "mediatek,mt6765-audsys", 63 .data = &audio_desc, 64 }, { 65 /* sentinel */ 66 } 67 }; 68 MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_audio); 69 70 static struct platform_driver clk_mt6765_audio_drv = { 71 .probe = mtk_clk_simple_probe, 72 .remove = mtk_clk_simple_remove, 73 .driver = { 74 .name = "clk-mt6765-audio", 75 .of_match_table = of_match_clk_mt6765_audio, 76 }, 77 }; 78 module_platform_driver(clk_mt6765_audio_drv); 79 MODULE_LICENSE("GPL"); 80