Linux 4.19.133
[linux/fpc-iii.git] / drivers / clk / mediatek / clk-mt6797-img.c
blob94cc48065918eef943b786106c60639e5680b25a
1 /* Copyright (c) 2017 MediaTek Inc.
2 * Author: Kevin Chen <kevin-cw.chen@mediatek.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/clk-provider.h>
15 #include <linux/platform_device.h>
16 #include <dt-bindings/clock/mt6797-clk.h>
18 #include "clk-mtk.h"
19 #include "clk-gate.h"
21 static const struct mtk_gate_regs img_cg_regs = {
22 .set_ofs = 0x0004,
23 .clr_ofs = 0x0008,
24 .sta_ofs = 0x0000,
27 #define GATE_IMG(_id, _name, _parent, _shift) { \
28 .id = _id, \
29 .name = _name, \
30 .parent_name = _parent, \
31 .regs = &img_cg_regs, \
32 .shift = _shift, \
33 .ops = &mtk_clk_gate_ops_setclr, \
36 static const struct mtk_gate img_clks[] = {
37 GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "mm_sel", 11),
38 GATE_IMG(CLK_IMG_DPE, "img_dpe", "mm_sel", 10),
39 GATE_IMG(CLK_IMG_DIP, "img_dip", "mm_sel", 6),
40 GATE_IMG(CLK_IMG_LARB6, "img_larb6", "mm_sel", 0),
43 static const struct of_device_id of_match_clk_mt6797_img[] = {
44 { .compatible = "mediatek,mt6797-imgsys", },
48 static int clk_mt6797_img_probe(struct platform_device *pdev)
50 struct clk_onecell_data *clk_data;
51 int r;
52 struct device_node *node = pdev->dev.of_node;
54 clk_data = mtk_alloc_clk_data(CLK_IMG_NR);
56 mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
57 clk_data);
59 r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
60 if (r)
61 dev_err(&pdev->dev,
62 "could not register clock provider: %s: %d\n",
63 pdev->name, r);
65 return r;
68 static struct platform_driver clk_mt6797_img_drv = {
69 .probe = clk_mt6797_img_probe,
70 .driver = {
71 .name = "clk-mt6797-img",
72 .of_match_table = of_match_clk_mt6797_img,
76 builtin_platform_driver(clk_mt6797_img_drv);