Skip to content

Commit 1aca993

Browse files
Owen Chenbebarino
authored andcommitted
clk: mediatek: Add MT6765 clock support
Add MT6765 clock support, include topckgen, apmixedsys, infracfg, mcucfg and subsystem clocks. Signed-off-by: Owen Chen <[email protected]> Signed-off-by: Mars Cheng <[email protected]> Signed-off-by: Macpaul Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent eb7beb6 commit 1aca993

File tree

9 files changed

+1523
-0
lines changed

9 files changed

+1523
-0
lines changed

drivers/clk/mediatek/Kconfig

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,92 @@ config COMMON_CLK_MT2712_VENCSYS
117117
---help---
118118
This driver supports MediaTek MT2712 vencsys clocks.
119119

120+
config COMMON_CLK_MT6765
121+
bool "Clock driver for MediaTek MT6765"
122+
depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
123+
select COMMON_CLK_MEDIATEK
124+
default ARCH_MEDIATEK && ARM64
125+
help
126+
This driver supports MediaTek MT6765 basic clocks.
127+
128+
config COMMON_CLK_MT6765_AUDIOSYS
129+
bool "Clock driver for MediaTek MT6765 audiosys"
130+
depends on COMMON_CLK_MT6765
131+
help
132+
This driver supports MediaTek MT6765 audiosys clocks.
133+
134+
config COMMON_CLK_MT6765_CAMSYS
135+
bool "Clock driver for MediaTek MT6765 camsys"
136+
depends on COMMON_CLK_MT6765
137+
help
138+
This driver supports MediaTek MT6765 camsys clocks.
139+
140+
config COMMON_CLK_MT6765_GCESYS
141+
bool "Clock driver for MediaTek MT6765 gcesys"
142+
depends on COMMON_CLK_MT6765
143+
help
144+
This driver supports MediaTek MT6765 gcesys clocks.
145+
146+
config COMMON_CLK_MT6765_MMSYS
147+
bool "Clock driver for MediaTek MT6765 mmsys"
148+
depends on COMMON_CLK_MT6765
149+
help
150+
This driver supports MediaTek MT6765 mmsys clocks.
151+
152+
config COMMON_CLK_MT6765_IMGSYS
153+
bool "Clock driver for MediaTek MT6765 imgsys"
154+
depends on COMMON_CLK_MT6765
155+
help
156+
This driver supports MediaTek MT6765 imgsys clocks.
157+
158+
config COMMON_CLK_MT6765_VCODECSYS
159+
bool "Clock driver for MediaTek MT6765 vcodecsys"
160+
depends on COMMON_CLK_MT6765
161+
help
162+
This driver supports MediaTek MT6765 vcodecsys clocks.
163+
164+
config COMMON_CLK_MT6765_MFGSYS
165+
bool "Clock driver for MediaTek MT6765 mfgsys"
166+
depends on COMMON_CLK_MT6765
167+
help
168+
This driver supports MediaTek MT6765 mfgsys clocks.
169+
170+
config COMMON_CLK_MT6765_MIPI0ASYS
171+
bool "Clock driver for MediaTek MT6765 mipi0asys"
172+
depends on COMMON_CLK_MT6765
173+
help
174+
This driver supports MediaTek MT6765 mipi0asys clocks.
175+
176+
config COMMON_CLK_MT6765_MIPI0BSYS
177+
bool "Clock driver for MediaTek MT6765 mipi0bsys"
178+
depends on COMMON_CLK_MT6765
179+
help
180+
This driver supports MediaTek MT6765 mipi0bsys clocks.
181+
182+
config COMMON_CLK_MT6765_MIPI1ASYS
183+
bool "Clock driver for MediaTek MT6765 mipi1asys"
184+
depends on COMMON_CLK_MT6765
185+
help
186+
This driver supports MediaTek MT6765 mipi1asys clocks.
187+
188+
config COMMON_CLK_MT6765_MIPI1BSYS
189+
bool "Clock driver for MediaTek MT6765 mipi1bsys"
190+
depends on COMMON_CLK_MT6765
191+
help
192+
This driver supports MediaTek MT6765 mipi1bsys clocks.
193+
194+
config COMMON_CLK_MT6765_MIPI2ASYS
195+
bool "Clock driver for MediaTek MT6765 mipi2asys"
196+
depends on COMMON_CLK_MT6765
197+
help
198+
This driver supports MediaTek MT6765 mipi2asys clocks.
199+
200+
config COMMON_CLK_MT6765_MIPI2BSYS
201+
bool "Clock driver for MediaTek MT6765 mipi2bsys"
202+
depends on COMMON_CLK_MT6765
203+
help
204+
This driver supports MediaTek MT6765 mipi2bsys clocks.
205+
120206
config COMMON_CLK_MT6779
121207
bool "Clock driver for MediaTek MT6779"
122208
depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST

