18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2019 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Author: Wendell Lin <wendell.lin@mediatek.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 88c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 98c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt6779-clk.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "clk-mtk.h" 128c2ecf20Sopenharmony_ci#include "clk-gate.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs cam_cg_regs = { 158c2ecf20Sopenharmony_ci .set_ofs = 0x0004, 168c2ecf20Sopenharmony_ci .clr_ofs = 0x0008, 178c2ecf20Sopenharmony_ci .sta_ofs = 0x0000, 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define GATE_CAM(_id, _name, _parent, _shift) \ 218c2ecf20Sopenharmony_ci GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, \ 228c2ecf20Sopenharmony_ci &mtk_clk_gate_ops_setclr) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistatic const struct mtk_gate cam_clks[] = { 258c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_LARB10, "camsys_larb10", "cam_sel", 0), 268c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_DFP_VAD, "camsys_dfp_vad", "cam_sel", 1), 278c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_LARB11, "camsys_larb11", "cam_sel", 2), 288c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_LARB9, "camsys_larb9", "cam_sel", 3), 298c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAM, "camsys_cam", "cam_sel", 6), 308c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAMTG, "camsys_camtg", "cam_sel", 7), 318c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_SENINF, "camsys_seninf", "cam_sel", 8), 328c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAMSV0, "camsys_camsv0", "cam_sel", 9), 338c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAMSV1, "camsys_camsv1", "cam_sel", 10), 348c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAMSV2, "camsys_camsv2", "cam_sel", 11), 358c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CAMSV3, "camsys_camsv3", "cam_sel", 12), 368c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_CCU, "camsys_ccu", "cam_sel", 13), 378c2ecf20Sopenharmony_ci GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14), 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt6779_cam[] = { 418c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt6779-camsys", }, 428c2ecf20Sopenharmony_ci {} 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic int clk_mt6779_cam_probe(struct platform_device *pdev) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 488c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks), 538c2ecf20Sopenharmony_ci clk_data); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt6779_cam_drv = { 598c2ecf20Sopenharmony_ci .probe = clk_mt6779_cam_probe, 608c2ecf20Sopenharmony_ci .driver = { 618c2ecf20Sopenharmony_ci .name = "clk-mt6779-cam", 628c2ecf20Sopenharmony_ci .of_match_table = of_match_clk_mt6779_cam, 638c2ecf20Sopenharmony_ci }, 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cibuiltin_platform_driver(clk_mt6779_cam_drv); 67