Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 //
0003 // Copyright (c) 2022 MediaTek Inc.
0004 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
0005 
0006 #include <linux/clk-provider.h>
0007 #include <linux/platform_device.h>
0008 #include <dt-bindings/clock/mt8186-clk.h>
0009 
0010 #include "clk-gate.h"
0011 #include "clk-mtk.h"
0012 
0013 static const struct mtk_gate_regs img_cg_regs = {
0014     .set_ofs = 0x4,
0015     .clr_ofs = 0x8,
0016     .sta_ofs = 0x0,
0017 };
0018 
0019 #define GATE_IMG(_id, _name, _parent, _shift)           \
0020     GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
0021 
0022 static const struct mtk_gate img1_clks[] = {
0023     GATE_IMG(CLK_IMG1_LARB9_IMG1, "img1_larb9_img1", "top_img1", 0),
0024     GATE_IMG(CLK_IMG1_LARB10_IMG1, "img1_larb10_img1", "top_img1", 1),
0025     GATE_IMG(CLK_IMG1_DIP, "img1_dip", "top_img1", 2),
0026     GATE_IMG(CLK_IMG1_GALS_IMG1, "img1_gals_img1", "top_img1", 12),
0027 };
0028 
0029 static const struct mtk_gate img2_clks[] = {
0030     GATE_IMG(CLK_IMG2_LARB9_IMG2, "img2_larb9_img2", "top_img1", 0),
0031     GATE_IMG(CLK_IMG2_LARB10_IMG2, "img2_larb10_img2", "top_img1", 1),
0032     GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "top_img1", 6),
0033     GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "top_img1", 7),
0034     GATE_IMG(CLK_IMG2_MSS, "img2_mss", "top_img1", 8),
0035     GATE_IMG(CLK_IMG2_GALS_IMG2, "img2_gals_img2", "top_img1", 12),
0036 };
0037 
0038 static const struct mtk_clk_desc img1_desc = {
0039     .clks = img1_clks,
0040     .num_clks = ARRAY_SIZE(img1_clks),
0041 };
0042 
0043 static const struct mtk_clk_desc img2_desc = {
0044     .clks = img2_clks,
0045     .num_clks = ARRAY_SIZE(img2_clks),
0046 };
0047 
0048 static const struct of_device_id of_match_clk_mt8186_img[] = {
0049     {
0050         .compatible = "mediatek,mt8186-imgsys1",
0051         .data = &img1_desc,
0052     }, {
0053         .compatible = "mediatek,mt8186-imgsys2",
0054         .data = &img2_desc,
0055     }, {
0056         /* sentinel */
0057     }
0058 };
0059 
0060 static struct platform_driver clk_mt8186_img_drv = {
0061     .probe = mtk_clk_simple_probe,
0062     .remove = mtk_clk_simple_remove,
0063     .driver = {
0064         .name = "clk-mt8186-img",
0065         .of_match_table = of_match_clk_mt8186_img,
0066     },
0067 };
0068 builtin_platform_driver(clk_mt8186_img_drv);