drivers/clk/mediatek/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o reset.o clk-mux.o
33

4+
obj-$(CONFIG_COMMON_CLK_MT6765) += clk-mt6765.o
5+
obj-$(CONFIG_COMMON_CLK_MT6765_AUDIOSYS) += clk-mt6765-audio.o
6+
obj-$(CONFIG_COMMON_CLK_MT6765_CAMSYS) += clk-mt6765-cam.o
7+
obj-$(CONFIG_COMMON_CLK_MT6765_IMGSYS) += clk-mt6765-img.o
8+
obj-$(CONFIG_COMMON_CLK_MT6765_MIPI0ASYS) += clk-mt6765-mipi0a.o
9+
obj-$(CONFIG_COMMON_CLK_MT6765_MMSYS) += clk-mt6765-mm.o
10+
obj-$(CONFIG_COMMON_CLK_MT6765_VCODECSYS) += clk-mt6765-vcodec.o
411
obj-$(CONFIG_COMMON_CLK_MT6779) += clk-mt6779.o
512
obj-$(CONFIG_COMMON_CLK_MT6779_MMSYS) += clk-mt6779-mm.o
613
obj-$(CONFIG_COMMON_CLK_MT6779_IMGSYS) += clk-mt6779-img.o
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2018 MediaTek Inc.
4+
* Author: Owen Chen <[email protected]>
5+
*/
6+
7+
#include <linux/clk-provider.h>
8+
#include <linux/platform_device.h>
9+
10+
#include "clk-mtk.h"
11+
#include "clk-gate.h"
12+
13+
#include <dt-bindings/clock/mt6765-clk.h>
14+
15+
static const struct mtk_gate_regs audio0_cg_regs = {
16+
.set_ofs = 0x0,
17+
.clr_ofs = 0x0,
18+
.sta_ofs = 0x0,
19+
};
20+
21+
static const struct mtk_gate_regs audio1_cg_regs = {
22+
.set_ofs = 0x4,
23+
.clr_ofs = 0x4,
24+
.sta_ofs = 0x4,
25+
};
26+
27+
#define GATE_AUDIO0(_id, _name, _parent, _shift) { \
28+
.id = _id, \
29+
.name = _name, \
30+
.parent_name = _parent, \
31+
.regs = &audio0_cg_regs, \
32+
.shift = _shift, \
33+
.ops = &mtk_clk_gate_ops_no_setclr, \
34+
}
35+
36+
#define GATE_AUDIO1(_id, _name, _parent, _shift) { \
37+
.id = _id, \
38+
.name = _name, \
39+
.parent_name = _parent, \
40+
.regs = &audio1_cg_regs, \
41+
.shift = _shift, \
42+
.ops = &mtk_clk_gate_ops_no_setclr, \
43+
}
44+
45+
static const struct mtk_gate audio_clks[] = {
46+
/* AUDIO0 */
47+
GATE_AUDIO0(CLK_AUDIO_AFE, "aud_afe", "audio_ck", 2),
48+
GATE_AUDIO0(CLK_AUDIO_22M, "aud_22m", "aud_engen1_ck", 8),
49+
GATE_AUDIO0(CLK_AUDIO_APLL_TUNER, "aud_apll_tuner",
50+
"aud_engen1_ck", 19),
51+
GATE_AUDIO0(CLK_AUDIO_ADC, "aud_adc", "audio_ck", 24),
52+
GATE_AUDIO0(CLK_AUDIO_DAC, "aud_dac", "audio_ck", 25),
53+
GATE_AUDIO0(CLK_AUDIO_DAC_PREDIS, "aud_dac_predis",
54+
"audio_ck", 26),
55+
GATE_AUDIO0(CLK_AUDIO_TML, "aud_tml", "audio_ck", 27),
56+
/* AUDIO1 */
57+
GATE_AUDIO1(CLK_AUDIO_I2S1_BCLK, "aud_i2s1_bclk",
58+
"audio_ck", 4),
59+
GATE_AUDIO1(CLK_AUDIO_I2S2_BCLK, "aud_i2s2_bclk",
60+
"audio_ck", 5),
61+
GATE_AUDIO1(CLK_AUDIO_I2S3_BCLK, "aud_i2s3_bclk",
62+
"audio_ck", 6),
63+
GATE_AUDIO1(CLK_AUDIO_I2S4_BCLK, "aud_i2s4_bclk",
64+
"audio_ck", 7),
65+
};
66+
67+
static int clk_mt6765_audio_probe(struct platform_device *pdev)
68+
{
69+
struct clk_onecell_data *clk_data;
70+
int r;
71+
struct device_node *node = pdev->dev.of_node;
72+
73+
clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK);
74+
75+
mtk_clk_register_gates(node, audio_clks,
76+
ARRAY_SIZE(audio_clks), clk_data);
77+
78+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
79+
80+
if (r)
81+
pr_err("%s(): could not register clock provider: %d\n",
82+
__func__, r);
83+
84+
return r;
85+
}
86+
87+
static const struct of_device_id of_match_clk_mt6765_audio[] = {
88+
{ .compatible = "mediatek,mt6765-audsys", },
89+
{}
90+
};
91+
92+
static struct platform_driver clk_mt6765_audio_drv = {
93+
.probe = clk_mt6765_audio_probe,
94+
.driver = {
95+
.name = "clk-mt6765-audio",
96+
.of_match_table = of_match_clk_mt6765_audio,
97+
},
98+
};
99+
100+
builtin_platform_driver(clk_mt6765_audio_drv);

