162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci// 362306a36Sopenharmony_ci// Copyright (c) 2022 MediaTek Inc. 462306a36Sopenharmony_ci// Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/clk-provider.h> 762306a36Sopenharmony_ci#include <linux/platform_device.h> 862306a36Sopenharmony_ci#include <dt-bindings/clock/mt8186-clk.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "clk-gate.h" 1162306a36Sopenharmony_ci#include "clk-mtk.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistatic const struct mtk_gate_regs img_cg_regs = { 1462306a36Sopenharmony_ci .set_ofs = 0x4, 1562306a36Sopenharmony_ci .clr_ofs = 0x8, 1662306a36Sopenharmony_ci .sta_ofs = 0x0, 1762306a36Sopenharmony_ci}; 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define GATE_IMG(_id, _name, _parent, _shift) \ 2062306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistatic const struct mtk_gate img1_clks[] = { 2362306a36Sopenharmony_ci GATE_IMG(CLK_IMG1_LARB9_IMG1, "img1_larb9_img1", "top_img1", 0), 2462306a36Sopenharmony_ci GATE_IMG(CLK_IMG1_LARB10_IMG1, "img1_larb10_img1", "top_img1", 1), 2562306a36Sopenharmony_ci GATE_IMG(CLK_IMG1_DIP, "img1_dip", "top_img1", 2), 2662306a36Sopenharmony_ci GATE_IMG(CLK_IMG1_GALS_IMG1, "img1_gals_img1", "top_img1", 12), 2762306a36Sopenharmony_ci}; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistatic const struct mtk_gate img2_clks[] = { 3062306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_LARB9_IMG2, "img2_larb9_img2", "top_img1", 0), 3162306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_LARB10_IMG2, "img2_larb10_img2", "top_img1", 1), 3262306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "top_img1", 6), 3362306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "top_img1", 7), 3462306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_MSS, "img2_mss", "top_img1", 8), 3562306a36Sopenharmony_ci GATE_IMG(CLK_IMG2_GALS_IMG2, "img2_gals_img2", "top_img1", 12), 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic const struct mtk_clk_desc img1_desc = { 3962306a36Sopenharmony_ci .clks = img1_clks, 4062306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(img1_clks), 4162306a36Sopenharmony_ci}; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistatic const struct mtk_clk_desc img2_desc = { 4462306a36Sopenharmony_ci .clks = img2_clks, 4562306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(img2_clks), 4662306a36Sopenharmony_ci}; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8186_img[] = { 4962306a36Sopenharmony_ci { 5062306a36Sopenharmony_ci .compatible = "mediatek,mt8186-imgsys1", 5162306a36Sopenharmony_ci .data = &img1_desc, 5262306a36Sopenharmony_ci }, { 5362306a36Sopenharmony_ci .compatible = "mediatek,mt8186-imgsys2", 5462306a36Sopenharmony_ci .data = &img2_desc, 5562306a36Sopenharmony_ci }, { 5662306a36Sopenharmony_ci /* sentinel */ 5762306a36Sopenharmony_ci } 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt8186_img); 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_cistatic struct platform_driver clk_mt8186_img_drv = { 6262306a36Sopenharmony_ci .probe = mtk_clk_simple_probe, 6362306a36Sopenharmony_ci .remove_new = mtk_clk_simple_remove, 6462306a36Sopenharmony_ci .driver = { 6562306a36Sopenharmony_ci .name = "clk-mt8186-img", 6662306a36Sopenharmony_ci .of_match_table = of_match_clk_mt8186_img, 6762306a36Sopenharmony_ci }, 6862306a36Sopenharmony_ci}; 6962306a36Sopenharmony_cimodule_platform_driver(clk_mt8186_img_drv); 7062306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 71