blob: c62f9371b7ee884a0ba828fc251f5000c6925edf [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 apuconn_cg_regs = {
15 .set_ofs = 0x0004,
16 .clr_ofs = 0x0008,
17 .sta_ofs = 0x0000,
18};
19
20#define GATE_APU_CONN(_id, _name, _parent, _shift) { \
21 .id = _id, \
22 .name = _name, \
23 .parent_name = _parent, \
24 .regs = &apuconn_cg_regs, \
25 .shift = _shift, \
26 .ops = &mtk_clk_gate_ops_setclr, \
27 }
28
29static const struct mtk_gate apuconn_clks[] = {
30 GATE_APU_CONN(CLK_APU_CONN_APU, "apu_conn_apu", "dsp1_sel", 0),
31 GATE_APU_CONN(CLK_APU_CONN_AHB, "apu_conn_ahb", "dsp_sel", 1),
32 GATE_APU_CONN(CLK_APU_CONN_AXI, "apu_conn_axi", "dsp_sel", 2),
33 GATE_APU_CONN(CLK_APU_CONN_ISP, "apu_conn_isp", "dsp_sel", 3),
34 GATE_APU_CONN(CLK_APU_CONN_CAM_ADL, "apu_conn_cam_adl",
35 "dsp_sel", 4),
36 GATE_APU_CONN(CLK_APU_CONN_IMG_ADL, "apu_conn_img_adl",
37 "dsp_sel", 5),
38 GATE_APU_CONN(CLK_APU_CONN_EMI_26M, "apu_conn_emi_26m",
39 "dsp_sel", 6),
40 GATE_APU_CONN(CLK_APU_CONN_VPU_UDI, "apu_conn_vpu_udi",
41 "dsp_sel", 7),
42};
43
44static const struct of_device_id of_match_clk_mt6779_apuconn[] = {
45 { .compatible = "mediatek,mt6779-apu_conn", },
46 {}
47};
48
49static int clk_mt6779_apuconn_probe(struct platform_device *pdev)
50{
51 struct clk_onecell_data *clk_data;
52 struct device_node *node = pdev->dev.of_node;
53
54 clk_data = mtk_alloc_clk_data(CLK_APU_CONN_NR_CLK);
55
56 mtk_clk_register_gates(node, apuconn_clks, ARRAY_SIZE(apuconn_clks),
57 clk_data);
58
59 return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
60}
61
62static struct platform_driver clk_mt6779_apuconn_drv = {
63 .probe = clk_mt6779_apuconn_probe,
64 .driver = {
65 .name = "clk-mt6779-apu_conn",
66 .of_match_table = of_match_clk_mt6779_apuconn,
67 },
68};
69
70builtin_platform_driver(clk_mt6779_apuconn_drv);