1*4898e77fSGarmin.Chang // SPDX-License-Identifier: GPL-2.0-only 2*4898e77fSGarmin.Chang /* 3*4898e77fSGarmin.Chang * Copyright (c) 2022 MediaTek Inc. 4*4898e77fSGarmin.Chang * Author: Garmin Chang <garmin.chang@mediatek.com> 5*4898e77fSGarmin.Chang */ 6*4898e77fSGarmin.Chang 7*4898e77fSGarmin.Chang #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8*4898e77fSGarmin.Chang #include <linux/clk-provider.h> 9*4898e77fSGarmin.Chang #include <linux/platform_device.h> 10*4898e77fSGarmin.Chang 11*4898e77fSGarmin.Chang #include "clk-gate.h" 12*4898e77fSGarmin.Chang #include "clk-mtk.h" 13*4898e77fSGarmin.Chang 14*4898e77fSGarmin.Chang static const struct mtk_gate_regs vpp1_0_cg_regs = { 15*4898e77fSGarmin.Chang .set_ofs = 0x104, 16*4898e77fSGarmin.Chang .clr_ofs = 0x108, 17*4898e77fSGarmin.Chang .sta_ofs = 0x100, 18*4898e77fSGarmin.Chang }; 19*4898e77fSGarmin.Chang 20*4898e77fSGarmin.Chang static const struct mtk_gate_regs vpp1_1_cg_regs = { 21*4898e77fSGarmin.Chang .set_ofs = 0x114, 22*4898e77fSGarmin.Chang .clr_ofs = 0x118, 23*4898e77fSGarmin.Chang .sta_ofs = 0x110, 24*4898e77fSGarmin.Chang }; 25*4898e77fSGarmin.Chang 26*4898e77fSGarmin.Chang #define GATE_VPP1_0(_id, _name, _parent, _shift) \ 27*4898e77fSGarmin.Chang GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 28*4898e77fSGarmin.Chang 29*4898e77fSGarmin.Chang #define GATE_VPP1_1(_id, _name, _parent, _shift) \ 30*4898e77fSGarmin.Chang GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 31*4898e77fSGarmin.Chang 32*4898e77fSGarmin.Chang static const struct mtk_gate vpp1_clks[] = { 33*4898e77fSGarmin.Chang /* VPP1_0 */ 34*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0), 35*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1), 36*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2), 37*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3), 38*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4), 39*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5), 40*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6), 41*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7), 42*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8), 43*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9), 44*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10), 45*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11), 46*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12), 47*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13), 48*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14), 49*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15), 50*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 16), 51*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 17), 52*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 18), 53*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19), 54*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 20), 55*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 21), 56*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 22), 57*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 23), 58*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 24), 59*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 25), 60*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 26), 61*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 27), 62*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28), 63*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29), 64*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30), 65*4898e77fSGarmin.Chang GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31), 66*4898e77fSGarmin.Chang /* VPP1_1 */ 67*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 0), 68*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 1), 69*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 2), 70*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 3), 71*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 4), 72*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 5), 73*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7), 74*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8), 75*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9), 76*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 10), 77*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 11), 78*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 12), 79*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 13), 80*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "top_vpp", 16), 81*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "top_vpp", 17), 82*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18), 83*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp", 19), 84*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_vpp", 20), 85*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ", "top_vpp", 21), 86*4898e77fSGarmin.Chang GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "top_vpp", 26), 87*4898e77fSGarmin.Chang }; 88*4898e77fSGarmin.Chang 89*4898e77fSGarmin.Chang static const struct mtk_clk_desc vpp1_desc = { 90*4898e77fSGarmin.Chang .clks = vpp1_clks, 91*4898e77fSGarmin.Chang .num_clks = ARRAY_SIZE(vpp1_clks), 92*4898e77fSGarmin.Chang }; 93*4898e77fSGarmin.Chang 94*4898e77fSGarmin.Chang static const struct platform_device_id clk_mt8188_vpp1_id_table[] = { 95*4898e77fSGarmin.Chang { .name = "clk-mt8188-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc }, 96*4898e77fSGarmin.Chang { /* sentinel */ } 97*4898e77fSGarmin.Chang }; 98*4898e77fSGarmin.Chang MODULE_DEVICE_TABLE(platform, clk_mt8188_vpp1_id_table); 99*4898e77fSGarmin.Chang 100*4898e77fSGarmin.Chang static struct platform_driver clk_mt8188_vpp1_drv = { 101*4898e77fSGarmin.Chang .probe = mtk_clk_pdev_probe, 102*4898e77fSGarmin.Chang .remove_new = mtk_clk_pdev_remove, 103*4898e77fSGarmin.Chang .driver = { 104*4898e77fSGarmin.Chang .name = "clk-mt8188-vpp1", 105*4898e77fSGarmin.Chang }, 106*4898e77fSGarmin.Chang .id_table = clk_mt8188_vpp1_id_table, 107*4898e77fSGarmin.Chang }; 108*4898e77fSGarmin.Chang module_platform_driver(clk_mt8188_vpp1_drv); 109*4898e77fSGarmin.Chang MODULE_LICENSE("GPL"); 110