150df7722SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only 250df7722SChun-Jie Chen // 350df7722SChun-Jie Chen // Copyright (c) 2021 MediaTek Inc. 450df7722SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 550df7722SChun-Jie Chen 650df7722SChun-Jie Chen #include "clk-gate.h" 750df7722SChun-Jie Chen #include "clk-mtk.h" 850df7722SChun-Jie Chen 950df7722SChun-Jie Chen #include <dt-bindings/clock/mt8195-clk.h> 1050df7722SChun-Jie Chen #include <linux/clk-provider.h> 1150df7722SChun-Jie Chen #include <linux/platform_device.h> 1250df7722SChun-Jie Chen 1350df7722SChun-Jie Chen static const struct mtk_gate_regs vpp1_0_cg_regs = { 1450df7722SChun-Jie Chen .set_ofs = 0x104, 1550df7722SChun-Jie Chen .clr_ofs = 0x108, 1650df7722SChun-Jie Chen .sta_ofs = 0x100, 1750df7722SChun-Jie Chen }; 1850df7722SChun-Jie Chen 1950df7722SChun-Jie Chen static const struct mtk_gate_regs vpp1_1_cg_regs = { 2050df7722SChun-Jie Chen .set_ofs = 0x114, 2150df7722SChun-Jie Chen .clr_ofs = 0x118, 2250df7722SChun-Jie Chen .sta_ofs = 0x110, 2350df7722SChun-Jie Chen }; 2450df7722SChun-Jie Chen 2550df7722SChun-Jie Chen #define GATE_VPP1_0(_id, _name, _parent, _shift) \ 2650df7722SChun-Jie Chen GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 2750df7722SChun-Jie Chen 2850df7722SChun-Jie Chen #define GATE_VPP1_1(_id, _name, _parent, _shift) \ 2950df7722SChun-Jie Chen GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 3050df7722SChun-Jie Chen 3150df7722SChun-Jie Chen static const struct mtk_gate vpp1_clks[] = { 3250df7722SChun-Jie Chen /* VPP1_0 */ 3350df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0), 3450df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1), 3550df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2), 3650df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3), 3750df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4), 3850df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5), 3950df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6), 4050df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7), 4150df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8), 4250df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9), 4350df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10), 4450df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11), 4550df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12), 4650df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13), 4750df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14), 4850df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15), 4950df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 16), 5050df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 17), 5150df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 18), 5250df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 19), 5350df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 20), 5450df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_VPPSYS1_GALS, "vpp1_vppsys1_gals", "top_vpp", 21), 5550df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 22), 5650df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 23), 5750df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_VPPSYS1_LARB, "vpp1_vppsys1_larb", "top_vpp", 24), 5850df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 25), 5950df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 26), 6050df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 27), 6150df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 28), 6250df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 29), 6350df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_DL_ASYNC, "vpp1_dl_async", "top_vpp", 30), 6450df7722SChun-Jie Chen GATE_VPP1_0(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 31), 6550df7722SChun-Jie Chen /* VPP1_1 */ 6650df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 0), 6750df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 1), 6850df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 2), 6950df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 3), 7050df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 4), 7150df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 5), 7250df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 6), 7350df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7), 7450df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 8), 7550df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 9), 7650df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 10), 7750df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "hdmirx_p", 11), 7850df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "hdmirx_p", 12), 7950df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "in_dgi", 13), 8050df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_dgi_out", 14), 8150df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_dgi_out", 15), 8250df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 16), 8350df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP0_DL_RELAY, "vpp1_vpp0_dl_relay", "top_vpp", 17), 8450df7722SChun-Jie Chen GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26), 8550df7722SChun-Jie Chen }; 8650df7722SChun-Jie Chen 8765c10c50SAngeloGioacchino Del Regno static const struct mtk_clk_desc vpp1_desc = { 8865c10c50SAngeloGioacchino Del Regno .clks = vpp1_clks, 8965c10c50SAngeloGioacchino Del Regno .num_clks = ARRAY_SIZE(vpp1_clks), 9065c10c50SAngeloGioacchino Del Regno }; 91b132c2a8SMoudy Ho 9265c10c50SAngeloGioacchino Del Regno static const struct platform_device_id clk_mt8195_vpp1_id_table[] = { 9365c10c50SAngeloGioacchino Del Regno { .name = "clk-mt8195-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc }, 9465c10c50SAngeloGioacchino Del Regno { /* sentinel */ } 9565c10c50SAngeloGioacchino Del Regno }; 9665c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(platform, clk_mt8195_vpp1_id_table); 9750df7722SChun-Jie Chen 9850df7722SChun-Jie Chen static struct platform_driver clk_mt8195_vpp1_drv = { 9965c10c50SAngeloGioacchino Del Regno .probe = mtk_clk_pdev_probe, 100*b3bc7275SUwe Kleine-König .remove_new = mtk_clk_pdev_remove, 10150df7722SChun-Jie Chen .driver = { 10250df7722SChun-Jie Chen .name = "clk-mt8195-vpp1", 10350df7722SChun-Jie Chen }, 10465c10c50SAngeloGioacchino Del Regno .id_table = clk_mt8195_vpp1_id_table, 10550df7722SChun-Jie Chen }; 106164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8195_vpp1_drv); 107a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL"); 108