blob: 12e324da98b4662154b237036ec85c71d368f706 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 MediaTek Inc.
4 * Author: Wendell Lin <wendell.lin@mediatek.com>
5 */
6
7#include <linux/clk-provider.h>
8#include <linux/platform_device.h>
9
10#include "clk-mtk.h"
11#include "clk-gate.h"
12
13#include <dt-bindings/clock/mt6779-clk.h>
14
15static const struct mtk_gate_regs vdec0_cg_regs = {
16 .set_ofs = 0x0000,
17 .clr_ofs = 0x0004,
18 .sta_ofs = 0x0000,
19};
20
21static const struct mtk_gate_regs vdec1_cg_regs = {
22 .set_ofs = 0x0008,
23 .clr_ofs = 0x000c,
24 .sta_ofs = 0x0008,
25};
26
27#define GATE_VDEC0(_id, _name, _parent, _shift) { \
28 .id = _id, \
29 .name = _name, \
30 .parent_name = _parent, \
31 .regs = &vdec0_cg_regs, \
32 .shift = _shift, \
33 .ops = &mtk_clk_gate_ops_setclr_inv, \
34}
35
36#define GATE_VDEC1(_id, _name, _parent, _shift) { \
37 .id = _id, \
38 .name = _name, \
39 .parent_name = _parent, \
40 .regs = &vdec1_cg_regs, \
41 .shift = _shift, \
42 .ops = &mtk_clk_gate_ops_setclr_inv, \
43}
44
45static const struct mtk_gate vdec_clks[] = {
46 GATE_VDEC0(CLK_VDEC_VDEC, "vdec_cken", "vdec_sel", 0),
47 GATE_VDEC1(CLK_VDEC_LARB1, "vdec_larb1_cken", "vdec_sel", 0),
48};
49
50static const struct of_device_id of_match_clk_mt6779_vdec[] = {
51 { .compatible = "mediatek,mt6779-vdecsys", },
52 {}
53};
54
55static int clk_mt6779_vdec_probe(struct platform_device *pdev)
56{
57 struct clk_onecell_data *clk_data;
58 struct device_node *node = pdev->dev.of_node;
59
60 clk_data = mtk_alloc_clk_data(CLK_VDEC_GCON_NR_CLK);
61
62 mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
63 clk_data);
64
65 return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
66}
67
68static struct platform_driver clk_mt6779_vdec_drv = {
69 .probe = clk_mt6779_vdec_probe,
70 .driver = {
71 .name = "clk-mt6779-vdec",
72 .of_match_table = of_match_clk_mt6779_vdec,
73 },
74};
75
76builtin_platform_driver(clk_mt6779_vdec_drv);