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 img_cg_regs
= {
19 #define GATE_IMG(_id, _name, _parent, _shift) \
20 GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
22 static const struct mtk_gate img_clks
[] = {
23 GATE_IMG(CLK_IMG_LARB9
, "img_larb9", "top_img", 0),
24 GATE_IMG(CLK_IMG_TRAW0
, "img_traw0", "top_img", 1),
25 GATE_IMG(CLK_IMG_TRAW1
, "img_traw1", "top_img", 2),
26 GATE_IMG(CLK_IMG_TRAW2
, "img_traw2", "top_img", 3),
27 GATE_IMG(CLK_IMG_TRAW3
, "img_traw3", "top_img", 4),
28 GATE_IMG(CLK_IMG_DIP0
, "img_dip0", "top_img", 8),
29 GATE_IMG(CLK_IMG_WPE0
, "img_wpe0", "top_img", 9),
30 GATE_IMG(CLK_IMG_IPE
, "img_ipe", "top_img", 10),
31 GATE_IMG(CLK_IMG_DIP1
, "img_dip1", "top_img", 11),
32 GATE_IMG(CLK_IMG_WPE1
, "img_wpe1", "top_img", 12),
33 GATE_IMG(CLK_IMG_GALS
, "img_gals", "top_img", 31),
36 static const struct mtk_gate img1_dip_top_clks
[] = {
37 GATE_IMG(CLK_IMG1_DIP_TOP_LARB10
, "img1_dip_top_larb10", "top_img", 0),
38 GATE_IMG(CLK_IMG1_DIP_TOP_DIP_TOP
, "img1_dip_top_dip_top", "top_img", 1),
41 static const struct mtk_gate img1_dip_nr_clks
[] = {
42 GATE_IMG(CLK_IMG1_DIP_NR_RESERVE
, "img1_dip_nr_reserve", "top_img", 0),
43 GATE_IMG(CLK_IMG1_DIP_NR_DIP_NR
, "img1_dip_nr_dip_nr", "top_img", 1),
46 static const struct mtk_gate img1_wpe_clks
[] = {
47 GATE_IMG(CLK_IMG1_WPE_LARB11
, "img1_wpe_larb11", "top_img", 0),
48 GATE_IMG(CLK_IMG1_WPE_WPE
, "img1_wpe_wpe", "top_img", 1),
51 static const struct mtk_clk_desc img_desc
= {
53 .num_clks
= ARRAY_SIZE(img_clks
),
56 static const struct mtk_clk_desc img1_dip_top_desc
= {
57 .clks
= img1_dip_top_clks
,
58 .num_clks
= ARRAY_SIZE(img1_dip_top_clks
),
61 static const struct mtk_clk_desc img1_dip_nr_desc
= {
62 .clks
= img1_dip_nr_clks
,
63 .num_clks
= ARRAY_SIZE(img1_dip_nr_clks
),
66 static const struct mtk_clk_desc img1_wpe_desc
= {
67 .clks
= img1_wpe_clks
,
68 .num_clks
= ARRAY_SIZE(img1_wpe_clks
),
71 static const struct of_device_id of_match_clk_mt8195_img
[] = {
73 .compatible
= "mediatek,mt8195-imgsys",
76 .compatible
= "mediatek,mt8195-imgsys1_dip_top",
77 .data
= &img1_dip_top_desc
,
79 .compatible
= "mediatek,mt8195-imgsys1_dip_nr",
80 .data
= &img1_dip_nr_desc
,
82 .compatible
= "mediatek,mt8195-imgsys1_wpe",
83 .data
= &img1_wpe_desc
,
88 MODULE_DEVICE_TABLE(of
, of_match_clk_mt8195_img
);
90 static struct platform_driver clk_mt8195_img_drv
= {
91 .probe
= mtk_clk_simple_probe
,
92 .remove
= mtk_clk_simple_remove
,
94 .name
= "clk-mt8195-img",
95 .of_match_table
= of_match_clk_mt8195_img
,
98 module_platform_driver(clk_mt8195_img_drv
);
100 MODULE_DESCRIPTION("MediaTek MT8195 imgsys clocks driver");
101 MODULE_LICENSE("GPL");