xref: /linux/drivers/clk/mediatek/clk-mt6735-topckgen.c (revision 9f3a2ba62c7226a6604b8aaeb92b5ff906fa4e6b)
1*43c04ed7SYassine Oudjana // SPDX-License-Identifier: GPL-2.0
2*43c04ed7SYassine Oudjana /*
3*43c04ed7SYassine Oudjana  * Copyright (c) 2022 Yassine Oudjana <y.oudjana@protonmail.com>
4*43c04ed7SYassine Oudjana  */
5*43c04ed7SYassine Oudjana 
6*43c04ed7SYassine Oudjana #include <linux/clk-provider.h>
7*43c04ed7SYassine Oudjana #include <linux/platform_device.h>
8*43c04ed7SYassine Oudjana 
9*43c04ed7SYassine Oudjana #include "clk-mtk.h"
10*43c04ed7SYassine Oudjana #include "clk-mux.h"
11*43c04ed7SYassine Oudjana 
12*43c04ed7SYassine Oudjana #include <dt-bindings/clock/mediatek,mt6735-topckgen.h>
13*43c04ed7SYassine Oudjana 
14*43c04ed7SYassine Oudjana #define CLK_CFG_0		0x40
15*43c04ed7SYassine Oudjana #define CLK_CFG_0_SET		0x44
16*43c04ed7SYassine Oudjana #define CLK_CFG_0_CLR		0x48
17*43c04ed7SYassine Oudjana #define CLK_CFG_1		0x50
18*43c04ed7SYassine Oudjana #define CLK_CFG_1_SET		0x54
19*43c04ed7SYassine Oudjana #define CLK_CFG_1_CLR		0x58
20*43c04ed7SYassine Oudjana #define CLK_CFG_2		0x60
21*43c04ed7SYassine Oudjana #define CLK_CFG_2_SET		0x64
22*43c04ed7SYassine Oudjana #define CLK_CFG_2_CLR		0x68
23*43c04ed7SYassine Oudjana #define CLK_CFG_3		0x70
24*43c04ed7SYassine Oudjana #define CLK_CFG_3_SET		0x74
25*43c04ed7SYassine Oudjana #define CLK_CFG_3_CLR		0x78
26*43c04ed7SYassine Oudjana #define CLK_CFG_4		0x80
27*43c04ed7SYassine Oudjana #define CLK_CFG_4_SET		0x84
28*43c04ed7SYassine Oudjana #define CLK_CFG_4_CLR		0x88
29*43c04ed7SYassine Oudjana #define CLK_CFG_5		0x90
30*43c04ed7SYassine Oudjana #define CLK_CFG_5_SET		0x94
31*43c04ed7SYassine Oudjana #define CLK_CFG_5_CLR		0x98
32*43c04ed7SYassine Oudjana #define CLK_CFG_6		0xa0
33*43c04ed7SYassine Oudjana #define CLK_CFG_6_SET		0xa4
34*43c04ed7SYassine Oudjana #define CLK_CFG_6_CLR		0xa8
35*43c04ed7SYassine Oudjana #define CLK_CFG_7		0xb0
36*43c04ed7SYassine Oudjana #define CLK_CFG_7_SET		0xb4
37*43c04ed7SYassine Oudjana #define CLK_CFG_7_CLR		0xb8
38*43c04ed7SYassine Oudjana 
39*43c04ed7SYassine Oudjana static DEFINE_SPINLOCK(mt6735_topckgen_lock);
40*43c04ed7SYassine Oudjana 
41*43c04ed7SYassine Oudjana /* Some clocks with unknown details are modeled as fixed clocks */
42*43c04ed7SYassine Oudjana static const struct mtk_fixed_clk topckgen_fixed_clks[] = {
43*43c04ed7SYassine Oudjana 	/*
44*43c04ed7SYassine Oudjana 	 * This clock is available as a parent option for multiple
45*43c04ed7SYassine Oudjana 	 * muxes and seems like an alternative name for clk26m at first,
46*43c04ed7SYassine Oudjana 	 * but it appears alongside it in several muxes which should
47*43c04ed7SYassine Oudjana 	 * mean it is a separate clock.
48*43c04ed7SYassine Oudjana 	 */
49*43c04ed7SYassine Oudjana 	FIXED_CLK(CLK_TOP_AD_SYS_26M_CK, "ad_sys_26m_ck", "clk26m", 26 * MHZ),
50*43c04ed7SYassine Oudjana 	/*
51*43c04ed7SYassine Oudjana 	 * This clock is the parent of DMPLL divisors. It might be MEMPLL
52*43c04ed7SYassine Oudjana 	 * or its parent, as DMPLL appears to be an alternative name for
53*43c04ed7SYassine Oudjana 	 * MEMPLL.
54*43c04ed7SYassine Oudjana 	 */
55*43c04ed7SYassine Oudjana 	FIXED_CLK(CLK_TOP_CLKPH_MCK_O, "clkph_mck_o", NULL, 0),
56*43c04ed7SYassine Oudjana 	/*
57*43c04ed7SYassine Oudjana 	 * DMPLL clock (dmpll_ck), controlled by DDRPHY.
58*43c04ed7SYassine Oudjana 	 */
59*43c04ed7SYassine Oudjana 	FIXED_CLK(CLK_TOP_DMPLL, "dmpll", "clkph_mck_o", 0),
60*43c04ed7SYassine Oudjana 	/*
61*43c04ed7SYassine Oudjana 	 * MIPI DPI clock. Parent option for dpi0_sel. Unknown parent.
62*43c04ed7SYassine Oudjana 	 */
63*43c04ed7SYassine Oudjana 	FIXED_CLK(CLK_TOP_DPI_CK, "dpi_ck", NULL, 0),
64*43c04ed7SYassine Oudjana 	/*
65*43c04ed7SYassine Oudjana 	 * This clock is a child of WHPLL which is controlled by
66*43c04ed7SYassine Oudjana 	 * the modem.
67*43c04ed7SYassine Oudjana 	 */
68*43c04ed7SYassine Oudjana 	FIXED_CLK(CLK_TOP_WHPLL_AUDIO_CK, "whpll_audio_ck", NULL, 0)
69*43c04ed7SYassine Oudjana };
70*43c04ed7SYassine Oudjana 
71*43c04ed7SYassine Oudjana static const struct mtk_fixed_factor topckgen_factors[] = {
72*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "mainpll", 1, 2),
73*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "mainpll", 1, 3),
74*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "mainpll", 1, 5),
75*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "mainpll", 1, 2),
76*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "mainpll", 1, 4),
77*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "mainpll", 1, 8),
78*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "mainpll", 1, 16),
79*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "mainpll", 1, 2),
80*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "mainpll", 1, 4),
81*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "mainpll", 1, 2),
82*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "mainpll", 1, 4),
83*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "mainpll", 1, 2),
84*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "mainpll", 1, 4),
85*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2),
86*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3),
87*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5),
88*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll", 1, 26),
89*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll", 1, 2),
90*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll", 1, 4),
91*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll", 1, 8),
92*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll", 1, 2),
93*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll", 1, 4),
94*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll", 1, 8),
95*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll", 1, 2),
96*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll", 1, 4),
97*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2),
98*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll", 1, 4),
99*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_MSDCPLL_D8, "msdcpll_d8", "msdcpll", 1, 8),
100*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll", 1, 16),
101*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_VENCPLL_D3, "vencpll_d3", "vencpll", 1, 3),
102*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll", 1, 2),
103*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll", 1, 4),
104*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_DMPLL_D2, "dmpll_d2", "clkph_mck_o", 1, 2),
105*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_DMPLL_D4, "dmpll_d4", "clkph_mck_o", 1, 4),
106*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_DMPLL_D8, "dmpll_d8", "clkph_mck_o", 1, 8),
107*43c04ed7SYassine Oudjana 	FACTOR(CLK_TOP_AD_SYS_26M_D2, "ad_sys_26m_d2", "clk26m", 1, 2)
108*43c04ed7SYassine Oudjana };
109*43c04ed7SYassine Oudjana 
110*43c04ed7SYassine Oudjana static const char * const axi_sel_parents[] = {
111*43c04ed7SYassine Oudjana 	"clk26m",
112*43c04ed7SYassine Oudjana 	"syspll1_d2",
113*43c04ed7SYassine Oudjana 	"syspll_d5",
114*43c04ed7SYassine Oudjana 	"syspll1_d4",
115*43c04ed7SYassine Oudjana 	"univpll_d5",
116*43c04ed7SYassine Oudjana 	"univpll2_d2",
117*43c04ed7SYassine Oudjana 	"dmpll",
118*43c04ed7SYassine Oudjana 	"dmpll_d2"
119*43c04ed7SYassine Oudjana };
120*43c04ed7SYassine Oudjana 
121*43c04ed7SYassine Oudjana static const char * const mem_sel_parents[] = {
122*43c04ed7SYassine Oudjana 	"clk26m",
123*43c04ed7SYassine Oudjana 	"dmpll"
124*43c04ed7SYassine Oudjana };
125*43c04ed7SYassine Oudjana 
126*43c04ed7SYassine Oudjana static const char * const ddrphycfg_parents[] = {
127*43c04ed7SYassine Oudjana 	"clk26m",
128*43c04ed7SYassine Oudjana 	"syspll1_d8"
129*43c04ed7SYassine Oudjana };
130*43c04ed7SYassine Oudjana 
131*43c04ed7SYassine Oudjana static const char * const mm_sel_parents[] = {
132*43c04ed7SYassine Oudjana 	"clk26m",
133*43c04ed7SYassine Oudjana 	"vencpll",
134*43c04ed7SYassine Oudjana 	"syspll1_d2",
135*43c04ed7SYassine Oudjana 	"syspll_d5",
136*43c04ed7SYassine Oudjana 	"syspll1_d4",
137*43c04ed7SYassine Oudjana 	"univpll_d5",
138*43c04ed7SYassine Oudjana 	"univpll2_d2",
139*43c04ed7SYassine Oudjana 	"dmpll"
140*43c04ed7SYassine Oudjana };
141*43c04ed7SYassine Oudjana 
142*43c04ed7SYassine Oudjana static const char * const pwm_sel_parents[] = {
143*43c04ed7SYassine Oudjana 	"clk26m",
144*43c04ed7SYassine Oudjana 	"univpll2_d4",
145*43c04ed7SYassine Oudjana 	"univpll3_d2",
146*43c04ed7SYassine Oudjana 	"univpll1_d4"
147*43c04ed7SYassine Oudjana };
148*43c04ed7SYassine Oudjana 
149*43c04ed7SYassine Oudjana static const char * const vdec_sel_parents[] = {
150*43c04ed7SYassine Oudjana 	"clk26m",
151*43c04ed7SYassine Oudjana 	"syspll1_d2",
152*43c04ed7SYassine Oudjana 	"syspll_d5",
153*43c04ed7SYassine Oudjana 	"syspll1_d4",
154*43c04ed7SYassine Oudjana 	"univpll_d5",
155*43c04ed7SYassine Oudjana 	"syspll_d2",
156*43c04ed7SYassine Oudjana 	"syspll2_d2",
157*43c04ed7SYassine Oudjana 	"msdcpll_d2"
158*43c04ed7SYassine Oudjana };
159*43c04ed7SYassine Oudjana 
160*43c04ed7SYassine Oudjana static const char * const mfg_sel_parents[] = {
161*43c04ed7SYassine Oudjana 	"clk26m",
162*43c04ed7SYassine Oudjana 	"mmpll",
163*43c04ed7SYassine Oudjana 	"clk26m",
164*43c04ed7SYassine Oudjana 	"clk26m",
165*43c04ed7SYassine Oudjana 	"clk26m",
166*43c04ed7SYassine Oudjana 	"clk26m",
167*43c04ed7SYassine Oudjana 	"clk26m",
168*43c04ed7SYassine Oudjana 	"clk26m",
169*43c04ed7SYassine Oudjana 	"clk26m",
170*43c04ed7SYassine Oudjana 	"syspll_d3",
171*43c04ed7SYassine Oudjana 	"syspll1_d2",
172*43c04ed7SYassine Oudjana 	"syspll_d5",
173*43c04ed7SYassine Oudjana 	"univpll_d3",
174*43c04ed7SYassine Oudjana 	"univpll1_d2"
175*43c04ed7SYassine Oudjana };
176*43c04ed7SYassine Oudjana 
177*43c04ed7SYassine Oudjana static const char * const camtg_sel_parents[] = {
178*43c04ed7SYassine Oudjana 	"clk26m",
179*43c04ed7SYassine Oudjana 	"univpll_d26",
180*43c04ed7SYassine Oudjana 	"univpll2_d2",
181*43c04ed7SYassine Oudjana 	"syspll3_d2",
182*43c04ed7SYassine Oudjana 	"syspll3_d4",
183*43c04ed7SYassine Oudjana 	"msdcpll_d4"
184*43c04ed7SYassine Oudjana };
185*43c04ed7SYassine Oudjana 
186*43c04ed7SYassine Oudjana static const char * const uart_sel_parents[] = {
187*43c04ed7SYassine Oudjana 	"clk26m",
188*43c04ed7SYassine Oudjana 	"univpll2_d8"
189*43c04ed7SYassine Oudjana };
190*43c04ed7SYassine Oudjana 
191*43c04ed7SYassine Oudjana static const char * const spi_sel_parents[] = {
192*43c04ed7SYassine Oudjana 	"clk26m",
193*43c04ed7SYassine Oudjana 	"syspll3_d2",
194*43c04ed7SYassine Oudjana 	"msdcpll_d8",
195*43c04ed7SYassine Oudjana 	"syspll2_d4",
196*43c04ed7SYassine Oudjana 	"syspll4_d2",
197*43c04ed7SYassine Oudjana 	"univpll2_d4",
198*43c04ed7SYassine Oudjana 	"univpll1_d8"
199*43c04ed7SYassine Oudjana };
200*43c04ed7SYassine Oudjana 
201*43c04ed7SYassine Oudjana static const char * const usb20_sel_parents[] = {
202*43c04ed7SYassine Oudjana 	"clk26m",
203*43c04ed7SYassine Oudjana 	"univpll1_d8",
204*43c04ed7SYassine Oudjana 	"univpll3_d4"
205*43c04ed7SYassine Oudjana };
206*43c04ed7SYassine Oudjana 
207*43c04ed7SYassine Oudjana static const char * const msdc50_0_sel_parents[] = {
208*43c04ed7SYassine Oudjana 	"clk26m",
209*43c04ed7SYassine Oudjana 	"syspll1_d2",
210*43c04ed7SYassine Oudjana 	"syspll2_d2",
211*43c04ed7SYassine Oudjana 	"syspll4_d2",
212*43c04ed7SYassine Oudjana 	"univpll_d5",
213*43c04ed7SYassine Oudjana 	"univpll1_d4"
214*43c04ed7SYassine Oudjana };
215*43c04ed7SYassine Oudjana 
216*43c04ed7SYassine Oudjana static const char * const msdc30_0_sel_parents[] = {
217*43c04ed7SYassine Oudjana 	"clk26m",
218*43c04ed7SYassine Oudjana 	"msdcpll",
219*43c04ed7SYassine Oudjana 	"msdcpll_d2",
220*43c04ed7SYassine Oudjana 	"msdcpll_d4",
221*43c04ed7SYassine Oudjana 	"syspll2_d2",
222*43c04ed7SYassine Oudjana 	"syspll1_d4",
223*43c04ed7SYassine Oudjana 	"univpll1_d4",
224*43c04ed7SYassine Oudjana 	"univpll_d3",
225*43c04ed7SYassine Oudjana 	"univpll_d26",
226*43c04ed7SYassine Oudjana 	"syspll2_d4",
227*43c04ed7SYassine Oudjana 	"univpll_d2"
228*43c04ed7SYassine Oudjana };
229*43c04ed7SYassine Oudjana 
230*43c04ed7SYassine Oudjana static const char * const msdc30_1_2_sel_parents[] = {
231*43c04ed7SYassine Oudjana 	"clk26m",
232*43c04ed7SYassine Oudjana 	"univpll2_d2",
233*43c04ed7SYassine Oudjana 	"msdcpll_d4",
234*43c04ed7SYassine Oudjana 	"syspll2_d2",
235*43c04ed7SYassine Oudjana 	"syspll1_d4",
236*43c04ed7SYassine Oudjana 	"univpll1_d4",
237*43c04ed7SYassine Oudjana 	"univpll_d26",
238*43c04ed7SYassine Oudjana 	"syspll2_d4"
239*43c04ed7SYassine Oudjana };
240*43c04ed7SYassine Oudjana 
241*43c04ed7SYassine Oudjana static const char * const msdc30_3_sel_parents[] = {
242*43c04ed7SYassine Oudjana 	"clk26m",
243*43c04ed7SYassine Oudjana 	"univpll2_d2",
244*43c04ed7SYassine Oudjana 	"msdcpll_d4",
245*43c04ed7SYassine Oudjana 	"syspll2_d2",
246*43c04ed7SYassine Oudjana 	"syspll1_d4",
247*43c04ed7SYassine Oudjana 	"univpll1_d4",
248*43c04ed7SYassine Oudjana 	"univpll_d26",
249*43c04ed7SYassine Oudjana 	"msdcpll_d16",
250*43c04ed7SYassine Oudjana 	"syspll2_d4"
251*43c04ed7SYassine Oudjana };
252*43c04ed7SYassine Oudjana 
253*43c04ed7SYassine Oudjana static const char * const audio_sel_parents[] = {
254*43c04ed7SYassine Oudjana 	"clk26m",
255*43c04ed7SYassine Oudjana 	"syspll3_d4",
256*43c04ed7SYassine Oudjana 	"syspll4_d4",
257*43c04ed7SYassine Oudjana 	"syspll1_d16"
258*43c04ed7SYassine Oudjana };
259*43c04ed7SYassine Oudjana 
260*43c04ed7SYassine Oudjana static const char * const aud_intbus_sel_parents[] = {
261*43c04ed7SYassine Oudjana 	"clk26m",
262*43c04ed7SYassine Oudjana 	"syspll1_d4",
263*43c04ed7SYassine Oudjana 	"syspll4_d2",
264*43c04ed7SYassine Oudjana 	"dmpll_d4"
265*43c04ed7SYassine Oudjana };
266*43c04ed7SYassine Oudjana 
267*43c04ed7SYassine Oudjana static const char * const pmicspi_sel_parents[] = {
268*43c04ed7SYassine Oudjana 	"clk26m",
269*43c04ed7SYassine Oudjana 	"syspll1_d8",
270*43c04ed7SYassine Oudjana 	"syspll3_d4",
271*43c04ed7SYassine Oudjana 	"syspll1_d16",
272*43c04ed7SYassine Oudjana 	"univpll3_d4",
273*43c04ed7SYassine Oudjana 	"univpll_d26",
274*43c04ed7SYassine Oudjana 	"dmpll_d4",
275*43c04ed7SYassine Oudjana 	"dmpll_d8"
276*43c04ed7SYassine Oudjana };
277*43c04ed7SYassine Oudjana 
278*43c04ed7SYassine Oudjana static const char * const scp_sel_parents[] = {
279*43c04ed7SYassine Oudjana 	"clk26m",
280*43c04ed7SYassine Oudjana 	"syspll1_d8",
281*43c04ed7SYassine Oudjana 	"dmpll_d2",
282*43c04ed7SYassine Oudjana 	"dmpll_d4"
283*43c04ed7SYassine Oudjana };
284*43c04ed7SYassine Oudjana 
285*43c04ed7SYassine Oudjana static const char * const atb_sel_parents[] = {
286*43c04ed7SYassine Oudjana 	"clk26m",
287*43c04ed7SYassine Oudjana 	"syspll1_d2",
288*43c04ed7SYassine Oudjana 	"syspll_d5",
289*43c04ed7SYassine Oudjana 	"dmpll"
290*43c04ed7SYassine Oudjana };
291*43c04ed7SYassine Oudjana 
292*43c04ed7SYassine Oudjana static const char * const dpi0_sel_parents[] = {
293*43c04ed7SYassine Oudjana 	"clk26m",
294*43c04ed7SYassine Oudjana 	"tvdpll",
295*43c04ed7SYassine Oudjana 	"tvdpll_d2",
296*43c04ed7SYassine Oudjana 	"tvdpll_d4",
297*43c04ed7SYassine Oudjana 	"dpi_ck"
298*43c04ed7SYassine Oudjana };
299*43c04ed7SYassine Oudjana 
300*43c04ed7SYassine Oudjana static const char * const scam_sel_parents[] = {
301*43c04ed7SYassine Oudjana 	"clk26m",
302*43c04ed7SYassine Oudjana 	"syspll3_d2",
303*43c04ed7SYassine Oudjana 	"univpll2_d4",
304*43c04ed7SYassine Oudjana 	"vencpll_d3"
305*43c04ed7SYassine Oudjana };
306*43c04ed7SYassine Oudjana 
307*43c04ed7SYassine Oudjana static const char * const mfg13m_sel_parents[] = {
308*43c04ed7SYassine Oudjana 	"clk26m",
309*43c04ed7SYassine Oudjana 	"ad_sys_26m_d2"
310*43c04ed7SYassine Oudjana };
311*43c04ed7SYassine Oudjana 
312*43c04ed7SYassine Oudjana static const char * const aud_1_2_sel_parents[] = {
313*43c04ed7SYassine Oudjana 	"clk26m",
314*43c04ed7SYassine Oudjana 	"apll1"
315*43c04ed7SYassine Oudjana };
316*43c04ed7SYassine Oudjana 
317*43c04ed7SYassine Oudjana static const char * const irda_sel_parents[] = {
318*43c04ed7SYassine Oudjana 	"clk26m",
319*43c04ed7SYassine Oudjana 	"univpll2_d4"
320*43c04ed7SYassine Oudjana };
321*43c04ed7SYassine Oudjana 
322*43c04ed7SYassine Oudjana static const char * const irtx_sel_parents[] = {
323*43c04ed7SYassine Oudjana 	"clk26m",
324*43c04ed7SYassine Oudjana 	"ad_sys_26m_ck"
325*43c04ed7SYassine Oudjana };
326*43c04ed7SYassine Oudjana 
327*43c04ed7SYassine Oudjana static const char * const disppwm_sel_parents[] = {
328*43c04ed7SYassine Oudjana 	"clk26m",
329*43c04ed7SYassine Oudjana 	"univpll2_d4",
330*43c04ed7SYassine Oudjana 	"syspll4_d2_d8",
331*43c04ed7SYassine Oudjana 	"ad_sys_26m_ck"
332*43c04ed7SYassine Oudjana };
333*43c04ed7SYassine Oudjana 
334*43c04ed7SYassine Oudjana static const struct mtk_mux topckgen_muxes[] = {
335*43c04ed7SYassine Oudjana 	MUX_CLR_SET_UPD(CLK_TOP_AXI_SEL, "axi_sel", axi_sel_parents, CLK_CFG_0, CLK_CFG_0_SET, CLK_CFG_0_CLR, 0, 3, 0, 0),
336*43c04ed7SYassine Oudjana 	MUX_CLR_SET_UPD(CLK_TOP_MEM_SEL, "mem_sel", mem_sel_parents, CLK_CFG_0, CLK_CFG_0_SET, CLK_CFG_0_CLR, 8, 1, 0, 0),
337*43c04ed7SYassine Oudjana 	MUX_CLR_SET_UPD(CLK_TOP_DDRPHY_SEL, "ddrphycfg_sel", ddrphycfg_parents, CLK_CFG_0, CLK_CFG_0_SET, CLK_CFG_0_CLR, 16, 1, 0, 0),
338*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MM_SEL, "mm_sel", mm_sel_parents, CLK_CFG_0, CLK_CFG_0_SET, CLK_CFG_0_CLR, 24, 3, 31, 0, 0),
339*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM_SEL, "pwm_sel", pwm_sel_parents, CLK_CFG_1, CLK_CFG_1_SET, CLK_CFG_1_CLR, 0, 2, 7, 0, 0),
340*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_sel_parents, CLK_CFG_1, CLK_CFG_1_SET, CLK_CFG_1_CLR, 8, 3, 15, 0, 0),
341*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_SEL, "mfg_sel", mfg_sel_parents, CLK_CFG_1, CLK_CFG_1_SET, CLK_CFG_1_CLR, 16, 4, 23, 0, 0),
342*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_sel_parents, CLK_CFG_1, CLK_CFG_1_SET, CLK_CFG_1_CLR, 24, 3, 31, 0, 0),
343*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_UART_SEL, "uart_sel", uart_sel_parents, CLK_CFG_2, CLK_CFG_2_SET, CLK_CFG_2_CLR, 0, 1, 7, 0, 0),
344*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI_SEL, "spi_sel", spi_sel_parents, CLK_CFG_2, CLK_CFG_2_SET, CLK_CFG_2_CLR, 8, 3, 15, 0, 0),
345*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_USB20_SEL, "usb20_sel", usb20_sel_parents, CLK_CFG_2, CLK_CFG_2_SET, CLK_CFG_2_CLR, 16, 2, 23, 0, 0),
346*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel", msdc50_0_sel_parents, CLK_CFG_2, CLK_CFG_2_SET, CLK_CFG_2_CLR, 24, 3, 31, 0, 0),
347*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_0_SEL, "msdc30_0_sel", msdc30_0_sel_parents, CLK_CFG_3, CLK_CFG_3_SET, CLK_CFG_3_CLR, 0, 4, 7, 0, 0),
348*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_1_2_sel_parents, CLK_CFG_3, CLK_CFG_3_SET, CLK_CFG_3_CLR, 8, 3, 15, 0, 0),
349*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_1_2_sel_parents, CLK_CFG_3, CLK_CFG_3_SET, CLK_CFG_3_CLR, 16, 3, 23, 0, 0),
350*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_3_sel_parents, CLK_CFG_3, CLK_CFG_3_SET, CLK_CFG_3_CLR, 24, 4, 31, 0, 0),
351*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_SEL, "audio_sel", audio_sel_parents, CLK_CFG_4, CLK_CFG_4_SET, CLK_CFG_4_CLR, 0, 2, 7, 0, 0),
352*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDINTBUS_SEL, "aud_intbus_sel", aud_intbus_sel_parents, CLK_CFG_4, CLK_CFG_4_SET, CLK_CFG_4_CLR, 8, 2, 15, 0, 0),
353*43c04ed7SYassine Oudjana 	MUX_CLR_SET_UPD(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_sel_parents, CLK_CFG_4, CLK_CFG_4_SET, CLK_CFG_4_CLR, 16, 3, 0, 0),
354*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_SCP_SEL, "scp_sel", scp_sel_parents, CLK_CFG_4, CLK_CFG_4_SET, CLK_CFG_4_CLR, 24, 2, 31, 0, 0),
355*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_ATB_SEL, "atb_sel", atb_sel_parents, CLK_CFG_5, CLK_CFG_5_SET, CLK_CFG_5_CLR, 0, 2, 7, 0, 0),
356*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_sel_parents, CLK_CFG_5, CLK_CFG_5_SET, CLK_CFG_5_CLR, 8, 3, 15, 0, 0),
357*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_SCAM_SEL, "scam_sel", scam_sel_parents, CLK_CFG_5, CLK_CFG_5_SET, CLK_CFG_5_CLR, 16, 2, 23, 0, 0),
358*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG13M_SEL, "mfg13m_sel", mfg13m_sel_parents, CLK_CFG_5, CLK_CFG_5_SET, CLK_CFG_5_CLR, 24, 1, 31, 0, 0),
359*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD1_SEL, "aud_1_sel", aud_1_2_sel_parents, CLK_CFG_6, CLK_CFG_6_SET, CLK_CFG_6_CLR, 0, 1, 7, 0, 0),
360*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD2_SEL, "aud_2_sel", aud_1_2_sel_parents, CLK_CFG_6, CLK_CFG_6_SET, CLK_CFG_6_CLR, 8, 1, 15, 0, 0),
361*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_IRDA_SEL, "irda_sel", irda_sel_parents, CLK_CFG_6, CLK_CFG_6_SET, CLK_CFG_6_CLR, 16, 1, 23, 0, 0),
362*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_IRTX_SEL, "irtx_sel", irtx_sel_parents, CLK_CFG_6, CLK_CFG_6_SET, CLK_CFG_6_CLR, 24, 1, 31, 0, 0),
363*43c04ed7SYassine Oudjana 	MUX_GATE_CLR_SET_UPD(CLK_TOP_DISPPWM_SEL, "disppwm_sel", disppwm_sel_parents, CLK_CFG_7, CLK_CFG_7_SET, CLK_CFG_7_CLR, 0, 2, 7, 0, 0),
364*43c04ed7SYassine Oudjana };
365*43c04ed7SYassine Oudjana 
366*43c04ed7SYassine Oudjana static const struct mtk_clk_desc topckgen_desc = {
367*43c04ed7SYassine Oudjana 	.fixed_clks = topckgen_fixed_clks,
368*43c04ed7SYassine Oudjana 	.num_fixed_clks = ARRAY_SIZE(topckgen_fixed_clks),
369*43c04ed7SYassine Oudjana 	.factor_clks = topckgen_factors,
370*43c04ed7SYassine Oudjana 	.num_factor_clks = ARRAY_SIZE(topckgen_factors),
371*43c04ed7SYassine Oudjana 	.mux_clks = topckgen_muxes,
372*43c04ed7SYassine Oudjana 	.num_mux_clks = ARRAY_SIZE(topckgen_muxes),
373*43c04ed7SYassine Oudjana 	.clk_lock = &mt6735_topckgen_lock,
374*43c04ed7SYassine Oudjana };
375*43c04ed7SYassine Oudjana 
376*43c04ed7SYassine Oudjana static const struct of_device_id of_match_mt6735_topckgen[] = {
377*43c04ed7SYassine Oudjana 	{ .compatible = "mediatek,mt6735-topckgen", .data = &topckgen_desc},
378*43c04ed7SYassine Oudjana 	{ /* sentinel */ }
379*43c04ed7SYassine Oudjana };
380*43c04ed7SYassine Oudjana MODULE_DEVICE_TABLE(of, of_match_mt6735_topckgen);
381*43c04ed7SYassine Oudjana 
382*43c04ed7SYassine Oudjana static struct platform_driver clk_mt6735_topckgen = {
383*43c04ed7SYassine Oudjana 	.probe = mtk_clk_simple_probe,
384*43c04ed7SYassine Oudjana 	.remove = mtk_clk_simple_remove,
385*43c04ed7SYassine Oudjana 	.driver = {
386*43c04ed7SYassine Oudjana 		.name = "clk-mt6735-topckgen",
387*43c04ed7SYassine Oudjana 		.of_match_table = of_match_mt6735_topckgen,
388*43c04ed7SYassine Oudjana 	},
389*43c04ed7SYassine Oudjana };
390*43c04ed7SYassine Oudjana module_platform_driver(clk_mt6735_topckgen);
391*43c04ed7SYassine Oudjana 
392*43c04ed7SYassine Oudjana MODULE_AUTHOR("Yassine Oudjana <y.oudjana@protonmail.com>");
393*43c04ed7SYassine Oudjana MODULE_DESCRIPTION("MediaTek MT6735 topckgen clock driver");
394*43c04ed7SYassine Oudjana MODULE_LICENSE("GPL");
395