1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // Copyright (c) 2022 MediaTek Inc. 4 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 5 6 #include <linux/clk-provider.h> 7 #include <linux/platform_device.h> 8 #include <dt-bindings/clock/mt8186-clk.h> 9 10 #include "clk-gate.h" 11 #include "clk-mtk.h" 12 13 static const struct mtk_gate_regs img_cg_regs = { 14 .set_ofs = 0x4, 15 .clr_ofs = 0x8, 16 .sta_ofs = 0x0, 17 }; 18 19 #define GATE_IMG(_id, _name, _parent, _shift) \ 20 GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 21 22 static const struct mtk_gate img1_clks[] = { 23 GATE_IMG(CLK_IMG1_LARB9_IMG1, "img1_larb9_img1", "top_img1", 0), 24 GATE_IMG(CLK_IMG1_LARB10_IMG1, "img1_larb10_img1", "top_img1", 1), 25 GATE_IMG(CLK_IMG1_DIP, "img1_dip", "top_img1", 2), 26 GATE_IMG(CLK_IMG1_GALS_IMG1, "img1_gals_img1", "top_img1", 12), 27 }; 28 29 static const struct mtk_gate img2_clks[] = { 30 GATE_IMG(CLK_IMG2_LARB9_IMG2, "img2_larb9_img2", "top_img1", 0), 31 GATE_IMG(CLK_IMG2_LARB10_IMG2, "img2_larb10_img2", "top_img1", 1), 32 GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "top_img1", 6), 33 GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "top_img1", 7), 34 GATE_IMG(CLK_IMG2_MSS, "img2_mss", "top_img1", 8), 35 GATE_IMG(CLK_IMG2_GALS_IMG2, "img2_gals_img2", "top_img1", 12), 36 }; 37 38 static const struct mtk_clk_desc img1_desc = { 39 .clks = img1_clks, 40 .num_clks = ARRAY_SIZE(img1_clks), 41 }; 42 43 static const struct mtk_clk_desc img2_desc = { 44 .clks = img2_clks, 45 .num_clks = ARRAY_SIZE(img2_clks), 46 }; 47 48 static const struct of_device_id of_match_clk_mt8186_img[] = { 49 { 50 .compatible = "mediatek,mt8186-imgsys1", 51 .data = &img1_desc, 52 }, { 53 .compatible = "mediatek,mt8186-imgsys2", 54 .data = &img2_desc, 55 }, { 56 /* sentinel */ 57 } 58 }; 59 MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_img); 60 61 static struct platform_driver clk_mt8186_img_drv = { 62 .probe = mtk_clk_simple_probe, 63 .remove_new = mtk_clk_simple_remove, 64 .driver = { 65 .name = "clk-mt8186-img", 66 .of_match_table = of_match_clk_mt8186_img, 67 }, 68 }; 69 module_platform_driver(clk_mt8186_img_drv); 70 71 MODULE_DESCRIPTION("MediaTek MT8186 imgsys clocks driver"); 72 MODULE_LICENSE("GPL"); 73