Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / mediatek / clk-mt2701-g3d.c
blob1328c112a38fed702d3a1526155a1bc2643b9bb8
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2018 MediaTek Inc.
4 * Author: Sean Wang <sean.wang@mediatek.com>
6 */
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>
14 #include "clk-mtk.h"
15 #include "clk-gate.h"
17 #include <dt-bindings/clock/mt2701-clk.h>
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, \
28 static const struct mtk_gate_regs g3d_cg_regs = {
29 .sta_ofs = 0x0,
30 .set_ofs = 0x4,
31 .clr_ofs = 0x8,
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;
42 int r;
44 clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);
46 mtk_clk_register_gates(node, g3d_clks, ARRAY_SIZE(g3d_clks),
47 clk_data);
49 r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
50 if (r)
51 dev_err(&pdev->dev,
52 "could not register clock provider: %s: %d\n",
53 pdev->name, r);
55 mtk_register_reset_controller(node, 1, 0xc);
57 return r;
60 static const struct of_device_id of_match_clk_mt2701_g3d[] = {
62 .compatible = "mediatek,mt2701-g3dsys",
63 .data = clk_mt2701_g3dsys_init,
64 }, {
65 /* sentinel */
69 static int clk_mt2701_g3d_probe(struct platform_device *pdev)
71 int (*clk_init)(struct platform_device *);
72 int r;
74 clk_init = of_device_get_match_data(&pdev->dev);
75 if (!clk_init)
76 return -EINVAL;
78 r = clk_init(pdev);
79 if (r)
80 dev_err(&pdev->dev,
81 "could not register clock provider: %s: %d\n",
82 pdev->name, r);
84 return r;
87 static struct platform_driver clk_mt2701_g3d_drv = {
88 .probe = clk_mt2701_g3d_probe,
89 .driver = {
90 .name = "clk-mt2701-g3d",
91 .of_match_table = of_match_clk_mt2701_g3d,
95 builtin_platform_driver(clk_mt2701_g3d_drv);