drivers/clk/mediatek/clk-mt6765-cam.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2018 MediaTek Inc.
4+
* Author: Owen Chen <[email protected]>
5+
*/
6+
7+
#include <linux/clk-provider.h>
8+
#include <linux/platform_device.h>
9+
10+
#include "clk-mtk.h"
11+
#include "clk-gate.h"
12+
13+
#include <dt-bindings/clock/mt6765-clk.h>
14+
15+
static const struct mtk_gate_regs cam_cg_regs = {
16+
.set_ofs = 0x4,
17+
.clr_ofs = 0x8,
18+
.sta_ofs = 0x0,
19+
};
20+
21+
#define GATE_CAM(_id, _name, _parent, _shift) { \
22+
.id = _id, \
23+
.name = _name, \
24+
.parent_name = _parent, \
25+
.regs = &cam_cg_regs, \
26+
.shift = _shift, \
27+
.ops = &mtk_clk_gate_ops_setclr, \
28+
}
29+
30+
static const struct mtk_gate cam_clks[] = {
31+
GATE_CAM(CLK_CAM_LARB3, "cam_larb3", "mm_ck", 0),
32+
GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "mm_ck", 1),
33+
GATE_CAM(CLK_CAM, "cam", "mm_ck", 6),
34+
GATE_CAM(CLK_CAMTG, "camtg", "mm_ck", 7),
35+
GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "mm_ck", 8),
36+
GATE_CAM(CLK_CAMSV0, "camsv0", "mm_ck", 9),
37+
GATE_CAM(CLK_CAMSV1, "camsv1", "mm_ck", 10),
38+
GATE_CAM(CLK_CAMSV2, "camsv2", "mm_ck", 11),
39+
GATE_CAM(CLK_CAM_CCU, "cam_ccu", "mm_ck", 12),
40+
};
41+
42+
static int clk_mt6765_cam_probe(struct platform_device *pdev)
43+
{
44+
struct clk_onecell_data *clk_data;
45+
int r;
46+
struct device_node *node = pdev->dev.of_node;
47+
48+
clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
49+
50+
mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks), clk_data);
51+
52+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
53+
54+
if (r)
55+
pr_err("%s(): could not register clock provider: %d\n",
56+
__func__, r);
57+
58+
return r;
59+
}
60+
61+
static const struct of_device_id of_match_clk_mt6765_cam[] = {
62+
{ .compatible = "mediatek,mt6765-camsys", },
63+
{}
64+
};
65+
66+
static struct platform_driver clk_mt6765_cam_drv = {
67+
.probe = clk_mt6765_cam_probe,
68+
.driver = {
69+
.name = "clk-mt6765-cam",
70+
.of_match_table = of_match_clk_mt6765_cam,
71+
},
72+
};
73+
74+
builtin_platform_driver(clk_mt6765_cam_drv);

