// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2022 MediaTek Inc. * Author: Chong-ming Wei */ #include #include #include #include #include "clk-mtk.h" #include "clk-gate.h" #include #define MT_CCF_BRINGUP 1 /* Regular Number Definition */ #define INV_OFS -1 #define INV_BIT -1 static const struct mtk_gate_regs dip_nr1_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_DIP_NR1_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &dip_nr1_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate dip_nr1_dip1_clks[] = { GATE_DIP_NR1_DIP1(CLK_DIP_NR1_DIP1_LARB, "dip_nr1_dip1_larb", "img1_ck"/* parent */, 0), GATE_DIP_NR1_DIP1(CLK_DIP_NR1_DIP1_DIP_NR1, "dip_nr1_dip1_dip_nr1", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc dip_nr1_dip1_mcd = { .clks = dip_nr1_dip1_clks, .num_clks = CLK_DIP_NR1_DIP1_NR_CLK, }; static const struct mtk_gate_regs dip_nr2_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_DIP_NR2_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &dip_nr2_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate dip_nr2_dip1_clks[] = { GATE_DIP_NR2_DIP1(CLK_DIP_NR2_DIP1_LARB15, "dip_nr2_dip1_larb15", "img1_ck"/* parent */, 0), GATE_DIP_NR2_DIP1(CLK_DIP_NR2_DIP1_DIP_NR, "dip_nr2_dip1_dip_nr", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc dip_nr2_dip1_mcd = { .clks = dip_nr2_dip1_clks, .num_clks = CLK_DIP_NR2_DIP1_NR_CLK, }; static const struct mtk_gate_regs dip_top_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_DIP_TOP_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &dip_top_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate dip_top_dip1_clks[] = { GATE_DIP_TOP_DIP1(CLK_DIP_TOP_DIP1_LARB10, "dip_dip1_larb10", "img1_ck"/* parent */, 0), GATE_DIP_TOP_DIP1(CLK_DIP_TOP_DIP1_DIP_TOP, "dip_dip1_dip_top", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc dip_top_dip1_mcd = { .clks = dip_top_dip1_clks, .num_clks = CLK_DIP_TOP_DIP1_NR_CLK, }; static const struct mtk_gate_regs img0_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; static const struct mtk_gate_regs img1_cg_regs = { .set_ofs = 0x54, .clr_ofs = 0x58, .sta_ofs = 0x50, }; #define GATE_IMG0(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &img0_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } #define GATE_IMG1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &img1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate img_clks[] = { /* IMG0 */ GATE_IMG0(CLK_IMG_LARB9, "img_larb9", "img1_ck"/* parent */, 0), GATE_IMG0(CLK_IMG_TRAW0, "img_traw0", "img1_ck"/* parent */, 1), GATE_IMG0(CLK_IMG_TRAW1, "img_traw1", "img1_ck"/* parent */, 2), GATE_IMG0(CLK_IMG_VCORE_GALS, "img_vcore_gals", "img1_ck"/* parent */, 3), GATE_IMG0(CLK_IMG_DIP0, "img_dip0", "img1_ck"/* parent */, 8), GATE_IMG0(CLK_IMG_WPE0, "img_wpe0", "img1_ck"/* parent */, 9), GATE_IMG0(CLK_IMG_IPE, "img_ipe", "img1_ck"/* parent */, 10), GATE_IMG0(CLK_IMG_WPE1, "img_wpe1", "img1_ck"/* parent */, 12), GATE_IMG0(CLK_IMG_WPE2, "img_wpe2", "img1_ck"/* parent */, 13), GATE_IMG0(CLK_IMG_AVS, "img_avs", "imgavs_ck"/* parent */, 17), GATE_IMG0(CLK_IMG_GALS, "img_gals", "img1_ck"/* parent */, 31), /* IMG1 */ GATE_IMG1(CLK_IMG_FDVT, "img_fdvt", "ipe_ck"/* parent */, 0), GATE_IMG1(CLK_IMG_ME, "img_me", "ipe_ck"/* parent */, 1), GATE_IMG1(CLK_IMG_MMG, "img_mmg", "ipe_ck"/* parent */, 2), GATE_IMG1(CLK_IMG_LARB12, "img_larb12", "ipe_ck"/* parent */, 3), }; static const struct mtk_clk_desc img_mcd = { .clks = img_clks, .num_clks = CLK_IMG_NR_CLK, }; static const struct mtk_gate_regs traw_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_TRAW_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &traw_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate traw_dip1_clks[] = { GATE_TRAW_DIP1(CLK_TRAW_DIP1_LARB28, "traw_dip1_larb28", "img1_ck"/* parent */, 0), GATE_TRAW_DIP1(CLK_TRAW_DIP1_TRAW, "traw_dip1_traw", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc traw_dip1_mcd = { .clks = traw_dip1_clks, .num_clks = CLK_TRAW_DIP1_NR_CLK, }; static const struct mtk_gate_regs wpe1_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_WPE1_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &wpe1_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate wpe1_dip1_clks[] = { GATE_WPE1_DIP1(CLK_WPE1_DIP1_LARB11, "wpe1_dip1_larb11", "img1_ck"/* parent */, 0), GATE_WPE1_DIP1(CLK_WPE1_DIP1_WPE, "wpe1_dip1_wpe", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc wpe1_dip1_mcd = { .clks = wpe1_dip1_clks, .num_clks = CLK_WPE1_DIP1_NR_CLK, }; static const struct mtk_gate_regs wpe2_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_WPE2_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &wpe2_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate wpe2_dip1_clks[] = { GATE_WPE2_DIP1(CLK_WPE2_DIP1_LARB11, "wpe2_dip1_larb11", "img1_ck"/* parent */, 0), GATE_WPE2_DIP1(CLK_WPE2_DIP1_WPE, "wpe2_dip1_wpe", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc wpe2_dip1_mcd = { .clks = wpe2_dip1_clks, .num_clks = CLK_WPE2_DIP1_NR_CLK, }; static const struct mtk_gate_regs wpe3_dip1_cg_regs = { .set_ofs = 0x4, .clr_ofs = 0x8, .sta_ofs = 0x0, }; #define GATE_WPE3_DIP1(_id, _name, _parent, _shift) { \ .id = _id, \ .name = _name, \ .parent_name = _parent, \ .regs = &wpe3_dip1_cg_regs, \ .shift = _shift, \ .ops = &mtk_clk_gate_ops_setclr, \ } static const struct mtk_gate wpe3_dip1_clks[] = { GATE_WPE3_DIP1(CLK_WPE3_DIP1_LARB11, "wpe3_dip1_larb11", "img1_ck"/* parent */, 0), GATE_WPE3_DIP1(CLK_WPE3_DIP1_WPE, "wpe3_dip1_wpe", "img1_ck"/* parent */, 1), }; static const struct mtk_clk_desc wpe3_dip1_mcd = { .clks = wpe3_dip1_clks, .num_clks = CLK_WPE3_DIP1_NR_CLK, }; static const struct of_device_id of_match_clk_mt6886_img[] = { { .compatible = "mediatek,mt6886-dip_nr1_dip1", .data = &dip_nr1_dip1_mcd, }, { .compatible = "mediatek,mt6886-dip_nr2_dip1", .data = &dip_nr2_dip1_mcd, }, { .compatible = "mediatek,mt6886-dip_top_dip1", .data = &dip_top_dip1_mcd, }, { .compatible = "mediatek,mt6886-imgsys_main", .data = &img_mcd, }, { .compatible = "mediatek,mt6886-traw_dip1", .data = &traw_dip1_mcd, }, { .compatible = "mediatek,mt6886-wpe1_dip1", .data = &wpe1_dip1_mcd, }, { .compatible = "mediatek,mt6886-wpe2_dip1", .data = &wpe2_dip1_mcd, }, { .compatible = "mediatek,mt6886-wpe3_dip1", .data = &wpe3_dip1_mcd, }, { /* sentinel */ } }; static int clk_mt6886_img_grp_probe(struct platform_device *pdev) { int r; #if MT_CCF_BRINGUP pr_notice("%s: %s init begin\n", __func__, pdev->name); #endif r = mtk_clk_simple_probe(pdev); if (r) dev_err(&pdev->dev, "could not register clock provider: %s: %d\n", pdev->name, r); #if MT_CCF_BRINGUP pr_notice("%s: %s init end\n", __func__, pdev->name); #endif return r; } static struct platform_driver clk_mt6886_img_drv = { .probe = clk_mt6886_img_grp_probe, .driver = { .name = "clk-mt6886-img", .of_match_table = of_match_clk_mt6886_img, }, }; module_platform_driver(clk_mt6886_img_drv); MODULE_LICENSE("GPL");