xref: /linux/drivers/clk/mediatek/clk-mt8195-venc.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1 // SPDX-License-Identifier: GPL-2.0-only
2 //
3 // Copyright (c) 2021 MediaTek Inc.
4 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
5 
6 #include "clk-gate.h"
7 #include "clk-mtk.h"
8 
9 #include <dt-bindings/clock/mt8195-clk.h>
10 #include <linux/clk-provider.h>
11 #include <linux/platform_device.h>
12 
13 static const struct mtk_gate_regs venc_cg_regs = {
14 	.set_ofs = 0x4,
15 	.clr_ofs = 0x8,
16 	.sta_ofs = 0x0,
17 };
18 
19 #define GATE_VENC(_id, _name, _parent, _shift)			\
20 	GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
21 
22 static const struct mtk_gate venc_clks[] = {
23 	GATE_VENC(CLK_VENC_LARB, "venc_larb", "top_venc", 0),
24 	GATE_VENC(CLK_VENC_VENC, "venc_venc", "top_venc", 4),
25 	GATE_VENC(CLK_VENC_JPGENC, "venc_jpgenc", "top_venc", 8),
26 	GATE_VENC(CLK_VENC_JPGDEC, "venc_jpgdec", "top_venc", 12),
27 	GATE_VENC(CLK_VENC_JPGDEC_C1, "venc_jpgdec_c1", "top_venc", 16),
28 	GATE_VENC(CLK_VENC_GALS, "venc_gals", "top_venc", 28),
29 };
30 
31 static const struct mtk_gate venc_core1_clks[] = {
32 	GATE_VENC(CLK_VENC_CORE1_LARB, "venc_core1_larb", "top_venc", 0),
33 	GATE_VENC(CLK_VENC_CORE1_VENC, "venc_core1_venc", "top_venc", 4),
34 	GATE_VENC(CLK_VENC_CORE1_JPGENC, "venc_core1_jpgenc", "top_venc", 8),
35 	GATE_VENC(CLK_VENC_CORE1_JPGDEC, "venc_core1_jpgdec", "top_venc", 12),
36 	GATE_VENC(CLK_VENC_CORE1_JPGDEC_C1, "venc_core1_jpgdec_c1", "top_venc", 16),
37 	GATE_VENC(CLK_VENC_CORE1_GALS, "venc_core1_gals", "top_venc", 28),
38 };
39 
40 static const struct mtk_clk_desc venc_desc = {
41 	.clks = venc_clks,
42 	.num_clks = ARRAY_SIZE(venc_clks),
43 };
44 
45 static const struct mtk_clk_desc venc_core1_desc = {
46 	.clks = venc_core1_clks,
47 	.num_clks = ARRAY_SIZE(venc_core1_clks),
48 };
49 
50 static const struct of_device_id of_match_clk_mt8195_venc[] = {
51 	{
52 		.compatible = "mediatek,mt8195-vencsys",
53 		.data = &venc_desc,
54 	}, {
55 		.compatible = "mediatek,mt8195-vencsys_core1",
56 		.data = &venc_core1_desc,
57 	}, {
58 		/* sentinel */
59 	}
60 };
61 MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_venc);
62 
63 static struct platform_driver clk_mt8195_venc_drv = {
64 	.probe = mtk_clk_simple_probe,
65 	.remove = mtk_clk_simple_remove,
66 	.driver = {
67 		.name = "clk-mt8195-venc",
68 		.of_match_table = of_match_clk_mt8195_venc,
69 	},
70 };
71 module_platform_driver(clk_mt8195_venc_drv);
72 
73 MODULE_DESCRIPTION("MediaTek MT8195 Video Encoders clocks driver");
74 MODULE_LICENSE("GPL");
75