1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2018 MediaTek Inc.
4  * Author: Sean Wang <sean.wang@mediatek.com>
5  *
6  */
7 
8 #include <linux/clk-provider.h>
9 #include <linux/of.h>
10 #include <linux/of_address.h>
11 #include <linux/of_device.h>
12 #include <linux/platform_device.h>
13 
14 #include "clk-mtk.h"
15 #include "clk-gate.h"
16 
17 #include <dt-bindings/clock/mt2701-clk.h>
18 
19 #define GATE_G3D(_id, _name, _parent, _shift) {	\
20 		.id = _id,				\
21 		.name = _name,				\
22 		.parent_name = _parent,			\
23 		.regs = &g3d_cg_regs,			\
24 		.shift = _shift,			\
25 		.ops = &mtk_clk_gate_ops_setclr,	\
26 	}
27 
28 static const struct mtk_gate_regs g3d_cg_regs = {
29 	.sta_ofs = 0x0,
30 	.set_ofs = 0x4,
31 	.clr_ofs = 0x8,
32 };
33 
34 static const struct mtk_gate g3d_clks[] = {
35 	GATE_DUMMY(CLK_DUMMY, "g3d_dummy"),
36 	GATE_G3D(CLK_G3DSYS_CORE, "g3d_core", "mfg_sel", 0),
37 };
38 
39 static u16 rst_ofs[] = { 0xc, };
40 
41 static const struct mtk_clk_rst_desc clk_rst_desc = {
42 	.version = MTK_RST_SIMPLE,
43 	.rst_bank_ofs = rst_ofs,
44 	.rst_bank_nr = ARRAY_SIZE(rst_ofs),
45 };
46 
47 static const struct mtk_clk_desc g3d_desc = {
48 	.clks = g3d_clks,
49 	.num_clks = ARRAY_SIZE(g3d_clks),
50 	.rst_desc = &clk_rst_desc,
51 };
52 
53 static const struct of_device_id of_match_clk_mt2701_g3d[] = {
54 	{ .compatible = "mediatek,mt2701-g3dsys", .data = &g3d_desc },
55 	{ /* sentinel */ }
56 };
57 
58 static struct platform_driver clk_mt2701_g3d_drv = {
59 	.probe = mtk_clk_simple_probe,
60 	.remove = mtk_clk_simple_remove,
61 	.driver = {
62 		.name = "clk-mt2701-g3d",
63 		.of_match_table = of_match_clk_mt2701_g3d,
64 	},
65 };
66 
67 builtin_platform_driver(clk_mt2701_g3d_drv);
68