drivers/clk/mediatek/clk-mt6765-img.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2018 MediaTek Inc.
4+
* Author: Owen Chen <[email protected]>
5+
*/
6+
7+
#include <linux/clk-provider.h>
8+
#include <linux/platform_device.h>
9+
10+
#include "clk-mtk.h"
11+
#include "clk-gate.h"
12+
13+
#include <dt-bindings/clock/mt6765-clk.h>
14+
15+
static const struct mtk_gate_regs img_cg_regs = {
16+
.set_ofs = 0x4,
17+
.clr_ofs = 0x8,
18+
.sta_ofs = 0x0,
19+
};
20+
21+
#define GATE_IMG(_id, _name, _parent, _shift) { \
22+
.id = _id, \
23+
.name = _name, \
24+
.parent_name = _parent, \
25+
.regs = &img_cg_regs, \
26+
.shift = _shift, \
27+
.ops = &mtk_clk_gate_ops_setclr, \
28+
}
29+
30+
static const struct mtk_gate img_clks[] = {
31+
GATE_IMG(CLK_IMG_LARB2, "img_larb2", "mm_ck", 0),
32+
GATE_IMG(CLK_IMG_DIP, "img_dip", "mm_ck", 2),
33+
GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "mm_ck", 3),
34+
GATE_IMG(CLK_IMG_DPE, "img_dpe", "mm_ck", 4),
35+
GATE_IMG(CLK_IMG_RSC, "img_rsc", "mm_ck", 5),
36+
};
37+
38+
static int clk_mt6765_img_probe(struct platform_device *pdev)
39+
{
40+
struct clk_onecell_data *clk_data;
41+
int r;
42+
struct device_node *node = pdev->dev.of_node;
43+
44+
clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
45+
46+
mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks), clk_data);
47+
48+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
49+
50+
if (r)
51+
pr_err("%s(): could not register clock provider: %d\n",
52+
__func__, r);
53+
54+
return r;
55+
}
56+
57+
static const struct of_device_id of_match_clk_mt6765_img[] = {
58+
{ .compatible = "mediatek,mt6765-imgsys", },
59+
{}
60+
};
61+
62+
static struct platform_driver clk_mt6765_img_drv = {
63+
.probe = clk_mt6765_img_probe,
64+
.driver = {
65+
.name = "clk-mt6765-img",
66+
.of_match_table = of_match_clk_mt6765_img,
67+
},
68+
};
69+
70+
builtin_platform_driver(clk_mt6765_img_drv);

0 commit comments

Comments
 (0)