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 img_cg_regs = { 218c2ecf20Sopenharmony_ci .set_ofs = 0x4, 228c2ecf20Sopenharmony_ci .clr_ofs = 0x8, 238c2ecf20Sopenharmony_ci .sta_ofs = 0x0, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define GATE_IMG(_id, _name, _parent, _shift) { \ 278c2ecf20Sopenharmony_ci .id = _id, \ 288c2ecf20Sopenharmony_ci .name = _name, \ 298c2ecf20Sopenharmony_ci .parent_name = _parent, \ 308c2ecf20Sopenharmony_ci .regs = &img_cg_regs, \ 318c2ecf20Sopenharmony_ci .shift = _shift, \ 328c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 338c2ecf20Sopenharmony_ci } 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic const struct mtk_gate img_clks[] __initconst = { 368c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_LARB1_SMI, "img_larb1_smi", "smi_mm", 0), 378c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_CAM_SMI, "img_cam_smi", "smi_mm", 5), 388c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_CAM_CAM, "img_cam_cam", "smi_mm", 6), 398c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_SEN_TG, "img_sen_tg", "cam_mm", 7), 408c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_SEN_CAM, "img_sen_cam", "smi_mm", 8), 418c2ecf20Sopenharmony_ci GATE_IMG(CLK_IMG_VENC, "img_venc", "smi_mm", 9), 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic void __init mtk_imgsys_init(struct device_node *node) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 478c2ecf20Sopenharmony_ci int r; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks), clk_data); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci if (r) 568c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 578c2ecf20Sopenharmony_ci __func__, r); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8167-imgsys", mtk_imgsys_init); 61