1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright (c) 2021 MediaTek Inc.
4 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
9 #include <dt-bindings/clock/mt8195-clk.h>
10 #include <linux/clk-provider.h>
11 #include <linux/platform_device.h>
13 static const struct mtk_gate_regs vdec0_cg_regs
= {
19 static const struct mtk_gate_regs vdec1_cg_regs
= {
25 static const struct mtk_gate_regs vdec2_cg_regs
= {
31 #define GATE_VDEC0(_id, _name, _parent, _shift) \
32 GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
34 #define GATE_VDEC1(_id, _name, _parent, _shift) \
35 GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
37 #define GATE_VDEC2(_id, _name, _parent, _shift) \
38 GATE_MTK(_id, _name, _parent, &vdec2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
40 static const struct mtk_gate vdec_clks
[] = {
42 GATE_VDEC0(CLK_VDEC_VDEC
, "vdec_vdec", "top_vdec", 0),
44 GATE_VDEC1(CLK_VDEC_LAT
, "vdec_lat", "top_vdec", 0),
46 GATE_VDEC2(CLK_VDEC_LARB1
, "vdec_larb1", "top_vdec", 0),
49 static const struct mtk_gate vdec_core1_clks
[] = {
51 GATE_VDEC0(CLK_VDEC_CORE1_VDEC
, "vdec_core1_vdec", "top_vdec", 0),
53 GATE_VDEC1(CLK_VDEC_CORE1_LAT
, "vdec_core1_lat", "top_vdec", 0),
55 GATE_VDEC2(CLK_VDEC_CORE1_LARB1
, "vdec_core1_larb1", "top_vdec", 0),
58 static const struct mtk_gate vdec_soc_clks
[] = {
60 GATE_VDEC0(CLK_VDEC_SOC_VDEC
, "vdec_soc_vdec", "top_vdec", 0),
62 GATE_VDEC1(CLK_VDEC_SOC_LAT
, "vdec_soc_lat", "top_vdec", 0),
64 GATE_VDEC2(CLK_VDEC_SOC_LARB1
, "vdec_soc_larb1", "top_vdec", 0),
67 static const struct mtk_clk_desc vdec_desc
= {
69 .num_clks
= ARRAY_SIZE(vdec_clks
),
72 static const struct mtk_clk_desc vdec_core1_desc
= {
73 .clks
= vdec_core1_clks
,
74 .num_clks
= ARRAY_SIZE(vdec_core1_clks
),
77 static const struct mtk_clk_desc vdec_soc_desc
= {
78 .clks
= vdec_soc_clks
,
79 .num_clks
= ARRAY_SIZE(vdec_soc_clks
),
82 static const struct of_device_id of_match_clk_mt8195_vdec
[] = {
84 .compatible
= "mediatek,mt8195-vdecsys",
87 .compatible
= "mediatek,mt8195-vdecsys_core1",
88 .data
= &vdec_core1_desc
,
90 .compatible
= "mediatek,mt8195-vdecsys_soc",
91 .data
= &vdec_soc_desc
,
96 MODULE_DEVICE_TABLE(of
, of_match_clk_mt8195_vdec
);
98 static struct platform_driver clk_mt8195_vdec_drv
= {
99 .probe
= mtk_clk_simple_probe
,
100 .remove
= mtk_clk_simple_remove
,
102 .name
= "clk-mt8195-vdec",
103 .of_match_table
= of_match_clk_mt8195_vdec
,
106 module_platform_driver(clk_mt8195_vdec_drv
);
108 MODULE_DESCRIPTION("MediaTek MT8195 Video Decoders clocks driver");
109 MODULE_LICENSE("GPL");