blob: 59372ead48294b12673e8f3c01ce78acdc0753af [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#include <dt-bindings/clock/mt6779-clk.h>
10
11#include "clk-mtk.h"
12#include "clk-gate.h"
13
14static const struct mtk_gate_regs apu1_cg_regs = {
15 .set_ofs = 0x0004,
16 .clr_ofs = 0x0008,
17 .sta_ofs = 0x0000,
18};
19
20#define GATE_APU1(_id, _name, _parent, _shift) { \
21 .id = _id, \
22 .name = _name, \
23 .parent_name = _parent, \
24 .regs = &apu1_cg_regs, \
25 .shift = _shift, \
26 .ops = &mtk_clk_gate_ops_setclr, \
27 }
28
29static const struct mtk_gate apu1_clks[] = {
30 GATE_APU1(CLK_APU1_APU, "apu1_apu", "dsp2_sel", 0),
31 GATE_APU1(CLK_APU1_AXI_M, "apu1_axi", "dsp2_sel", 1),
32 GATE_APU1(CLK_APU1_JTAG, "apu1_jtag", "dsp2_sel", 2),
33};
34
35static const struct of_device_id of_match_clk_mt6779_apu1[] = {
36 { .compatible = "mediatek,mt6779-apu1", },
37 {}
38};
39
40static int clk_mt6779_apu1_probe(struct platform_device *pdev)
41{
42 struct clk_onecell_data *clk_data;
43 struct device_node *node = pdev->dev.of_node;
44
45 clk_data = mtk_alloc_clk_data(CLK_APU1_NR_CLK);
46
47 mtk_clk_register_gates(node, apu1_clks, ARRAY_SIZE(apu1_clks),
48 clk_data);
49
50 return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
51}
52
53static struct platform_driver clk_mt6779_apu1_drv = {
54 .probe = clk_mt6779_apu1_probe,
55 .driver = {
56 .name = "clk-mt6779-apu1",
57 .of_match_table = of_match_clk_mt6779_apu1,
58 },
59};
60
61builtin_platform_driver(clk_mt6779_apu1_drv);