18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc. 48c2ecf20Sopenharmony_ci// Author: Weiyi Lu <weiyi.lu@mediatek.com> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 78c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "clk-mtk.h" 108c2ecf20Sopenharmony_ci#include "clk-gate.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt8183-clk.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs ipu_core1_cg_regs = { 158c2ecf20Sopenharmony_ci .set_ofs = 0x4, 168c2ecf20Sopenharmony_ci .clr_ofs = 0x8, 178c2ecf20Sopenharmony_ci .sta_ofs = 0x0, 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define GATE_IPU_CORE1(_id, _name, _parent, _shift) \ 218c2ecf20Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_core1_cg_regs, _shift, \ 228c2ecf20Sopenharmony_ci &mtk_clk_gate_ops_setclr) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistatic const struct mtk_gate ipu_core1_clks[] = { 258c2ecf20Sopenharmony_ci GATE_IPU_CORE1(CLK_IPU_CORE1_JTAG, "ipu_core1_jtag", "dsp_sel", 0), 268c2ecf20Sopenharmony_ci GATE_IPU_CORE1(CLK_IPU_CORE1_AXI, "ipu_core1_axi", "dsp_sel", 1), 278c2ecf20Sopenharmony_ci GATE_IPU_CORE1(CLK_IPU_CORE1_IPU, "ipu_core1_ipu", "dsp_sel", 2), 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic int clk_mt8183_ipu_core1_probe(struct platform_device *pdev) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 338c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_IPU_CORE1_NR_CLK); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, ipu_core1_clks, ARRAY_SIZE(ipu_core1_clks), 388c2ecf20Sopenharmony_ci clk_data); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8183_ipu_core1[] = { 448c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt8183-ipu_core1", }, 458c2ecf20Sopenharmony_ci {} 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt8183_ipu_core1_drv = { 498c2ecf20Sopenharmony_ci .probe = clk_mt8183_ipu_core1_probe, 508c2ecf20Sopenharmony_ci .driver = { 518c2ecf20Sopenharmony_ci .name = "clk-mt8183-ipu_core1", 528c2ecf20Sopenharmony_ci .of_match_table = of_match_clk_mt8183_ipu_core1, 538c2ecf20Sopenharmony_ci }, 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cibuiltin_platform_driver(clk_mt8183_ipu_core1_drv); 57