162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci//
362306a36Sopenharmony_ci// Copyright (c) 2021 MediaTek Inc.
462306a36Sopenharmony_ci// Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include "clk-gate.h"
762306a36Sopenharmony_ci#include "clk-mtk.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <dt-bindings/clock/mt8195-clk.h>
1062306a36Sopenharmony_ci#include <linux/clk-provider.h>
1162306a36Sopenharmony_ci#include <linux/platform_device.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistatic const struct mtk_gate_regs vpp1_0_cg_regs = {
1462306a36Sopenharmony_ci	.set_ofs = 0x104,
1562306a36Sopenharmony_ci	.clr_ofs = 0x108,
1662306a36Sopenharmony_ci	.sta_ofs = 0x100,
1762306a36Sopenharmony_ci};
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_cistatic const struct mtk_gate_regs vpp1_1_cg_regs = {
2062306a36Sopenharmony_ci	.set_ofs = 0x114,
2162306a36Sopenharmony_ci	.clr_ofs = 0x118,
2262306a36Sopenharmony_ci	.sta_ofs = 0x110,
2362306a36Sopenharmony_ci};
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define GATE_VPP1_0(_id, _name, _parent, _shift)			\
2662306a36Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define GATE_VPP1_1(_id, _name, _parent, _shift)			\
2962306a36Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cistatic const struct mtk_gate vpp1_clks[] = {
3262306a36Sopenharmony_ci	/* VPP1_0 */
3362306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0),
3462306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1),
3562306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2),
3662306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3),
3762306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4),
3862306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5),
3962306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6),
4062306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7),
4162306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8),
4262306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9),
4362306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10),
4462306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11),
4562306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12),
4662306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13),
4762306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14),
4862306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15),
4962306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 16),
5062306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 17),
5162306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 18),
5262306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 19),
5362306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 20),
5462306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_VPPSYS1_GALS, "vpp1_vppsys1_gals", "top_vpp", 21),
5562306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 22),
5662306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 23),
5762306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_VPPSYS1_LARB, "vpp1_vppsys1_larb", "top_vpp", 24),
5862306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 25),
5962306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 26),
6062306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 27),
6162306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 28),
6262306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 29),
6362306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_DL_ASYNC, "vpp1_dl_async", "top_vpp", 30),
6462306a36Sopenharmony_ci	GATE_VPP1_0(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 31),
6562306a36Sopenharmony_ci	/* VPP1_1 */
6662306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 0),
6762306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 1),
6862306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 2),
6962306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 3),
7062306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 4),
7162306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 5),
7262306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 6),
7362306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7),
7462306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 8),
7562306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 9),
7662306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 10),
7762306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "hdmirx_p", 11),
7862306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "hdmirx_p", 12),
7962306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "in_dgi", 13),
8062306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_dgi_out", 14),
8162306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_dgi_out", 15),
8262306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 16),
8362306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP0_DL_RELAY, "vpp1_vpp0_dl_relay", "top_vpp", 17),
8462306a36Sopenharmony_ci	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26),
8562306a36Sopenharmony_ci};
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cistatic const struct mtk_clk_desc vpp1_desc = {
8862306a36Sopenharmony_ci	.clks = vpp1_clks,
8962306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(vpp1_clks),
9062306a36Sopenharmony_ci};
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cistatic const struct platform_device_id clk_mt8195_vpp1_id_table[] = {
9362306a36Sopenharmony_ci	{ .name = "clk-mt8195-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc },
9462306a36Sopenharmony_ci	{ /* sentinel */ }
9562306a36Sopenharmony_ci};
9662306a36Sopenharmony_ciMODULE_DEVICE_TABLE(platform, clk_mt8195_vpp1_id_table);
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cistatic struct platform_driver clk_mt8195_vpp1_drv = {
9962306a36Sopenharmony_ci	.probe = mtk_clk_pdev_probe,
10062306a36Sopenharmony_ci	.remove_new = mtk_clk_pdev_remove,
10162306a36Sopenharmony_ci	.driver = {
10262306a36Sopenharmony_ci		.name = "clk-mt8195-vpp1",
10362306a36Sopenharmony_ci	},
10462306a36Sopenharmony_ci	.id_table = clk_mt8195_vpp1_id_table,
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_cimodule_platform_driver(clk_mt8195_vpp1_drv);
10762306a36Sopenharmony_ciMODULE_LICENSE("GPL");
108