1710774e0Smtk01761 // SPDX-License-Identifier: GPL-2.0
2710774e0Smtk01761 /*
3710774e0Smtk01761  * Copyright (c) 2019 MediaTek Inc.
4710774e0Smtk01761  * Author: Wendell Lin <wendell.lin@mediatek.com>
5710774e0Smtk01761  */
6710774e0Smtk01761 
7f09b9460SMiles Chen #include <linux/module.h>
8710774e0Smtk01761 #include <linux/clk-provider.h>
9710774e0Smtk01761 #include <linux/platform_device.h>
10710774e0Smtk01761 
11710774e0Smtk01761 #include "clk-mtk.h"
12710774e0Smtk01761 #include "clk-gate.h"
13710774e0Smtk01761 
14710774e0Smtk01761 #include <dt-bindings/clock/mt6779-clk.h>
15710774e0Smtk01761 
16710774e0Smtk01761 static const struct mtk_gate_regs venc_cg_regs = {
17710774e0Smtk01761 	.set_ofs = 0x0004,
18710774e0Smtk01761 	.clr_ofs = 0x0008,
19710774e0Smtk01761 	.sta_ofs = 0x0000,
20710774e0Smtk01761 };
21710774e0Smtk01761 
22710774e0Smtk01761 #define GATE_VENC_I(_id, _name, _parent, _shift)		\
23710774e0Smtk01761 	GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift,	\
24710774e0Smtk01761 		&mtk_clk_gate_ops_setclr_inv)
25710774e0Smtk01761 
26710774e0Smtk01761 static const struct mtk_gate venc_clks[] = {
27710774e0Smtk01761 	GATE_VENC_I(CLK_VENC_GCON_LARB, "venc_larb", "venc_sel", 0),
28710774e0Smtk01761 	GATE_VENC_I(CLK_VENC_GCON_VENC, "venc_venc", "venc_sel", 4),
29710774e0Smtk01761 	GATE_VENC_I(CLK_VENC_GCON_JPGENC, "venc_jpgenc", "venc_sel", 8),
30710774e0Smtk01761 	GATE_VENC_I(CLK_VENC_GCON_GALS, "venc_gals", "venc_sel", 28),
31710774e0Smtk01761 };
32710774e0Smtk01761 
33dc6fdd8aSMiles Chen static const struct mtk_clk_desc venc_desc = {
34dc6fdd8aSMiles Chen 	.clks = venc_clks,
35dc6fdd8aSMiles Chen 	.num_clks = ARRAY_SIZE(venc_clks),
36710774e0Smtk01761 };
37710774e0Smtk01761 
38dc6fdd8aSMiles Chen static const struct of_device_id of_match_clk_mt6779_venc[] = {
39710774e0Smtk01761 	{
40dc6fdd8aSMiles Chen 		.compatible = "mediatek,mt6779-vencsys",
41dc6fdd8aSMiles Chen 		.data = &venc_desc,
42dc6fdd8aSMiles Chen 	}, {
43dc6fdd8aSMiles Chen 		/* sentinel */
44710774e0Smtk01761 	}
45dc6fdd8aSMiles Chen };
4665c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_venc);
47710774e0Smtk01761 
48710774e0Smtk01761 static struct platform_driver clk_mt6779_venc_drv = {
49dc6fdd8aSMiles Chen 	.probe = mtk_clk_simple_probe,
50*61ca6ee7SUwe Kleine-König 	.remove_new = mtk_clk_simple_remove,
51710774e0Smtk01761 	.driver = {
52710774e0Smtk01761 		.name = "clk-mt6779-venc",
53710774e0Smtk01761 		.of_match_table = of_match_clk_mt6779_venc,
54710774e0Smtk01761 	},
55710774e0Smtk01761 };
56710774e0Smtk01761 
57f09b9460SMiles Chen module_platform_driver(clk_mt6779_venc_drv);
58f09b9460SMiles Chen MODULE_LICENSE("GPL");
59