1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018 MediaTek Inc.
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 u16 rst_ofs[] = { 0xc, };
40 static const struct mtk_clk_rst_desc clk_rst_desc = {
41 .version = MTK_RST_SIMPLE,
42 .rst_bank_ofs = rst_ofs,
43 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
46 static int clk_mt2701_g3dsys_init(struct platform_device *pdev)
48 struct clk_hw_onecell_data *clk_data;
49 struct device_node *node = pdev->dev.of_node;
52 clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);
54 mtk_clk_register_gates(node, g3d_clks, ARRAY_SIZE(g3d_clks),
57 r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
60 "could not register clock provider: %s: %d\n",
63 mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
68 static const struct of_device_id of_match_clk_mt2701_g3d[] = {
70 .compatible = "mediatek,mt2701-g3dsys",
71 .data = clk_mt2701_g3dsys_init,
77 static int clk_mt2701_g3d_probe(struct platform_device *pdev)
79 int (*clk_init)(struct platform_device *);
82 clk_init = of_device_get_match_data(&pdev->dev);
89 "could not register clock provider: %s: %d\n",
95 static struct platform_driver clk_mt2701_g3d_drv = {
96 .probe = clk_mt2701_g3d_probe,
98 .name = "clk-mt2701-g3d",
99 .of_match_table = of_match_clk_mt2701_g3d,
103 builtin_platform_driver(clk_mt2701_g3d_drv);