xref: /linux/drivers/clk/mediatek/clk-mt8192-mdp.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1b565d41fSChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only
2b565d41fSChun-Jie Chen //
3b565d41fSChun-Jie Chen // Copyright (c) 2021 MediaTek Inc.
4b565d41fSChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
5b565d41fSChun-Jie Chen 
6b565d41fSChun-Jie Chen #include <linux/clk-provider.h>
7a96cbb14SRob Herring #include <linux/mod_devicetable.h>
8b565d41fSChun-Jie Chen #include <linux/platform_device.h>
9b565d41fSChun-Jie Chen 
10b565d41fSChun-Jie Chen #include "clk-mtk.h"
11b565d41fSChun-Jie Chen #include "clk-gate.h"
12b565d41fSChun-Jie Chen 
13b565d41fSChun-Jie Chen #include <dt-bindings/clock/mt8192-clk.h>
14b565d41fSChun-Jie Chen 
15b565d41fSChun-Jie Chen static const struct mtk_gate_regs mdp0_cg_regs = {
16b565d41fSChun-Jie Chen 	.set_ofs = 0x104,
17b565d41fSChun-Jie Chen 	.clr_ofs = 0x108,
18b565d41fSChun-Jie Chen 	.sta_ofs = 0x100,
19b565d41fSChun-Jie Chen };
20b565d41fSChun-Jie Chen 
21b565d41fSChun-Jie Chen static const struct mtk_gate_regs mdp1_cg_regs = {
22b565d41fSChun-Jie Chen 	.set_ofs = 0x124,
23b565d41fSChun-Jie Chen 	.clr_ofs = 0x128,
24b565d41fSChun-Jie Chen 	.sta_ofs = 0x120,
25b565d41fSChun-Jie Chen };
26b565d41fSChun-Jie Chen 
27b565d41fSChun-Jie Chen #define GATE_MDP0(_id, _name, _parent, _shift)	\
28b565d41fSChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &mdp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
29b565d41fSChun-Jie Chen 
30b565d41fSChun-Jie Chen #define GATE_MDP1(_id, _name, _parent, _shift)	\
31b565d41fSChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &mdp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
32b565d41fSChun-Jie Chen 
33b565d41fSChun-Jie Chen static const struct mtk_gate mdp_clks[] = {
34b565d41fSChun-Jie Chen 	/* MDP0 */
35b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_RDMA0, "mdp_mdp_rdma0", "mdp_sel", 0),
36b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_TDSHP0, "mdp_mdp_tdshp0", "mdp_sel", 1),
37b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_IMG_DL_ASYNC0, "mdp_img_dl_async0", "mdp_sel", 2),
38b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_IMG_DL_ASYNC1, "mdp_img_dl_async1", "mdp_sel", 3),
39b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_RDMA1, "mdp_mdp_rdma1", "mdp_sel", 4),
40b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_TDSHP1, "mdp_mdp_tdshp1", "mdp_sel", 5),
41b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_SMI0, "mdp_smi0", "mdp_sel", 6),
42b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_APB_BUS, "mdp_apb_bus", "mdp_sel", 7),
43b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_WROT0, "mdp_mdp_wrot0", "mdp_sel", 8),
44b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_RSZ0, "mdp_mdp_rsz0", "mdp_sel", 9),
45b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_HDR0, "mdp_mdp_hdr0", "mdp_sel", 10),
46b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_MUTEX0, "mdp_mdp_mutex0", "mdp_sel", 11),
47b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_WROT1, "mdp_mdp_wrot1", "mdp_sel", 12),
48b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_RSZ1, "mdp_mdp_rsz1", "mdp_sel", 13),
49b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_HDR1, "mdp_mdp_hdr1", "mdp_sel", 14),
50b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_FAKE_ENG0, "mdp_mdp_fake_eng0", "mdp_sel", 15),
51b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_AAL0, "mdp_mdp_aal0", "mdp_sel", 16),
52b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_AAL1, "mdp_mdp_aal1", "mdp_sel", 17),
53b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_COLOR0, "mdp_mdp_color0", "mdp_sel", 18),
54b565d41fSChun-Jie Chen 	GATE_MDP0(CLK_MDP_COLOR1, "mdp_mdp_color1", "mdp_sel", 19),
55b565d41fSChun-Jie Chen 	/* MDP1 */
56b565d41fSChun-Jie Chen 	GATE_MDP1(CLK_MDP_IMG_DL_RELAY0_ASYNC0, "mdp_img_dl_relay0_async0", "mdp_sel", 0),
57b565d41fSChun-Jie Chen 	GATE_MDP1(CLK_MDP_IMG_DL_RELAY1_ASYNC1, "mdp_img_dl_relay1_async1", "mdp_sel", 8),
58b565d41fSChun-Jie Chen };
59b565d41fSChun-Jie Chen 
60b565d41fSChun-Jie Chen static const struct mtk_clk_desc mdp_desc = {
61b565d41fSChun-Jie Chen 	.clks = mdp_clks,
62b565d41fSChun-Jie Chen 	.num_clks = ARRAY_SIZE(mdp_clks),
63b565d41fSChun-Jie Chen };
64b565d41fSChun-Jie Chen 
65b565d41fSChun-Jie Chen static const struct of_device_id of_match_clk_mt8192_mdp[] = {
66b565d41fSChun-Jie Chen 	{
67b565d41fSChun-Jie Chen 		.compatible = "mediatek,mt8192-mdpsys",
68b565d41fSChun-Jie Chen 		.data = &mdp_desc,
69b565d41fSChun-Jie Chen 	}, {
70b565d41fSChun-Jie Chen 		/* sentinel */
71b565d41fSChun-Jie Chen 	}
72b565d41fSChun-Jie Chen };
7365c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_mdp);
74b565d41fSChun-Jie Chen 
75b565d41fSChun-Jie Chen static struct platform_driver clk_mt8192_mdp_drv = {
76b565d41fSChun-Jie Chen 	.probe = mtk_clk_simple_probe,
77*f00b45dbSUwe Kleine-König 	.remove = mtk_clk_simple_remove,
78b565d41fSChun-Jie Chen 	.driver = {
79b565d41fSChun-Jie Chen 		.name = "clk-mt8192-mdp",
80b565d41fSChun-Jie Chen 		.of_match_table = of_match_clk_mt8192_mdp,
81b565d41fSChun-Jie Chen 	},
82b565d41fSChun-Jie Chen };
83164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8192_mdp_drv);
84f5100c41SAngeloGioacchino Del Regno 
85f5100c41SAngeloGioacchino Del Regno MODULE_DESCRIPTION("MediaTek MT8192 Multimedia Data Path clocks driver");
86a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL");
87