18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2020 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Copyright (c) 2020 BayLibre, SAS 58c2ecf20Sopenharmony_ci * Author: James Liao <jamesjj.liao@mediatek.com> 68c2ecf20Sopenharmony_ci * Fabien Parent <fparent@baylibre.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 108c2ecf20Sopenharmony_ci#include <linux/of.h> 118c2ecf20Sopenharmony_ci#include <linux/of_address.h> 128c2ecf20Sopenharmony_ci#include <linux/of_device.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "clk-mtk.h" 168c2ecf20Sopenharmony_ci#include "clk-gate.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt8167-clk.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs aud_cg_regs = { 218c2ecf20Sopenharmony_ci .set_ofs = 0x0, 228c2ecf20Sopenharmony_ci .clr_ofs = 0x0, 238c2ecf20Sopenharmony_ci .sta_ofs = 0x0, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define GATE_AUD(_id, _name, _parent, _shift) { \ 278c2ecf20Sopenharmony_ci .id = _id, \ 288c2ecf20Sopenharmony_ci .name = _name, \ 298c2ecf20Sopenharmony_ci .parent_name = _parent, \ 308c2ecf20Sopenharmony_ci .regs = &aud_cg_regs, \ 318c2ecf20Sopenharmony_ci .shift = _shift, \ 328c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_no_setclr, \ 338c2ecf20Sopenharmony_ci } 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic const struct mtk_gate aud_clks[] __initconst = { 368c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_AFE, "aud_afe", "clk26m_ck", 2), 378c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_I2S, "aud_i2s", "i2s_infra_bck", 6), 388c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_22M, "aud_22m", "rg_aud_engen1", 8), 398c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_24M, "aud_24m", "rg_aud_engen2", 9), 408c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_INTDIR, "aud_intdir", "rg_aud_spdif_in", 15), 418c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_APLL2_TUNER, "aud_apll2_tuner", "rg_aud_engen2", 18), 428c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_APLL_TUNER, "aud_apll_tuner", "rg_aud_engen1", 19), 438c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_HDMI, "aud_hdmi", "apll12_div4", 20), 448c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_SPDF, "aud_spdf", "apll12_div6", 21), 458c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_ADC, "aud_adc", "aud_afe", 24), 468c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_DAC, "aud_dac", "aud_afe", 25), 478c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_DAC_PREDIS, "aud_dac_predis", "aud_afe", 26), 488c2ecf20Sopenharmony_ci GATE_AUD(CLK_AUD_TML, "aud_tml", "aud_afe", 27), 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic void __init mtk_audsys_init(struct device_node *node) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 548c2ecf20Sopenharmony_ci int r; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, aud_clks, ARRAY_SIZE(aud_clks), clk_data); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 618c2ecf20Sopenharmony_ci if (r) 628c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 638c2ecf20Sopenharmony_ci __func__, r); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_audsys, "mediatek,mt8167-audsys", mtk_audsys_init); 67