1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018 MediaTek Inc.
4 * Author: Sean Wang <sean.wang@mediatek.com>
8 #include <linux/clk-provider.h>
10 #include <linux/of_address.h>
11 #include <linux/of_device.h>
12 #include <linux/platform_device.h>
17 #include <dt-bindings/clock/mt2701-clk.h>
19 #define GATE_G3D(_id, _name, _parent, _shift) { \
22 .parent_name = _parent, \
23 .regs = &g3d_cg_regs, \
25 .ops = &mtk_clk_gate_ops_setclr, \
28 static const struct mtk_gate_regs g3d_cg_regs
= {
34 static const struct mtk_gate g3d_clks
[] = {
35 GATE_G3D(CLK_G3DSYS_CORE
, "g3d_core", "mfg_sel", 0),
38 static int clk_mt2701_g3dsys_init(struct platform_device
*pdev
)
40 struct clk_onecell_data
*clk_data
;
41 struct device_node
*node
= pdev
->dev
.of_node
;
44 clk_data
= mtk_alloc_clk_data(CLK_G3DSYS_NR
);
46 mtk_clk_register_gates(node
, g3d_clks
, ARRAY_SIZE(g3d_clks
),
49 r
= of_clk_add_provider(node
, of_clk_src_onecell_get
, clk_data
);
52 "could not register clock provider: %s: %d\n",
55 mtk_register_reset_controller(node
, 1, 0xc);
60 static const struct of_device_id of_match_clk_mt2701_g3d
[] = {
62 .compatible
= "mediatek,mt2701-g3dsys",
63 .data
= clk_mt2701_g3dsys_init
,
69 static int clk_mt2701_g3d_probe(struct platform_device
*pdev
)
71 int (*clk_init
)(struct platform_device
*);
74 clk_init
= of_device_get_match_data(&pdev
->dev
);
81 "could not register clock provider: %s: %d\n",
87 static struct platform_driver clk_mt2701_g3d_drv
= {
88 .probe
= clk_mt2701_g3d_probe
,
90 .name
= "clk-mt2701-g3d",
91 .of_match_table
= of_match_clk_mt2701_g3d
,
95 builtin_platform_driver(clk_mt2701_g3d_drv
);