blob: 8aed37b886a4612a1fd22fc611edaeba271d9773 [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 venc_cg_regs = {
15 .set_ofs = 0x4,
16 .clr_ofs = 0x8,
17 .sta_ofs = 0x0,
18};
19
20#define GATE_VENC(_id, _name, _parent, _shift) { \
21 .id = _id, \
22 .name = _name, \
23 .parent_name = _parent, \
24 .regs = &venc_cg_regs, \
25 .shift = _shift, \
26 .ops = &mtk_clk_gate_ops_setclr_inv, \
27 }
28
29static const struct mtk_gate venc_clks[] = {
30 /* VENC */
31 GATE_VENC(CLK_VENC, "venc_fvenc_ck", "mm_sel", 4),
32 GATE_VENC(CLK_VENC_JPGENC, "venc_jpgenc_ck", "mm_sel", 8),
33};
34
35static int clk_mt8168_venc_probe(struct platform_device *pdev)
36{
37 struct clk_onecell_data *clk_data;
38 int r;
39 struct device_node *node = pdev->dev.of_node;
40
41 clk_data = mtk_alloc_clk_data(CLK_VENC_NR_CLK);
42
43 mtk_clk_register_gates(node, venc_clks, ARRAY_SIZE(venc_clks),
44 clk_data);
45
46 r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
47
48 if (r)
49 pr_err("%s(): could not register clock provider: %d\n",
50 __func__, r);
51
52 return r;
53}
54
55static const struct of_device_id of_match_clk_mt8168_venc[] = {
56 { .compatible = "mediatek,mt8168-vencsys", },
57 {}
58};
59
60static struct platform_driver clk_mt8168_venc_drv = {
61 .probe = clk_mt8168_venc_probe,
62 .driver = {
63 .name = "clk-mt8168-venc",
64 .of_match_table = of_match_clk_mt8168_venc,
65 },
66};
67
68builtin_platform_driver(clk_mt8168_venc_drv);