1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright (c) 2021 MediaTek Inc.
4 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
6 #include <linux/clk-provider.h>
7 #include <linux/mod_devicetable.h>
8 #include <linux/platform_device.h>
13 #include <dt-bindings/clock/mt8192-clk.h>
15 static const struct mtk_gate_regs vdec0_cg_regs
= {
21 static const struct mtk_gate_regs vdec1_cg_regs
= {
27 static const struct mtk_gate_regs vdec2_cg_regs
= {
33 #define GATE_VDEC0(_id, _name, _parent, _shift) \
34 GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
36 #define GATE_VDEC1(_id, _name, _parent, _shift) \
37 GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
39 #define GATE_VDEC2(_id, _name, _parent, _shift) \
40 GATE_MTK(_id, _name, _parent, &vdec2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
42 static const struct mtk_gate vdec_clks
[] = {
44 GATE_VDEC0(CLK_VDEC_VDEC
, "vdec_vdec", "vdec_sel", 0),
45 GATE_VDEC0(CLK_VDEC_ACTIVE
, "vdec_active", "vdec_sel", 4),
47 GATE_VDEC1(CLK_VDEC_LAT
, "vdec_lat", "vdec_sel", 0),
48 GATE_VDEC1(CLK_VDEC_LAT_ACTIVE
, "vdec_lat_active", "vdec_sel", 4),
50 GATE_VDEC2(CLK_VDEC_LARB1
, "vdec_larb1", "vdec_sel", 0),
53 static const struct mtk_gate vdec_soc_clks
[] = {
55 GATE_VDEC0(CLK_VDEC_SOC_VDEC
, "vdec_soc_vdec", "vdec_sel", 0),
56 GATE_VDEC0(CLK_VDEC_SOC_VDEC_ACTIVE
, "vdec_soc_vdec_active", "vdec_sel", 4),
58 GATE_VDEC1(CLK_VDEC_SOC_LAT
, "vdec_soc_lat", "vdec_sel", 0),
59 GATE_VDEC1(CLK_VDEC_SOC_LAT_ACTIVE
, "vdec_soc_lat_active", "vdec_sel", 4),
61 GATE_VDEC2(CLK_VDEC_SOC_LARB1
, "vdec_soc_larb1", "vdec_sel", 0),
64 static const struct mtk_clk_desc vdec_desc
= {
66 .num_clks
= ARRAY_SIZE(vdec_clks
),
69 static const struct mtk_clk_desc vdec_soc_desc
= {
70 .clks
= vdec_soc_clks
,
71 .num_clks
= ARRAY_SIZE(vdec_soc_clks
),
74 static const struct of_device_id of_match_clk_mt8192_vdec
[] = {
76 .compatible
= "mediatek,mt8192-vdecsys",
79 .compatible
= "mediatek,mt8192-vdecsys_soc",
80 .data
= &vdec_soc_desc
,
85 MODULE_DEVICE_TABLE(of
, of_match_clk_mt8192_vdec
);
87 static struct platform_driver clk_mt8192_vdec_drv
= {
88 .probe
= mtk_clk_simple_probe
,
89 .remove
= mtk_clk_simple_remove
,
91 .name
= "clk-mt8192-vdec",
92 .of_match_table
= of_match_clk_mt8192_vdec
,
95 module_platform_driver(clk_mt8192_vdec_drv
);
97 MODULE_DESCRIPTION("MediaTek MT8192 Video Decoders clocks driver");
98 MODULE_LICENSE("GPL");