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 img_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_IMG(_id, _name, _parent, _shift) \ 218c2ecf20Sopenharmony_ci GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, \ 228c2ecf20Sopenharmony_ci &mtk_clk_gate_ops_setclr) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistatic const struct mtk_gate img_clks[] = { 258c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_LARB5, "img_larb5", "img_sel", 0), 268c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_LARB2, "img_larb2", "img_sel", 1), 278c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_DIP, "img_dip", "img_sel", 2), 288c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "img_sel", 3), 298c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_DPE, "img_dpe", "img_sel", 4), 308c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_RSC, "img_rsc", "img_sel", 5), 318c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_MFB, "img_mfb", "img_sel", 6), 328c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_WPE_A, "img_wpe_a", "img_sel", 7), 338c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_WPE_B, "img_wpe_b", "img_sel", 8), 348c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9), 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic int clk_mt8183_img_probe(struct platform_device *pdev) 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 408c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks), 458c2ecf20Sopenharmony_ci clk_data); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8183_img[] = { 518c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt8183-imgsys", }, 528c2ecf20Sopenharmony_ci {} 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt8183_img_drv = { 568c2ecf20Sopenharmony_ci .probe = clk_mt8183_img_probe, 578c2ecf20Sopenharmony_ci .driver = { 588c2ecf20Sopenharmony_ci .name = "clk-mt8183-img", 598c2ecf20Sopenharmony_ci .of_match_table = of_match_clk_mt8183_img, 608c2ecf20Sopenharmony_ci }, 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cibuiltin_platform_driver(clk_mt8183_img_drv); 64