blob: 49739b1c8bcf65f5bd9f79b403bdfd8cdf9782b5 [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 apu0_cg_regs = {
15 .set_ofs = 0x0004,
16 .clr_ofs = 0x0008,
17 .sta_ofs = 0x0000,
18};
19
20#define GATE_APU0(_id, _name, _parent, _shift) { \
21 .id = _id, \
22 .name = _name, \
23 .parent_name = _parent, \
24 .regs = &apu0_cg_regs, \
25 .shift = _shift, \
26 .ops = &mtk_clk_gate_ops_setclr, \
27 }
28
29static const struct mtk_gate apu0_clks[] = {
30 GATE_APU0(CLK_APU0_APU, "apu0_apu", "dsp1_sel", 0),
31 GATE_APU0(CLK_APU0_AXI_M, "apu0_axi", "dsp1_sel", 1),
32 GATE_APU0(CLK_APU0_JTAG, "apu0_jtag", "dsp1_sel", 2),
33};
34
35static const struct of_device_id of_match_clk_mt6779_apu0[] = {
36 { .compatible = "mediatek,mt6779-apu0", },
37 {}
38};
39
40static int clk_mt6779_apu0_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_APU0_NR_CLK);
46
47 mtk_clk_register_gates(node, apu0_clks, ARRAY_SIZE(apu0_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_apu0_drv = {
54 .probe = clk_mt6779_apu0_probe,
55 .driver = {
56 .name = "clk-mt6779-apu0",
57 .of_match_table = of_match_clk_mt6779_apu0,
58 },
59};
60
61builtin_platform_driver(clk_mt6779_apu0_drv);