summaryrefslogtreecommitdiffstats
path: root/drivers/clk/mediatek/clk-mt8183-ipu_conn.c
blob: 14a4c3ff82a1bcde3d715c6e69be91596a81d287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2018 MediaTek Inc.
// Author: Weiyi Lu <weiyi.lu@mediatek.com>

#include <linux/clk-provider.h>
#include <linux/platform_device.h>

#include "clk-mtk.h"
#include "clk-gate.h"

#include <dt-bindings/clock/mt8183-clk.h>

static const struct mtk_gate_regs ipu_conn_cg_regs = {
	.set_ofs = 0x4,
	.clr_ofs = 0x8,
	.sta_ofs = 0x0,
};

static const struct mtk_gate_regs ipu_conn_apb_cg_regs = {
	.set_ofs = 0x10,
	.clr_ofs = 0x10,
	.sta_ofs = 0x10,
};

static const struct mtk_gate_regs ipu_conn_axi_cg_regs = {
	.set_ofs = 0x18,
	.clr_ofs = 0x18,
	.sta_ofs = 0x18,
};

static const struct mtk_gate_regs ipu_conn_axi1_cg_regs = {
	.set_ofs = 0x1c,
	.clr_ofs = 0x1c,
	.sta_ofs = 0x1c,
};

static const struct mtk_gate_regs ipu_conn_axi2_cg_regs = {
	.set_ofs = 0x20,
	.clr_ofs = 0x20,
	.sta_ofs = 0x20,
};

#define GATE_IPU_CONN(_id, _name, _parent, _shift)			\
	GATE_MTK(_id, _name, _parent, &ipu_conn_cg_regs, _shift,	\
		&mtk_clk_gate_ops_setclr)

#define GATE_IPU_CONN_APB(_id, _name, _parent, _shift)			\
	GATE_MTK(_id, _name, _parent, &ipu_conn_apb_cg_regs, _shift,	\
		&mtk_clk_gate_ops_no_setclr)

#define GATE_IPU_CONN_AXI_I(_id, _name, _parent, _shift)		\
	GATE_MTK(_id, _name, _parent, &ipu_conn_axi_cg_regs, _shift,	\
		&mtk_clk_gate_ops_no_setclr_inv)

#define GATE_IPU_CONN_AXI1_I(_id, _name, _parent, _shift)		\
	GATE_MTK(_id, _name, _parent, &ipu_conn_axi1_cg_regs, _shift,	\
		&mtk_clk_gate_ops_no_setclr_inv)

#define GATE_IPU_CONN_AXI2_I(_id, _name, _parent, _shift)		\
	GATE_MTK(_id, _name, _parent, &ipu_conn_axi2_cg_regs, _shift,	\
		&mtk_clk_gate_ops_no_setclr_inv)

static const struct mtk_gate ipu_conn_clks[] = {
	GATE_IPU_CONN(CLK_IPU_CONN_IPU,
		"ipu_conn_ipu", "dsp_sel", 0),
	GATE_IPU_CONN(CLK_IPU_CONN_AHB,
		"ipu_conn_ahb", "dsp_sel", 1),
	GATE_IPU_CONN(CLK_IPU_CONN_AXI,
		"ipu_conn_axi", "dsp_sel", 2),
	GATE_IPU_CONN(CLK_IPU_CONN_ISP,
		"ipu_conn_isp", "dsp_sel", 3),
	GATE_IPU_CONN(CLK_IPU_CONN_CAM_ADL,
		"ipu_conn_cam_adl", "dsp_sel", 4),
	GATE_IPU_CONN(CLK_IPU_CONN_IMG_ADL,
		"ipu_conn_img_adl", "dsp_sel", 5),
	GATE_IPU_CONN_APB(CLK_IPU_CONN_DAP_RX,
		"ipu_conn_dap_rx", "dsp1_sel", 0),
	GATE_IPU_CONN_APB(CLK_IPU_CONN_APB2AXI,
		"ipu_conn_apb2axi", "dsp1_sel", 3),
	GATE_IPU_CONN_APB(CLK_IPU_CONN_APB2AHB,
		"ipu_conn_apb2ahb", "dsp1_sel", 20),
	GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU_CAB1TO2,
		"ipu_conn_ipu_cab1to2", "dsp1_sel", 6),
	GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU1_CAB1TO2,
		"ipu_conn_ipu1_cab1to2", "dsp1_sel", 13),
	GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU2_CAB1TO2,
		"ipu_conn_ipu2_cab1to2", "dsp1_sel", 20),
	GATE_IPU_CONN_AXI1_I(CLK_IPU_CONN_CAB3TO3,
		"ipu_conn_cab3to3", "dsp1_sel", 0),
	GATE_IPU_CONN_AXI2_I(CLK_IPU_CONN_CAB2TO1,
		"ipu_conn_cab2to1", "dsp1_sel", 14),
	GATE_IPU_CONN_AXI2_I(CLK_IPU_CONN_CAB3TO1_SLICE,
		"ipu_conn_cab3to1_slice", "dsp1_sel", 17),
};

static const struct mtk_clk_desc ipu_conn_desc = {
	.clks = ipu_conn_clks,
	.num_clks = ARRAY_SIZE(ipu_conn_clks),
};

static const struct of_device_id of_match_clk_mt8183_ipu_conn[] = {
	{
		.compatible = "mediatek,mt8183-ipu_conn",
		.data = &ipu_conn_desc,
	}, {
		/* sentinel */
	}
};

static struct platform_driver clk_mt8183_ipu_conn_drv = {
	.probe = mtk_clk_simple_probe,
	.remove = mtk_clk_simple_remove,
	.driver = {
		.name = "clk-mt8183-ipu_conn",
		.of_match_table = of_match_clk_mt8183_ipu_conn,
	},
};

builtin_platform_driver(clk_mt8183_ipu_conn_drv);