1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2022 MediaTek Inc.
4 * Author: Garmin Chang <garmin.chang@mediatek.com>
7 #include <dt-bindings/clock/mediatek,mt8188-clk.h>
8 #include <linux/clk-provider.h>
9 #include <linux/platform_device.h>
14 static const struct mtk_gate_regs vdec0_cg_regs
= {
20 static const struct mtk_gate_regs vdec1_cg_regs
= {
26 static const struct mtk_gate_regs vdec2_cg_regs
= {
32 #define GATE_VDEC0(_id, _name, _parent, _shift) \
33 GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
35 #define GATE_VDEC1(_id, _name, _parent, _shift) \
36 GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
38 #define GATE_VDEC2(_id, _name, _parent, _shift) \
39 GATE_MTK(_id, _name, _parent, &vdec2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
41 static const struct mtk_gate vdec1_clks
[] = {
43 GATE_VDEC0(CLK_VDEC1_SOC_VDEC
, "vdec1_soc_vdec", "top_vdec", 0),
44 GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ACTIVE
, "vdec1_soc_vdec_active", "top_vdec", 4),
45 GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ENG
, "vdec1_soc_vdec_eng", "top_vdec", 8),
47 GATE_VDEC1(CLK_VDEC1_SOC_LAT
, "vdec1_soc_lat", "top_vdec", 0),
48 GATE_VDEC1(CLK_VDEC1_SOC_LAT_ACTIVE
, "vdec1_soc_lat_active", "top_vdec", 4),
49 GATE_VDEC1(CLK_VDEC1_SOC_LAT_ENG
, "vdec1_soc_lat_eng", "top_vdec", 8),
51 GATE_VDEC2(CLK_VDEC1_SOC_LARB1
, "vdec1_soc_larb1", "top_vdec", 0),
54 static const struct mtk_gate vdec2_clks
[] = {
56 GATE_VDEC0(CLK_VDEC2_VDEC
, "vdec2_vdec", "top_vdec", 0),
57 GATE_VDEC0(CLK_VDEC2_VDEC_ACTIVE
, "vdec2_vdec_active", "top_vdec", 4),
58 GATE_VDEC0(CLK_VDEC2_VDEC_ENG
, "vdec2_vdec_eng", "top_vdec", 8),
60 GATE_VDEC1(CLK_VDEC2_LAT
, "vdec2_lat", "top_vdec", 0),
62 GATE_VDEC2(CLK_VDEC2_LARB1
, "vdec2_larb1", "top_vdec", 0),
65 static const struct mtk_clk_desc vdec1_desc
= {
67 .num_clks
= ARRAY_SIZE(vdec1_clks
),
70 static const struct mtk_clk_desc vdec2_desc
= {
72 .num_clks
= ARRAY_SIZE(vdec2_clks
),
75 static const struct of_device_id of_match_clk_mt8188_vdec
[] = {
76 { .compatible
= "mediatek,mt8188-vdecsys-soc", .data
= &vdec1_desc
},
77 { .compatible
= "mediatek,mt8188-vdecsys", .data
= &vdec2_desc
},
80 MODULE_DEVICE_TABLE(of
, of_match_clk_mt8188_vdec
);
82 static struct platform_driver clk_mt8188_vdec_drv
= {
83 .probe
= mtk_clk_simple_probe
,
84 .remove
= mtk_clk_simple_remove
,
86 .name
= "clk-mt8188-vdec",
87 .of_match_table
= of_match_clk_mt8188_vdec
,
91 module_platform_driver(clk_mt8188_vdec_drv
);
93 MODULE_DESCRIPTION("MediaTek MT8188 Video Decoders clocks driver");
94 MODULE_LICENSE("GPL");