blob: 865ad31846345d2478e2df43ee8a350ff3855b5d [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2019 MediaTek Inc.
4 */
5
6#include <linux/clk-provider.h>
7#include <linux/platform_device.h>
8
9#include "clk-mtk.h"
10#include "clk-gate.h"
11
12#include <dt-bindings/clock/mt8168-clk.h>
13
14static const struct mtk_gate_regs vdec0_cg_regs = {
15 .set_ofs = 0x0,
16 .clr_ofs = 0x4,
17 .sta_ofs = 0x0,
18};
19
20static const struct mtk_gate_regs vdec1_cg_regs = {
21 .set_ofs = 0x8,
22 .clr_ofs = 0xc,
23 .sta_ofs = 0x8,
24};
25
26#define GATE_VDEC0(_id, _name, _parent, _shift) { \
27 .id = _id, \
28 .name = _name, \
29 .parent_name = _parent, \
30 .regs = &vdec0_cg_regs, \
31 .shift = _shift, \
32 .ops = &mtk_clk_gate_ops_setclr_inv, \
33 }
34
35#define GATE_VDEC1(_id, _name, _parent, _shift) { \
36 .id = _id, \
37 .name = _name, \
38 .parent_name = _parent, \
39 .regs = &vdec1_cg_regs, \
40 .shift = _shift, \
41 .ops = &mtk_clk_gate_ops_setclr_inv, \
42 }
43
44static const struct mtk_gate vdec_clks[] = {
45 /* VDEC0 */
46 GATE_VDEC0(CLK_VDEC_VDEC, "vdec_fvdec_ck", "mm_sel", 0),
47 /* VDEC1 */
48 GATE_VDEC1(CLK_VDEC_LARB1, "vdec_flarb1_ck", "mm_sel", 0),
49};
50
51static int clk_mt8168_vdec_probe(struct platform_device *pdev)
52{
53 struct clk_onecell_data *clk_data;
54 int r;
55 struct device_node *node = pdev->dev.of_node;
56
57 clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
58
59 mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks),
60 clk_data);
61
62 r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
63
64 if (r)
65 pr_err("%s(): could not register clock provider: %d\n",
66 __func__, r);
67
68 return r;
69}
70
71static const struct of_device_id of_match_clk_mt8168_vdec[] = {
72 { .compatible = "mediatek,mt8168-vdecsys", },
73 {}
74};
75
76static struct platform_driver clk_mt8168_vdec_drv = {
77 .probe = clk_mt8168_vdec_probe,
78 .driver = {
79 .name = "clk-mt8168-vdec",
80 .of_match_table = of_match_clk_mt8168_vdec,
81 },
82};
83
84builtin_platform_driver(clk_mt8168_vdec_drv);