1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Amlogic Meson-G12A Clock Controller Driver
4 *
5 * Copyright (c) 2016 Baylibre SAS.
6 * Author: Michael Turquette <mturquette@baylibre.com>
7 *
8 * Copyright (c) 2018 Amlogic, inc.
9 * Author: Qiufang Dai <qiufang.dai@amlogic.com>
10 * Author: Jian Hu <jian.hu@amlogic.com>
11 */
12
13 #include <linux/clk-provider.h>
14 #include <linux/init.h>
15 #include <linux/of.h>
16 #include <linux/platform_device.h>
17 #include <linux/clk.h>
18 #include <linux/module.h>
19
20 #include "clk-mpll.h"
21 #include "clk-pll.h"
22 #include "clk-regmap.h"
23 #include "clk-cpu-dyndiv.h"
24 #include "vid-pll-div.h"
25 #include "vclk.h"
26 #include "meson-eeclk.h"
27
28 #include <dt-bindings/clock/g12a-clkc.h>
29
30 #define HHI_MIPI_CNTL0 0x000
31 #define HHI_MIPI_CNTL1 0x004
32 #define HHI_MIPI_CNTL2 0x008
33 #define HHI_MIPI_STS 0x00c
34 #define HHI_GP0_PLL_CNTL0 0x040
35 #define HHI_GP0_PLL_CNTL1 0x044
36 #define HHI_GP0_PLL_CNTL2 0x048
37 #define HHI_GP0_PLL_CNTL3 0x04c
38 #define HHI_GP0_PLL_CNTL4 0x050
39 #define HHI_GP0_PLL_CNTL5 0x054
40 #define HHI_GP0_PLL_CNTL6 0x058
41 #define HHI_GP0_PLL_STS 0x05c
42 #define HHI_GP1_PLL_CNTL0 0x060
43 #define HHI_GP1_PLL_CNTL1 0x064
44 #define HHI_GP1_PLL_CNTL2 0x068
45 #define HHI_GP1_PLL_CNTL3 0x06c
46 #define HHI_GP1_PLL_CNTL4 0x070
47 #define HHI_GP1_PLL_CNTL5 0x074
48 #define HHI_GP1_PLL_CNTL6 0x078
49 #define HHI_GP1_PLL_STS 0x07c
50 #define HHI_PCIE_PLL_CNTL0 0x098
51 #define HHI_PCIE_PLL_CNTL1 0x09c
52 #define HHI_PCIE_PLL_CNTL2 0x0a0
53 #define HHI_PCIE_PLL_CNTL3 0x0a4
54 #define HHI_PCIE_PLL_CNTL4 0x0a8
55 #define HHI_PCIE_PLL_CNTL5 0x0ac
56 #define HHI_PCIE_PLL_STS 0x0b8
57 #define HHI_HIFI_PLL_CNTL0 0x0d8
58 #define HHI_HIFI_PLL_CNTL1 0x0dc
59 #define HHI_HIFI_PLL_CNTL2 0x0e0
60 #define HHI_HIFI_PLL_CNTL3 0x0e4
61 #define HHI_HIFI_PLL_CNTL4 0x0e8
62 #define HHI_HIFI_PLL_CNTL5 0x0ec
63 #define HHI_HIFI_PLL_CNTL6 0x0f0
64 #define HHI_VIID_CLK_DIV 0x128
65 #define HHI_VIID_CLK_CNTL 0x12c
66 #define HHI_GCLK_MPEG0 0x140
67 #define HHI_GCLK_MPEG1 0x144
68 #define HHI_GCLK_MPEG2 0x148
69 #define HHI_GCLK_OTHER 0x150
70 #define HHI_GCLK_OTHER2 0x154
71 #define HHI_SYS_CPU_CLK_CNTL1 0x15c
72 #define HHI_VID_CLK_DIV 0x164
73 #define HHI_MPEG_CLK_CNTL 0x174
74 #define HHI_AUD_CLK_CNTL 0x178
75 #define HHI_VID_CLK_CNTL 0x17c
76 #define HHI_TS_CLK_CNTL 0x190
77 #define HHI_VID_CLK_CNTL2 0x194
78 #define HHI_SYS_CPU_CLK_CNTL0 0x19c
79 #define HHI_VID_PLL_CLK_DIV 0x1a0
80 #define HHI_MALI_CLK_CNTL 0x1b0
81 #define HHI_VPU_CLKC_CNTL 0x1b4
82 #define HHI_VPU_CLK_CNTL 0x1bc
83 #define HHI_ISP_CLK_CNTL 0x1c0
84 #define HHI_NNA_CLK_CNTL 0x1c8
85 #define HHI_HDMI_CLK_CNTL 0x1cc
86 #define HHI_VDEC_CLK_CNTL 0x1e0
87 #define HHI_VDEC2_CLK_CNTL 0x1e4
88 #define HHI_VDEC3_CLK_CNTL 0x1e8
89 #define HHI_VDEC4_CLK_CNTL 0x1ec
90 #define HHI_HDCP22_CLK_CNTL 0x1f0
91 #define HHI_VAPBCLK_CNTL 0x1f4
92 #define HHI_SYS_CPUB_CLK_CNTL1 0x200
93 #define HHI_SYS_CPUB_CLK_CNTL 0x208
94 #define HHI_VPU_CLKB_CNTL 0x20c
95 #define HHI_SYS_CPU_CLK_CNTL2 0x210
96 #define HHI_SYS_CPU_CLK_CNTL3 0x214
97 #define HHI_SYS_CPU_CLK_CNTL4 0x218
98 #define HHI_SYS_CPU_CLK_CNTL5 0x21c
99 #define HHI_SYS_CPU_CLK_CNTL6 0x220
100 #define HHI_GEN_CLK_CNTL 0x228
101 #define HHI_VDIN_MEAS_CLK_CNTL 0x250
102 #define HHI_MIPIDSI_PHY_CLK_CNTL 0x254
103 #define HHI_NAND_CLK_CNTL 0x25c
104 #define HHI_SD_EMMC_CLK_CNTL 0x264
105 #define HHI_MPLL_CNTL0 0x278
106 #define HHI_MPLL_CNTL1 0x27c
107 #define HHI_MPLL_CNTL2 0x280
108 #define HHI_MPLL_CNTL3 0x284
109 #define HHI_MPLL_CNTL4 0x288
110 #define HHI_MPLL_CNTL5 0x28c
111 #define HHI_MPLL_CNTL6 0x290
112 #define HHI_MPLL_CNTL7 0x294
113 #define HHI_MPLL_CNTL8 0x298
114 #define HHI_FIX_PLL_CNTL0 0x2a0
115 #define HHI_FIX_PLL_CNTL1 0x2a4
116 #define HHI_FIX_PLL_CNTL3 0x2ac
117 #define HHI_SYS_PLL_CNTL0 0x2f4
118 #define HHI_SYS_PLL_CNTL1 0x2f8
119 #define HHI_SYS_PLL_CNTL2 0x2fc
120 #define HHI_SYS_PLL_CNTL3 0x300
121 #define HHI_SYS_PLL_CNTL4 0x304
122 #define HHI_SYS_PLL_CNTL5 0x308
123 #define HHI_SYS_PLL_CNTL6 0x30c
124 #define HHI_HDMI_PLL_CNTL0 0x320
125 #define HHI_HDMI_PLL_CNTL1 0x324
126 #define HHI_HDMI_PLL_CNTL2 0x328
127 #define HHI_HDMI_PLL_CNTL3 0x32c
128 #define HHI_HDMI_PLL_CNTL4 0x330
129 #define HHI_HDMI_PLL_CNTL5 0x334
130 #define HHI_HDMI_PLL_CNTL6 0x338
131 #define HHI_SPICC_CLK_CNTL 0x3dc
132 #define HHI_SYS1_PLL_CNTL0 0x380
133 #define HHI_SYS1_PLL_CNTL1 0x384
134 #define HHI_SYS1_PLL_CNTL2 0x388
135 #define HHI_SYS1_PLL_CNTL3 0x38c
136 #define HHI_SYS1_PLL_CNTL4 0x390
137 #define HHI_SYS1_PLL_CNTL5 0x394
138 #define HHI_SYS1_PLL_CNTL6 0x398
139
140 static struct clk_regmap g12a_fixed_pll_dco = {
141 .data = &(struct meson_clk_pll_data){
142 .en = {
143 .reg_off = HHI_FIX_PLL_CNTL0,
144 .shift = 28,
145 .width = 1,
146 },
147 .m = {
148 .reg_off = HHI_FIX_PLL_CNTL0,
149 .shift = 0,
150 .width = 8,
151 },
152 .n = {
153 .reg_off = HHI_FIX_PLL_CNTL0,
154 .shift = 10,
155 .width = 5,
156 },
157 .frac = {
158 .reg_off = HHI_FIX_PLL_CNTL1,
159 .shift = 0,
160 .width = 17,
161 },
162 .l = {
163 .reg_off = HHI_FIX_PLL_CNTL0,
164 .shift = 31,
165 .width = 1,
166 },
167 .rst = {
168 .reg_off = HHI_FIX_PLL_CNTL0,
169 .shift = 29,
170 .width = 1,
171 },
172 },
173 .hw.init = &(struct clk_init_data){
174 .name = "fixed_pll_dco",
175 .ops = &meson_clk_pll_ro_ops,
176 .parent_data = &(const struct clk_parent_data) {
177 .fw_name = "xtal",
178 },
179 .num_parents = 1,
180 },
181 };
182
183 static struct clk_regmap g12a_fixed_pll = {
184 .data = &(struct clk_regmap_div_data){
185 .offset = HHI_FIX_PLL_CNTL0,
186 .shift = 16,
187 .width = 2,
188 .flags = CLK_DIVIDER_POWER_OF_TWO,
189 },
190 .hw.init = &(struct clk_init_data){
191 .name = "fixed_pll",
192 .ops = &clk_regmap_divider_ro_ops,
193 .parent_hws = (const struct clk_hw *[]) {
194 &g12a_fixed_pll_dco.hw
195 },
196 .num_parents = 1,
197 /*
198 * This clock won't ever change at runtime so
199 * CLK_SET_RATE_PARENT is not required
200 */
201 },
202 };
203
204 static const struct pll_mult_range g12a_sys_pll_mult_range = {
205 .min = 128,
206 .max = 250,
207 };
208
209 static struct clk_regmap g12a_sys_pll_dco = {
210 .data = &(struct meson_clk_pll_data){
211 .en = {
212 .reg_off = HHI_SYS_PLL_CNTL0,
213 .shift = 28,
214 .width = 1,
215 },
216 .m = {
217 .reg_off = HHI_SYS_PLL_CNTL0,
218 .shift = 0,
219 .width = 8,
220 },
221 .n = {
222 .reg_off = HHI_SYS_PLL_CNTL0,
223 .shift = 10,
224 .width = 5,
225 },
226 .l = {
227 .reg_off = HHI_SYS_PLL_CNTL0,
228 .shift = 31,
229 .width = 1,
230 },
231 .rst = {
232 .reg_off = HHI_SYS_PLL_CNTL0,
233 .shift = 29,
234 .width = 1,
235 },
236 .range = &g12a_sys_pll_mult_range,
237 },
238 .hw.init = &(struct clk_init_data){
239 .name = "sys_pll_dco",
240 .ops = &meson_clk_pll_ops,
241 .parent_data = &(const struct clk_parent_data) {
242 .fw_name = "xtal",
243 },
244 .num_parents = 1,
245 /* This clock feeds the CPU, avoid disabling it */
246 .flags = CLK_IS_CRITICAL,
247 },
248 };
249
250 static struct clk_regmap g12a_sys_pll = {
251 .data = &(struct clk_regmap_div_data){
252 .offset = HHI_SYS_PLL_CNTL0,
253 .shift = 16,
254 .width = 3,
255 .flags = CLK_DIVIDER_POWER_OF_TWO,
256 },
257 .hw.init = &(struct clk_init_data){
258 .name = "sys_pll",
259 .ops = &clk_regmap_divider_ops,
260 .parent_hws = (const struct clk_hw *[]) {
261 &g12a_sys_pll_dco.hw
262 },
263 .num_parents = 1,
264 .flags = CLK_SET_RATE_PARENT,
265 },
266 };
267
268 static struct clk_regmap g12b_sys1_pll_dco = {
269 .data = &(struct meson_clk_pll_data){
270 .en = {
271 .reg_off = HHI_SYS1_PLL_CNTL0,
272 .shift = 28,
273 .width = 1,
274 },
275 .m = {
276 .reg_off = HHI_SYS1_PLL_CNTL0,
277 .shift = 0,
278 .width = 8,
279 },
280 .n = {
281 .reg_off = HHI_SYS1_PLL_CNTL0,
282 .shift = 10,
283 .width = 5,
284 },
285 .l = {
286 .reg_off = HHI_SYS1_PLL_CNTL0,
287 .shift = 31,
288 .width = 1,
289 },
290 .rst = {
291 .reg_off = HHI_SYS1_PLL_CNTL0,
292 .shift = 29,
293 .width = 1,
294 },
295 .range = &g12a_sys_pll_mult_range,
296 },
297 .hw.init = &(struct clk_init_data){
298 .name = "sys1_pll_dco",
299 .ops = &meson_clk_pll_ops,
300 .parent_data = &(const struct clk_parent_data) {
301 .fw_name = "xtal",
302 },
303 .num_parents = 1,
304 /* This clock feeds the CPU, avoid disabling it */
305 .flags = CLK_IS_CRITICAL,
306 },
307 };
308
309 static struct clk_regmap g12b_sys1_pll = {
310 .data = &(struct clk_regmap_div_data){
311 .offset = HHI_SYS1_PLL_CNTL0,
312 .shift = 16,
313 .width = 3,
314 .flags = CLK_DIVIDER_POWER_OF_TWO,
315 },
316 .hw.init = &(struct clk_init_data){
317 .name = "sys1_pll",
318 .ops = &clk_regmap_divider_ops,
319 .parent_hws = (const struct clk_hw *[]) {
320 &g12b_sys1_pll_dco.hw
321 },
322 .num_parents = 1,
323 .flags = CLK_SET_RATE_PARENT,
324 },
325 };
326
327 static struct clk_regmap g12a_sys_pll_div16_en = {
328 .data = &(struct clk_regmap_gate_data){
329 .offset = HHI_SYS_CPU_CLK_CNTL1,
330 .bit_idx = 24,
331 },
332 .hw.init = &(struct clk_init_data) {
333 .name = "sys_pll_div16_en",
334 .ops = &clk_regmap_gate_ro_ops,
335 .parent_hws = (const struct clk_hw *[]) { &g12a_sys_pll.hw },
336 .num_parents = 1,
337 /*
338 * This clock is used to debug the sys_pll range
339 * Linux should not change it at runtime
340 */
341 },
342 };
343
344 static struct clk_regmap g12b_sys1_pll_div16_en = {
345 .data = &(struct clk_regmap_gate_data){
346 .offset = HHI_SYS_CPUB_CLK_CNTL1,
347 .bit_idx = 24,
348 },
349 .hw.init = &(struct clk_init_data) {
350 .name = "sys1_pll_div16_en",
351 .ops = &clk_regmap_gate_ro_ops,
352 .parent_hws = (const struct clk_hw *[]) {
353 &g12b_sys1_pll.hw
354 },
355 .num_parents = 1,
356 /*
357 * This clock is used to debug the sys_pll range
358 * Linux should not change it at runtime
359 */
360 },
361 };
362
363 static struct clk_fixed_factor g12a_sys_pll_div16 = {
364 .mult = 1,
365 .div = 16,
366 .hw.init = &(struct clk_init_data){
367 .name = "sys_pll_div16",
368 .ops = &clk_fixed_factor_ops,
369 .parent_hws = (const struct clk_hw *[]) {
370 &g12a_sys_pll_div16_en.hw
371 },
372 .num_parents = 1,
373 },
374 };
375
376 static struct clk_fixed_factor g12b_sys1_pll_div16 = {
377 .mult = 1,
378 .div = 16,
379 .hw.init = &(struct clk_init_data){
380 .name = "sys1_pll_div16",
381 .ops = &clk_fixed_factor_ops,
382 .parent_hws = (const struct clk_hw *[]) {
383 &g12b_sys1_pll_div16_en.hw
384 },
385 .num_parents = 1,
386 },
387 };
388
389 static struct clk_fixed_factor g12a_fclk_div2_div = {
390 .mult = 1,
391 .div = 2,
392 .hw.init = &(struct clk_init_data){
393 .name = "fclk_div2_div",
394 .ops = &clk_fixed_factor_ops,
395 .parent_hws = (const struct clk_hw *[]) { &g12a_fixed_pll.hw },
396 .num_parents = 1,
397 },
398 };
399
400 static struct clk_regmap g12a_fclk_div2 = {
401 .data = &(struct clk_regmap_gate_data){
402 .offset = HHI_FIX_PLL_CNTL1,
403 .bit_idx = 24,
404 },
405 .hw.init = &(struct clk_init_data){
406 .name = "fclk_div2",
407 .ops = &clk_regmap_gate_ops,
408 .parent_hws = (const struct clk_hw *[]) {
409 &g12a_fclk_div2_div.hw
410 },
411 .num_parents = 1,
412 /*
413 * Similar to fclk_div3, it seems that this clock is used by
414 * the resident firmware and is required by the platform to
415 * operate correctly.
416 * Until the following condition are met, we need this clock to
417 * be marked as critical:
418 * a) Mark the clock used by a firmware resource, if possible
419 * b) CCF has a clock hand-off mechanism to make the sure the
420 * clock stays on until the proper driver comes along
421 */
422 .flags = CLK_IS_CRITICAL,
423 },
424 };
425
426 static struct clk_fixed_factor g12a_fclk_div3_div = {
427 .mult = 1,
428 .div = 3,
429 .hw.init = &(struct clk_init_data){
430 .name = "fclk_div3_div",
431 .ops = &clk_fixed_factor_ops,
432 .parent_hws = (const struct clk_hw *[]) { &g12a_fixed_pll.hw },
433 .num_parents = 1,
434 },
435 };
436
437 static struct clk_regmap g12a_fclk_div3 = {
438 .data = &(struct clk_regmap_gate_data){
439 .offset = HHI_FIX_PLL_CNTL1,
440 .bit_idx = 20,
441 },
442 .hw.init = &(struct clk_init_data){
443 .name = "fclk_div3",
444 .ops = &clk_regmap_gate_ops,
445 .parent_hws = (const struct clk_hw *[]) {
446 &g12a_fclk_div3_div.hw
447 },
448 .num_parents = 1,
449 /*
450 * This clock is used by the resident firmware and is required
451 * by the platform to operate correctly.
452 * Until the following condition are met, we need this clock to
453 * be marked as critical:
454 * a) Mark the clock used by a firmware resource, if possible
455 * b) CCF has a clock hand-off mechanism to make the sure the
456 * clock stays on until the proper driver comes along
457 */
458 .flags = CLK_IS_CRITICAL,
459 },
460 };
461
462 /* Datasheet names this field as "premux0" */
463 static struct clk_regmap g12a_cpu_clk_premux0 = {
464 .data = &(struct clk_regmap_mux_data){
465 .offset = HHI_SYS_CPU_CLK_CNTL0,
466 .mask = 0x3,
467 .shift = 0,
468 .flags = CLK_MUX_ROUND_CLOSEST,
469 },
470 .hw.init = &(struct clk_init_data){
471 .name = "cpu_clk_dyn0_sel",
472 .ops = &clk_regmap_mux_ops,
473 .parent_data = (const struct clk_parent_data []) {
474 { .fw_name = "xtal", },
475 { .hw = &g12a_fclk_div2.hw },
476 { .hw = &g12a_fclk_div3.hw },
477 },
478 .num_parents = 3,
479 .flags = CLK_SET_RATE_PARENT,
480 },
481 };
482
483 /* Datasheet names this field as "premux1" */
484 static struct clk_regmap g12a_cpu_clk_premux1 = {
485 .data = &(struct clk_regmap_mux_data){
486 .offset = HHI_SYS_CPU_CLK_CNTL0,
487 .mask = 0x3,
488 .shift = 16,
489 },
490 .hw.init = &(struct clk_init_data){
491 .name = "cpu_clk_dyn1_sel",
492 .ops = &clk_regmap_mux_ops,
493 .parent_data = (const struct clk_parent_data []) {
494 { .fw_name = "xtal", },
495 { .hw = &g12a_fclk_div2.hw },
496 { .hw = &g12a_fclk_div3.hw },
497 },
498 .num_parents = 3,
499 /* This sub-tree is used a parking clock */
500 .flags = CLK_SET_RATE_NO_REPARENT
501 },
502 };
503
504 /* Datasheet names this field as "mux0_divn_tcnt" */
505 static struct clk_regmap g12a_cpu_clk_mux0_div = {
506 .data = &(struct meson_clk_cpu_dyndiv_data){
507 .div = {
508 .reg_off = HHI_SYS_CPU_CLK_CNTL0,
509 .shift = 4,
510 .width = 6,
511 },
512 .dyn = {
513 .reg_off = HHI_SYS_CPU_CLK_CNTL0,
514 .shift = 26,
515 .width = 1,
516 },
517 },
518 .hw.init = &(struct clk_init_data){
519 .name = "cpu_clk_dyn0_div",
520 .ops = &meson_clk_cpu_dyndiv_ops,
521 .parent_hws = (const struct clk_hw *[]) {
522 &g12a_cpu_clk_premux0.hw
523 },
524 .num_parents = 1,
525 .flags = CLK_SET_RATE_PARENT,
526 },
527 };
528
529 /* Datasheet names this field as "postmux0" */
530 static struct clk_regmap g12a_cpu_clk_postmux0 = {
531 .data = &(struct clk_regmap_mux_data){
532 .offset = HHI_SYS_CPU_CLK_CNTL0,
533 .mask = 0x1,
534 .shift = 2,
535 .flags = CLK_MUX_ROUND_CLOSEST,
536 },
537 .hw.init = &(struct clk_init_data){
538 .name = "cpu_clk_dyn0",
539 .ops = &clk_regmap_mux_ops,
540 .parent_hws = (const struct clk_hw *[]) {
541 &g12a_cpu_clk_premux0.hw,
542 &g12a_cpu_clk_mux0_div.hw,
543 },
544 .num_parents = 2,
545 .flags = CLK_SET_RATE_PARENT,
546 },
547 };
548
549 /* Datasheet names this field as "Mux1_divn_tcnt" */
550 static struct clk_regmap g12a_cpu_clk_mux1_div = {
551 .data = &(struct clk_regmap_div_data){
552 .offset = HHI_SYS_CPU_CLK_CNTL0,
553 .shift = 20,
554 .width = 6,
555 },
556 .hw.init = &(struct clk_init_data){
557 .name = "cpu_clk_dyn1_div",
558 .ops = &clk_regmap_divider_ro_ops,
559 .parent_hws = (const struct clk_hw *[]) {
560 &g12a_cpu_clk_premux1.hw
561 },
562 .num_parents = 1,
563 },
564 };
565
566 /* Datasheet names this field as "postmux1" */
567 static struct clk_regmap g12a_cpu_clk_postmux1 = {
568 .data = &(struct clk_regmap_mux_data){
569 .offset = HHI_SYS_CPU_CLK_CNTL0,
570 .mask = 0x1,
571 .shift = 18,
572 },
573 .hw.init = &(struct clk_init_data){
574 .name = "cpu_clk_dyn1",
575 .ops = &clk_regmap_mux_ops,
576 .parent_hws = (const struct clk_hw *[]) {
577 &g12a_cpu_clk_premux1.hw,
578 &g12a_cpu_clk_mux1_div.hw,
579 },
580 .num_parents = 2,
581 /* This sub-tree is used a parking clock */
582 .flags = CLK_SET_RATE_NO_REPARENT,
583 },
584 };
585
586 /* Datasheet names this field as "Final_dyn_mux_sel" */
587 static struct clk_regmap g12a_cpu_clk_dyn = {
588 .data = &(struct clk_regmap_mux_data){
589 .offset = HHI_SYS_CPU_CLK_CNTL0,
590 .mask = 0x1,
591 .shift = 10,
592 .flags = CLK_MUX_ROUND_CLOSEST,
593 },
594 .hw.init = &(struct clk_init_data){
595 .name = "cpu_clk_dyn",
596 .ops = &clk_regmap_mux_ops,
597 .parent_hws = (const struct clk_hw *[]) {
598 &g12a_cpu_clk_postmux0.hw,
599 &g12a_cpu_clk_postmux1.hw,
600 },
601 .num_parents = 2,
602 .flags = CLK_SET_RATE_PARENT,
603 },
604 };
605
606 /* Datasheet names this field as "Final_mux_sel" */
607 static struct clk_regmap g12a_cpu_clk = {
608 .data = &(struct clk_regmap_mux_data){
609 .offset = HHI_SYS_CPU_CLK_CNTL0,
610 .mask = 0x1,
611 .shift = 11,
612 .flags = CLK_MUX_ROUND_CLOSEST,
613 },
614 .hw.init = &(struct clk_init_data){
615 .name = "cpu_clk",
616 .ops = &clk_regmap_mux_ops,
617 .parent_hws = (const struct clk_hw *[]) {
618 &g12a_cpu_clk_dyn.hw,
619 &g12a_sys_pll.hw,
620 },
621 .num_parents = 2,
622 .flags = CLK_SET_RATE_PARENT,
623 },
624 };
625
626 /* Datasheet names this field as "Final_mux_sel" */
627 static struct clk_regmap g12b_cpu_clk = {
628 .data = &(struct clk_regmap_mux_data){
629 .offset = HHI_SYS_CPU_CLK_CNTL0,
630 .mask = 0x1,
631 .shift = 11,
632 .flags = CLK_MUX_ROUND_CLOSEST,
633 },
634 .hw.init = &(struct clk_init_data){
635 .name = "cpu_clk",
636 .ops = &clk_regmap_mux_ops,
637 .parent_hws = (const struct clk_hw *[]) {
638 &g12a_cpu_clk_dyn.hw,
639 &g12b_sys1_pll.hw
640 },
641 .num_parents = 2,
642 .flags = CLK_SET_RATE_PARENT,
643 },
644 };
645
646 /* Datasheet names this field as "premux0" */
647 static struct clk_regmap g12b_cpub_clk_premux0 = {
648 .data = &(struct clk_regmap_mux_data){
649 .offset = HHI_SYS_CPUB_CLK_CNTL,
650 .mask = 0x3,
651 .shift = 0,
652 .flags = CLK_MUX_ROUND_CLOSEST,
653 },
654 .hw.init = &(struct clk_init_data){
655 .name = "cpub_clk_dyn0_sel",
656 .ops = &clk_regmap_mux_ops,
657 .parent_data = (const struct clk_parent_data []) {
658 { .fw_name = "xtal", },
659 { .hw = &g12a_fclk_div2.hw },
660 { .hw = &g12a_fclk_div3.hw },
661 },
662 .num_parents = 3,
663 .flags = CLK_SET_RATE_PARENT,
664 },
665 };
666
667 /* Datasheet names this field as "mux0_divn_tcnt" */
668 static struct clk_regmap g12b_cpub_clk_mux0_div = {
669 .data = &(struct meson_clk_cpu_dyndiv_data){
670 .div = {
671 .reg_off = HHI_SYS_CPUB_CLK_CNTL,
672 .shift = 4,
673 .width = 6,
674 },
675 .dyn = {
676 .reg_off = HHI_SYS_CPUB_CLK_CNTL,
677 .shift = 26,
678 .width = 1,
679 },
680 },
681 .hw.init = &(struct clk_init_data){
682 .name = "cpub_clk_dyn0_div",
683 .ops = &meson_clk_cpu_dyndiv_ops,
684 .parent_hws = (const struct clk_hw *[]) {
685 &g12b_cpub_clk_premux0.hw
686 },
687 .num_parents = 1,
688 .flags = CLK_SET_RATE_PARENT,
689 },
690 };
691
692 /* Datasheet names this field as "postmux0" */
693 static struct clk_regmap g12b_cpub_clk_postmux0 = {
694 .data = &(struct clk_regmap_mux_data){
695 .offset = HHI_SYS_CPUB_CLK_CNTL,
696 .mask = 0x1,
697 .shift = 2,
698 .flags = CLK_MUX_ROUND_CLOSEST,
699 },
700 .hw.init = &(struct clk_init_data){
701 .name = "cpub_clk_dyn0",
702 .ops = &clk_regmap_mux_ops,
703 .parent_hws = (const struct clk_hw *[]) {
704 &g12b_cpub_clk_premux0.hw,
705 &g12b_cpub_clk_mux0_div.hw
706 },
707 .num_parents = 2,
708 .flags = CLK_SET_RATE_PARENT,
709 },
710 };
711
712 /* Datasheet names this field as "premux1" */
713 static struct clk_regmap g12b_cpub_clk_premux1 = {
714 .data = &(struct clk_regmap_mux_data){
715 .offset = HHI_SYS_CPUB_CLK_CNTL,
716 .mask = 0x3,
717 .shift = 16,
718 },
719 .hw.init = &(struct clk_init_data){
720 .name = "cpub_clk_dyn1_sel",
721 .ops = &clk_regmap_mux_ops,
722 .parent_data = (const struct clk_parent_data []) {
723 { .fw_name = "xtal", },
724 { .hw = &g12a_fclk_div2.hw },
725 { .hw = &g12a_fclk_div3.hw },
726 },
727 .num_parents = 3,
728 /* This sub-tree is used a parking clock */
729 .flags = CLK_SET_RATE_NO_REPARENT,
730 },
731 };
732
733 /* Datasheet names this field as "Mux1_divn_tcnt" */
734 static struct clk_regmap g12b_cpub_clk_mux1_div = {
735 .data = &(struct clk_regmap_div_data){
736 .offset = HHI_SYS_CPUB_CLK_CNTL,
737 .shift = 20,
738 .width = 6,
739 },
740 .hw.init = &(struct clk_init_data){
741 .name = "cpub_clk_dyn1_div",
742 .ops = &clk_regmap_divider_ro_ops,
743 .parent_hws = (const struct clk_hw *[]) {
744 &g12b_cpub_clk_premux1.hw
745 },
746 .num_parents = 1,
747 },
748 };
749
750 /* Datasheet names this field as "postmux1" */
751 static struct clk_regmap g12b_cpub_clk_postmux1 = {
752 .data = &(struct clk_regmap_mux_data){
753 .offset = HHI_SYS_CPUB_CLK_CNTL,
754 .mask = 0x1,
755 .shift = 18,
756 },
757 .hw.init = &(struct clk_init_data){
758 .name = "cpub_clk_dyn1",
759 .ops = &clk_regmap_mux_ops,
760 .parent_hws = (const struct clk_hw *[]) {
761 &g12b_cpub_clk_premux1.hw,
762 &g12b_cpub_clk_mux1_div.hw
763 },
764 .num_parents = 2,
765 /* This sub-tree is used a parking clock */
766 .flags = CLK_SET_RATE_NO_REPARENT,
767 },
768 };
769
770 /* Datasheet names this field as "Final_dyn_mux_sel" */
771 static struct clk_regmap g12b_cpub_clk_dyn = {
772 .data = &(struct clk_regmap_mux_data){
773 .offset = HHI_SYS_CPUB_CLK_CNTL,
774 .mask = 0x1,
775 .shift = 10,
776 .flags = CLK_MUX_ROUND_CLOSEST,
777 },
778 .hw.init = &(struct clk_init_data){
779 .name = "cpub_clk_dyn",
780 .ops = &clk_regmap_mux_ops,
781 .parent_hws = (const struct clk_hw *[]) {
782 &g12b_cpub_clk_postmux0.hw,
783 &g12b_cpub_clk_postmux1.hw
784 },
785 .num_parents = 2,
786 .flags = CLK_SET_RATE_PARENT,
787 },
788 };
789
790 /* Datasheet names this field as "Final_mux_sel" */
791 static struct clk_regmap g12b_cpub_clk = {
792 .data = &(struct clk_regmap_mux_data){
793 .offset = HHI_SYS_CPUB_CLK_CNTL,
794 .mask = 0x1,
795 .shift = 11,
796 .flags = CLK_MUX_ROUND_CLOSEST,
797 },
798 .hw.init = &(struct clk_init_data){
799 .name = "cpub_clk",
800 .ops = &clk_regmap_mux_ops,
801 .parent_hws = (const struct clk_hw *[]) {
802 &g12b_cpub_clk_dyn.hw,
803 &g12a_sys_pll.hw
804 },
805 .num_parents = 2,
806 .flags = CLK_SET_RATE_PARENT,
807 },
808 };
809
810 static struct clk_regmap sm1_gp1_pll;
811
812 /* Datasheet names this field as "premux0" */
813 static struct clk_regmap sm1_dsu_clk_premux0 = {
814 .data = &(struct clk_regmap_mux_data){
815 .offset = HHI_SYS_CPU_CLK_CNTL5,
816 .mask = 0x3,
817 .shift = 0,
818 },
819 .hw.init = &(struct clk_init_data){
820 .name = "dsu_clk_dyn0_sel",
821 .ops = &clk_regmap_mux_ro_ops,
822 .parent_data = (const struct clk_parent_data []) {
823 { .fw_name = "xtal", },
824 { .hw = &g12a_fclk_div2.hw },
825 { .hw = &g12a_fclk_div3.hw },
826 { .hw = &sm1_gp1_pll.hw },
827 },
828 .num_parents = 4,
829 },
830 };
831
832 /* Datasheet names this field as "premux1" */
833 static struct clk_regmap sm1_dsu_clk_premux1 = {
834 .data = &(struct clk_regmap_mux_data){
835 .offset = HHI_SYS_CPU_CLK_CNTL5,
836 .mask = 0x3,
837 .shift = 16,
838 },
839 .hw.init = &(struct clk_init_data){
840 .name = "dsu_clk_dyn1_sel",
841 .ops = &clk_regmap_mux_ro_ops,
842 .parent_data = (const struct clk_parent_data []) {
843 { .fw_name = "xtal", },
844 { .hw = &g12a_fclk_div2.hw },
845 { .hw = &g12a_fclk_div3.hw },
846 { .hw = &sm1_gp1_pll.hw },
847 },
848 .num_parents = 4,
849 },
850 };
851
852 /* Datasheet names this field as "Mux0_divn_tcnt" */
853 static struct clk_regmap sm1_dsu_clk_mux0_div = {
854 .data = &(struct clk_regmap_div_data){
855 .offset = HHI_SYS_CPU_CLK_CNTL5,
856 .shift = 4,
857 .width = 6,
858 },
859 .hw.init = &(struct clk_init_data){
860 .name = "dsu_clk_dyn0_div",
861 .ops = &clk_regmap_divider_ro_ops,
862 .parent_hws = (const struct clk_hw *[]) {
863 &sm1_dsu_clk_premux0.hw
864 },
865 .num_parents = 1,
866 },
867 };
868
869 /* Datasheet names this field as "postmux0" */
870 static struct clk_regmap sm1_dsu_clk_postmux0 = {
871 .data = &(struct clk_regmap_mux_data){
872 .offset = HHI_SYS_CPU_CLK_CNTL5,
873 .mask = 0x1,
874 .shift = 2,
875 },
876 .hw.init = &(struct clk_init_data){
877 .name = "dsu_clk_dyn0",
878 .ops = &clk_regmap_mux_ro_ops,
879 .parent_hws = (const struct clk_hw *[]) {
880 &sm1_dsu_clk_premux0.hw,
881 &sm1_dsu_clk_mux0_div.hw,
882 },
883 .num_parents = 2,
884 },
885 };
886
887 /* Datasheet names this field as "Mux1_divn_tcnt" */
888 static struct clk_regmap sm1_dsu_clk_mux1_div = {
889 .data = &(struct clk_regmap_div_data){
890 .offset = HHI_SYS_CPU_CLK_CNTL5,
891 .shift = 20,
892 .width = 6,
893 },
894 .hw.init = &(struct clk_init_data){
895 .name = "dsu_clk_dyn1_div",
896 .ops = &clk_regmap_divider_ro_ops,
897 .parent_hws = (const struct clk_hw *[]) {
898 &sm1_dsu_clk_premux1.hw
899 },
900 .num_parents = 1,
901 },
902 };
903
904 /* Datasheet names this field as "postmux1" */
905 static struct clk_regmap sm1_dsu_clk_postmux1 = {
906 .data = &(struct clk_regmap_mux_data){
907 .offset = HHI_SYS_CPU_CLK_CNTL5,
908 .mask = 0x1,
909 .shift = 18,
910 },
911 .hw.init = &(struct clk_init_data){
912 .name = "dsu_clk_dyn1",
913 .ops = &clk_regmap_mux_ro_ops,
914 .parent_hws = (const struct clk_hw *[]) {
915 &sm1_dsu_clk_premux1.hw,
916 &sm1_dsu_clk_mux1_div.hw,
917 },
918 .num_parents = 2,
919 },
920 };
921
922 /* Datasheet names this field as "Final_dyn_mux_sel" */
923 static struct clk_regmap sm1_dsu_clk_dyn = {
924 .data = &(struct clk_regmap_mux_data){
925 .offset = HHI_SYS_CPU_CLK_CNTL5,
926 .mask = 0x1,
927 .shift = 10,
928 },
929 .hw.init = &(struct clk_init_data){
930 .name = "dsu_clk_dyn",
931 .ops = &clk_regmap_mux_ro_ops,
932 .parent_hws = (const struct clk_hw *[]) {
933 &sm1_dsu_clk_postmux0.hw,
934 &sm1_dsu_clk_postmux1.hw,
935 },
936 .num_parents = 2,
937 },
938 };
939
940 /* Datasheet names this field as "Final_mux_sel" */
941 static struct clk_regmap sm1_dsu_final_clk = {
942 .data = &(struct clk_regmap_mux_data){
943 .offset = HHI_SYS_CPU_CLK_CNTL5,
944 .mask = 0x1,
945 .shift = 11,
946 },
947 .hw.init = &(struct clk_init_data){
948 .name = "dsu_clk_final",
949 .ops = &clk_regmap_mux_ro_ops,
950 .parent_hws = (const struct clk_hw *[]) {
951 &sm1_dsu_clk_dyn.hw,
952 &g12a_sys_pll.hw,
953 },
954 .num_parents = 2,
955 },
956 };
957
958 /* Datasheet names this field as "Cpu_clk_sync_mux_sel" bit 0 */
959 static struct clk_regmap sm1_cpu1_clk = {
960 .data = &(struct clk_regmap_mux_data){
961 .offset = HHI_SYS_CPU_CLK_CNTL6,
962 .mask = 0x1,
963 .shift = 24,
964 },
965 .hw.init = &(struct clk_init_data){
966 .name = "cpu1_clk",
967 .ops = &clk_regmap_mux_ro_ops,
968 .parent_hws = (const struct clk_hw *[]) {
969 &g12a_cpu_clk.hw,
970 /* This CPU also have a dedicated clock tree */
971 },
972 .num_parents = 1,
973 },
974 };
975
976 /* Datasheet names this field as "Cpu_clk_sync_mux_sel" bit 1 */
977 static struct clk_regmap sm1_cpu2_clk = {
978 .data = &(struct clk_regmap_mux_data){
979 .offset = HHI_SYS_CPU_CLK_CNTL6,
980 .mask = 0x1,
981 .shift = 25,
982 },
983 .hw.init = &(struct clk_init_data){
984 .name = "cpu2_clk",
985 .ops = &clk_regmap_mux_ro_ops,
986 .parent_hws = (const struct clk_hw *[]) {
987 &g12a_cpu_clk.hw,
988 /* This CPU also have a dedicated clock tree */
989 },
990 .num_parents = 1,
991 },
992 };
993
994 /* Datasheet names this field as "Cpu_clk_sync_mux_sel" bit 2 */
995 static struct clk_regmap sm1_cpu3_clk = {
996 .data = &(struct clk_regmap_mux_data){
997 .offset = HHI_SYS_CPU_CLK_CNTL6,
998 .mask = 0x1,
999 .shift = 26,
1000 },
1001 .hw.init = &(struct clk_init_data){
1002 .name = "cpu3_clk",
1003 .ops = &clk_regmap_mux_ro_ops,
1004 .parent_hws = (const struct clk_hw *[]) {
1005 &g12a_cpu_clk.hw,
1006 /* This CPU also have a dedicated clock tree */
1007 },
1008 .num_parents = 1,
1009 },
1010 };
1011
1012 /* Datasheet names this field as "Cpu_clk_sync_mux_sel" bit 4 */
1013 static struct clk_regmap sm1_dsu_clk = {
1014 .data = &(struct clk_regmap_mux_data){
1015 .offset = HHI_SYS_CPU_CLK_CNTL6,
1016 .mask = 0x1,
1017 .shift = 27,
1018 },
1019 .hw.init = &(struct clk_init_data){
1020 .name = "dsu_clk",
1021 .ops = &clk_regmap_mux_ro_ops,
1022 .parent_hws = (const struct clk_hw *[]) {
1023 &g12a_cpu_clk.hw,
1024 &sm1_dsu_final_clk.hw,
1025 },
1026 .num_parents = 2,
1027 },
1028 };
1029
g12a_cpu_clk_mux_notifier_cb(struct notifier_block * nb,unsigned long event,void * data)1030 static int g12a_cpu_clk_mux_notifier_cb(struct notifier_block *nb,
1031 unsigned long event, void *data)
1032 {
1033 if (event == POST_RATE_CHANGE || event == PRE_RATE_CHANGE) {
1034 /* Wait for clock propagation before/after changing the mux */
1035 udelay(100);
1036 return NOTIFY_OK;
1037 }
1038
1039 return NOTIFY_DONE;
1040 }
1041
1042 static struct notifier_block g12a_cpu_clk_mux_nb = {
1043 .notifier_call = g12a_cpu_clk_mux_notifier_cb,
1044 };
1045
1046 struct g12a_cpu_clk_postmux_nb_data {
1047 struct notifier_block nb;
1048 struct clk_hw *xtal;
1049 struct clk_hw *cpu_clk_dyn;
1050 struct clk_hw *cpu_clk_postmux0;
1051 struct clk_hw *cpu_clk_postmux1;
1052 struct clk_hw *cpu_clk_premux1;
1053 };
1054
g12a_cpu_clk_postmux_notifier_cb(struct notifier_block * nb,unsigned long event,void * data)1055 static int g12a_cpu_clk_postmux_notifier_cb(struct notifier_block *nb,
1056 unsigned long event, void *data)
1057 {
1058 struct g12a_cpu_clk_postmux_nb_data *nb_data =
1059 container_of(nb, struct g12a_cpu_clk_postmux_nb_data, nb);
1060
1061 switch (event) {
1062 case PRE_RATE_CHANGE:
1063 /*
1064 * This notifier means cpu_clk_postmux0 clock will be changed
1065 * to feed cpu_clk, this is the current path :
1066 * cpu_clk
1067 * \- cpu_clk_dyn
1068 * \- cpu_clk_postmux0
1069 * \- cpu_clk_muxX_div
1070 * \- cpu_clk_premux0
1071 * \- fclk_div3 or fclk_div2
1072 * OR
1073 * \- cpu_clk_premux0
1074 * \- fclk_div3 or fclk_div2
1075 */
1076
1077 /* Setup cpu_clk_premux1 to xtal */
1078 clk_hw_set_parent(nb_data->cpu_clk_premux1,
1079 nb_data->xtal);
1080
1081 /* Setup cpu_clk_postmux1 to bypass divider */
1082 clk_hw_set_parent(nb_data->cpu_clk_postmux1,
1083 nb_data->cpu_clk_premux1);
1084
1085 /* Switch to parking clk on cpu_clk_postmux1 */
1086 clk_hw_set_parent(nb_data->cpu_clk_dyn,
1087 nb_data->cpu_clk_postmux1);
1088
1089 /*
1090 * Now, cpu_clk is 24MHz in the current path :
1091 * cpu_clk
1092 * \- cpu_clk_dyn
1093 * \- cpu_clk_postmux1
1094 * \- cpu_clk_premux1
1095 * \- xtal
1096 */
1097
1098 udelay(100);
1099
1100 return NOTIFY_OK;
1101
1102 case POST_RATE_CHANGE:
1103 /*
1104 * The cpu_clk_postmux0 has ben updated, now switch back
1105 * cpu_clk_dyn to cpu_clk_postmux0 and take the changes
1106 * in account.
1107 */
1108
1109 /* Configure cpu_clk_dyn back to cpu_clk_postmux0 */
1110 clk_hw_set_parent(nb_data->cpu_clk_dyn,
1111 nb_data->cpu_clk_postmux0);
1112
1113 /*
1114 * new path :
1115 * cpu_clk
1116 * \- cpu_clk_dyn
1117 * \- cpu_clk_postmux0
1118 * \- cpu_clk_muxX_div
1119 * \- cpu_clk_premux0
1120 * \- fclk_div3 or fclk_div2
1121 * OR
1122 * \- cpu_clk_premux0
1123 * \- fclk_div3 or fclk_div2
1124 */
1125
1126 udelay(100);
1127
1128 return NOTIFY_OK;
1129
1130 default:
1131 return NOTIFY_DONE;
1132 }
1133 }
1134
1135 static struct g12a_cpu_clk_postmux_nb_data g12a_cpu_clk_postmux0_nb_data = {
1136 .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw,
1137 .cpu_clk_postmux0 = &g12a_cpu_clk_postmux0.hw,
1138 .cpu_clk_postmux1 = &g12a_cpu_clk_postmux1.hw,
1139 .cpu_clk_premux1 = &g12a_cpu_clk_premux1.hw,
1140 .nb.notifier_call = g12a_cpu_clk_postmux_notifier_cb,
1141 };
1142
1143 static struct g12a_cpu_clk_postmux_nb_data g12b_cpub_clk_postmux0_nb_data = {
1144 .cpu_clk_dyn = &g12b_cpub_clk_dyn.hw,
1145 .cpu_clk_postmux0 = &g12b_cpub_clk_postmux0.hw,
1146 .cpu_clk_postmux1 = &g12b_cpub_clk_postmux1.hw,
1147 .cpu_clk_premux1 = &g12b_cpub_clk_premux1.hw,
1148 .nb.notifier_call = g12a_cpu_clk_postmux_notifier_cb,
1149 };
1150
1151 struct g12a_sys_pll_nb_data {
1152 struct notifier_block nb;
1153 struct clk_hw *sys_pll;
1154 struct clk_hw *cpu_clk;
1155 struct clk_hw *cpu_clk_dyn;
1156 };
1157
g12a_sys_pll_notifier_cb(struct notifier_block * nb,unsigned long event,void * data)1158 static int g12a_sys_pll_notifier_cb(struct notifier_block *nb,
1159 unsigned long event, void *data)
1160 {
1161 struct g12a_sys_pll_nb_data *nb_data =
1162 container_of(nb, struct g12a_sys_pll_nb_data, nb);
1163
1164 switch (event) {
1165 case PRE_RATE_CHANGE:
1166 /*
1167 * This notifier means sys_pll clock will be changed
1168 * to feed cpu_clk, this the current path :
1169 * cpu_clk
1170 * \- sys_pll
1171 * \- sys_pll_dco
1172 */
1173
1174 /* Configure cpu_clk to use cpu_clk_dyn */
1175 clk_hw_set_parent(nb_data->cpu_clk,
1176 nb_data->cpu_clk_dyn);
1177
1178 /*
1179 * Now, cpu_clk uses the dyn path
1180 * cpu_clk
1181 * \- cpu_clk_dyn
1182 * \- cpu_clk_dynX
1183 * \- cpu_clk_dynX_sel
1184 * \- cpu_clk_dynX_div
1185 * \- xtal/fclk_div2/fclk_div3
1186 * \- xtal/fclk_div2/fclk_div3
1187 */
1188
1189 udelay(100);
1190
1191 return NOTIFY_OK;
1192
1193 case POST_RATE_CHANGE:
1194 /*
1195 * The sys_pll has ben updated, now switch back cpu_clk to
1196 * sys_pll
1197 */
1198
1199 /* Configure cpu_clk to use sys_pll */
1200 clk_hw_set_parent(nb_data->cpu_clk,
1201 nb_data->sys_pll);
1202
1203 udelay(100);
1204
1205 /* new path :
1206 * cpu_clk
1207 * \- sys_pll
1208 * \- sys_pll_dco
1209 */
1210
1211 return NOTIFY_OK;
1212
1213 default:
1214 return NOTIFY_DONE;
1215 }
1216 }
1217
1218 static struct g12a_sys_pll_nb_data g12a_sys_pll_nb_data = {
1219 .sys_pll = &g12a_sys_pll.hw,
1220 .cpu_clk = &g12a_cpu_clk.hw,
1221 .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw,
1222 .nb.notifier_call = g12a_sys_pll_notifier_cb,
1223 };
1224
1225 /* G12B first CPU cluster uses sys1_pll */
1226 static struct g12a_sys_pll_nb_data g12b_cpu_clk_sys1_pll_nb_data = {
1227 .sys_pll = &g12b_sys1_pll.hw,
1228 .cpu_clk = &g12b_cpu_clk.hw,
1229 .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw,
1230 .nb.notifier_call = g12a_sys_pll_notifier_cb,
1231 };
1232
1233 /* G12B second CPU cluster uses sys_pll */
1234 static struct g12a_sys_pll_nb_data g12b_cpub_clk_sys_pll_nb_data = {
1235 .sys_pll = &g12a_sys_pll.hw,
1236 .cpu_clk = &g12b_cpub_clk.hw,
1237 .cpu_clk_dyn = &g12b_cpub_clk_dyn.hw,
1238 .nb.notifier_call = g12a_sys_pll_notifier_cb,
1239 };
1240
1241 static struct clk_regmap g12a_cpu_clk_div16_en = {
1242 .data = &(struct clk_regmap_gate_data){
1243 .offset = HHI_SYS_CPU_CLK_CNTL1,
1244 .bit_idx = 1,
1245 },
1246 .hw.init = &(struct clk_init_data) {
1247 .name = "cpu_clk_div16_en",
1248 .ops = &clk_regmap_gate_ro_ops,
1249 .parent_data = &(const struct clk_parent_data) {
1250 /*
1251 * Note:
1252 * G12A and G12B have different cpu clocks (with
1253 * different struct clk_hw). We fallback to the global
1254 * naming string mechanism so this clock picks
1255 * up the appropriate one. Same goes for the other
1256 * clock using cpu cluster A clock output and present
1257 * on both G12 variant.
1258 */
1259 .name = "cpu_clk",
1260 .index = -1,
1261 },
1262 .num_parents = 1,
1263 /*
1264 * This clock is used to debug the cpu_clk range
1265 * Linux should not change it at runtime
1266 */
1267 },
1268 };
1269
1270 static struct clk_regmap g12b_cpub_clk_div16_en = {
1271 .data = &(struct clk_regmap_gate_data){
1272 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1273 .bit_idx = 1,
1274 },
1275 .hw.init = &(struct clk_init_data) {
1276 .name = "cpub_clk_div16_en",
1277 .ops = &clk_regmap_gate_ro_ops,
1278 .parent_hws = (const struct clk_hw *[]) {
1279 &g12b_cpub_clk.hw
1280 },
1281 .num_parents = 1,
1282 /*
1283 * This clock is used to debug the cpu_clk range
1284 * Linux should not change it at runtime
1285 */
1286 },
1287 };
1288
1289 static struct clk_fixed_factor g12a_cpu_clk_div16 = {
1290 .mult = 1,
1291 .div = 16,
1292 .hw.init = &(struct clk_init_data){
1293 .name = "cpu_clk_div16",
1294 .ops = &clk_fixed_factor_ops,
1295 .parent_hws = (const struct clk_hw *[]) {
1296 &g12a_cpu_clk_div16_en.hw
1297 },
1298 .num_parents = 1,
1299 },
1300 };
1301
1302 static struct clk_fixed_factor g12b_cpub_clk_div16 = {
1303 .mult = 1,
1304 .div = 16,
1305 .hw.init = &(struct clk_init_data){
1306 .name = "cpub_clk_div16",
1307 .ops = &clk_fixed_factor_ops,
1308 .parent_hws = (const struct clk_hw *[]) {
1309 &g12b_cpub_clk_div16_en.hw
1310 },
1311 .num_parents = 1,
1312 },
1313 };
1314
1315 static struct clk_regmap g12a_cpu_clk_apb_div = {
1316 .data = &(struct clk_regmap_div_data){
1317 .offset = HHI_SYS_CPU_CLK_CNTL1,
1318 .shift = 3,
1319 .width = 3,
1320 .flags = CLK_DIVIDER_POWER_OF_TWO,
1321 },
1322 .hw.init = &(struct clk_init_data){
1323 .name = "cpu_clk_apb_div",
1324 .ops = &clk_regmap_divider_ro_ops,
1325 .parent_data = &(const struct clk_parent_data) {
1326 .name = "cpu_clk",
1327 .index = -1,
1328 },
1329 .num_parents = 1,
1330 },
1331 };
1332
1333 static struct clk_regmap g12a_cpu_clk_apb = {
1334 .data = &(struct clk_regmap_gate_data){
1335 .offset = HHI_SYS_CPU_CLK_CNTL1,
1336 .bit_idx = 1,
1337 },
1338 .hw.init = &(struct clk_init_data) {
1339 .name = "cpu_clk_apb",
1340 .ops = &clk_regmap_gate_ro_ops,
1341 .parent_hws = (const struct clk_hw *[]) {
1342 &g12a_cpu_clk_apb_div.hw
1343 },
1344 .num_parents = 1,
1345 /*
1346 * This clock is set by the ROM monitor code,
1347 * Linux should not change it at runtime
1348 */
1349 },
1350 };
1351
1352 static struct clk_regmap g12a_cpu_clk_atb_div = {
1353 .data = &(struct clk_regmap_div_data){
1354 .offset = HHI_SYS_CPU_CLK_CNTL1,
1355 .shift = 6,
1356 .width = 3,
1357 .flags = CLK_DIVIDER_POWER_OF_TWO,
1358 },
1359 .hw.init = &(struct clk_init_data){
1360 .name = "cpu_clk_atb_div",
1361 .ops = &clk_regmap_divider_ro_ops,
1362 .parent_data = &(const struct clk_parent_data) {
1363 .name = "cpu_clk",
1364 .index = -1,
1365 },
1366 .num_parents = 1,
1367 },
1368 };
1369
1370 static struct clk_regmap g12a_cpu_clk_atb = {
1371 .data = &(struct clk_regmap_gate_data){
1372 .offset = HHI_SYS_CPU_CLK_CNTL1,
1373 .bit_idx = 17,
1374 },
1375 .hw.init = &(struct clk_init_data) {
1376 .name = "cpu_clk_atb",
1377 .ops = &clk_regmap_gate_ro_ops,
1378 .parent_hws = (const struct clk_hw *[]) {
1379 &g12a_cpu_clk_atb_div.hw
1380 },
1381 .num_parents = 1,
1382 /*
1383 * This clock is set by the ROM monitor code,
1384 * Linux should not change it at runtime
1385 */
1386 },
1387 };
1388
1389 static struct clk_regmap g12a_cpu_clk_axi_div = {
1390 .data = &(struct clk_regmap_div_data){
1391 .offset = HHI_SYS_CPU_CLK_CNTL1,
1392 .shift = 9,
1393 .width = 3,
1394 .flags = CLK_DIVIDER_POWER_OF_TWO,
1395 },
1396 .hw.init = &(struct clk_init_data){
1397 .name = "cpu_clk_axi_div",
1398 .ops = &clk_regmap_divider_ro_ops,
1399 .parent_data = &(const struct clk_parent_data) {
1400 .name = "cpu_clk",
1401 .index = -1,
1402 },
1403 .num_parents = 1,
1404 },
1405 };
1406
1407 static struct clk_regmap g12a_cpu_clk_axi = {
1408 .data = &(struct clk_regmap_gate_data){
1409 .offset = HHI_SYS_CPU_CLK_CNTL1,
1410 .bit_idx = 18,
1411 },
1412 .hw.init = &(struct clk_init_data) {
1413 .name = "cpu_clk_axi",
1414 .ops = &clk_regmap_gate_ro_ops,
1415 .parent_hws = (const struct clk_hw *[]) {
1416 &g12a_cpu_clk_axi_div.hw
1417 },
1418 .num_parents = 1,
1419 /*
1420 * This clock is set by the ROM monitor code,
1421 * Linux should not change it at runtime
1422 */
1423 },
1424 };
1425
1426 static struct clk_regmap g12a_cpu_clk_trace_div = {
1427 .data = &(struct clk_regmap_div_data){
1428 .offset = HHI_SYS_CPU_CLK_CNTL1,
1429 .shift = 20,
1430 .width = 3,
1431 .flags = CLK_DIVIDER_POWER_OF_TWO,
1432 },
1433 .hw.init = &(struct clk_init_data){
1434 .name = "cpu_clk_trace_div",
1435 .ops = &clk_regmap_divider_ro_ops,
1436 .parent_data = &(const struct clk_parent_data) {
1437 .name = "cpu_clk",
1438 .index = -1,
1439 },
1440 .num_parents = 1,
1441 },
1442 };
1443
1444 static struct clk_regmap g12a_cpu_clk_trace = {
1445 .data = &(struct clk_regmap_gate_data){
1446 .offset = HHI_SYS_CPU_CLK_CNTL1,
1447 .bit_idx = 23,
1448 },
1449 .hw.init = &(struct clk_init_data) {
1450 .name = "cpu_clk_trace",
1451 .ops = &clk_regmap_gate_ro_ops,
1452 .parent_hws = (const struct clk_hw *[]) {
1453 &g12a_cpu_clk_trace_div.hw
1454 },
1455 .num_parents = 1,
1456 /*
1457 * This clock is set by the ROM monitor code,
1458 * Linux should not change it at runtime
1459 */
1460 },
1461 };
1462
1463 static struct clk_fixed_factor g12b_cpub_clk_div2 = {
1464 .mult = 1,
1465 .div = 2,
1466 .hw.init = &(struct clk_init_data){
1467 .name = "cpub_clk_div2",
1468 .ops = &clk_fixed_factor_ops,
1469 .parent_hws = (const struct clk_hw *[]) {
1470 &g12b_cpub_clk.hw
1471 },
1472 .num_parents = 1,
1473 },
1474 };
1475
1476 static struct clk_fixed_factor g12b_cpub_clk_div3 = {
1477 .mult = 1,
1478 .div = 3,
1479 .hw.init = &(struct clk_init_data){
1480 .name = "cpub_clk_div3",
1481 .ops = &clk_fixed_factor_ops,
1482 .parent_hws = (const struct clk_hw *[]) {
1483 &g12b_cpub_clk.hw
1484 },
1485 .num_parents = 1,
1486 },
1487 };
1488
1489 static struct clk_fixed_factor g12b_cpub_clk_div4 = {
1490 .mult = 1,
1491 .div = 4,
1492 .hw.init = &(struct clk_init_data){
1493 .name = "cpub_clk_div4",
1494 .ops = &clk_fixed_factor_ops,
1495 .parent_hws = (const struct clk_hw *[]) {
1496 &g12b_cpub_clk.hw
1497 },
1498 .num_parents = 1,
1499 },
1500 };
1501
1502 static struct clk_fixed_factor g12b_cpub_clk_div5 = {
1503 .mult = 1,
1504 .div = 5,
1505 .hw.init = &(struct clk_init_data){
1506 .name = "cpub_clk_div5",
1507 .ops = &clk_fixed_factor_ops,
1508 .parent_hws = (const struct clk_hw *[]) {
1509 &g12b_cpub_clk.hw
1510 },
1511 .num_parents = 1,
1512 },
1513 };
1514
1515 static struct clk_fixed_factor g12b_cpub_clk_div6 = {
1516 .mult = 1,
1517 .div = 6,
1518 .hw.init = &(struct clk_init_data){
1519 .name = "cpub_clk_div6",
1520 .ops = &clk_fixed_factor_ops,
1521 .parent_hws = (const struct clk_hw *[]) {
1522 &g12b_cpub_clk.hw
1523 },
1524 .num_parents = 1,
1525 },
1526 };
1527
1528 static struct clk_fixed_factor g12b_cpub_clk_div7 = {
1529 .mult = 1,
1530 .div = 7,
1531 .hw.init = &(struct clk_init_data){
1532 .name = "cpub_clk_div7",
1533 .ops = &clk_fixed_factor_ops,
1534 .parent_hws = (const struct clk_hw *[]) {
1535 &g12b_cpub_clk.hw
1536 },
1537 .num_parents = 1,
1538 },
1539 };
1540
1541 static struct clk_fixed_factor g12b_cpub_clk_div8 = {
1542 .mult = 1,
1543 .div = 8,
1544 .hw.init = &(struct clk_init_data){
1545 .name = "cpub_clk_div8",
1546 .ops = &clk_fixed_factor_ops,
1547 .parent_hws = (const struct clk_hw *[]) {
1548 &g12b_cpub_clk.hw
1549 },
1550 .num_parents = 1,
1551 },
1552 };
1553
1554 static u32 mux_table_cpub[] = { 1, 2, 3, 4, 5, 6, 7 };
1555 static struct clk_regmap g12b_cpub_clk_apb_sel = {
1556 .data = &(struct clk_regmap_mux_data){
1557 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1558 .mask = 7,
1559 .shift = 3,
1560 .table = mux_table_cpub,
1561 },
1562 .hw.init = &(struct clk_init_data){
1563 .name = "cpub_clk_apb_sel",
1564 .ops = &clk_regmap_mux_ro_ops,
1565 .parent_hws = (const struct clk_hw *[]) {
1566 &g12b_cpub_clk_div2.hw,
1567 &g12b_cpub_clk_div3.hw,
1568 &g12b_cpub_clk_div4.hw,
1569 &g12b_cpub_clk_div5.hw,
1570 &g12b_cpub_clk_div6.hw,
1571 &g12b_cpub_clk_div7.hw,
1572 &g12b_cpub_clk_div8.hw
1573 },
1574 .num_parents = 7,
1575 },
1576 };
1577
1578 static struct clk_regmap g12b_cpub_clk_apb = {
1579 .data = &(struct clk_regmap_gate_data){
1580 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1581 .bit_idx = 16,
1582 .flags = CLK_GATE_SET_TO_DISABLE,
1583 },
1584 .hw.init = &(struct clk_init_data) {
1585 .name = "cpub_clk_apb",
1586 .ops = &clk_regmap_gate_ro_ops,
1587 .parent_hws = (const struct clk_hw *[]) {
1588 &g12b_cpub_clk_apb_sel.hw
1589 },
1590 .num_parents = 1,
1591 /*
1592 * This clock is set by the ROM monitor code,
1593 * Linux should not change it at runtime
1594 */
1595 },
1596 };
1597
1598 static struct clk_regmap g12b_cpub_clk_atb_sel = {
1599 .data = &(struct clk_regmap_mux_data){
1600 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1601 .mask = 7,
1602 .shift = 6,
1603 .table = mux_table_cpub,
1604 },
1605 .hw.init = &(struct clk_init_data){
1606 .name = "cpub_clk_atb_sel",
1607 .ops = &clk_regmap_mux_ro_ops,
1608 .parent_hws = (const struct clk_hw *[]) {
1609 &g12b_cpub_clk_div2.hw,
1610 &g12b_cpub_clk_div3.hw,
1611 &g12b_cpub_clk_div4.hw,
1612 &g12b_cpub_clk_div5.hw,
1613 &g12b_cpub_clk_div6.hw,
1614 &g12b_cpub_clk_div7.hw,
1615 &g12b_cpub_clk_div8.hw
1616 },
1617 .num_parents = 7,
1618 },
1619 };
1620
1621 static struct clk_regmap g12b_cpub_clk_atb = {
1622 .data = &(struct clk_regmap_gate_data){
1623 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1624 .bit_idx = 17,
1625 .flags = CLK_GATE_SET_TO_DISABLE,
1626 },
1627 .hw.init = &(struct clk_init_data) {
1628 .name = "cpub_clk_atb",
1629 .ops = &clk_regmap_gate_ro_ops,
1630 .parent_hws = (const struct clk_hw *[]) {
1631 &g12b_cpub_clk_atb_sel.hw
1632 },
1633 .num_parents = 1,
1634 /*
1635 * This clock is set by the ROM monitor code,
1636 * Linux should not change it at runtime
1637 */
1638 },
1639 };
1640
1641 static struct clk_regmap g12b_cpub_clk_axi_sel = {
1642 .data = &(struct clk_regmap_mux_data){
1643 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1644 .mask = 7,
1645 .shift = 9,
1646 .table = mux_table_cpub,
1647 },
1648 .hw.init = &(struct clk_init_data){
1649 .name = "cpub_clk_axi_sel",
1650 .ops = &clk_regmap_mux_ro_ops,
1651 .parent_hws = (const struct clk_hw *[]) {
1652 &g12b_cpub_clk_div2.hw,
1653 &g12b_cpub_clk_div3.hw,
1654 &g12b_cpub_clk_div4.hw,
1655 &g12b_cpub_clk_div5.hw,
1656 &g12b_cpub_clk_div6.hw,
1657 &g12b_cpub_clk_div7.hw,
1658 &g12b_cpub_clk_div8.hw
1659 },
1660 .num_parents = 7,
1661 },
1662 };
1663
1664 static struct clk_regmap g12b_cpub_clk_axi = {
1665 .data = &(struct clk_regmap_gate_data){
1666 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1667 .bit_idx = 18,
1668 .flags = CLK_GATE_SET_TO_DISABLE,
1669 },
1670 .hw.init = &(struct clk_init_data) {
1671 .name = "cpub_clk_axi",
1672 .ops = &clk_regmap_gate_ro_ops,
1673 .parent_hws = (const struct clk_hw *[]) {
1674 &g12b_cpub_clk_axi_sel.hw
1675 },
1676 .num_parents = 1,
1677 /*
1678 * This clock is set by the ROM monitor code,
1679 * Linux should not change it at runtime
1680 */
1681 },
1682 };
1683
1684 static struct clk_regmap g12b_cpub_clk_trace_sel = {
1685 .data = &(struct clk_regmap_mux_data){
1686 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1687 .mask = 7,
1688 .shift = 20,
1689 .table = mux_table_cpub,
1690 },
1691 .hw.init = &(struct clk_init_data){
1692 .name = "cpub_clk_trace_sel",
1693 .ops = &clk_regmap_mux_ro_ops,
1694 .parent_hws = (const struct clk_hw *[]) {
1695 &g12b_cpub_clk_div2.hw,
1696 &g12b_cpub_clk_div3.hw,
1697 &g12b_cpub_clk_div4.hw,
1698 &g12b_cpub_clk_div5.hw,
1699 &g12b_cpub_clk_div6.hw,
1700 &g12b_cpub_clk_div7.hw,
1701 &g12b_cpub_clk_div8.hw
1702 },
1703 .num_parents = 7,
1704 },
1705 };
1706
1707 static struct clk_regmap g12b_cpub_clk_trace = {
1708 .data = &(struct clk_regmap_gate_data){
1709 .offset = HHI_SYS_CPUB_CLK_CNTL1,
1710 .bit_idx = 23,
1711 .flags = CLK_GATE_SET_TO_DISABLE,
1712 },
1713 .hw.init = &(struct clk_init_data) {
1714 .name = "cpub_clk_trace",
1715 .ops = &clk_regmap_gate_ro_ops,
1716 .parent_hws = (const struct clk_hw *[]) {
1717 &g12b_cpub_clk_trace_sel.hw
1718 },
1719 .num_parents = 1,
1720 /*
1721 * This clock is set by the ROM monitor code,
1722 * Linux should not change it at runtime
1723 */
1724 },
1725 };
1726
1727 static const struct pll_mult_range g12a_gp0_pll_mult_range = {
1728 .min = 125,
1729 .max = 255,
1730 };
1731
1732 /*
1733 * Internal gp0 pll emulation configuration parameters
1734 */
1735 static const struct reg_sequence g12a_gp0_init_regs[] = {
1736 { .reg = HHI_GP0_PLL_CNTL1, .def = 0x00000000 },
1737 { .reg = HHI_GP0_PLL_CNTL2, .def = 0x00000000 },
1738 { .reg = HHI_GP0_PLL_CNTL3, .def = 0x48681c00 },
1739 { .reg = HHI_GP0_PLL_CNTL4, .def = 0x33771290 },
1740 { .reg = HHI_GP0_PLL_CNTL5, .def = 0x39272000 },
1741 { .reg = HHI_GP0_PLL_CNTL6, .def = 0x56540000 },
1742 };
1743
1744 static struct clk_regmap g12a_gp0_pll_dco = {
1745 .data = &(struct meson_clk_pll_data){
1746 .en = {
1747 .reg_off = HHI_GP0_PLL_CNTL0,
1748 .shift = 28,
1749 .width = 1,
1750 },
1751 .m = {
1752 .reg_off = HHI_GP0_PLL_CNTL0,
1753 .shift = 0,
1754 .width = 8,
1755 },
1756 .n = {
1757 .reg_off = HHI_GP0_PLL_CNTL0,
1758 .shift = 10,
1759 .width = 5,
1760 },
1761 .frac = {
1762 .reg_off = HHI_GP0_PLL_CNTL1,
1763 .shift = 0,
1764 .width = 17,
1765 },
1766 .l = {
1767 .reg_off = HHI_GP0_PLL_CNTL0,
1768 .shift = 31,
1769 .width = 1,
1770 },
1771 .rst = {
1772 .reg_off = HHI_GP0_PLL_CNTL0,
1773 .shift = 29,
1774 .width = 1,
1775 },
1776 .range = &g12a_gp0_pll_mult_range,
1777 .init_regs = g12a_gp0_init_regs,
1778 .init_count = ARRAY_SIZE(g12a_gp0_init_regs),
1779 },
1780 .hw.init = &(struct clk_init_data){
1781 .name = "gp0_pll_dco",
1782 .ops = &meson_clk_pll_ops,
1783 .parent_data = &(const struct clk_parent_data) {
1784 .fw_name = "xtal",
1785 },
1786 .num_parents = 1,
1787 },
1788 };
1789
1790 static struct clk_regmap g12a_gp0_pll = {
1791 .data = &(struct clk_regmap_div_data){
1792 .offset = HHI_GP0_PLL_CNTL0,
1793 .shift = 16,
1794 .width = 3,
1795 .flags = (CLK_DIVIDER_POWER_OF_TWO |
1796 CLK_DIVIDER_ROUND_CLOSEST),
1797 },
1798 .hw.init = &(struct clk_init_data){
1799 .name = "gp0_pll",
1800 .ops = &clk_regmap_divider_ops,
1801 .parent_hws = (const struct clk_hw *[]) {
1802 &g12a_gp0_pll_dco.hw
1803 },
1804 .num_parents = 1,
1805 .flags = CLK_SET_RATE_PARENT,
1806 },
1807 };
1808
1809 static struct clk_regmap sm1_gp1_pll_dco = {
1810 .data = &(struct meson_clk_pll_data){
1811 .en = {
1812 .reg_off = HHI_GP1_PLL_CNTL0,
1813 .shift = 28,
1814 .width = 1,
1815 },
1816 .m = {
1817 .reg_off = HHI_GP1_PLL_CNTL0,
1818 .shift = 0,
1819 .width = 8,
1820 },
1821 .n = {
1822 .reg_off = HHI_GP1_PLL_CNTL0,
1823 .shift = 10,
1824 .width = 5,
1825 },
1826 .frac = {
1827 .reg_off = HHI_GP1_PLL_CNTL1,
1828 .shift = 0,
1829 .width = 17,
1830 },
1831 .l = {
1832 .reg_off = HHI_GP1_PLL_CNTL0,
1833 .shift = 31,
1834 .width = 1,
1835 },
1836 .rst = {
1837 .reg_off = HHI_GP1_PLL_CNTL0,
1838 .shift = 29,
1839 .width = 1,
1840 },
1841 },
1842 .hw.init = &(struct clk_init_data){
1843 .name = "gp1_pll_dco",
1844 .ops = &meson_clk_pll_ro_ops,
1845 .parent_data = &(const struct clk_parent_data) {
1846 .fw_name = "xtal",
1847 },
1848 .num_parents = 1,
1849 /* This clock feeds the DSU, avoid disabling it */
1850 .flags = CLK_IS_CRITICAL,
1851 },
1852 };
1853
1854 static struct clk_regmap sm1_gp1_pll = {
1855 .data = &(struct clk_regmap_div_data){
1856 .offset = HHI_GP1_PLL_CNTL0,
1857 .shift = 16,
1858 .width = 3,
1859 .flags = (CLK_DIVIDER_POWER_OF_TWO |
1860 CLK_DIVIDER_ROUND_CLOSEST),
1861 },
1862 .hw.init = &(struct clk_init_data){
1863 .name = "gp1_pll",
1864 .ops = &clk_regmap_divider_ro_ops,
1865 .parent_hws = (const struct clk_hw *[]) {
1866 &sm1_gp1_pll_dco.hw
1867 },
1868 .num_parents = 1,
1869 },
1870 };
1871
1872 /*
1873 * Internal hifi pll emulation configuration parameters
1874 */
1875 static const struct reg_sequence g12a_hifi_init_regs[] = {
1876 { .reg = HHI_HIFI_PLL_CNTL1, .def = 0x00000000 },
1877 { .reg = HHI_HIFI_PLL_CNTL2, .def = 0x00000000 },
1878 { .reg = HHI_HIFI_PLL_CNTL3, .def = 0x6a285c00 },
1879 { .reg = HHI_HIFI_PLL_CNTL4, .def = 0x65771290 },
1880 { .reg = HHI_HIFI_PLL_CNTL5, .def = 0x39272000 },
1881 { .reg = HHI_HIFI_PLL_CNTL6, .def = 0x56540000 },
1882 };
1883
1884 static struct clk_regmap g12a_hifi_pll_dco = {
1885 .data = &(struct meson_clk_pll_data){
1886 .en = {
1887 .reg_off = HHI_HIFI_PLL_CNTL0,
1888 .shift = 28,
1889 .width = 1,
1890 },
1891 .m = {
1892 .reg_off = HHI_HIFI_PLL_CNTL0,
1893 .shift = 0,
1894 .width = 8,
1895 },
1896 .n = {
1897 .reg_off = HHI_HIFI_PLL_CNTL0,
1898 .shift = 10,
1899 .width = 5,
1900 },
1901 .frac = {
1902 .reg_off = HHI_HIFI_PLL_CNTL1,
1903 .shift = 0,
1904 .width = 17,
1905 },
1906 .l = {
1907 .reg_off = HHI_HIFI_PLL_CNTL0,
1908 .shift = 31,
1909 .width = 1,
1910 },
1911 .rst = {
1912 .reg_off = HHI_HIFI_PLL_CNTL0,
1913 .shift = 29,
1914 .width = 1,
1915 },
1916 .range = &g12a_gp0_pll_mult_range,
1917 .init_regs = g12a_hifi_init_regs,
1918 .init_count = ARRAY_SIZE(g12a_hifi_init_regs),
1919 .flags = CLK_MESON_PLL_ROUND_CLOSEST,
1920 },
1921 .hw.init = &(struct clk_init_data){
1922 .name = "hifi_pll_dco",
1923 .ops = &meson_clk_pll_ops,
1924 .parent_data = &(const struct clk_parent_data) {
1925 .fw_name = "xtal",
1926 },
1927 .num_parents = 1,
1928 },
1929 };
1930
1931 static struct clk_regmap g12a_hifi_pll = {
1932 .data = &(struct clk_regmap_div_data){
1933 .offset = HHI_HIFI_PLL_CNTL0,
1934 .shift = 16,
1935 .width = 2,
1936 .flags = (CLK_DIVIDER_POWER_OF_TWO |
1937 CLK_DIVIDER_ROUND_CLOSEST),
1938 },
1939 .hw.init = &(struct clk_init_data){
1940 .name = "hifi_pll",
1941 .ops = &clk_regmap_divider_ops,
1942 .parent_hws = (const struct clk_hw *[]) {
1943 &g12a_hifi_pll_dco.hw
1944 },
1945 .num_parents = 1,
1946 .flags = CLK_SET_RATE_PARENT,
1947 },
1948 };
1949
1950 /*
1951 * The Meson G12A PCIE PLL is fined tuned to deliver a very precise
1952 * 100MHz reference clock for the PCIe Analog PHY, and thus requires
1953 * a strict register sequence to enable the PLL.
1954 */
1955 static const struct reg_sequence g12a_pcie_pll_init_regs[] = {
1956 { .reg = HHI_PCIE_PLL_CNTL0, .def = 0x20090496 },
1957 { .reg = HHI_PCIE_PLL_CNTL0, .def = 0x30090496 },
1958 { .reg = HHI_PCIE_PLL_CNTL1, .def = 0x00000000 },
1959 { .reg = HHI_PCIE_PLL_CNTL2, .def = 0x00001100 },
1960 { .reg = HHI_PCIE_PLL_CNTL3, .def = 0x10058e00 },
1961 { .reg = HHI_PCIE_PLL_CNTL4, .def = 0x000100c0 },
1962 { .reg = HHI_PCIE_PLL_CNTL5, .def = 0x68000048 },
1963 { .reg = HHI_PCIE_PLL_CNTL5, .def = 0x68000068, .delay_us = 20 },
1964 { .reg = HHI_PCIE_PLL_CNTL4, .def = 0x008100c0, .delay_us = 10 },
1965 { .reg = HHI_PCIE_PLL_CNTL0, .def = 0x34090496 },
1966 { .reg = HHI_PCIE_PLL_CNTL0, .def = 0x14090496, .delay_us = 10 },
1967 { .reg = HHI_PCIE_PLL_CNTL2, .def = 0x00001000 },
1968 };
1969
1970 /* Keep a single entry table for recalc/round_rate() ops */
1971 static const struct pll_params_table g12a_pcie_pll_table[] = {
1972 PLL_PARAMS(150, 1),
1973 {0, 0},
1974 };
1975
1976 static struct clk_regmap g12a_pcie_pll_dco = {
1977 .data = &(struct meson_clk_pll_data){
1978 .en = {
1979 .reg_off = HHI_PCIE_PLL_CNTL0,
1980 .shift = 28,
1981 .width = 1,
1982 },
1983 .m = {
1984 .reg_off = HHI_PCIE_PLL_CNTL0,
1985 .shift = 0,
1986 .width = 8,
1987 },
1988 .n = {
1989 .reg_off = HHI_PCIE_PLL_CNTL0,
1990 .shift = 10,
1991 .width = 5,
1992 },
1993 .frac = {
1994 .reg_off = HHI_PCIE_PLL_CNTL1,
1995 .shift = 0,
1996 .width = 12,
1997 },
1998 .l = {
1999 .reg_off = HHI_PCIE_PLL_CNTL0,
2000 .shift = 31,
2001 .width = 1,
2002 },
2003 .rst = {
2004 .reg_off = HHI_PCIE_PLL_CNTL0,
2005 .shift = 29,
2006 .width = 1,
2007 },
2008 .table = g12a_pcie_pll_table,
2009 .init_regs = g12a_pcie_pll_init_regs,
2010 .init_count = ARRAY_SIZE(g12a_pcie_pll_init_regs),
2011 },
2012 .hw.init = &(struct clk_init_data){
2013 .name = "pcie_pll_dco",
2014 .ops = &meson_clk_pcie_pll_ops,
2015 .parent_data = &(const struct clk_parent_data) {
2016 .fw_name = "xtal",
2017 },
2018 .num_parents = 1,
2019 },
2020 };
2021
2022 static struct clk_fixed_factor g12a_pcie_pll_dco_div2 = {
2023 .mult = 1,
2024 .div = 2,
2025 .hw.init = &(struct clk_init_data){
2026 .name = "pcie_pll_dco_div2",
2027 .ops = &clk_fixed_factor_ops,
2028 .parent_hws = (const struct clk_hw *[]) {
2029 &g12a_pcie_pll_dco.hw
2030 },
2031 .num_parents = 1,
2032 .flags = CLK_SET_RATE_PARENT,
2033 },
2034 };
2035
2036 static struct clk_regmap g12a_pcie_pll_od = {
2037 .data = &(struct clk_regmap_div_data){
2038 .offset = HHI_PCIE_PLL_CNTL0,
2039 .shift = 16,
2040 .width = 5,
2041 .flags = CLK_DIVIDER_ROUND_CLOSEST |
2042 CLK_DIVIDER_ONE_BASED |
2043 CLK_DIVIDER_ALLOW_ZERO,
2044 },
2045 .hw.init = &(struct clk_init_data){
2046 .name = "pcie_pll_od",
2047 .ops = &clk_regmap_divider_ops,
2048 .parent_hws = (const struct clk_hw *[]) {
2049 &g12a_pcie_pll_dco_div2.hw
2050 },
2051 .num_parents = 1,
2052 .flags = CLK_SET_RATE_PARENT,
2053 },
2054 };
2055
2056 static struct clk_fixed_factor g12a_pcie_pll = {
2057 .mult = 1,
2058 .div = 2,
2059 .hw.init = &(struct clk_init_data){
2060 .name = "pcie_pll_pll",
2061 .ops = &clk_fixed_factor_ops,
2062 .parent_hws = (const struct clk_hw *[]) {
2063 &g12a_pcie_pll_od.hw
2064 },
2065 .num_parents = 1,
2066 .flags = CLK_SET_RATE_PARENT,
2067 },
2068 };
2069
2070 static struct clk_regmap g12a_hdmi_pll_dco = {
2071 .data = &(struct meson_clk_pll_data){
2072 .en = {
2073 .reg_off = HHI_HDMI_PLL_CNTL0,
2074 .shift = 28,
2075 .width = 1,
2076 },
2077 .m = {
2078 .reg_off = HHI_HDMI_PLL_CNTL0,
2079 .shift = 0,
2080 .width = 8,
2081 },
2082 .n = {
2083 .reg_off = HHI_HDMI_PLL_CNTL0,
2084 .shift = 10,
2085 .width = 5,
2086 },
2087 .frac = {
2088 .reg_off = HHI_HDMI_PLL_CNTL1,
2089 .shift = 0,
2090 .width = 16,
2091 },
2092 .l = {
2093 .reg_off = HHI_HDMI_PLL_CNTL0,
2094 .shift = 30,
2095 .width = 1,
2096 },
2097 .rst = {
2098 .reg_off = HHI_HDMI_PLL_CNTL0,
2099 .shift = 29,
2100 .width = 1,
2101 },
2102 },
2103 .hw.init = &(struct clk_init_data){
2104 .name = "hdmi_pll_dco",
2105 .ops = &meson_clk_pll_ro_ops,
2106 .parent_data = &(const struct clk_parent_data) {
2107 .fw_name = "xtal",
2108 },
2109 .num_parents = 1,
2110 /*
2111 * Display directly handle hdmi pll registers ATM, we need
2112 * NOCACHE to keep our view of the clock as accurate as possible
2113 */
2114 .flags = CLK_GET_RATE_NOCACHE,
2115 },
2116 };
2117
2118 static struct clk_regmap g12a_hdmi_pll_od = {
2119 .data = &(struct clk_regmap_div_data){
2120 .offset = HHI_HDMI_PLL_CNTL0,
2121 .shift = 16,
2122 .width = 2,
2123 .flags = CLK_DIVIDER_POWER_OF_TWO,
2124 },
2125 .hw.init = &(struct clk_init_data){
2126 .name = "hdmi_pll_od",
2127 .ops = &clk_regmap_divider_ro_ops,
2128 .parent_hws = (const struct clk_hw *[]) {
2129 &g12a_hdmi_pll_dco.hw
2130 },
2131 .num_parents = 1,
2132 .flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT,
2133 },
2134 };
2135
2136 static struct clk_regmap g12a_hdmi_pll_od2 = {
2137 .data = &(struct clk_regmap_div_data){
2138 .offset = HHI_HDMI_PLL_CNTL0,
2139 .shift = 18,
2140 .width = 2,
2141 .flags = CLK_DIVIDER_POWER_OF_TWO,
2142 },
2143 .hw.init = &(struct clk_init_data){
2144 .name = "hdmi_pll_od2",
2145 .ops = &clk_regmap_divider_ro_ops,
2146 .parent_hws = (const struct clk_hw *[]) {
2147 &g12a_hdmi_pll_od.hw
2148 },
2149 .num_parents = 1,
2150 .flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT,
2151 },
2152 };
2153
2154 static struct clk_regmap g12a_hdmi_pll = {
2155 .data = &(struct clk_regmap_div_data){
2156 .offset = HHI_HDMI_PLL_CNTL0,
2157 .shift = 20,
2158 .width = 2,
2159 .flags = CLK_DIVIDER_POWER_OF_TWO,
2160 },
2161 .hw.init = &(struct clk_init_data){
2162 .name = "hdmi_pll",
2163 .ops = &clk_regmap_divider_ro_ops,
2164 .parent_hws = (const struct clk_hw *[]) {
2165 &g12a_hdmi_pll_od2.hw
2166 },
2167 .num_parents = 1,
2168 .flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT,
2169 },
2170 };
2171
2172 static struct clk_fixed_factor g12a_fclk_div4_div = {
2173 .mult = 1,
2174 .div = 4,
2175 .hw.init = &(struct clk_init_data){
2176 .name = "fclk_div4_div",
2177 .ops = &clk_fixed_factor_ops,
2178 .parent_hws = (const struct clk_hw *[]) { &g12a_fixed_pll.hw },
2179 .num_parents = 1,
2180 },
2181 };
2182
2183 static struct clk_regmap g12a_fclk_div4 = {
2184 .data = &(struct clk_regmap_gate_data){
2185 .offset = HHI_FIX_PLL_CNTL1,
2186 .bit_idx = 21,
2187 },
2188 .hw.init = &(struct clk_init_data){
2189 .name = "fclk_div4",
2190 .ops = &clk_regmap_gate_ops,
2191 .parent_hws = (const struct clk_hw *[]) {
2192 &g12a_fclk_div4_div.hw
2193 },
2194 .num_parents = 1,
2195 },
2196 };
2197
2198 static struct clk_fixed_factor g12a_fclk_div5_div = {
2199 .mult = 1,
2200 .div = 5,
2201 .hw.init = &(struct clk_init_data){
2202 .name = "fclk_div5_div",
2203 .ops = &clk_fixed_factor_ops,
2204 .parent_hws = (const struct clk_hw *[]) { &g12a_fixed_pll.hw },
2205 .num_parents = 1,
2206 },
2207 };
2208
2209 static struct clk_regmap g12a_fclk_div5 = {
2210 .data = &(struct clk_regmap_gate_data){
2211 .offset = HHI_FIX_PLL_CNTL1,
2212 .bit_idx = 22,
2213 },
2214 .hw.init = &(struct clk_init_data){
2215 .name = "fclk_div5",
2216 .ops = &clk_regmap_gate_ops,
2217 .parent_hws = (const struct clk_hw *[]) {
2218 &g12a_fclk_div5_div.hw
2219 },
2220 .num_parents = 1,
2221 },
2222 };
2223
2224 static struct clk_fixed_factor g12a_fclk_div7_div = {
2225 .mult = 1,
2226 .div = 7,
2227 .hw.init = &(struct clk_init_data){
2228 .name = "fclk_div7_div",
2229 .ops = &clk_fixed_factor_ops,
2230 .parent_hws = (const struct clk_hw *[]) { &g12a_fixed_pll.hw },
2231 .num_parents = 1,
2232 },
2233 };
2234
2235 static struct clk_regmap g12a_fclk_div7 = {
2236 .data = &(struct clk_regmap_gate_data){
2237 .offset = HHI_FIX_PLL_CNTL1,
2238 .bit_idx = 23,
2239 },
2240 .hw.init = &(struct clk_init_data){
2241 .name = "fclk_div7",
2242 .ops = &clk_regmap_gate_ops,
2243 .parent_hws = (const struct clk_hw *[]) {
2244 &g12a_fclk_div7_div.hw
2245 },
2246 .num_parents = 1,
2247 },
2248 };
2249
2250 static struct clk_fixed_factor g12a_fclk_div2p5_div = {
2251 .mult = 1,
2252 .div = 5,
2253 .hw.init = &(struct clk_init_data){
2254 .name = "fclk_div2p5_div",
2255 .ops = &clk_fixed_factor_ops,
2256 .parent_hws = (const struct clk_hw *[]) {
2257 &g12a_fixed_pll_dco.hw
2258 },
2259 .num_parents = 1,
2260 },
2261 };
2262
2263 static struct clk_regmap g12a_fclk_div2p5 = {
2264 .data = &(struct clk_regmap_gate_data){
2265 .offset = HHI_FIX_PLL_CNTL1,
2266 .bit_idx = 25,
2267 },
2268 .hw.init = &(struct clk_init_data){
2269 .name = "fclk_div2p5",
2270 .ops = &clk_regmap_gate_ops,
2271 .parent_hws = (const struct clk_hw *[]) {
2272 &g12a_fclk_div2p5_div.hw
2273 },
2274 .num_parents = 1,
2275 },
2276 };
2277
2278 static struct clk_fixed_factor g12a_mpll_50m_div = {
2279 .mult = 1,
2280 .div = 80,
2281 .hw.init = &(struct clk_init_data){
2282 .name = "mpll_50m_div",
2283 .ops = &clk_fixed_factor_ops,
2284 .parent_hws = (const struct clk_hw *[]) {
2285 &g12a_fixed_pll_dco.hw
2286 },
2287 .num_parents = 1,
2288 },
2289 };
2290
2291 static struct clk_regmap g12a_mpll_50m = {
2292 .data = &(struct clk_regmap_mux_data){
2293 .offset = HHI_FIX_PLL_CNTL3,
2294 .mask = 0x1,
2295 .shift = 5,
2296 },
2297 .hw.init = &(struct clk_init_data){
2298 .name = "mpll_50m",
2299 .ops = &clk_regmap_mux_ro_ops,
2300 .parent_data = (const struct clk_parent_data []) {
2301 { .fw_name = "xtal", },
2302 { .hw = &g12a_mpll_50m_div.hw },
2303 },
2304 .num_parents = 2,
2305 },
2306 };
2307
2308 static struct clk_fixed_factor g12a_mpll_prediv = {
2309 .mult = 1,
2310 .div = 2,
2311 .hw.init = &(struct clk_init_data){
2312 .name = "mpll_prediv",
2313 .ops = &clk_fixed_factor_ops,
2314 .parent_hws = (const struct clk_hw *[]) {
2315 &g12a_fixed_pll_dco.hw
2316 },
2317 .num_parents = 1,
2318 },
2319 };
2320
2321 static const struct reg_sequence g12a_mpll0_init_regs[] = {
2322 { .reg = HHI_MPLL_CNTL2, .def = 0x40000033 },
2323 };
2324
2325 static struct clk_regmap g12a_mpll0_div = {
2326 .data = &(struct meson_clk_mpll_data){
2327 .sdm = {
2328 .reg_off = HHI_MPLL_CNTL1,
2329 .shift = 0,
2330 .width = 14,
2331 },
2332 .sdm_en = {
2333 .reg_off = HHI_MPLL_CNTL1,
2334 .shift = 30,
2335 .width = 1,
2336 },
2337 .n2 = {
2338 .reg_off = HHI_MPLL_CNTL1,
2339 .shift = 20,
2340 .width = 9,
2341 },
2342 .ssen = {
2343 .reg_off = HHI_MPLL_CNTL1,
2344 .shift = 29,
2345 .width = 1,
2346 },
2347 .init_regs = g12a_mpll0_init_regs,
2348 .init_count = ARRAY_SIZE(g12a_mpll0_init_regs),
2349 },
2350 .hw.init = &(struct clk_init_data){
2351 .name = "mpll0_div",
2352 .ops = &meson_clk_mpll_ops,
2353 .parent_hws = (const struct clk_hw *[]) {
2354 &g12a_mpll_prediv.hw
2355 },
2356 .num_parents = 1,
2357 },
2358 };
2359
2360 static struct clk_regmap g12a_mpll0 = {
2361 .data = &(struct clk_regmap_gate_data){
2362 .offset = HHI_MPLL_CNTL1,
2363 .bit_idx = 31,
2364 },
2365 .hw.init = &(struct clk_init_data){
2366 .name = "mpll0",
2367 .ops = &clk_regmap_gate_ops,
2368 .parent_hws = (const struct clk_hw *[]) { &g12a_mpll0_div.hw },
2369 .num_parents = 1,
2370 .flags = CLK_SET_RATE_PARENT,
2371 },
2372 };
2373
2374 static const struct reg_sequence g12a_mpll1_init_regs[] = {
2375 { .reg = HHI_MPLL_CNTL4, .def = 0x40000033 },
2376 };
2377
2378 static struct clk_regmap g12a_mpll1_div = {
2379 .data = &(struct meson_clk_mpll_data){
2380 .sdm = {
2381 .reg_off = HHI_MPLL_CNTL3,
2382 .shift = 0,
2383 .width = 14,
2384 },
2385 .sdm_en = {
2386 .reg_off = HHI_MPLL_CNTL3,
2387 .shift = 30,
2388 .width = 1,
2389 },
2390 .n2 = {
2391 .reg_off = HHI_MPLL_CNTL3,
2392 .shift = 20,
2393 .width = 9,
2394 },
2395 .ssen = {
2396 .reg_off = HHI_MPLL_CNTL3,
2397 .shift = 29,
2398 .width = 1,
2399 },
2400 .init_regs = g12a_mpll1_init_regs,
2401 .init_count = ARRAY_SIZE(g12a_mpll1_init_regs),
2402 },
2403 .hw.init = &(struct clk_init_data){
2404 .name = "mpll1_div",
2405 .ops = &meson_clk_mpll_ops,
2406 .parent_hws = (const struct clk_hw *[]) {
2407 &g12a_mpll_prediv.hw
2408 },
2409 .num_parents = 1,
2410 },
2411 };
2412
2413 static struct clk_regmap g12a_mpll1 = {
2414 .data = &(struct clk_regmap_gate_data){
2415 .offset = HHI_MPLL_CNTL3,
2416 .bit_idx = 31,
2417 },
2418 .hw.init = &(struct clk_init_data){
2419 .name = "mpll1",
2420 .ops = &clk_regmap_gate_ops,
2421 .parent_hws = (const struct clk_hw *[]) { &g12a_mpll1_div.hw },
2422 .num_parents = 1,
2423 .flags = CLK_SET_RATE_PARENT,
2424 },
2425 };
2426
2427 static const struct reg_sequence g12a_mpll2_init_regs[] = {
2428 { .reg = HHI_MPLL_CNTL6, .def = 0x40000033 },
2429 };
2430
2431 static struct clk_regmap g12a_mpll2_div = {
2432 .data = &(struct meson_clk_mpll_data){
2433 .sdm = {
2434 .reg_off = HHI_MPLL_CNTL5,
2435 .shift = 0,
2436 .width = 14,
2437 },
2438 .sdm_en = {
2439 .reg_off = HHI_MPLL_CNTL5,
2440 .shift = 30,
2441 .width = 1,
2442 },
2443 .n2 = {
2444 .reg_off = HHI_MPLL_CNTL5,
2445 .shift = 20,
2446 .width = 9,
2447 },
2448 .ssen = {
2449 .reg_off = HHI_MPLL_CNTL5,
2450 .shift = 29,
2451 .width = 1,
2452 },
2453 .init_regs = g12a_mpll2_init_regs,
2454 .init_count = ARRAY_SIZE(g12a_mpll2_init_regs),
2455 },
2456 .hw.init = &(struct clk_init_data){
2457 .name = "mpll2_div",
2458 .ops = &meson_clk_mpll_ops,
2459 .parent_hws = (const struct clk_hw *[]) {
2460 &g12a_mpll_prediv.hw
2461 },
2462 .num_parents = 1,
2463 },
2464 };
2465
2466 static struct clk_regmap g12a_mpll2 = {
2467 .data = &(struct clk_regmap_gate_data){
2468 .offset = HHI_MPLL_CNTL5,
2469 .bit_idx = 31,
2470 },
2471 .hw.init = &(struct clk_init_data){
2472 .name = "mpll2",
2473 .ops = &clk_regmap_gate_ops,
2474 .parent_hws = (const struct clk_hw *[]) { &g12a_mpll2_div.hw },
2475 .num_parents = 1,
2476 .flags = CLK_SET_RATE_PARENT,
2477 },
2478 };
2479
2480 static const struct reg_sequence g12a_mpll3_init_regs[] = {
2481 { .reg = HHI_MPLL_CNTL8, .def = 0x40000033 },
2482 };
2483
2484 static struct clk_regmap g12a_mpll3_div = {
2485 .data = &(struct meson_clk_mpll_data){
2486 .sdm = {
2487 .reg_off = HHI_MPLL_CNTL7,
2488 .shift = 0,
2489 .width = 14,
2490 },
2491 .sdm_en = {
2492 .reg_off = HHI_MPLL_CNTL7,
2493 .shift = 30,
2494 .width = 1,
2495 },
2496 .n2 = {
2497 .reg_off = HHI_MPLL_CNTL7,
2498 .shift = 20,
2499 .width = 9,
2500 },
2501 .ssen = {
2502 .reg_off = HHI_MPLL_CNTL7,
2503 .shift = 29,
2504 .width = 1,
2505 },
2506 .init_regs = g12a_mpll3_init_regs,
2507 .init_count = ARRAY_SIZE(g12a_mpll3_init_regs),
2508 },
2509 .hw.init = &(struct clk_init_data){
2510 .name = "mpll3_div",
2511 .ops = &meson_clk_mpll_ops,
2512 .parent_hws = (const struct clk_hw *[]) {
2513 &g12a_mpll_prediv.hw
2514 },
2515 .num_parents = 1,
2516 },
2517 };
2518
2519 static struct clk_regmap g12a_mpll3 = {
2520 .data = &(struct clk_regmap_gate_data){
2521 .offset = HHI_MPLL_CNTL7,
2522 .bit_idx = 31,
2523 },
2524 .hw.init = &(struct clk_init_data){
2525 .name = "mpll3",
2526 .ops = &clk_regmap_gate_ops,
2527 .parent_hws = (const struct clk_hw *[]) { &g12a_mpll3_div.hw },
2528 .num_parents = 1,
2529 .flags = CLK_SET_RATE_PARENT,
2530 },
2531 };
2532
2533 static u32 mux_table_clk81[] = { 0, 2, 3, 4, 5, 6, 7 };
2534 static const struct clk_parent_data clk81_parent_data[] = {
2535 { .fw_name = "xtal", },
2536 { .hw = &g12a_fclk_div7.hw },
2537 { .hw = &g12a_mpll1.hw },
2538 { .hw = &g12a_mpll2.hw },
2539 { .hw = &g12a_fclk_div4.hw },
2540 { .hw = &g12a_fclk_div3.hw },
2541 { .hw = &g12a_fclk_div5.hw },
2542 };
2543
2544 static struct clk_regmap g12a_mpeg_clk_sel = {
2545 .data = &(struct clk_regmap_mux_data){
2546 .offset = HHI_MPEG_CLK_CNTL,
2547 .mask = 0x7,
2548 .shift = 12,
2549 .table = mux_table_clk81,
2550 },
2551 .hw.init = &(struct clk_init_data){
2552 .name = "mpeg_clk_sel",
2553 .ops = &clk_regmap_mux_ro_ops,
2554 .parent_data = clk81_parent_data,
2555 .num_parents = ARRAY_SIZE(clk81_parent_data),
2556 },
2557 };
2558
2559 static struct clk_regmap g12a_mpeg_clk_div = {
2560 .data = &(struct clk_regmap_div_data){
2561 .offset = HHI_MPEG_CLK_CNTL,
2562 .shift = 0,
2563 .width = 7,
2564 },
2565 .hw.init = &(struct clk_init_data){
2566 .name = "mpeg_clk_div",
2567 .ops = &clk_regmap_divider_ops,
2568 .parent_hws = (const struct clk_hw *[]) {
2569 &g12a_mpeg_clk_sel.hw
2570 },
2571 .num_parents = 1,
2572 .flags = CLK_SET_RATE_PARENT,
2573 },
2574 };
2575
2576 static struct clk_regmap g12a_clk81 = {
2577 .data = &(struct clk_regmap_gate_data){
2578 .offset = HHI_MPEG_CLK_CNTL,
2579 .bit_idx = 7,
2580 },
2581 .hw.init = &(struct clk_init_data){
2582 .name = "clk81",
2583 .ops = &clk_regmap_gate_ops,
2584 .parent_hws = (const struct clk_hw *[]) {
2585 &g12a_mpeg_clk_div.hw
2586 },
2587 .num_parents = 1,
2588 .flags = (CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
2589 },
2590 };
2591
2592 static const struct clk_parent_data g12a_sd_emmc_clk0_parent_data[] = {
2593 { .fw_name = "xtal", },
2594 { .hw = &g12a_fclk_div2.hw },
2595 { .hw = &g12a_fclk_div3.hw },
2596 { .hw = &g12a_fclk_div5.hw },
2597 { .hw = &g12a_fclk_div7.hw },
2598 /*
2599 * Following these parent clocks, we should also have had mpll2, mpll3
2600 * and gp0_pll but these clocks are too precious to be used here. All
2601 * the necessary rates for MMC and NAND operation can be achieved using
2602 * g12a_ee_core or fclk_div clocks
2603 */
2604 };
2605
2606 /* SDIO clock */
2607 static struct clk_regmap g12a_sd_emmc_a_clk0_sel = {
2608 .data = &(struct clk_regmap_mux_data){
2609 .offset = HHI_SD_EMMC_CLK_CNTL,
2610 .mask = 0x7,
2611 .shift = 9,
2612 },
2613 .hw.init = &(struct clk_init_data) {
2614 .name = "sd_emmc_a_clk0_sel",
2615 .ops = &clk_regmap_mux_ops,
2616 .parent_data = g12a_sd_emmc_clk0_parent_data,
2617 .num_parents = ARRAY_SIZE(g12a_sd_emmc_clk0_parent_data),
2618 .flags = CLK_SET_RATE_PARENT,
2619 },
2620 };
2621
2622 static struct clk_regmap g12a_sd_emmc_a_clk0_div = {
2623 .data = &(struct clk_regmap_div_data){
2624 .offset = HHI_SD_EMMC_CLK_CNTL,
2625 .shift = 0,
2626 .width = 7,
2627 },
2628 .hw.init = &(struct clk_init_data) {
2629 .name = "sd_emmc_a_clk0_div",
2630 .ops = &clk_regmap_divider_ops,
2631 .parent_hws = (const struct clk_hw *[]) {
2632 &g12a_sd_emmc_a_clk0_sel.hw
2633 },
2634 .num_parents = 1,
2635 .flags = CLK_SET_RATE_PARENT,
2636 },
2637 };
2638
2639 static struct clk_regmap g12a_sd_emmc_a_clk0 = {
2640 .data = &(struct clk_regmap_gate_data){
2641 .offset = HHI_SD_EMMC_CLK_CNTL,
2642 .bit_idx = 7,
2643 },
2644 .hw.init = &(struct clk_init_data){
2645 .name = "sd_emmc_a_clk0",
2646 .ops = &clk_regmap_gate_ops,
2647 .parent_hws = (const struct clk_hw *[]) {
2648 &g12a_sd_emmc_a_clk0_div.hw
2649 },
2650 .num_parents = 1,
2651 .flags = CLK_SET_RATE_PARENT,
2652 },
2653 };
2654
2655 /* SDcard clock */
2656 static struct clk_regmap g12a_sd_emmc_b_clk0_sel = {
2657 .data = &(struct clk_regmap_mux_data){
2658 .offset = HHI_SD_EMMC_CLK_CNTL,
2659 .mask = 0x7,
2660 .shift = 25,
2661 },
2662 .hw.init = &(struct clk_init_data) {
2663 .name = "sd_emmc_b_clk0_sel",
2664 .ops = &clk_regmap_mux_ops,
2665 .parent_data = g12a_sd_emmc_clk0_parent_data,
2666 .num_parents = ARRAY_SIZE(g12a_sd_emmc_clk0_parent_data),
2667 .flags = CLK_SET_RATE_PARENT,
2668 },
2669 };
2670
2671 static struct clk_regmap g12a_sd_emmc_b_clk0_div = {
2672 .data = &(struct clk_regmap_div_data){
2673 .offset = HHI_SD_EMMC_CLK_CNTL,
2674 .shift = 16,
2675 .width = 7,
2676 },
2677 .hw.init = &(struct clk_init_data) {
2678 .name = "sd_emmc_b_clk0_div",
2679 .ops = &clk_regmap_divider_ops,
2680 .parent_hws = (const struct clk_hw *[]) {
2681 &g12a_sd_emmc_b_clk0_sel.hw
2682 },
2683 .num_parents = 1,
2684 .flags = CLK_SET_RATE_PARENT,
2685 },
2686 };
2687
2688 static struct clk_regmap g12a_sd_emmc_b_clk0 = {
2689 .data = &(struct clk_regmap_gate_data){
2690 .offset = HHI_SD_EMMC_CLK_CNTL,
2691 .bit_idx = 23,
2692 },
2693 .hw.init = &(struct clk_init_data){
2694 .name = "sd_emmc_b_clk0",
2695 .ops = &clk_regmap_gate_ops,
2696 .parent_hws = (const struct clk_hw *[]) {
2697 &g12a_sd_emmc_b_clk0_div.hw
2698 },
2699 .num_parents = 1,
2700 .flags = CLK_SET_RATE_PARENT,
2701 },
2702 };
2703
2704 /* EMMC/NAND clock */
2705 static struct clk_regmap g12a_sd_emmc_c_clk0_sel = {
2706 .data = &(struct clk_regmap_mux_data){
2707 .offset = HHI_NAND_CLK_CNTL,
2708 .mask = 0x7,
2709 .shift = 9,
2710 },
2711 .hw.init = &(struct clk_init_data) {
2712 .name = "sd_emmc_c_clk0_sel",
2713 .ops = &clk_regmap_mux_ops,
2714 .parent_data = g12a_sd_emmc_clk0_parent_data,
2715 .num_parents = ARRAY_SIZE(g12a_sd_emmc_clk0_parent_data),
2716 .flags = CLK_SET_RATE_PARENT,
2717 },
2718 };
2719
2720 static struct clk_regmap g12a_sd_emmc_c_clk0_div = {
2721 .data = &(struct clk_regmap_div_data){
2722 .offset = HHI_NAND_CLK_CNTL,
2723 .shift = 0,
2724 .width = 7,
2725 },
2726 .hw.init = &(struct clk_init_data) {
2727 .name = "sd_emmc_c_clk0_div",
2728 .ops = &clk_regmap_divider_ops,
2729 .parent_hws = (const struct clk_hw *[]) {
2730 &g12a_sd_emmc_c_clk0_sel.hw
2731 },
2732 .num_parents = 1,
2733 .flags = CLK_SET_RATE_PARENT,
2734 },
2735 };
2736
2737 static struct clk_regmap g12a_sd_emmc_c_clk0 = {
2738 .data = &(struct clk_regmap_gate_data){
2739 .offset = HHI_NAND_CLK_CNTL,
2740 .bit_idx = 7,
2741 },
2742 .hw.init = &(struct clk_init_data){
2743 .name = "sd_emmc_c_clk0",
2744 .ops = &clk_regmap_gate_ops,
2745 .parent_hws = (const struct clk_hw *[]) {
2746 &g12a_sd_emmc_c_clk0_div.hw
2747 },
2748 .num_parents = 1,
2749 .flags = CLK_SET_RATE_PARENT,
2750 },
2751 };
2752
2753 /* Video Clocks */
2754
2755 static struct clk_regmap g12a_vid_pll_div = {
2756 .data = &(struct meson_vid_pll_div_data){
2757 .val = {
2758 .reg_off = HHI_VID_PLL_CLK_DIV,
2759 .shift = 0,
2760 .width = 15,
2761 },
2762 .sel = {
2763 .reg_off = HHI_VID_PLL_CLK_DIV,
2764 .shift = 16,
2765 .width = 2,
2766 },
2767 },
2768 .hw.init = &(struct clk_init_data) {
2769 .name = "vid_pll_div",
2770 .ops = &meson_vid_pll_div_ro_ops,
2771 .parent_hws = (const struct clk_hw *[]) { &g12a_hdmi_pll.hw },
2772 .num_parents = 1,
2773 .flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
2774 },
2775 };
2776
2777 static const struct clk_hw *g12a_vid_pll_parent_hws[] = {
2778 &g12a_vid_pll_div.hw,
2779 &g12a_hdmi_pll.hw,
2780 };
2781
2782 static struct clk_regmap g12a_vid_pll_sel = {
2783 .data = &(struct clk_regmap_mux_data){
2784 .offset = HHI_VID_PLL_CLK_DIV,
2785 .mask = 0x1,
2786 .shift = 18,
2787 },
2788 .hw.init = &(struct clk_init_data){
2789 .name = "vid_pll_sel",
2790 .ops = &clk_regmap_mux_ops,
2791 /*
2792 * bit 18 selects from 2 possible parents:
2793 * vid_pll_div or hdmi_pll
2794 */
2795 .parent_hws = g12a_vid_pll_parent_hws,
2796 .num_parents = ARRAY_SIZE(g12a_vid_pll_parent_hws),
2797 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
2798 },
2799 };
2800
2801 static struct clk_regmap g12a_vid_pll = {
2802 .data = &(struct clk_regmap_gate_data){
2803 .offset = HHI_VID_PLL_CLK_DIV,
2804 .bit_idx = 19,
2805 },
2806 .hw.init = &(struct clk_init_data) {
2807 .name = "vid_pll",
2808 .ops = &clk_regmap_gate_ops,
2809 .parent_hws = (const struct clk_hw *[]) {
2810 &g12a_vid_pll_sel.hw
2811 },
2812 .num_parents = 1,
2813 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
2814 },
2815 };
2816
2817 /* VPU Clock */
2818
2819 static const struct clk_hw *g12a_vpu_parent_hws[] = {
2820 &g12a_fclk_div3.hw,
2821 &g12a_fclk_div4.hw,
2822 &g12a_fclk_div5.hw,
2823 &g12a_fclk_div7.hw,
2824 &g12a_mpll1.hw,
2825 &g12a_vid_pll.hw,
2826 &g12a_hifi_pll.hw,
2827 &g12a_gp0_pll.hw,
2828 };
2829
2830 static struct clk_regmap g12a_vpu_0_sel = {
2831 .data = &(struct clk_regmap_mux_data){
2832 .offset = HHI_VPU_CLK_CNTL,
2833 .mask = 0x7,
2834 .shift = 9,
2835 },
2836 .hw.init = &(struct clk_init_data){
2837 .name = "vpu_0_sel",
2838 .ops = &clk_regmap_mux_ops,
2839 .parent_hws = g12a_vpu_parent_hws,
2840 .num_parents = ARRAY_SIZE(g12a_vpu_parent_hws),
2841 .flags = CLK_SET_RATE_NO_REPARENT,
2842 },
2843 };
2844
2845 static struct clk_regmap g12a_vpu_0_div = {
2846 .data = &(struct clk_regmap_div_data){
2847 .offset = HHI_VPU_CLK_CNTL,
2848 .shift = 0,
2849 .width = 7,
2850 },
2851 .hw.init = &(struct clk_init_data){
2852 .name = "vpu_0_div",
2853 .ops = &clk_regmap_divider_ops,
2854 .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_0_sel.hw },
2855 .num_parents = 1,
2856 .flags = CLK_SET_RATE_PARENT,
2857 },
2858 };
2859
2860 static struct clk_regmap g12a_vpu_0 = {
2861 .data = &(struct clk_regmap_gate_data){
2862 .offset = HHI_VPU_CLK_CNTL,
2863 .bit_idx = 8,
2864 },
2865 .hw.init = &(struct clk_init_data) {
2866 .name = "vpu_0",
2867 .ops = &clk_regmap_gate_ops,
2868 .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_0_div.hw },
2869 .num_parents = 1,
2870 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
2871 },
2872 };
2873
2874 static struct clk_regmap g12a_vpu_1_sel = {
2875 .data = &(struct clk_regmap_mux_data){
2876 .offset = HHI_VPU_CLK_CNTL,
2877 .mask = 0x7,
2878 .shift = 25,
2879 },
2880 .hw.init = &(struct clk_init_data){
2881 .name = "vpu_1_sel",
2882 .ops = &clk_regmap_mux_ops,
2883 .parent_hws = g12a_vpu_parent_hws,
2884 .num_parents = ARRAY_SIZE(g12a_vpu_parent_hws),
2885 .flags = CLK_SET_RATE_NO_REPARENT,
2886 },
2887 };
2888
2889 static struct clk_regmap g12a_vpu_1_div = {
2890 .data = &(struct clk_regmap_div_data){
2891 .offset = HHI_VPU_CLK_CNTL,
2892 .shift = 16,
2893 .width = 7,
2894 },
2895 .hw.init = &(struct clk_init_data){
2896 .name = "vpu_1_div",
2897 .ops = &clk_regmap_divider_ops,
2898 .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_1_sel.hw },
2899 .num_parents = 1,
2900 .flags = CLK_SET_RATE_PARENT,
2901 },
2902 };
2903
2904 static struct clk_regmap g12a_vpu_1 = {
2905 .data = &(struct clk_regmap_gate_data){
2906 .offset = HHI_VPU_CLK_CNTL,
2907 .bit_idx = 24,
2908 },
2909 .hw.init = &(struct clk_init_data) {
2910 .name = "vpu_1",
2911 .ops = &clk_regmap_gate_ops,
2912 .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_1_div.hw },
2913 .num_parents = 1,
2914 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
2915 },
2916 };
2917
2918 static struct clk_regmap g12a_vpu = {
2919 .data = &(struct clk_regmap_mux_data){
2920 .offset = HHI_VPU_CLK_CNTL,
2921 .mask = 1,
2922 .shift = 31,
2923 },
2924 .hw.init = &(struct clk_init_data){
2925 .name = "vpu",
2926 .ops = &clk_regmap_mux_ops,
2927 /*
2928 * bit 31 selects from 2 possible parents:
2929 * vpu_0 or vpu_1
2930 */
2931 .parent_hws = (const struct clk_hw *[]) {
2932 &g12a_vpu_0.hw,
2933 &g12a_vpu_1.hw,
2934 },
2935 .num_parents = 2,
2936 .flags = CLK_SET_RATE_NO_REPARENT,
2937 },
2938 };
2939
2940 /* VDEC clocks */
2941
2942 static const struct clk_hw *g12a_vdec_parent_hws[] = {
2943 &g12a_fclk_div2p5.hw,
2944 &g12a_fclk_div3.hw,
2945 &g12a_fclk_div4.hw,
2946 &g12a_fclk_div5.hw,
2947 &g12a_fclk_div7.hw,
2948 &g12a_hifi_pll.hw,
2949 &g12a_gp0_pll.hw,
2950 };
2951
2952 static struct clk_regmap g12a_vdec_1_sel = {
2953 .data = &(struct clk_regmap_mux_data){
2954 .offset = HHI_VDEC_CLK_CNTL,
2955 .mask = 0x7,
2956 .shift = 9,
2957 .flags = CLK_MUX_ROUND_CLOSEST,
2958 },
2959 .hw.init = &(struct clk_init_data){
2960 .name = "vdec_1_sel",
2961 .ops = &clk_regmap_mux_ops,
2962 .parent_hws = g12a_vdec_parent_hws,
2963 .num_parents = ARRAY_SIZE(g12a_vdec_parent_hws),
2964 .flags = CLK_SET_RATE_PARENT,
2965 },
2966 };
2967
2968 static struct clk_regmap g12a_vdec_1_div = {
2969 .data = &(struct clk_regmap_div_data){
2970 .offset = HHI_VDEC_CLK_CNTL,
2971 .shift = 0,
2972 .width = 7,
2973 .flags = CLK_DIVIDER_ROUND_CLOSEST,
2974 },
2975 .hw.init = &(struct clk_init_data){
2976 .name = "vdec_1_div",
2977 .ops = &clk_regmap_divider_ops,
2978 .parent_hws = (const struct clk_hw *[]) {
2979 &g12a_vdec_1_sel.hw
2980 },
2981 .num_parents = 1,
2982 .flags = CLK_SET_RATE_PARENT,
2983 },
2984 };
2985
2986 static struct clk_regmap g12a_vdec_1 = {
2987 .data = &(struct clk_regmap_gate_data){
2988 .offset = HHI_VDEC_CLK_CNTL,
2989 .bit_idx = 8,
2990 },
2991 .hw.init = &(struct clk_init_data) {
2992 .name = "vdec_1",
2993 .ops = &clk_regmap_gate_ops,
2994 .parent_hws = (const struct clk_hw *[]) {
2995 &g12a_vdec_1_div.hw
2996 },
2997 .num_parents = 1,
2998 .flags = CLK_SET_RATE_PARENT,
2999 },
3000 };
3001
3002 static struct clk_regmap g12a_vdec_hevcf_sel = {
3003 .data = &(struct clk_regmap_mux_data){
3004 .offset = HHI_VDEC2_CLK_CNTL,
3005 .mask = 0x7,
3006 .shift = 9,
3007 .flags = CLK_MUX_ROUND_CLOSEST,
3008 },
3009 .hw.init = &(struct clk_init_data){
3010 .name = "vdec_hevcf_sel",
3011 .ops = &clk_regmap_mux_ops,
3012 .parent_hws = g12a_vdec_parent_hws,
3013 .num_parents = ARRAY_SIZE(g12a_vdec_parent_hws),
3014 .flags = CLK_SET_RATE_PARENT,
3015 },
3016 };
3017
3018 static struct clk_regmap g12a_vdec_hevcf_div = {
3019 .data = &(struct clk_regmap_div_data){
3020 .offset = HHI_VDEC2_CLK_CNTL,
3021 .shift = 0,
3022 .width = 7,
3023 .flags = CLK_DIVIDER_ROUND_CLOSEST,
3024 },
3025 .hw.init = &(struct clk_init_data){
3026 .name = "vdec_hevcf_div",
3027 .ops = &clk_regmap_divider_ops,
3028 .parent_hws = (const struct clk_hw *[]) {
3029 &g12a_vdec_hevcf_sel.hw
3030 },
3031 .num_parents = 1,
3032 .flags = CLK_SET_RATE_PARENT,
3033 },
3034 };
3035
3036 static struct clk_regmap g12a_vdec_hevcf = {
3037 .data = &(struct clk_regmap_gate_data){
3038 .offset = HHI_VDEC2_CLK_CNTL,
3039 .bit_idx = 8,
3040 },
3041 .hw.init = &(struct clk_init_data) {
3042 .name = "vdec_hevcf",
3043 .ops = &clk_regmap_gate_ops,
3044 .parent_hws = (const struct clk_hw *[]) {
3045 &g12a_vdec_hevcf_div.hw
3046 },
3047 .num_parents = 1,
3048 .flags = CLK_SET_RATE_PARENT,
3049 },
3050 };
3051
3052 static struct clk_regmap g12a_vdec_hevc_sel = {
3053 .data = &(struct clk_regmap_mux_data){
3054 .offset = HHI_VDEC2_CLK_CNTL,
3055 .mask = 0x7,
3056 .shift = 25,
3057 .flags = CLK_MUX_ROUND_CLOSEST,
3058 },
3059 .hw.init = &(struct clk_init_data){
3060 .name = "vdec_hevc_sel",
3061 .ops = &clk_regmap_mux_ops,
3062 .parent_hws = g12a_vdec_parent_hws,
3063 .num_parents = ARRAY_SIZE(g12a_vdec_parent_hws),
3064 .flags = CLK_SET_RATE_PARENT,
3065 },
3066 };
3067
3068 static struct clk_regmap g12a_vdec_hevc_div = {
3069 .data = &(struct clk_regmap_div_data){
3070 .offset = HHI_VDEC2_CLK_CNTL,
3071 .shift = 16,
3072 .width = 7,
3073 .flags = CLK_DIVIDER_ROUND_CLOSEST,
3074 },
3075 .hw.init = &(struct clk_init_data){
3076 .name = "vdec_hevc_div",
3077 .ops = &clk_regmap_divider_ops,
3078 .parent_hws = (const struct clk_hw *[]) {
3079 &g12a_vdec_hevc_sel.hw
3080 },
3081 .num_parents = 1,
3082 .flags = CLK_SET_RATE_PARENT,
3083 },
3084 };
3085
3086 static struct clk_regmap g12a_vdec_hevc = {
3087 .data = &(struct clk_regmap_gate_data){
3088 .offset = HHI_VDEC2_CLK_CNTL,
3089 .bit_idx = 24,
3090 },
3091 .hw.init = &(struct clk_init_data) {
3092 .name = "vdec_hevc",
3093 .ops = &clk_regmap_gate_ops,
3094 .parent_hws = (const struct clk_hw *[]) {
3095 &g12a_vdec_hevc_div.hw
3096 },
3097 .num_parents = 1,
3098 .flags = CLK_SET_RATE_PARENT,
3099 },
3100 };
3101
3102 /* VAPB Clock */
3103
3104 static const struct clk_hw *g12a_vapb_parent_hws[] = {
3105 &g12a_fclk_div4.hw,
3106 &g12a_fclk_div3.hw,
3107 &g12a_fclk_div5.hw,
3108 &g12a_fclk_div7.hw,
3109 &g12a_mpll1.hw,
3110 &g12a_vid_pll.hw,
3111 &g12a_mpll2.hw,
3112 &g12a_fclk_div2p5.hw,
3113 };
3114
3115 static struct clk_regmap g12a_vapb_0_sel = {
3116 .data = &(struct clk_regmap_mux_data){
3117 .offset = HHI_VAPBCLK_CNTL,
3118 .mask = 0x3,
3119 .shift = 9,
3120 },
3121 .hw.init = &(struct clk_init_data){
3122 .name = "vapb_0_sel",
3123 .ops = &clk_regmap_mux_ops,
3124 .parent_hws = g12a_vapb_parent_hws,
3125 .num_parents = ARRAY_SIZE(g12a_vapb_parent_hws),
3126 .flags = CLK_SET_RATE_NO_REPARENT,
3127 },
3128 };
3129
3130 static struct clk_regmap g12a_vapb_0_div = {
3131 .data = &(struct clk_regmap_div_data){
3132 .offset = HHI_VAPBCLK_CNTL,
3133 .shift = 0,
3134 .width = 7,
3135 },
3136 .hw.init = &(struct clk_init_data){
3137 .name = "vapb_0_div",
3138 .ops = &clk_regmap_divider_ops,
3139 .parent_hws = (const struct clk_hw *[]) {
3140 &g12a_vapb_0_sel.hw
3141 },
3142 .num_parents = 1,
3143 .flags = CLK_SET_RATE_PARENT,
3144 },
3145 };
3146
3147 static struct clk_regmap g12a_vapb_0 = {
3148 .data = &(struct clk_regmap_gate_data){
3149 .offset = HHI_VAPBCLK_CNTL,
3150 .bit_idx = 8,
3151 },
3152 .hw.init = &(struct clk_init_data) {
3153 .name = "vapb_0",
3154 .ops = &clk_regmap_gate_ops,
3155 .parent_hws = (const struct clk_hw *[]) {
3156 &g12a_vapb_0_div.hw
3157 },
3158 .num_parents = 1,
3159 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3160 },
3161 };
3162
3163 static struct clk_regmap g12a_vapb_1_sel = {
3164 .data = &(struct clk_regmap_mux_data){
3165 .offset = HHI_VAPBCLK_CNTL,
3166 .mask = 0x3,
3167 .shift = 25,
3168 },
3169 .hw.init = &(struct clk_init_data){
3170 .name = "vapb_1_sel",
3171 .ops = &clk_regmap_mux_ops,
3172 .parent_hws = g12a_vapb_parent_hws,
3173 .num_parents = ARRAY_SIZE(g12a_vapb_parent_hws),
3174 .flags = CLK_SET_RATE_NO_REPARENT,
3175 },
3176 };
3177
3178 static struct clk_regmap g12a_vapb_1_div = {
3179 .data = &(struct clk_regmap_div_data){
3180 .offset = HHI_VAPBCLK_CNTL,
3181 .shift = 16,
3182 .width = 7,
3183 },
3184 .hw.init = &(struct clk_init_data){
3185 .name = "vapb_1_div",
3186 .ops = &clk_regmap_divider_ops,
3187 .parent_hws = (const struct clk_hw *[]) {
3188 &g12a_vapb_1_sel.hw
3189 },
3190 .num_parents = 1,
3191 .flags = CLK_SET_RATE_PARENT,
3192 },
3193 };
3194
3195 static struct clk_regmap g12a_vapb_1 = {
3196 .data = &(struct clk_regmap_gate_data){
3197 .offset = HHI_VAPBCLK_CNTL,
3198 .bit_idx = 24,
3199 },
3200 .hw.init = &(struct clk_init_data) {
3201 .name = "vapb_1",
3202 .ops = &clk_regmap_gate_ops,
3203 .parent_hws = (const struct clk_hw *[]) {
3204 &g12a_vapb_1_div.hw
3205 },
3206 .num_parents = 1,
3207 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3208 },
3209 };
3210
3211 static struct clk_regmap g12a_vapb_sel = {
3212 .data = &(struct clk_regmap_mux_data){
3213 .offset = HHI_VAPBCLK_CNTL,
3214 .mask = 1,
3215 .shift = 31,
3216 },
3217 .hw.init = &(struct clk_init_data){
3218 .name = "vapb_sel",
3219 .ops = &clk_regmap_mux_ops,
3220 /*
3221 * bit 31 selects from 2 possible parents:
3222 * vapb_0 or vapb_1
3223 */
3224 .parent_hws = (const struct clk_hw *[]) {
3225 &g12a_vapb_0.hw,
3226 &g12a_vapb_1.hw,
3227 },
3228 .num_parents = 2,
3229 .flags = CLK_SET_RATE_NO_REPARENT,
3230 },
3231 };
3232
3233 static struct clk_regmap g12a_vapb = {
3234 .data = &(struct clk_regmap_gate_data){
3235 .offset = HHI_VAPBCLK_CNTL,
3236 .bit_idx = 30,
3237 },
3238 .hw.init = &(struct clk_init_data) {
3239 .name = "vapb",
3240 .ops = &clk_regmap_gate_ops,
3241 .parent_hws = (const struct clk_hw *[]) { &g12a_vapb_sel.hw },
3242 .num_parents = 1,
3243 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3244 },
3245 };
3246
3247 static const struct clk_hw *g12a_vclk_parent_hws[] = {
3248 &g12a_vid_pll.hw,
3249 &g12a_gp0_pll.hw,
3250 &g12a_hifi_pll.hw,
3251 &g12a_mpll1.hw,
3252 &g12a_fclk_div3.hw,
3253 &g12a_fclk_div4.hw,
3254 &g12a_fclk_div5.hw,
3255 &g12a_fclk_div7.hw,
3256 };
3257
3258 static struct clk_regmap g12a_vclk_sel = {
3259 .data = &(struct clk_regmap_mux_data){
3260 .offset = HHI_VID_CLK_CNTL,
3261 .mask = 0x7,
3262 .shift = 16,
3263 },
3264 .hw.init = &(struct clk_init_data){
3265 .name = "vclk_sel",
3266 .ops = &clk_regmap_mux_ops,
3267 .parent_hws = g12a_vclk_parent_hws,
3268 .num_parents = ARRAY_SIZE(g12a_vclk_parent_hws),
3269 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3270 },
3271 };
3272
3273 static struct clk_regmap g12a_vclk2_sel = {
3274 .data = &(struct clk_regmap_mux_data){
3275 .offset = HHI_VIID_CLK_CNTL,
3276 .mask = 0x7,
3277 .shift = 16,
3278 },
3279 .hw.init = &(struct clk_init_data){
3280 .name = "vclk2_sel",
3281 .ops = &clk_regmap_mux_ops,
3282 .parent_hws = g12a_vclk_parent_hws,
3283 .num_parents = ARRAY_SIZE(g12a_vclk_parent_hws),
3284 .flags = CLK_SET_RATE_NO_REPARENT,
3285 },
3286 };
3287
3288 static struct clk_regmap g12a_vclk_input = {
3289 .data = &(struct clk_regmap_gate_data){
3290 .offset = HHI_VID_CLK_DIV,
3291 .bit_idx = 16,
3292 },
3293 .hw.init = &(struct clk_init_data) {
3294 .name = "vclk_input",
3295 .ops = &clk_regmap_gate_ops,
3296 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk_sel.hw },
3297 .num_parents = 1,
3298 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3299 },
3300 };
3301
3302 static struct clk_regmap g12a_vclk2_input = {
3303 .data = &(struct clk_regmap_gate_data){
3304 .offset = HHI_VIID_CLK_DIV,
3305 .bit_idx = 16,
3306 },
3307 .hw.init = &(struct clk_init_data) {
3308 .name = "vclk2_input",
3309 .ops = &clk_regmap_gate_ops,
3310 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_sel.hw },
3311 .num_parents = 1,
3312 },
3313 };
3314
3315 static struct clk_regmap g12a_vclk_div = {
3316 .data = &(struct clk_regmap_div_data){
3317 .offset = HHI_VID_CLK_DIV,
3318 .shift = 0,
3319 .width = 8,
3320 },
3321 .hw.init = &(struct clk_init_data){
3322 .name = "vclk_div",
3323 .ops = &clk_regmap_divider_ops,
3324 .parent_hws = (const struct clk_hw *[]) {
3325 &g12a_vclk_input.hw
3326 },
3327 .num_parents = 1,
3328 .flags = CLK_GET_RATE_NOCACHE,
3329 },
3330 };
3331
3332 static struct clk_regmap g12a_vclk2_div = {
3333 .data = &(struct meson_vclk_div_data){
3334 .div = {
3335 .reg_off = HHI_VIID_CLK_DIV,
3336 .shift = 0,
3337 .width = 8,
3338 },
3339 .enable = {
3340 .reg_off = HHI_VIID_CLK_DIV,
3341 .shift = 16,
3342 .width = 1,
3343 },
3344 .reset = {
3345 .reg_off = HHI_VIID_CLK_DIV,
3346 .shift = 17,
3347 .width = 1,
3348 },
3349 .flags = CLK_DIVIDER_ROUND_CLOSEST,
3350 },
3351 .hw.init = &(struct clk_init_data){
3352 .name = "vclk2_div",
3353 .ops = &meson_vclk_div_ops,
3354 .parent_hws = (const struct clk_hw *[]) {
3355 &g12a_vclk2_input.hw
3356 },
3357 .num_parents = 1,
3358 .flags = CLK_SET_RATE_GATE,
3359 },
3360 };
3361
3362 static struct clk_regmap g12a_vclk = {
3363 .data = &(struct clk_regmap_gate_data){
3364 .offset = HHI_VID_CLK_CNTL,
3365 .bit_idx = 19,
3366 },
3367 .hw.init = &(struct clk_init_data) {
3368 .name = "vclk",
3369 .ops = &clk_regmap_gate_ops,
3370 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk_div.hw },
3371 .num_parents = 1,
3372 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3373 },
3374 };
3375
3376 static struct clk_regmap g12a_vclk2 = {
3377 .data = &(struct meson_vclk_gate_data){
3378 .enable = {
3379 .reg_off = HHI_VIID_CLK_CNTL,
3380 .shift = 19,
3381 .width = 1,
3382 },
3383 .reset = {
3384 .reg_off = HHI_VIID_CLK_CNTL,
3385 .shift = 15,
3386 .width = 1,
3387 },
3388 },
3389 .hw.init = &(struct clk_init_data) {
3390 .name = "vclk2",
3391 .ops = &meson_vclk_gate_ops,
3392 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2_div.hw },
3393 .num_parents = 1,
3394 .flags = CLK_SET_RATE_PARENT,
3395 },
3396 };
3397
3398 static struct clk_regmap g12a_vclk_div1 = {
3399 .data = &(struct clk_regmap_gate_data){
3400 .offset = HHI_VID_CLK_CNTL,
3401 .bit_idx = 0,
3402 },
3403 .hw.init = &(struct clk_init_data) {
3404 .name = "vclk_div1",
3405 .ops = &clk_regmap_gate_ops,
3406 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk.hw },
3407 .num_parents = 1,
3408 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3409 },
3410 };
3411
3412 static struct clk_regmap g12a_vclk_div2_en = {
3413 .data = &(struct clk_regmap_gate_data){
3414 .offset = HHI_VID_CLK_CNTL,
3415 .bit_idx = 1,
3416 },
3417 .hw.init = &(struct clk_init_data) {
3418 .name = "vclk_div2_en",
3419 .ops = &clk_regmap_gate_ops,
3420 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk.hw },
3421 .num_parents = 1,
3422 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3423 },
3424 };
3425
3426 static struct clk_regmap g12a_vclk_div4_en = {
3427 .data = &(struct clk_regmap_gate_data){
3428 .offset = HHI_VID_CLK_CNTL,
3429 .bit_idx = 2,
3430 },
3431 .hw.init = &(struct clk_init_data) {
3432 .name = "vclk_div4_en",
3433 .ops = &clk_regmap_gate_ops,
3434 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk.hw },
3435 .num_parents = 1,
3436 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3437 },
3438 };
3439
3440 static struct clk_regmap g12a_vclk_div6_en = {
3441 .data = &(struct clk_regmap_gate_data){
3442 .offset = HHI_VID_CLK_CNTL,
3443 .bit_idx = 3,
3444 },
3445 .hw.init = &(struct clk_init_data) {
3446 .name = "vclk_div6_en",
3447 .ops = &clk_regmap_gate_ops,
3448 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk.hw },
3449 .num_parents = 1,
3450 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3451 },
3452 };
3453
3454 static struct clk_regmap g12a_vclk_div12_en = {
3455 .data = &(struct clk_regmap_gate_data){
3456 .offset = HHI_VID_CLK_CNTL,
3457 .bit_idx = 4,
3458 },
3459 .hw.init = &(struct clk_init_data) {
3460 .name = "vclk_div12_en",
3461 .ops = &clk_regmap_gate_ops,
3462 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk.hw },
3463 .num_parents = 1,
3464 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3465 },
3466 };
3467
3468 static struct clk_regmap g12a_vclk2_div1 = {
3469 .data = &(struct clk_regmap_gate_data){
3470 .offset = HHI_VIID_CLK_CNTL,
3471 .bit_idx = 0,
3472 },
3473 .hw.init = &(struct clk_init_data) {
3474 .name = "vclk2_div1",
3475 .ops = &clk_regmap_gate_ops,
3476 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
3477 .num_parents = 1,
3478 .flags = CLK_SET_RATE_PARENT,
3479 },
3480 };
3481
3482 static struct clk_regmap g12a_vclk2_div2_en = {
3483 .data = &(struct clk_regmap_gate_data){
3484 .offset = HHI_VIID_CLK_CNTL,
3485 .bit_idx = 1,
3486 },
3487 .hw.init = &(struct clk_init_data) {
3488 .name = "vclk2_div2_en",
3489 .ops = &clk_regmap_gate_ops,
3490 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
3491 .num_parents = 1,
3492 .flags = CLK_SET_RATE_PARENT,
3493 },
3494 };
3495
3496 static struct clk_regmap g12a_vclk2_div4_en = {
3497 .data = &(struct clk_regmap_gate_data){
3498 .offset = HHI_VIID_CLK_CNTL,
3499 .bit_idx = 2,
3500 },
3501 .hw.init = &(struct clk_init_data) {
3502 .name = "vclk2_div4_en",
3503 .ops = &clk_regmap_gate_ops,
3504 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
3505 .num_parents = 1,
3506 .flags = CLK_SET_RATE_PARENT,
3507 },
3508 };
3509
3510 static struct clk_regmap g12a_vclk2_div6_en = {
3511 .data = &(struct clk_regmap_gate_data){
3512 .offset = HHI_VIID_CLK_CNTL,
3513 .bit_idx = 3,
3514 },
3515 .hw.init = &(struct clk_init_data) {
3516 .name = "vclk2_div6_en",
3517 .ops = &clk_regmap_gate_ops,
3518 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
3519 .num_parents = 1,
3520 .flags = CLK_SET_RATE_PARENT,
3521 },
3522 };
3523
3524 static struct clk_regmap g12a_vclk2_div12_en = {
3525 .data = &(struct clk_regmap_gate_data){
3526 .offset = HHI_VIID_CLK_CNTL,
3527 .bit_idx = 4,
3528 },
3529 .hw.init = &(struct clk_init_data) {
3530 .name = "vclk2_div12_en",
3531 .ops = &clk_regmap_gate_ops,
3532 .parent_hws = (const struct clk_hw *[]) { &g12a_vclk2.hw },
3533 .num_parents = 1,
3534 .flags = CLK_SET_RATE_PARENT,
3535 },
3536 };
3537
3538 static struct clk_fixed_factor g12a_vclk_div2 = {
3539 .mult = 1,
3540 .div = 2,
3541 .hw.init = &(struct clk_init_data){
3542 .name = "vclk_div2",
3543 .ops = &clk_fixed_factor_ops,
3544 .parent_hws = (const struct clk_hw *[]) {
3545 &g12a_vclk_div2_en.hw
3546 },
3547 .num_parents = 1,
3548 },
3549 };
3550
3551 static struct clk_fixed_factor g12a_vclk_div4 = {
3552 .mult = 1,
3553 .div = 4,
3554 .hw.init = &(struct clk_init_data){
3555 .name = "vclk_div4",
3556 .ops = &clk_fixed_factor_ops,
3557 .parent_hws = (const struct clk_hw *[]) {
3558 &g12a_vclk_div4_en.hw
3559 },
3560 .num_parents = 1,
3561 },
3562 };
3563
3564 static struct clk_fixed_factor g12a_vclk_div6 = {
3565 .mult = 1,
3566 .div = 6,
3567 .hw.init = &(struct clk_init_data){
3568 .name = "vclk_div6",
3569 .ops = &clk_fixed_factor_ops,
3570 .parent_hws = (const struct clk_hw *[]) {
3571 &g12a_vclk_div6_en.hw
3572 },
3573 .num_parents = 1,
3574 },
3575 };
3576
3577 static struct clk_fixed_factor g12a_vclk_div12 = {
3578 .mult = 1,
3579 .div = 12,
3580 .hw.init = &(struct clk_init_data){
3581 .name = "vclk_div12",
3582 .ops = &clk_fixed_factor_ops,
3583 .parent_hws = (const struct clk_hw *[]) {
3584 &g12a_vclk_div12_en.hw
3585 },
3586 .num_parents = 1,
3587 },
3588 };
3589
3590 static struct clk_fixed_factor g12a_vclk2_div2 = {
3591 .mult = 1,
3592 .div = 2,
3593 .hw.init = &(struct clk_init_data){
3594 .name = "vclk2_div2",
3595 .ops = &clk_fixed_factor_ops,
3596 .parent_hws = (const struct clk_hw *[]) {
3597 &g12a_vclk2_div2_en.hw
3598 },
3599 .num_parents = 1,
3600 .flags = CLK_SET_RATE_PARENT,
3601 },
3602 };
3603
3604 static struct clk_fixed_factor g12a_vclk2_div4 = {
3605 .mult = 1,
3606 .div = 4,
3607 .hw.init = &(struct clk_init_data){
3608 .name = "vclk2_div4",
3609 .ops = &clk_fixed_factor_ops,
3610 .parent_hws = (const struct clk_hw *[]) {
3611 &g12a_vclk2_div4_en.hw
3612 },
3613 .num_parents = 1,
3614 .flags = CLK_SET_RATE_PARENT,
3615 },
3616 };
3617
3618 static struct clk_fixed_factor g12a_vclk2_div6 = {
3619 .mult = 1,
3620 .div = 6,
3621 .hw.init = &(struct clk_init_data){
3622 .name = "vclk2_div6",
3623 .ops = &clk_fixed_factor_ops,
3624 .parent_hws = (const struct clk_hw *[]) {
3625 &g12a_vclk2_div6_en.hw
3626 },
3627 .num_parents = 1,
3628 .flags = CLK_SET_RATE_PARENT,
3629 },
3630 };
3631
3632 static struct clk_fixed_factor g12a_vclk2_div12 = {
3633 .mult = 1,
3634 .div = 12,
3635 .hw.init = &(struct clk_init_data){
3636 .name = "vclk2_div12",
3637 .ops = &clk_fixed_factor_ops,
3638 .parent_hws = (const struct clk_hw *[]) {
3639 &g12a_vclk2_div12_en.hw
3640 },
3641 .num_parents = 1,
3642 .flags = CLK_SET_RATE_PARENT,
3643 },
3644 };
3645
3646 static u32 mux_table_cts_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
3647 static const struct clk_hw *g12a_cts_parent_hws[] = {
3648 &g12a_vclk_div1.hw,
3649 &g12a_vclk_div2.hw,
3650 &g12a_vclk_div4.hw,
3651 &g12a_vclk_div6.hw,
3652 &g12a_vclk_div12.hw,
3653 &g12a_vclk2_div1.hw,
3654 &g12a_vclk2_div2.hw,
3655 &g12a_vclk2_div4.hw,
3656 &g12a_vclk2_div6.hw,
3657 &g12a_vclk2_div12.hw,
3658 };
3659
3660 static struct clk_regmap g12a_cts_enci_sel = {
3661 .data = &(struct clk_regmap_mux_data){
3662 .offset = HHI_VID_CLK_DIV,
3663 .mask = 0xf,
3664 .shift = 28,
3665 .table = mux_table_cts_sel,
3666 },
3667 .hw.init = &(struct clk_init_data){
3668 .name = "cts_enci_sel",
3669 .ops = &clk_regmap_mux_ops,
3670 .parent_hws = g12a_cts_parent_hws,
3671 .num_parents = ARRAY_SIZE(g12a_cts_parent_hws),
3672 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3673 },
3674 };
3675
3676 static struct clk_regmap g12a_cts_encp_sel = {
3677 .data = &(struct clk_regmap_mux_data){
3678 .offset = HHI_VID_CLK_DIV,
3679 .mask = 0xf,
3680 .shift = 20,
3681 .table = mux_table_cts_sel,
3682 },
3683 .hw.init = &(struct clk_init_data){
3684 .name = "cts_encp_sel",
3685 .ops = &clk_regmap_mux_ops,
3686 .parent_hws = g12a_cts_parent_hws,
3687 .num_parents = ARRAY_SIZE(g12a_cts_parent_hws),
3688 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3689 },
3690 };
3691
3692 static struct clk_regmap g12a_cts_encl_sel = {
3693 .data = &(struct clk_regmap_mux_data){
3694 .offset = HHI_VIID_CLK_DIV,
3695 .mask = 0xf,
3696 .shift = 12,
3697 .table = mux_table_cts_sel,
3698 },
3699 .hw.init = &(struct clk_init_data){
3700 .name = "cts_encl_sel",
3701 .ops = &clk_regmap_mux_ops,
3702 .parent_hws = g12a_cts_parent_hws,
3703 .num_parents = ARRAY_SIZE(g12a_cts_parent_hws),
3704 .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3705 },
3706 };
3707
3708 static struct clk_regmap g12a_cts_vdac_sel = {
3709 .data = &(struct clk_regmap_mux_data){
3710 .offset = HHI_VIID_CLK_DIV,
3711 .mask = 0xf,
3712 .shift = 28,
3713 .table = mux_table_cts_sel,
3714 },
3715 .hw.init = &(struct clk_init_data){
3716 .name = "cts_vdac_sel",
3717 .ops = &clk_regmap_mux_ops,
3718 .parent_hws = g12a_cts_parent_hws,
3719 .num_parents = ARRAY_SIZE(g12a_cts_parent_hws),
3720 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3721 },
3722 };
3723
3724 /* TOFIX: add support for cts_tcon */
3725 static u32 mux_table_hdmi_tx_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
3726 static const struct clk_hw *g12a_cts_hdmi_tx_parent_hws[] = {
3727 &g12a_vclk_div1.hw,
3728 &g12a_vclk_div2.hw,
3729 &g12a_vclk_div4.hw,
3730 &g12a_vclk_div6.hw,
3731 &g12a_vclk_div12.hw,
3732 &g12a_vclk2_div1.hw,
3733 &g12a_vclk2_div2.hw,
3734 &g12a_vclk2_div4.hw,
3735 &g12a_vclk2_div6.hw,
3736 &g12a_vclk2_div12.hw,
3737 };
3738
3739 static struct clk_regmap g12a_hdmi_tx_sel = {
3740 .data = &(struct clk_regmap_mux_data){
3741 .offset = HHI_HDMI_CLK_CNTL,
3742 .mask = 0xf,
3743 .shift = 16,
3744 .table = mux_table_hdmi_tx_sel,
3745 },
3746 .hw.init = &(struct clk_init_data){
3747 .name = "hdmi_tx_sel",
3748 .ops = &clk_regmap_mux_ops,
3749 .parent_hws = g12a_cts_hdmi_tx_parent_hws,
3750 .num_parents = ARRAY_SIZE(g12a_cts_hdmi_tx_parent_hws),
3751 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3752 },
3753 };
3754
3755 static struct clk_regmap g12a_cts_enci = {
3756 .data = &(struct clk_regmap_gate_data){
3757 .offset = HHI_VID_CLK_CNTL2,
3758 .bit_idx = 0,
3759 },
3760 .hw.init = &(struct clk_init_data) {
3761 .name = "cts_enci",
3762 .ops = &clk_regmap_gate_ops,
3763 .parent_hws = (const struct clk_hw *[]) {
3764 &g12a_cts_enci_sel.hw
3765 },
3766 .num_parents = 1,
3767 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3768 },
3769 };
3770
3771 static struct clk_regmap g12a_cts_encp = {
3772 .data = &(struct clk_regmap_gate_data){
3773 .offset = HHI_VID_CLK_CNTL2,
3774 .bit_idx = 2,
3775 },
3776 .hw.init = &(struct clk_init_data) {
3777 .name = "cts_encp",
3778 .ops = &clk_regmap_gate_ops,
3779 .parent_hws = (const struct clk_hw *[]) {
3780 &g12a_cts_encp_sel.hw
3781 },
3782 .num_parents = 1,
3783 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3784 },
3785 };
3786
3787 static struct clk_regmap g12a_cts_encl = {
3788 .data = &(struct clk_regmap_gate_data){
3789 .offset = HHI_VID_CLK_CNTL2,
3790 .bit_idx = 3,
3791 },
3792 .hw.init = &(struct clk_init_data) {
3793 .name = "cts_encl",
3794 .ops = &clk_regmap_gate_ops,
3795 .parent_hws = (const struct clk_hw *[]) {
3796 &g12a_cts_encl_sel.hw
3797 },
3798 .num_parents = 1,
3799 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3800 },
3801 };
3802
3803 static struct clk_regmap g12a_cts_vdac = {
3804 .data = &(struct clk_regmap_gate_data){
3805 .offset = HHI_VID_CLK_CNTL2,
3806 .bit_idx = 4,
3807 },
3808 .hw.init = &(struct clk_init_data) {
3809 .name = "cts_vdac",
3810 .ops = &clk_regmap_gate_ops,
3811 .parent_hws = (const struct clk_hw *[]) {
3812 &g12a_cts_vdac_sel.hw
3813 },
3814 .num_parents = 1,
3815 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3816 },
3817 };
3818
3819 static struct clk_regmap g12a_hdmi_tx = {
3820 .data = &(struct clk_regmap_gate_data){
3821 .offset = HHI_VID_CLK_CNTL2,
3822 .bit_idx = 5,
3823 },
3824 .hw.init = &(struct clk_init_data) {
3825 .name = "hdmi_tx",
3826 .ops = &clk_regmap_gate_ops,
3827 .parent_hws = (const struct clk_hw *[]) {
3828 &g12a_hdmi_tx_sel.hw
3829 },
3830 .num_parents = 1,
3831 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
3832 },
3833 };
3834
3835 /* MIPI DSI Host Clocks */
3836
3837 static const struct clk_hw *g12a_mipi_dsi_pxclk_parent_hws[] = {
3838 &g12a_vid_pll.hw,
3839 &g12a_gp0_pll.hw,
3840 &g12a_hifi_pll.hw,
3841 &g12a_mpll1.hw,
3842 &g12a_fclk_div2.hw,
3843 &g12a_fclk_div2p5.hw,
3844 &g12a_fclk_div3.hw,
3845 &g12a_fclk_div7.hw,
3846 };
3847
3848 static struct clk_regmap g12a_mipi_dsi_pxclk_sel = {
3849 .data = &(struct clk_regmap_mux_data){
3850 .offset = HHI_MIPIDSI_PHY_CLK_CNTL,
3851 .mask = 0x7,
3852 .shift = 12,
3853 .flags = CLK_MUX_ROUND_CLOSEST,
3854 },
3855 .hw.init = &(struct clk_init_data){
3856 .name = "mipi_dsi_pxclk_sel",
3857 .ops = &clk_regmap_mux_ops,
3858 .parent_hws = g12a_mipi_dsi_pxclk_parent_hws,
3859 .num_parents = ARRAY_SIZE(g12a_mipi_dsi_pxclk_parent_hws),
3860 .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT,
3861 },
3862 };
3863
3864 /*
3865 * FIXME: Force as bypass by forcing a single /1 table entry, and doesn't on boot value
3866 * when setting a clock with this node in the clock path, but doesn't guarantee the divider
3867 * is at /1 at boot until a rate is set.
3868 */
3869 static const struct clk_div_table g12a_mipi_dsi_pxclk_div_table[] = {
3870 { .val = 0, .div = 1 },
3871 { /* sentinel */ },
3872 };
3873
3874 static struct clk_regmap g12a_mipi_dsi_pxclk_div = {
3875 .data = &(struct clk_regmap_div_data){
3876 .offset = HHI_MIPIDSI_PHY_CLK_CNTL,
3877 .shift = 0,
3878 .width = 7,
3879 .table = g12a_mipi_dsi_pxclk_div_table,
3880 },
3881 .hw.init = &(struct clk_init_data){
3882 .name = "mipi_dsi_pxclk_div",
3883 .ops = &clk_regmap_divider_ops,
3884 .parent_hws = (const struct clk_hw *[]) {
3885 &g12a_mipi_dsi_pxclk_sel.hw
3886 },
3887 .num_parents = 1,
3888 .flags = CLK_SET_RATE_PARENT,
3889 },
3890 };
3891
3892 static struct clk_regmap g12a_mipi_dsi_pxclk = {
3893 .data = &(struct clk_regmap_gate_data){
3894 .offset = HHI_MIPIDSI_PHY_CLK_CNTL,
3895 .bit_idx = 8,
3896 },
3897 .hw.init = &(struct clk_init_data) {
3898 .name = "mipi_dsi_pxclk",
3899 .ops = &clk_regmap_gate_ops,
3900 .parent_hws = (const struct clk_hw *[]) {
3901 &g12a_mipi_dsi_pxclk_div.hw
3902 },
3903 .num_parents = 1,
3904 .flags = CLK_SET_RATE_PARENT,
3905 },
3906 };
3907
3908 /* MIPI ISP Clocks */
3909
3910 static const struct clk_parent_data g12b_mipi_isp_parent_data[] = {
3911 { .fw_name = "xtal", },
3912 { .hw = &g12a_gp0_pll.hw },
3913 { .hw = &g12a_hifi_pll.hw },
3914 { .hw = &g12a_fclk_div2p5.hw },
3915 { .hw = &g12a_fclk_div3.hw },
3916 { .hw = &g12a_fclk_div4.hw },
3917 { .hw = &g12a_fclk_div5.hw },
3918 { .hw = &g12a_fclk_div7.hw },
3919 };
3920
3921 static struct clk_regmap g12b_mipi_isp_sel = {
3922 .data = &(struct clk_regmap_mux_data){
3923 .offset = HHI_ISP_CLK_CNTL,
3924 .mask = 7,
3925 .shift = 9,
3926 },
3927 .hw.init = &(struct clk_init_data){
3928 .name = "mipi_isp_sel",
3929 .ops = &clk_regmap_mux_ops,
3930 .parent_data = g12b_mipi_isp_parent_data,
3931 .num_parents = ARRAY_SIZE(g12b_mipi_isp_parent_data),
3932 },
3933 };
3934
3935 static struct clk_regmap g12b_mipi_isp_div = {
3936 .data = &(struct clk_regmap_div_data){
3937 .offset = HHI_ISP_CLK_CNTL,
3938 .shift = 0,
3939 .width = 7,
3940 },
3941 .hw.init = &(struct clk_init_data){
3942 .name = "mipi_isp_div",
3943 .ops = &clk_regmap_divider_ops,
3944 .parent_hws = (const struct clk_hw *[]) {
3945 &g12b_mipi_isp_sel.hw
3946 },
3947 .num_parents = 1,
3948 .flags = CLK_SET_RATE_PARENT,
3949 },
3950 };
3951
3952 static struct clk_regmap g12b_mipi_isp = {
3953 .data = &(struct clk_regmap_gate_data){
3954 .offset = HHI_ISP_CLK_CNTL,
3955 .bit_idx = 8,
3956 },
3957 .hw.init = &(struct clk_init_data) {
3958 .name = "mipi_isp",
3959 .ops = &clk_regmap_gate_ops,
3960 .parent_hws = (const struct clk_hw *[]) {
3961 &g12b_mipi_isp_div.hw
3962 },
3963 .num_parents = 1,
3964 .flags = CLK_SET_RATE_PARENT,
3965 },
3966 };
3967
3968 /* HDMI Clocks */
3969
3970 static const struct clk_parent_data g12a_hdmi_parent_data[] = {
3971 { .fw_name = "xtal", },
3972 { .hw = &g12a_fclk_div4.hw },
3973 { .hw = &g12a_fclk_div3.hw },
3974 { .hw = &g12a_fclk_div5.hw },
3975 };
3976
3977 static struct clk_regmap g12a_hdmi_sel = {
3978 .data = &(struct clk_regmap_mux_data){
3979 .offset = HHI_HDMI_CLK_CNTL,
3980 .mask = 0x3,
3981 .shift = 9,
3982 .flags = CLK_MUX_ROUND_CLOSEST,
3983 },
3984 .hw.init = &(struct clk_init_data){
3985 .name = "hdmi_sel",
3986 .ops = &clk_regmap_mux_ops,
3987 .parent_data = g12a_hdmi_parent_data,
3988 .num_parents = ARRAY_SIZE(g12a_hdmi_parent_data),
3989 .flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
3990 },
3991 };
3992
3993 static struct clk_regmap g12a_hdmi_div = {
3994 .data = &(struct clk_regmap_div_data){
3995 .offset = HHI_HDMI_CLK_CNTL,
3996 .shift = 0,
3997 .width = 7,
3998 },
3999 .hw.init = &(struct clk_init_data){
4000 .name = "hdmi_div",
4001 .ops = &clk_regmap_divider_ops,
4002 .parent_hws = (const struct clk_hw *[]) { &g12a_hdmi_sel.hw },
4003 .num_parents = 1,
4004 .flags = CLK_GET_RATE_NOCACHE,
4005 },
4006 };
4007
4008 static struct clk_regmap g12a_hdmi = {
4009 .data = &(struct clk_regmap_gate_data){
4010 .offset = HHI_HDMI_CLK_CNTL,
4011 .bit_idx = 8,
4012 },
4013 .hw.init = &(struct clk_init_data) {
4014 .name = "hdmi",
4015 .ops = &clk_regmap_gate_ops,
4016 .parent_hws = (const struct clk_hw *[]) { &g12a_hdmi_div.hw },
4017 .num_parents = 1,
4018 .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
4019 },
4020 };
4021
4022 /*
4023 * The MALI IP is clocked by two identical clocks (mali_0 and mali_1)
4024 * muxed by a glitch-free switch. The CCF can manage this glitch-free
4025 * mux because it does top-to-bottom updates the each clock tree and
4026 * switches to the "inactive" one when CLK_SET_RATE_GATE is set.
4027 */
4028 static const struct clk_parent_data g12a_mali_0_1_parent_data[] = {
4029 { .fw_name = "xtal", },
4030 { .hw = &g12a_gp0_pll.hw },
4031 { .hw = &g12a_hifi_pll.hw },
4032 { .hw = &g12a_fclk_div2p5.hw },
4033 { .hw = &g12a_fclk_div3.hw },
4034 { .hw = &g12a_fclk_div4.hw },
4035 { .hw = &g12a_fclk_div5.hw },
4036 { .hw = &g12a_fclk_div7.hw },
4037 };
4038
4039 static struct clk_regmap g12a_mali_0_sel = {
4040 .data = &(struct clk_regmap_mux_data){
4041 .offset = HHI_MALI_CLK_CNTL,
4042 .mask = 0x7,
4043 .shift = 9,
4044 },
4045 .hw.init = &(struct clk_init_data){
4046 .name = "mali_0_sel",
4047 .ops = &clk_regmap_mux_ops,
4048 .parent_data = g12a_mali_0_1_parent_data,
4049 .num_parents = 8,
4050 /*
4051 * Don't request the parent to change the rate because
4052 * all GPU frequencies can be derived from the fclk_*
4053 * clocks and one special GP0_PLL setting. This is
4054 * important because we need the MPLL clocks for audio.
4055 */
4056 .flags = 0,
4057 },
4058 };
4059
4060 static struct clk_regmap g12a_mali_0_div = {
4061 .data = &(struct clk_regmap_div_data){
4062 .offset = HHI_MALI_CLK_CNTL,
4063 .shift = 0,
4064 .width = 7,
4065 },
4066 .hw.init = &(struct clk_init_data){
4067 .name = "mali_0_div",
4068 .ops = &clk_regmap_divider_ops,
4069 .parent_hws = (const struct clk_hw *[]) {
4070 &g12a_mali_0_sel.hw
4071 },
4072 .num_parents = 1,
4073 .flags = CLK_SET_RATE_PARENT,
4074 },
4075 };
4076
4077 static struct clk_regmap g12a_mali_0 = {
4078 .data = &(struct clk_regmap_gate_data){
4079 .offset = HHI_MALI_CLK_CNTL,
4080 .bit_idx = 8,
4081 },
4082 .hw.init = &(struct clk_init_data){
4083 .name = "mali_0",
4084 .ops = &clk_regmap_gate_ops,
4085 .parent_hws = (const struct clk_hw *[]) {
4086 &g12a_mali_0_div.hw
4087 },
4088 .num_parents = 1,
4089 .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
4090 },
4091 };
4092
4093 static struct clk_regmap g12a_mali_1_sel = {
4094 .data = &(struct clk_regmap_mux_data){
4095 .offset = HHI_MALI_CLK_CNTL,
4096 .mask = 0x7,
4097 .shift = 25,
4098 },
4099 .hw.init = &(struct clk_init_data){
4100 .name = "mali_1_sel",
4101 .ops = &clk_regmap_mux_ops,
4102 .parent_data = g12a_mali_0_1_parent_data,
4103 .num_parents = 8,
4104 /*
4105 * Don't request the parent to change the rate because
4106 * all GPU frequencies can be derived from the fclk_*
4107 * clocks and one special GP0_PLL setting. This is
4108 * important because we need the MPLL clocks for audio.
4109 */
4110 .flags = 0,
4111 },
4112 };
4113
4114 static struct clk_regmap g12a_mali_1_div = {
4115 .data = &(struct clk_regmap_div_data){
4116 .offset = HHI_MALI_CLK_CNTL,
4117 .shift = 16,
4118 .width = 7,
4119 },
4120 .hw.init = &(struct clk_init_data){
4121 .name = "mali_1_div",
4122 .ops = &clk_regmap_divider_ops,
4123 .parent_hws = (const struct clk_hw *[]) {
4124 &g12a_mali_1_sel.hw
4125 },
4126 .num_parents = 1,
4127 .flags = CLK_SET_RATE_PARENT,
4128 },
4129 };
4130
4131 static struct clk_regmap g12a_mali_1 = {
4132 .data = &(struct clk_regmap_gate_data){
4133 .offset = HHI_MALI_CLK_CNTL,
4134 .bit_idx = 24,
4135 },
4136 .hw.init = &(struct clk_init_data){
4137 .name = "mali_1",
4138 .ops = &clk_regmap_gate_ops,
4139 .parent_hws = (const struct clk_hw *[]) {
4140 &g12a_mali_1_div.hw
4141 },
4142 .num_parents = 1,
4143 .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
4144 },
4145 };
4146
4147 static const struct clk_hw *g12a_mali_parent_hws[] = {
4148 &g12a_mali_0.hw,
4149 &g12a_mali_1.hw,
4150 };
4151
4152 static struct clk_regmap g12a_mali = {
4153 .data = &(struct clk_regmap_mux_data){
4154 .offset = HHI_MALI_CLK_CNTL,
4155 .mask = 1,
4156 .shift = 31,
4157 },
4158 .hw.init = &(struct clk_init_data){
4159 .name = "mali",
4160 .ops = &clk_regmap_mux_ops,
4161 .parent_hws = g12a_mali_parent_hws,
4162 .num_parents = 2,
4163 .flags = CLK_SET_RATE_PARENT,
4164 },
4165 };
4166
4167 static struct clk_regmap g12a_ts_div = {
4168 .data = &(struct clk_regmap_div_data){
4169 .offset = HHI_TS_CLK_CNTL,
4170 .shift = 0,
4171 .width = 8,
4172 },
4173 .hw.init = &(struct clk_init_data){
4174 .name = "ts_div",
4175 .ops = &clk_regmap_divider_ro_ops,
4176 .parent_data = &(const struct clk_parent_data) {
4177 .fw_name = "xtal",
4178 },
4179 .num_parents = 1,
4180 },
4181 };
4182
4183 static struct clk_regmap g12a_ts = {
4184 .data = &(struct clk_regmap_gate_data){
4185 .offset = HHI_TS_CLK_CNTL,
4186 .bit_idx = 8,
4187 },
4188 .hw.init = &(struct clk_init_data){
4189 .name = "ts",
4190 .ops = &clk_regmap_gate_ops,
4191 .parent_hws = (const struct clk_hw *[]) {
4192 &g12a_ts_div.hw
4193 },
4194 .num_parents = 1,
4195 },
4196 };
4197
4198 /* SPICC SCLK source clock */
4199
4200 static const struct clk_parent_data spicc_sclk_parent_data[] = {
4201 { .fw_name = "xtal", },
4202 { .hw = &g12a_clk81.hw },
4203 { .hw = &g12a_fclk_div4.hw },
4204 { .hw = &g12a_fclk_div3.hw },
4205 { .hw = &g12a_fclk_div2.hw },
4206 { .hw = &g12a_fclk_div5.hw },
4207 { .hw = &g12a_fclk_div7.hw },
4208 };
4209
4210 static struct clk_regmap g12a_spicc0_sclk_sel = {
4211 .data = &(struct clk_regmap_mux_data){
4212 .offset = HHI_SPICC_CLK_CNTL,
4213 .mask = 7,
4214 .shift = 7,
4215 },
4216 .hw.init = &(struct clk_init_data){
4217 .name = "spicc0_sclk_sel",
4218 .ops = &clk_regmap_mux_ops,
4219 .parent_data = spicc_sclk_parent_data,
4220 .num_parents = ARRAY_SIZE(spicc_sclk_parent_data),
4221 },
4222 };
4223
4224 static struct clk_regmap g12a_spicc0_sclk_div = {
4225 .data = &(struct clk_regmap_div_data){
4226 .offset = HHI_SPICC_CLK_CNTL,
4227 .shift = 0,
4228 .width = 6,
4229 },
4230 .hw.init = &(struct clk_init_data){
4231 .name = "spicc0_sclk_div",
4232 .ops = &clk_regmap_divider_ops,
4233 .parent_hws = (const struct clk_hw *[]) {
4234 &g12a_spicc0_sclk_sel.hw
4235 },
4236 .num_parents = 1,
4237 .flags = CLK_SET_RATE_PARENT,
4238 },
4239 };
4240
4241 static struct clk_regmap g12a_spicc0_sclk = {
4242 .data = &(struct clk_regmap_gate_data){
4243 .offset = HHI_SPICC_CLK_CNTL,
4244 .bit_idx = 6,
4245 },
4246 .hw.init = &(struct clk_init_data){
4247 .name = "spicc0_sclk",
4248 .ops = &clk_regmap_gate_ops,
4249 .parent_hws = (const struct clk_hw *[]) {
4250 &g12a_spicc0_sclk_div.hw
4251 },
4252 .num_parents = 1,
4253 .flags = CLK_SET_RATE_PARENT,
4254 },
4255 };
4256
4257 static struct clk_regmap g12a_spicc1_sclk_sel = {
4258 .data = &(struct clk_regmap_mux_data){
4259 .offset = HHI_SPICC_CLK_CNTL,
4260 .mask = 7,
4261 .shift = 23,
4262 },
4263 .hw.init = &(struct clk_init_data){
4264 .name = "spicc1_sclk_sel",
4265 .ops = &clk_regmap_mux_ops,
4266 .parent_data = spicc_sclk_parent_data,
4267 .num_parents = ARRAY_SIZE(spicc_sclk_parent_data),
4268 },
4269 };
4270
4271 static struct clk_regmap g12a_spicc1_sclk_div = {
4272 .data = &(struct clk_regmap_div_data){
4273 .offset = HHI_SPICC_CLK_CNTL,
4274 .shift = 16,
4275 .width = 6,
4276 },
4277 .hw.init = &(struct clk_init_data){
4278 .name = "spicc1_sclk_div",
4279 .ops = &clk_regmap_divider_ops,
4280 .parent_hws = (const struct clk_hw *[]) {
4281 &g12a_spicc1_sclk_sel.hw
4282 },
4283 .num_parents = 1,
4284 .flags = CLK_SET_RATE_PARENT,
4285 },
4286 };
4287
4288 static struct clk_regmap g12a_spicc1_sclk = {
4289 .data = &(struct clk_regmap_gate_data){
4290 .offset = HHI_SPICC_CLK_CNTL,
4291 .bit_idx = 22,
4292 },
4293 .hw.init = &(struct clk_init_data){
4294 .name = "spicc1_sclk",
4295 .ops = &clk_regmap_gate_ops,
4296 .parent_hws = (const struct clk_hw *[]) {
4297 &g12a_spicc1_sclk_div.hw
4298 },
4299 .num_parents = 1,
4300 .flags = CLK_SET_RATE_PARENT,
4301 },
4302 };
4303
4304 /* Neural Network Accelerator source clock */
4305
4306 static const struct clk_parent_data nna_clk_parent_data[] = {
4307 { .fw_name = "xtal", },
4308 { .hw = &g12a_gp0_pll.hw, },
4309 { .hw = &g12a_hifi_pll.hw, },
4310 { .hw = &g12a_fclk_div2p5.hw, },
4311 { .hw = &g12a_fclk_div3.hw, },
4312 { .hw = &g12a_fclk_div4.hw, },
4313 { .hw = &g12a_fclk_div5.hw, },
4314 { .hw = &g12a_fclk_div7.hw },
4315 };
4316
4317 static struct clk_regmap sm1_nna_axi_clk_sel = {
4318 .data = &(struct clk_regmap_mux_data){
4319 .offset = HHI_NNA_CLK_CNTL,
4320 .mask = 7,
4321 .shift = 9,
4322 },
4323 .hw.init = &(struct clk_init_data){
4324 .name = "nna_axi_clk_sel",
4325 .ops = &clk_regmap_mux_ops,
4326 .parent_data = nna_clk_parent_data,
4327 .num_parents = ARRAY_SIZE(nna_clk_parent_data),
4328 },
4329 };
4330
4331 static struct clk_regmap sm1_nna_axi_clk_div = {
4332 .data = &(struct clk_regmap_div_data){
4333 .offset = HHI_NNA_CLK_CNTL,
4334 .shift = 0,
4335 .width = 7,
4336 },
4337 .hw.init = &(struct clk_init_data){
4338 .name = "nna_axi_clk_div",
4339 .ops = &clk_regmap_divider_ops,
4340 .parent_hws = (const struct clk_hw *[]) {
4341 &sm1_nna_axi_clk_sel.hw
4342 },
4343 .num_parents = 1,
4344 .flags = CLK_SET_RATE_PARENT,
4345 },
4346 };
4347
4348 static struct clk_regmap sm1_nna_axi_clk = {
4349 .data = &(struct clk_regmap_gate_data){
4350 .offset = HHI_NNA_CLK_CNTL,
4351 .bit_idx = 8,
4352 },
4353 .hw.init = &(struct clk_init_data){
4354 .name = "nna_axi_clk",
4355 .ops = &clk_regmap_gate_ops,
4356 .parent_hws = (const struct clk_hw *[]) {
4357 &sm1_nna_axi_clk_div.hw
4358 },
4359 .num_parents = 1,
4360 .flags = CLK_SET_RATE_PARENT,
4361 },
4362 };
4363
4364 static struct clk_regmap sm1_nna_core_clk_sel = {
4365 .data = &(struct clk_regmap_mux_data){
4366 .offset = HHI_NNA_CLK_CNTL,
4367 .mask = 7,
4368 .shift = 25,
4369 },
4370 .hw.init = &(struct clk_init_data){
4371 .name = "nna_core_clk_sel",
4372 .ops = &clk_regmap_mux_ops,
4373 .parent_data = nna_clk_parent_data,
4374 .num_parents = ARRAY_SIZE(nna_clk_parent_data),
4375 },
4376 };
4377
4378 static struct clk_regmap sm1_nna_core_clk_div = {
4379 .data = &(struct clk_regmap_div_data){
4380 .offset = HHI_NNA_CLK_CNTL,
4381 .shift = 16,
4382 .width = 7,
4383 },
4384 .hw.init = &(struct clk_init_data){
4385 .name = "nna_core_clk_div",
4386 .ops = &clk_regmap_divider_ops,
4387 .parent_hws = (const struct clk_hw *[]) {
4388 &sm1_nna_core_clk_sel.hw
4389 },
4390 .num_parents = 1,
4391 .flags = CLK_SET_RATE_PARENT,
4392 },
4393 };
4394
4395 static struct clk_regmap sm1_nna_core_clk = {
4396 .data = &(struct clk_regmap_gate_data){
4397 .offset = HHI_NNA_CLK_CNTL,
4398 .bit_idx = 24,
4399 },
4400 .hw.init = &(struct clk_init_data){
4401 .name = "nna_core_clk",
4402 .ops = &clk_regmap_gate_ops,
4403 .parent_hws = (const struct clk_hw *[]) {
4404 &sm1_nna_core_clk_div.hw
4405 },
4406 .num_parents = 1,
4407 .flags = CLK_SET_RATE_PARENT,
4408 },
4409 };
4410
4411 #define MESON_GATE(_name, _reg, _bit) \
4412 MESON_PCLK(_name, _reg, _bit, &g12a_clk81.hw)
4413
4414 #define MESON_GATE_RO(_name, _reg, _bit) \
4415 MESON_PCLK_RO(_name, _reg, _bit, &g12a_clk81.hw)
4416
4417 /* Everything Else (EE) domain gates */
4418 static MESON_GATE(g12a_ddr, HHI_GCLK_MPEG0, 0);
4419 static MESON_GATE(g12a_dos, HHI_GCLK_MPEG0, 1);
4420 static MESON_GATE(g12a_audio_locker, HHI_GCLK_MPEG0, 2);
4421 static MESON_GATE(g12a_mipi_dsi_host, HHI_GCLK_MPEG0, 3);
4422 static MESON_GATE(g12a_eth_phy, HHI_GCLK_MPEG0, 4);
4423 static MESON_GATE(g12a_isa, HHI_GCLK_MPEG0, 5);
4424 static MESON_GATE(g12a_pl301, HHI_GCLK_MPEG0, 6);
4425 static MESON_GATE(g12a_periphs, HHI_GCLK_MPEG0, 7);
4426 static MESON_GATE(g12a_spicc_0, HHI_GCLK_MPEG0, 8);
4427 static MESON_GATE(g12a_i2c, HHI_GCLK_MPEG0, 9);
4428 static MESON_GATE(g12a_sana, HHI_GCLK_MPEG0, 10);
4429 static MESON_GATE(g12a_sd, HHI_GCLK_MPEG0, 11);
4430 static MESON_GATE(g12a_rng0, HHI_GCLK_MPEG0, 12);
4431 static MESON_GATE(g12a_uart0, HHI_GCLK_MPEG0, 13);
4432 static MESON_GATE(g12a_spicc_1, HHI_GCLK_MPEG0, 14);
4433 static MESON_GATE(g12a_hiu_reg, HHI_GCLK_MPEG0, 19);
4434 static MESON_GATE(g12a_mipi_dsi_phy, HHI_GCLK_MPEG0, 20);
4435 static MESON_GATE(g12a_assist_misc, HHI_GCLK_MPEG0, 23);
4436 static MESON_GATE(g12a_emmc_a, HHI_GCLK_MPEG0, 24);
4437 static MESON_GATE(g12a_emmc_b, HHI_GCLK_MPEG0, 25);
4438 static MESON_GATE(g12a_emmc_c, HHI_GCLK_MPEG0, 26);
4439 static MESON_GATE(g12a_audio_codec, HHI_GCLK_MPEG0, 28);
4440
4441 static MESON_GATE(g12a_audio, HHI_GCLK_MPEG1, 0);
4442 static MESON_GATE(g12a_eth_core, HHI_GCLK_MPEG1, 3);
4443 static MESON_GATE(g12a_demux, HHI_GCLK_MPEG1, 4);
4444 static MESON_GATE(g12a_audio_ififo, HHI_GCLK_MPEG1, 11);
4445 static MESON_GATE(g12a_adc, HHI_GCLK_MPEG1, 13);
4446 static MESON_GATE(g12a_uart1, HHI_GCLK_MPEG1, 16);
4447 static MESON_GATE(g12a_g2d, HHI_GCLK_MPEG1, 20);
4448 static MESON_GATE(g12a_reset, HHI_GCLK_MPEG1, 23);
4449 static MESON_GATE(g12a_pcie_comb, HHI_GCLK_MPEG1, 24);
4450 static MESON_GATE(g12a_parser, HHI_GCLK_MPEG1, 25);
4451 static MESON_GATE(g12a_usb_general, HHI_GCLK_MPEG1, 26);
4452 static MESON_GATE(g12a_pcie_phy, HHI_GCLK_MPEG1, 27);
4453 static MESON_GATE(g12a_ahb_arb0, HHI_GCLK_MPEG1, 29);
4454
4455 static MESON_GATE(g12a_ahb_data_bus, HHI_GCLK_MPEG2, 1);
4456 static MESON_GATE(g12a_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
4457 static MESON_GATE(g12a_htx_hdcp22, HHI_GCLK_MPEG2, 3);
4458 static MESON_GATE(g12a_htx_pclk, HHI_GCLK_MPEG2, 4);
4459 static MESON_GATE(g12a_bt656, HHI_GCLK_MPEG2, 6);
4460 static MESON_GATE(g12a_usb1_to_ddr, HHI_GCLK_MPEG2, 8);
4461 static MESON_GATE(g12b_mipi_isp_gate, HHI_GCLK_MPEG2, 17);
4462 static MESON_GATE(g12a_mmc_pclk, HHI_GCLK_MPEG2, 11);
4463 static MESON_GATE(g12a_uart2, HHI_GCLK_MPEG2, 15);
4464 static MESON_GATE(g12a_vpu_intr, HHI_GCLK_MPEG2, 25);
4465 static MESON_GATE(g12b_csi_phy1, HHI_GCLK_MPEG2, 28);
4466 static MESON_GATE(g12b_csi_phy0, HHI_GCLK_MPEG2, 29);
4467 static MESON_GATE(g12a_gic, HHI_GCLK_MPEG2, 30);
4468
4469 static MESON_GATE(g12a_vclk2_venci0, HHI_GCLK_OTHER, 1);
4470 static MESON_GATE(g12a_vclk2_venci1, HHI_GCLK_OTHER, 2);
4471 static MESON_GATE(g12a_vclk2_vencp0, HHI_GCLK_OTHER, 3);
4472 static MESON_GATE(g12a_vclk2_vencp1, HHI_GCLK_OTHER, 4);
4473 static MESON_GATE(g12a_vclk2_venct0, HHI_GCLK_OTHER, 5);
4474 static MESON_GATE(g12a_vclk2_venct1, HHI_GCLK_OTHER, 6);
4475 static MESON_GATE(g12a_vclk2_other, HHI_GCLK_OTHER, 7);
4476 static MESON_GATE(g12a_vclk2_enci, HHI_GCLK_OTHER, 8);
4477 static MESON_GATE(g12a_vclk2_encp, HHI_GCLK_OTHER, 9);
4478 static MESON_GATE(g12a_dac_clk, HHI_GCLK_OTHER, 10);
4479 static MESON_GATE(g12a_aoclk_gate, HHI_GCLK_OTHER, 14);
4480 static MESON_GATE(g12a_iec958_gate, HHI_GCLK_OTHER, 16);
4481 static MESON_GATE(g12a_enc480p, HHI_GCLK_OTHER, 20);
4482 static MESON_GATE(g12a_rng1, HHI_GCLK_OTHER, 21);
4483 static MESON_GATE(g12a_vclk2_enct, HHI_GCLK_OTHER, 22);
4484 static MESON_GATE(g12a_vclk2_encl, HHI_GCLK_OTHER, 23);
4485 static MESON_GATE(g12a_vclk2_venclmmc, HHI_GCLK_OTHER, 24);
4486 static MESON_GATE(g12a_vclk2_vencl, HHI_GCLK_OTHER, 25);
4487 static MESON_GATE(g12a_vclk2_other1, HHI_GCLK_OTHER, 26);
4488
4489 static MESON_GATE_RO(g12a_dma, HHI_GCLK_OTHER2, 0);
4490 static MESON_GATE_RO(g12a_efuse, HHI_GCLK_OTHER2, 1);
4491 static MESON_GATE_RO(g12a_rom_boot, HHI_GCLK_OTHER2, 2);
4492 static MESON_GATE_RO(g12a_reset_sec, HHI_GCLK_OTHER2, 3);
4493 static MESON_GATE_RO(g12a_sec_ahb_apb3, HHI_GCLK_OTHER2, 4);
4494
4495 /* Array of all clocks provided by this provider */
4496 static struct clk_hw *g12a_hw_clks[] = {
4497 [CLKID_SYS_PLL] = &g12a_sys_pll.hw,
4498 [CLKID_FIXED_PLL] = &g12a_fixed_pll.hw,
4499 [CLKID_FCLK_DIV2] = &g12a_fclk_div2.hw,
4500 [CLKID_FCLK_DIV3] = &g12a_fclk_div3.hw,
4501 [CLKID_FCLK_DIV4] = &g12a_fclk_div4.hw,
4502 [CLKID_FCLK_DIV5] = &g12a_fclk_div5.hw,
4503 [CLKID_FCLK_DIV7] = &g12a_fclk_div7.hw,
4504 [CLKID_FCLK_DIV2P5] = &g12a_fclk_div2p5.hw,
4505 [CLKID_GP0_PLL] = &g12a_gp0_pll.hw,
4506 [CLKID_MPEG_SEL] = &g12a_mpeg_clk_sel.hw,
4507 [CLKID_MPEG_DIV] = &g12a_mpeg_clk_div.hw,
4508 [CLKID_CLK81] = &g12a_clk81.hw,
4509 [CLKID_MPLL0] = &g12a_mpll0.hw,
4510 [CLKID_MPLL1] = &g12a_mpll1.hw,
4511 [CLKID_MPLL2] = &g12a_mpll2.hw,
4512 [CLKID_MPLL3] = &g12a_mpll3.hw,
4513 [CLKID_DDR] = &g12a_ddr.hw,
4514 [CLKID_DOS] = &g12a_dos.hw,
4515 [CLKID_AUDIO_LOCKER] = &g12a_audio_locker.hw,
4516 [CLKID_MIPI_DSI_HOST] = &g12a_mipi_dsi_host.hw,
4517 [CLKID_ETH_PHY] = &g12a_eth_phy.hw,
4518 [CLKID_ISA] = &g12a_isa.hw,
4519 [CLKID_PL301] = &g12a_pl301.hw,
4520 [CLKID_PERIPHS] = &g12a_periphs.hw,
4521 [CLKID_SPICC0] = &g12a_spicc_0.hw,
4522 [CLKID_I2C] = &g12a_i2c.hw,
4523 [CLKID_SANA] = &g12a_sana.hw,
4524 [CLKID_SD] = &g12a_sd.hw,
4525 [CLKID_RNG0] = &g12a_rng0.hw,
4526 [CLKID_UART0] = &g12a_uart0.hw,
4527 [CLKID_SPICC1] = &g12a_spicc_1.hw,
4528 [CLKID_HIU_IFACE] = &g12a_hiu_reg.hw,
4529 [CLKID_MIPI_DSI_PHY] = &g12a_mipi_dsi_phy.hw,
4530 [CLKID_ASSIST_MISC] = &g12a_assist_misc.hw,
4531 [CLKID_SD_EMMC_A] = &g12a_emmc_a.hw,
4532 [CLKID_SD_EMMC_B] = &g12a_emmc_b.hw,
4533 [CLKID_SD_EMMC_C] = &g12a_emmc_c.hw,
4534 [CLKID_AUDIO_CODEC] = &g12a_audio_codec.hw,
4535 [CLKID_AUDIO] = &g12a_audio.hw,
4536 [CLKID_ETH] = &g12a_eth_core.hw,
4537 [CLKID_DEMUX] = &g12a_demux.hw,
4538 [CLKID_AUDIO_IFIFO] = &g12a_audio_ififo.hw,
4539 [CLKID_ADC] = &g12a_adc.hw,
4540 [CLKID_UART1] = &g12a_uart1.hw,
4541 [CLKID_G2D] = &g12a_g2d.hw,
4542 [CLKID_RESET] = &g12a_reset.hw,
4543 [CLKID_PCIE_COMB] = &g12a_pcie_comb.hw,
4544 [CLKID_PARSER] = &g12a_parser.hw,
4545 [CLKID_USB] = &g12a_usb_general.hw,
4546 [CLKID_PCIE_PHY] = &g12a_pcie_phy.hw,
4547 [CLKID_AHB_ARB0] = &g12a_ahb_arb0.hw,
4548 [CLKID_AHB_DATA_BUS] = &g12a_ahb_data_bus.hw,
4549 [CLKID_AHB_CTRL_BUS] = &g12a_ahb_ctrl_bus.hw,
4550 [CLKID_HTX_HDCP22] = &g12a_htx_hdcp22.hw,
4551 [CLKID_HTX_PCLK] = &g12a_htx_pclk.hw,
4552 [CLKID_BT656] = &g12a_bt656.hw,
4553 [CLKID_USB1_DDR_BRIDGE] = &g12a_usb1_to_ddr.hw,
4554 [CLKID_MMC_PCLK] = &g12a_mmc_pclk.hw,
4555 [CLKID_UART2] = &g12a_uart2.hw,
4556 [CLKID_VPU_INTR] = &g12a_vpu_intr.hw,
4557 [CLKID_GIC] = &g12a_gic.hw,
4558 [CLKID_SD_EMMC_A_CLK0_SEL] = &g12a_sd_emmc_a_clk0_sel.hw,
4559 [CLKID_SD_EMMC_A_CLK0_DIV] = &g12a_sd_emmc_a_clk0_div.hw,
4560 [CLKID_SD_EMMC_A_CLK0] = &g12a_sd_emmc_a_clk0.hw,
4561 [CLKID_SD_EMMC_B_CLK0_SEL] = &g12a_sd_emmc_b_clk0_sel.hw,
4562 [CLKID_SD_EMMC_B_CLK0_DIV] = &g12a_sd_emmc_b_clk0_div.hw,
4563 [CLKID_SD_EMMC_B_CLK0] = &g12a_sd_emmc_b_clk0.hw,
4564 [CLKID_SD_EMMC_C_CLK0_SEL] = &g12a_sd_emmc_c_clk0_sel.hw,
4565 [CLKID_SD_EMMC_C_CLK0_DIV] = &g12a_sd_emmc_c_clk0_div.hw,
4566 [CLKID_SD_EMMC_C_CLK0] = &g12a_sd_emmc_c_clk0.hw,
4567 [CLKID_MPLL0_DIV] = &g12a_mpll0_div.hw,
4568 [CLKID_MPLL1_DIV] = &g12a_mpll1_div.hw,
4569 [CLKID_MPLL2_DIV] = &g12a_mpll2_div.hw,
4570 [CLKID_MPLL3_DIV] = &g12a_mpll3_div.hw,
4571 [CLKID_FCLK_DIV2_DIV] = &g12a_fclk_div2_div.hw,
4572 [CLKID_FCLK_DIV3_DIV] = &g12a_fclk_div3_div.hw,
4573 [CLKID_FCLK_DIV4_DIV] = &g12a_fclk_div4_div.hw,
4574 [CLKID_FCLK_DIV5_DIV] = &g12a_fclk_div5_div.hw,
4575 [CLKID_FCLK_DIV7_DIV] = &g12a_fclk_div7_div.hw,
4576 [CLKID_FCLK_DIV2P5_DIV] = &g12a_fclk_div2p5_div.hw,
4577 [CLKID_HIFI_PLL] = &g12a_hifi_pll.hw,
4578 [CLKID_VCLK2_VENCI0] = &g12a_vclk2_venci0.hw,
4579 [CLKID_VCLK2_VENCI1] = &g12a_vclk2_venci1.hw,
4580 [CLKID_VCLK2_VENCP0] = &g12a_vclk2_vencp0.hw,
4581 [CLKID_VCLK2_VENCP1] = &g12a_vclk2_vencp1.hw,
4582 [CLKID_VCLK2_VENCT0] = &g12a_vclk2_venct0.hw,
4583 [CLKID_VCLK2_VENCT1] = &g12a_vclk2_venct1.hw,
4584 [CLKID_VCLK2_OTHER] = &g12a_vclk2_other.hw,
4585 [CLKID_VCLK2_ENCI] = &g12a_vclk2_enci.hw,
4586 [CLKID_VCLK2_ENCP] = &g12a_vclk2_encp.hw,
4587 [CLKID_DAC_CLK] = &g12a_dac_clk.hw,
4588 [CLKID_AOCLK] = &g12a_aoclk_gate.hw,
4589 [CLKID_IEC958] = &g12a_iec958_gate.hw,
4590 [CLKID_ENC480P] = &g12a_enc480p.hw,
4591 [CLKID_RNG1] = &g12a_rng1.hw,
4592 [CLKID_VCLK2_ENCT] = &g12a_vclk2_enct.hw,
4593 [CLKID_VCLK2_ENCL] = &g12a_vclk2_encl.hw,
4594 [CLKID_VCLK2_VENCLMMC] = &g12a_vclk2_venclmmc.hw,
4595 [CLKID_VCLK2_VENCL] = &g12a_vclk2_vencl.hw,
4596 [CLKID_VCLK2_OTHER1] = &g12a_vclk2_other1.hw,
4597 [CLKID_FIXED_PLL_DCO] = &g12a_fixed_pll_dco.hw,
4598 [CLKID_SYS_PLL_DCO] = &g12a_sys_pll_dco.hw,
4599 [CLKID_GP0_PLL_DCO] = &g12a_gp0_pll_dco.hw,
4600 [CLKID_HIFI_PLL_DCO] = &g12a_hifi_pll_dco.hw,
4601 [CLKID_DMA] = &g12a_dma.hw,
4602 [CLKID_EFUSE] = &g12a_efuse.hw,
4603 [CLKID_ROM_BOOT] = &g12a_rom_boot.hw,
4604 [CLKID_RESET_SEC] = &g12a_reset_sec.hw,
4605 [CLKID_SEC_AHB_APB3] = &g12a_sec_ahb_apb3.hw,
4606 [CLKID_MPLL_PREDIV] = &g12a_mpll_prediv.hw,
4607 [CLKID_VPU_0_SEL] = &g12a_vpu_0_sel.hw,
4608 [CLKID_VPU_0_DIV] = &g12a_vpu_0_div.hw,
4609 [CLKID_VPU_0] = &g12a_vpu_0.hw,
4610 [CLKID_VPU_1_SEL] = &g12a_vpu_1_sel.hw,
4611 [CLKID_VPU_1_DIV] = &g12a_vpu_1_div.hw,
4612 [CLKID_VPU_1] = &g12a_vpu_1.hw,
4613 [CLKID_VPU] = &g12a_vpu.hw,
4614 [CLKID_VAPB_0_SEL] = &g12a_vapb_0_sel.hw,
4615 [CLKID_VAPB_0_DIV] = &g12a_vapb_0_div.hw,
4616 [CLKID_VAPB_0] = &g12a_vapb_0.hw,
4617 [CLKID_VAPB_1_SEL] = &g12a_vapb_1_sel.hw,
4618 [CLKID_VAPB_1_DIV] = &g12a_vapb_1_div.hw,
4619 [CLKID_VAPB_1] = &g12a_vapb_1.hw,
4620 [CLKID_VAPB_SEL] = &g12a_vapb_sel.hw,
4621 [CLKID_VAPB] = &g12a_vapb.hw,
4622 [CLKID_HDMI_PLL_DCO] = &g12a_hdmi_pll_dco.hw,
4623 [CLKID_HDMI_PLL_OD] = &g12a_hdmi_pll_od.hw,
4624 [CLKID_HDMI_PLL_OD2] = &g12a_hdmi_pll_od2.hw,
4625 [CLKID_HDMI_PLL] = &g12a_hdmi_pll.hw,
4626 [CLKID_VID_PLL] = &g12a_vid_pll_div.hw,
4627 [CLKID_VID_PLL_SEL] = &g12a_vid_pll_sel.hw,
4628 [CLKID_VID_PLL_DIV] = &g12a_vid_pll.hw,
4629 [CLKID_VCLK_SEL] = &g12a_vclk_sel.hw,
4630 [CLKID_VCLK2_SEL] = &g12a_vclk2_sel.hw,
4631 [CLKID_VCLK_INPUT] = &g12a_vclk_input.hw,
4632 [CLKID_VCLK2_INPUT] = &g12a_vclk2_input.hw,
4633 [CLKID_VCLK_DIV] = &g12a_vclk_div.hw,
4634 [CLKID_VCLK2_DIV] = &g12a_vclk2_div.hw,
4635 [CLKID_VCLK] = &g12a_vclk.hw,
4636 [CLKID_VCLK2] = &g12a_vclk2.hw,
4637 [CLKID_VCLK_DIV1] = &g12a_vclk_div1.hw,
4638 [CLKID_VCLK_DIV2_EN] = &g12a_vclk_div2_en.hw,
4639 [CLKID_VCLK_DIV4_EN] = &g12a_vclk_div4_en.hw,
4640 [CLKID_VCLK_DIV6_EN] = &g12a_vclk_div6_en.hw,
4641 [CLKID_VCLK_DIV12_EN] = &g12a_vclk_div12_en.hw,
4642 [CLKID_VCLK2_DIV1] = &g12a_vclk2_div1.hw,
4643 [CLKID_VCLK2_DIV2_EN] = &g12a_vclk2_div2_en.hw,
4644 [CLKID_VCLK2_DIV4_EN] = &g12a_vclk2_div4_en.hw,
4645 [CLKID_VCLK2_DIV6_EN] = &g12a_vclk2_div6_en.hw,
4646 [CLKID_VCLK2_DIV12_EN] = &g12a_vclk2_div12_en.hw,
4647 [CLKID_VCLK_DIV2] = &g12a_vclk_div2.hw,
4648 [CLKID_VCLK_DIV4] = &g12a_vclk_div4.hw,
4649 [CLKID_VCLK_DIV6] = &g12a_vclk_div6.hw,
4650 [CLKID_VCLK_DIV12] = &g12a_vclk_div12.hw,
4651 [CLKID_VCLK2_DIV2] = &g12a_vclk2_div2.hw,
4652 [CLKID_VCLK2_DIV4] = &g12a_vclk2_div4.hw,
4653 [CLKID_VCLK2_DIV6] = &g12a_vclk2_div6.hw,
4654 [CLKID_VCLK2_DIV12] = &g12a_vclk2_div12.hw,
4655 [CLKID_CTS_ENCI_SEL] = &g12a_cts_enci_sel.hw,
4656 [CLKID_CTS_ENCP_SEL] = &g12a_cts_encp_sel.hw,
4657 [CLKID_CTS_ENCL_SEL] = &g12a_cts_encl_sel.hw,
4658 [CLKID_CTS_VDAC_SEL] = &g12a_cts_vdac_sel.hw,
4659 [CLKID_HDMI_TX_SEL] = &g12a_hdmi_tx_sel.hw,
4660 [CLKID_CTS_ENCI] = &g12a_cts_enci.hw,
4661 [CLKID_CTS_ENCP] = &g12a_cts_encp.hw,
4662 [CLKID_CTS_ENCL] = &g12a_cts_encl.hw,
4663 [CLKID_CTS_VDAC] = &g12a_cts_vdac.hw,
4664 [CLKID_HDMI_TX] = &g12a_hdmi_tx.hw,
4665 [CLKID_HDMI_SEL] = &g12a_hdmi_sel.hw,
4666 [CLKID_HDMI_DIV] = &g12a_hdmi_div.hw,
4667 [CLKID_HDMI] = &g12a_hdmi.hw,
4668 [CLKID_MALI_0_SEL] = &g12a_mali_0_sel.hw,
4669 [CLKID_MALI_0_DIV] = &g12a_mali_0_div.hw,
4670 [CLKID_MALI_0] = &g12a_mali_0.hw,
4671 [CLKID_MALI_1_SEL] = &g12a_mali_1_sel.hw,
4672 [CLKID_MALI_1_DIV] = &g12a_mali_1_div.hw,
4673 [CLKID_MALI_1] = &g12a_mali_1.hw,
4674 [CLKID_MALI] = &g12a_mali.hw,
4675 [CLKID_MPLL_50M_DIV] = &g12a_mpll_50m_div.hw,
4676 [CLKID_MPLL_50M] = &g12a_mpll_50m.hw,
4677 [CLKID_SYS_PLL_DIV16_EN] = &g12a_sys_pll_div16_en.hw,
4678 [CLKID_SYS_PLL_DIV16] = &g12a_sys_pll_div16.hw,
4679 [CLKID_CPU_CLK_DYN0_SEL] = &g12a_cpu_clk_premux0.hw,
4680 [CLKID_CPU_CLK_DYN0_DIV] = &g12a_cpu_clk_mux0_div.hw,
4681 [CLKID_CPU_CLK_DYN0] = &g12a_cpu_clk_postmux0.hw,
4682 [CLKID_CPU_CLK_DYN1_SEL] = &g12a_cpu_clk_premux1.hw,
4683 [CLKID_CPU_CLK_DYN1_DIV] = &g12a_cpu_clk_mux1_div.hw,
4684 [CLKID_CPU_CLK_DYN1] = &g12a_cpu_clk_postmux1.hw,
4685 [CLKID_CPU_CLK_DYN] = &g12a_cpu_clk_dyn.hw,
4686 [CLKID_CPU_CLK] = &g12a_cpu_clk.hw,
4687 [CLKID_CPU_CLK_DIV16_EN] = &g12a_cpu_clk_div16_en.hw,
4688 [CLKID_CPU_CLK_DIV16] = &g12a_cpu_clk_div16.hw,
4689 [CLKID_CPU_CLK_APB_DIV] = &g12a_cpu_clk_apb_div.hw,
4690 [CLKID_CPU_CLK_APB] = &g12a_cpu_clk_apb.hw,
4691 [CLKID_CPU_CLK_ATB_DIV] = &g12a_cpu_clk_atb_div.hw,
4692 [CLKID_CPU_CLK_ATB] = &g12a_cpu_clk_atb.hw,
4693 [CLKID_CPU_CLK_AXI_DIV] = &g12a_cpu_clk_axi_div.hw,
4694 [CLKID_CPU_CLK_AXI] = &g12a_cpu_clk_axi.hw,
4695 [CLKID_CPU_CLK_TRACE_DIV] = &g12a_cpu_clk_trace_div.hw,
4696 [CLKID_CPU_CLK_TRACE] = &g12a_cpu_clk_trace.hw,
4697 [CLKID_PCIE_PLL_DCO] = &g12a_pcie_pll_dco.hw,
4698 [CLKID_PCIE_PLL_DCO_DIV2] = &g12a_pcie_pll_dco_div2.hw,
4699 [CLKID_PCIE_PLL_OD] = &g12a_pcie_pll_od.hw,
4700 [CLKID_PCIE_PLL] = &g12a_pcie_pll.hw,
4701 [CLKID_VDEC_1_SEL] = &g12a_vdec_1_sel.hw,
4702 [CLKID_VDEC_1_DIV] = &g12a_vdec_1_div.hw,
4703 [CLKID_VDEC_1] = &g12a_vdec_1.hw,
4704 [CLKID_VDEC_HEVC_SEL] = &g12a_vdec_hevc_sel.hw,
4705 [CLKID_VDEC_HEVC_DIV] = &g12a_vdec_hevc_div.hw,
4706 [CLKID_VDEC_HEVC] = &g12a_vdec_hevc.hw,
4707 [CLKID_VDEC_HEVCF_SEL] = &g12a_vdec_hevcf_sel.hw,
4708 [CLKID_VDEC_HEVCF_DIV] = &g12a_vdec_hevcf_div.hw,
4709 [CLKID_VDEC_HEVCF] = &g12a_vdec_hevcf.hw,
4710 [CLKID_TS_DIV] = &g12a_ts_div.hw,
4711 [CLKID_TS] = &g12a_ts.hw,
4712 [CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
4713 [CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
4714 [CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
4715 [CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
4716 [CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
4717 [CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
4718 [CLKID_MIPI_DSI_PXCLK_SEL] = &g12a_mipi_dsi_pxclk_sel.hw,
4719 [CLKID_MIPI_DSI_PXCLK_DIV] = &g12a_mipi_dsi_pxclk_div.hw,
4720 [CLKID_MIPI_DSI_PXCLK] = &g12a_mipi_dsi_pxclk.hw,
4721 };
4722
4723 static struct clk_hw *g12b_hw_clks[] = {
4724 [CLKID_SYS_PLL] = &g12a_sys_pll.hw,
4725 [CLKID_FIXED_PLL] = &g12a_fixed_pll.hw,
4726 [CLKID_FCLK_DIV2] = &g12a_fclk_div2.hw,
4727 [CLKID_FCLK_DIV3] = &g12a_fclk_div3.hw,
4728 [CLKID_FCLK_DIV4] = &g12a_fclk_div4.hw,
4729 [CLKID_FCLK_DIV5] = &g12a_fclk_div5.hw,
4730 [CLKID_FCLK_DIV7] = &g12a_fclk_div7.hw,
4731 [CLKID_FCLK_DIV2P5] = &g12a_fclk_div2p5.hw,
4732 [CLKID_GP0_PLL] = &g12a_gp0_pll.hw,
4733 [CLKID_MPEG_SEL] = &g12a_mpeg_clk_sel.hw,
4734 [CLKID_MPEG_DIV] = &g12a_mpeg_clk_div.hw,
4735 [CLKID_CLK81] = &g12a_clk81.hw,
4736 [CLKID_MPLL0] = &g12a_mpll0.hw,
4737 [CLKID_MPLL1] = &g12a_mpll1.hw,
4738 [CLKID_MPLL2] = &g12a_mpll2.hw,
4739 [CLKID_MPLL3] = &g12a_mpll3.hw,
4740 [CLKID_DDR] = &g12a_ddr.hw,
4741 [CLKID_DOS] = &g12a_dos.hw,
4742 [CLKID_AUDIO_LOCKER] = &g12a_audio_locker.hw,
4743 [CLKID_MIPI_DSI_HOST] = &g12a_mipi_dsi_host.hw,
4744 [CLKID_ETH_PHY] = &g12a_eth_phy.hw,
4745 [CLKID_ISA] = &g12a_isa.hw,
4746 [CLKID_PL301] = &g12a_pl301.hw,
4747 [CLKID_PERIPHS] = &g12a_periphs.hw,
4748 [CLKID_SPICC0] = &g12a_spicc_0.hw,
4749 [CLKID_I2C] = &g12a_i2c.hw,
4750 [CLKID_SANA] = &g12a_sana.hw,
4751 [CLKID_SD] = &g12a_sd.hw,
4752 [CLKID_RNG0] = &g12a_rng0.hw,
4753 [CLKID_UART0] = &g12a_uart0.hw,
4754 [CLKID_SPICC1] = &g12a_spicc_1.hw,
4755 [CLKID_HIU_IFACE] = &g12a_hiu_reg.hw,
4756 [CLKID_MIPI_DSI_PHY] = &g12a_mipi_dsi_phy.hw,
4757 [CLKID_ASSIST_MISC] = &g12a_assist_misc.hw,
4758 [CLKID_SD_EMMC_A] = &g12a_emmc_a.hw,
4759 [CLKID_SD_EMMC_B] = &g12a_emmc_b.hw,
4760 [CLKID_SD_EMMC_C] = &g12a_emmc_c.hw,
4761 [CLKID_AUDIO_CODEC] = &g12a_audio_codec.hw,
4762 [CLKID_AUDIO] = &g12a_audio.hw,
4763 [CLKID_ETH] = &g12a_eth_core.hw,
4764 [CLKID_DEMUX] = &g12a_demux.hw,
4765 [CLKID_AUDIO_IFIFO] = &g12a_audio_ififo.hw,
4766 [CLKID_ADC] = &g12a_adc.hw,
4767 [CLKID_UART1] = &g12a_uart1.hw,
4768 [CLKID_G2D] = &g12a_g2d.hw,
4769 [CLKID_RESET] = &g12a_reset.hw,
4770 [CLKID_PCIE_COMB] = &g12a_pcie_comb.hw,
4771 [CLKID_PARSER] = &g12a_parser.hw,
4772 [CLKID_USB] = &g12a_usb_general.hw,
4773 [CLKID_PCIE_PHY] = &g12a_pcie_phy.hw,
4774 [CLKID_AHB_ARB0] = &g12a_ahb_arb0.hw,
4775 [CLKID_AHB_DATA_BUS] = &g12a_ahb_data_bus.hw,
4776 [CLKID_AHB_CTRL_BUS] = &g12a_ahb_ctrl_bus.hw,
4777 [CLKID_HTX_HDCP22] = &g12a_htx_hdcp22.hw,
4778 [CLKID_HTX_PCLK] = &g12a_htx_pclk.hw,
4779 [CLKID_BT656] = &g12a_bt656.hw,
4780 [CLKID_USB1_DDR_BRIDGE] = &g12a_usb1_to_ddr.hw,
4781 [CLKID_MMC_PCLK] = &g12a_mmc_pclk.hw,
4782 [CLKID_UART2] = &g12a_uart2.hw,
4783 [CLKID_VPU_INTR] = &g12a_vpu_intr.hw,
4784 [CLKID_GIC] = &g12a_gic.hw,
4785 [CLKID_SD_EMMC_A_CLK0_SEL] = &g12a_sd_emmc_a_clk0_sel.hw,
4786 [CLKID_SD_EMMC_A_CLK0_DIV] = &g12a_sd_emmc_a_clk0_div.hw,
4787 [CLKID_SD_EMMC_A_CLK0] = &g12a_sd_emmc_a_clk0.hw,
4788 [CLKID_SD_EMMC_B_CLK0_SEL] = &g12a_sd_emmc_b_clk0_sel.hw,
4789 [CLKID_SD_EMMC_B_CLK0_DIV] = &g12a_sd_emmc_b_clk0_div.hw,
4790 [CLKID_SD_EMMC_B_CLK0] = &g12a_sd_emmc_b_clk0.hw,
4791 [CLKID_SD_EMMC_C_CLK0_SEL] = &g12a_sd_emmc_c_clk0_sel.hw,
4792 [CLKID_SD_EMMC_C_CLK0_DIV] = &g12a_sd_emmc_c_clk0_div.hw,
4793 [CLKID_SD_EMMC_C_CLK0] = &g12a_sd_emmc_c_clk0.hw,
4794 [CLKID_MPLL0_DIV] = &g12a_mpll0_div.hw,
4795 [CLKID_MPLL1_DIV] = &g12a_mpll1_div.hw,
4796 [CLKID_MPLL2_DIV] = &g12a_mpll2_div.hw,
4797 [CLKID_MPLL3_DIV] = &g12a_mpll3_div.hw,
4798 [CLKID_FCLK_DIV2_DIV] = &g12a_fclk_div2_div.hw,
4799 [CLKID_FCLK_DIV3_DIV] = &g12a_fclk_div3_div.hw,
4800 [CLKID_FCLK_DIV4_DIV] = &g12a_fclk_div4_div.hw,
4801 [CLKID_FCLK_DIV5_DIV] = &g12a_fclk_div5_div.hw,
4802 [CLKID_FCLK_DIV7_DIV] = &g12a_fclk_div7_div.hw,
4803 [CLKID_FCLK_DIV2P5_DIV] = &g12a_fclk_div2p5_div.hw,
4804 [CLKID_HIFI_PLL] = &g12a_hifi_pll.hw,
4805 [CLKID_VCLK2_VENCI0] = &g12a_vclk2_venci0.hw,
4806 [CLKID_VCLK2_VENCI1] = &g12a_vclk2_venci1.hw,
4807 [CLKID_VCLK2_VENCP0] = &g12a_vclk2_vencp0.hw,
4808 [CLKID_VCLK2_VENCP1] = &g12a_vclk2_vencp1.hw,
4809 [CLKID_VCLK2_VENCT0] = &g12a_vclk2_venct0.hw,
4810 [CLKID_VCLK2_VENCT1] = &g12a_vclk2_venct1.hw,
4811 [CLKID_VCLK2_OTHER] = &g12a_vclk2_other.hw,
4812 [CLKID_VCLK2_ENCI] = &g12a_vclk2_enci.hw,
4813 [CLKID_VCLK2_ENCP] = &g12a_vclk2_encp.hw,
4814 [CLKID_DAC_CLK] = &g12a_dac_clk.hw,
4815 [CLKID_AOCLK] = &g12a_aoclk_gate.hw,
4816 [CLKID_IEC958] = &g12a_iec958_gate.hw,
4817 [CLKID_ENC480P] = &g12a_enc480p.hw,
4818 [CLKID_RNG1] = &g12a_rng1.hw,
4819 [CLKID_VCLK2_ENCT] = &g12a_vclk2_enct.hw,
4820 [CLKID_VCLK2_ENCL] = &g12a_vclk2_encl.hw,
4821 [CLKID_VCLK2_VENCLMMC] = &g12a_vclk2_venclmmc.hw,
4822 [CLKID_VCLK2_VENCL] = &g12a_vclk2_vencl.hw,
4823 [CLKID_VCLK2_OTHER1] = &g12a_vclk2_other1.hw,
4824 [CLKID_FIXED_PLL_DCO] = &g12a_fixed_pll_dco.hw,
4825 [CLKID_SYS_PLL_DCO] = &g12a_sys_pll_dco.hw,
4826 [CLKID_GP0_PLL_DCO] = &g12a_gp0_pll_dco.hw,
4827 [CLKID_HIFI_PLL_DCO] = &g12a_hifi_pll_dco.hw,
4828 [CLKID_DMA] = &g12a_dma.hw,
4829 [CLKID_EFUSE] = &g12a_efuse.hw,
4830 [CLKID_ROM_BOOT] = &g12a_rom_boot.hw,
4831 [CLKID_RESET_SEC] = &g12a_reset_sec.hw,
4832 [CLKID_SEC_AHB_APB3] = &g12a_sec_ahb_apb3.hw,
4833 [CLKID_MPLL_PREDIV] = &g12a_mpll_prediv.hw,
4834 [CLKID_VPU_0_SEL] = &g12a_vpu_0_sel.hw,
4835 [CLKID_VPU_0_DIV] = &g12a_vpu_0_div.hw,
4836 [CLKID_VPU_0] = &g12a_vpu_0.hw,
4837 [CLKID_VPU_1_SEL] = &g12a_vpu_1_sel.hw,
4838 [CLKID_VPU_1_DIV] = &g12a_vpu_1_div.hw,
4839 [CLKID_VPU_1] = &g12a_vpu_1.hw,
4840 [CLKID_VPU] = &g12a_vpu.hw,
4841 [CLKID_VAPB_0_SEL] = &g12a_vapb_0_sel.hw,
4842 [CLKID_VAPB_0_DIV] = &g12a_vapb_0_div.hw,
4843 [CLKID_VAPB_0] = &g12a_vapb_0.hw,
4844 [CLKID_VAPB_1_SEL] = &g12a_vapb_1_sel.hw,
4845 [CLKID_VAPB_1_DIV] = &g12a_vapb_1_div.hw,
4846 [CLKID_VAPB_1] = &g12a_vapb_1.hw,
4847 [CLKID_VAPB_SEL] = &g12a_vapb_sel.hw,
4848 [CLKID_VAPB] = &g12a_vapb.hw,
4849 [CLKID_HDMI_PLL_DCO] = &g12a_hdmi_pll_dco.hw,
4850 [CLKID_HDMI_PLL_OD] = &g12a_hdmi_pll_od.hw,
4851 [CLKID_HDMI_PLL_OD2] = &g12a_hdmi_pll_od2.hw,
4852 [CLKID_HDMI_PLL] = &g12a_hdmi_pll.hw,
4853 [CLKID_VID_PLL] = &g12a_vid_pll_div.hw,
4854 [CLKID_VID_PLL_SEL] = &g12a_vid_pll_sel.hw,
4855 [CLKID_VID_PLL_DIV] = &g12a_vid_pll.hw,
4856 [CLKID_VCLK_SEL] = &g12a_vclk_sel.hw,
4857 [CLKID_VCLK2_SEL] = &g12a_vclk2_sel.hw,
4858 [CLKID_VCLK_INPUT] = &g12a_vclk_input.hw,
4859 [CLKID_VCLK2_INPUT] = &g12a_vclk2_input.hw,
4860 [CLKID_VCLK_DIV] = &g12a_vclk_div.hw,
4861 [CLKID_VCLK2_DIV] = &g12a_vclk2_div.hw,
4862 [CLKID_VCLK] = &g12a_vclk.hw,
4863 [CLKID_VCLK2] = &g12a_vclk2.hw,
4864 [CLKID_VCLK_DIV1] = &g12a_vclk_div1.hw,
4865 [CLKID_VCLK_DIV2_EN] = &g12a_vclk_div2_en.hw,
4866 [CLKID_VCLK_DIV4_EN] = &g12a_vclk_div4_en.hw,
4867 [CLKID_VCLK_DIV6_EN] = &g12a_vclk_div6_en.hw,
4868 [CLKID_VCLK_DIV12_EN] = &g12a_vclk_div12_en.hw,
4869 [CLKID_VCLK2_DIV1] = &g12a_vclk2_div1.hw,
4870 [CLKID_VCLK2_DIV2_EN] = &g12a_vclk2_div2_en.hw,
4871 [CLKID_VCLK2_DIV4_EN] = &g12a_vclk2_div4_en.hw,
4872 [CLKID_VCLK2_DIV6_EN] = &g12a_vclk2_div6_en.hw,
4873 [CLKID_VCLK2_DIV12_EN] = &g12a_vclk2_div12_en.hw,
4874 [CLKID_VCLK_DIV2] = &g12a_vclk_div2.hw,
4875 [CLKID_VCLK_DIV4] = &g12a_vclk_div4.hw,
4876 [CLKID_VCLK_DIV6] = &g12a_vclk_div6.hw,
4877 [CLKID_VCLK_DIV12] = &g12a_vclk_div12.hw,
4878 [CLKID_VCLK2_DIV2] = &g12a_vclk2_div2.hw,
4879 [CLKID_VCLK2_DIV4] = &g12a_vclk2_div4.hw,
4880 [CLKID_VCLK2_DIV6] = &g12a_vclk2_div6.hw,
4881 [CLKID_VCLK2_DIV12] = &g12a_vclk2_div12.hw,
4882 [CLKID_CTS_ENCI_SEL] = &g12a_cts_enci_sel.hw,
4883 [CLKID_CTS_ENCP_SEL] = &g12a_cts_encp_sel.hw,
4884 [CLKID_CTS_ENCL_SEL] = &g12a_cts_encl_sel.hw,
4885 [CLKID_CTS_VDAC_SEL] = &g12a_cts_vdac_sel.hw,
4886 [CLKID_HDMI_TX_SEL] = &g12a_hdmi_tx_sel.hw,
4887 [CLKID_CTS_ENCI] = &g12a_cts_enci.hw,
4888 [CLKID_CTS_ENCP] = &g12a_cts_encp.hw,
4889 [CLKID_CTS_ENCL] = &g12a_cts_encl.hw,
4890 [CLKID_CTS_VDAC] = &g12a_cts_vdac.hw,
4891 [CLKID_HDMI_TX] = &g12a_hdmi_tx.hw,
4892 [CLKID_HDMI_SEL] = &g12a_hdmi_sel.hw,
4893 [CLKID_HDMI_DIV] = &g12a_hdmi_div.hw,
4894 [CLKID_HDMI] = &g12a_hdmi.hw,
4895 [CLKID_MALI_0_SEL] = &g12a_mali_0_sel.hw,
4896 [CLKID_MALI_0_DIV] = &g12a_mali_0_div.hw,
4897 [CLKID_MALI_0] = &g12a_mali_0.hw,
4898 [CLKID_MALI_1_SEL] = &g12a_mali_1_sel.hw,
4899 [CLKID_MALI_1_DIV] = &g12a_mali_1_div.hw,
4900 [CLKID_MALI_1] = &g12a_mali_1.hw,
4901 [CLKID_MALI] = &g12a_mali.hw,
4902 [CLKID_MPLL_50M_DIV] = &g12a_mpll_50m_div.hw,
4903 [CLKID_MPLL_50M] = &g12a_mpll_50m.hw,
4904 [CLKID_SYS_PLL_DIV16_EN] = &g12a_sys_pll_div16_en.hw,
4905 [CLKID_SYS_PLL_DIV16] = &g12a_sys_pll_div16.hw,
4906 [CLKID_CPU_CLK_DYN0_SEL] = &g12a_cpu_clk_premux0.hw,
4907 [CLKID_CPU_CLK_DYN0_DIV] = &g12a_cpu_clk_mux0_div.hw,
4908 [CLKID_CPU_CLK_DYN0] = &g12a_cpu_clk_postmux0.hw,
4909 [CLKID_CPU_CLK_DYN1_SEL] = &g12a_cpu_clk_premux1.hw,
4910 [CLKID_CPU_CLK_DYN1_DIV] = &g12a_cpu_clk_mux1_div.hw,
4911 [CLKID_CPU_CLK_DYN1] = &g12a_cpu_clk_postmux1.hw,
4912 [CLKID_CPU_CLK_DYN] = &g12a_cpu_clk_dyn.hw,
4913 [CLKID_CPU_CLK] = &g12b_cpu_clk.hw,
4914 [CLKID_CPU_CLK_DIV16_EN] = &g12a_cpu_clk_div16_en.hw,
4915 [CLKID_CPU_CLK_DIV16] = &g12a_cpu_clk_div16.hw,
4916 [CLKID_CPU_CLK_APB_DIV] = &g12a_cpu_clk_apb_div.hw,
4917 [CLKID_CPU_CLK_APB] = &g12a_cpu_clk_apb.hw,
4918 [CLKID_CPU_CLK_ATB_DIV] = &g12a_cpu_clk_atb_div.hw,
4919 [CLKID_CPU_CLK_ATB] = &g12a_cpu_clk_atb.hw,
4920 [CLKID_CPU_CLK_AXI_DIV] = &g12a_cpu_clk_axi_div.hw,
4921 [CLKID_CPU_CLK_AXI] = &g12a_cpu_clk_axi.hw,
4922 [CLKID_CPU_CLK_TRACE_DIV] = &g12a_cpu_clk_trace_div.hw,
4923 [CLKID_CPU_CLK_TRACE] = &g12a_cpu_clk_trace.hw,
4924 [CLKID_PCIE_PLL_DCO] = &g12a_pcie_pll_dco.hw,
4925 [CLKID_PCIE_PLL_DCO_DIV2] = &g12a_pcie_pll_dco_div2.hw,
4926 [CLKID_PCIE_PLL_OD] = &g12a_pcie_pll_od.hw,
4927 [CLKID_PCIE_PLL] = &g12a_pcie_pll.hw,
4928 [CLKID_VDEC_1_SEL] = &g12a_vdec_1_sel.hw,
4929 [CLKID_VDEC_1_DIV] = &g12a_vdec_1_div.hw,
4930 [CLKID_VDEC_1] = &g12a_vdec_1.hw,
4931 [CLKID_VDEC_HEVC_SEL] = &g12a_vdec_hevc_sel.hw,
4932 [CLKID_VDEC_HEVC_DIV] = &g12a_vdec_hevc_div.hw,
4933 [CLKID_VDEC_HEVC] = &g12a_vdec_hevc.hw,
4934 [CLKID_VDEC_HEVCF_SEL] = &g12a_vdec_hevcf_sel.hw,
4935 [CLKID_VDEC_HEVCF_DIV] = &g12a_vdec_hevcf_div.hw,
4936 [CLKID_VDEC_HEVCF] = &g12a_vdec_hevcf.hw,
4937 [CLKID_TS_DIV] = &g12a_ts_div.hw,
4938 [CLKID_TS] = &g12a_ts.hw,
4939 [CLKID_SYS1_PLL_DCO] = &g12b_sys1_pll_dco.hw,
4940 [CLKID_SYS1_PLL] = &g12b_sys1_pll.hw,
4941 [CLKID_SYS1_PLL_DIV16_EN] = &g12b_sys1_pll_div16_en.hw,
4942 [CLKID_SYS1_PLL_DIV16] = &g12b_sys1_pll_div16.hw,
4943 [CLKID_CPUB_CLK_DYN0_SEL] = &g12b_cpub_clk_premux0.hw,
4944 [CLKID_CPUB_CLK_DYN0_DIV] = &g12b_cpub_clk_mux0_div.hw,
4945 [CLKID_CPUB_CLK_DYN0] = &g12b_cpub_clk_postmux0.hw,
4946 [CLKID_CPUB_CLK_DYN1_SEL] = &g12b_cpub_clk_premux1.hw,
4947 [CLKID_CPUB_CLK_DYN1_DIV] = &g12b_cpub_clk_mux1_div.hw,
4948 [CLKID_CPUB_CLK_DYN1] = &g12b_cpub_clk_postmux1.hw,
4949 [CLKID_CPUB_CLK_DYN] = &g12b_cpub_clk_dyn.hw,
4950 [CLKID_CPUB_CLK] = &g12b_cpub_clk.hw,
4951 [CLKID_CPUB_CLK_DIV16_EN] = &g12b_cpub_clk_div16_en.hw,
4952 [CLKID_CPUB_CLK_DIV16] = &g12b_cpub_clk_div16.hw,
4953 [CLKID_CPUB_CLK_DIV2] = &g12b_cpub_clk_div2.hw,
4954 [CLKID_CPUB_CLK_DIV3] = &g12b_cpub_clk_div3.hw,
4955 [CLKID_CPUB_CLK_DIV4] = &g12b_cpub_clk_div4.hw,
4956 [CLKID_CPUB_CLK_DIV5] = &g12b_cpub_clk_div5.hw,
4957 [CLKID_CPUB_CLK_DIV6] = &g12b_cpub_clk_div6.hw,
4958 [CLKID_CPUB_CLK_DIV7] = &g12b_cpub_clk_div7.hw,
4959 [CLKID_CPUB_CLK_DIV8] = &g12b_cpub_clk_div8.hw,
4960 [CLKID_CPUB_CLK_APB_SEL] = &g12b_cpub_clk_apb_sel.hw,
4961 [CLKID_CPUB_CLK_APB] = &g12b_cpub_clk_apb.hw,
4962 [CLKID_CPUB_CLK_ATB_SEL] = &g12b_cpub_clk_atb_sel.hw,
4963 [CLKID_CPUB_CLK_ATB] = &g12b_cpub_clk_atb.hw,
4964 [CLKID_CPUB_CLK_AXI_SEL] = &g12b_cpub_clk_axi_sel.hw,
4965 [CLKID_CPUB_CLK_AXI] = &g12b_cpub_clk_axi.hw,
4966 [CLKID_CPUB_CLK_TRACE_SEL] = &g12b_cpub_clk_trace_sel.hw,
4967 [CLKID_CPUB_CLK_TRACE] = &g12b_cpub_clk_trace.hw,
4968 [CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
4969 [CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
4970 [CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
4971 [CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
4972 [CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
4973 [CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
4974 [CLKID_NNA_AXI_CLK_SEL] = &sm1_nna_axi_clk_sel.hw,
4975 [CLKID_NNA_AXI_CLK_DIV] = &sm1_nna_axi_clk_div.hw,
4976 [CLKID_NNA_AXI_CLK] = &sm1_nna_axi_clk.hw,
4977 [CLKID_NNA_CORE_CLK_SEL] = &sm1_nna_core_clk_sel.hw,
4978 [CLKID_NNA_CORE_CLK_DIV] = &sm1_nna_core_clk_div.hw,
4979 [CLKID_NNA_CORE_CLK] = &sm1_nna_core_clk.hw,
4980 [CLKID_MIPI_DSI_PXCLK_SEL] = &g12a_mipi_dsi_pxclk_sel.hw,
4981 [CLKID_MIPI_DSI_PXCLK_DIV] = &g12a_mipi_dsi_pxclk_div.hw,
4982 [CLKID_MIPI_DSI_PXCLK] = &g12a_mipi_dsi_pxclk.hw,
4983 [CLKID_MIPI_ISP_SEL] = &g12b_mipi_isp_sel.hw,
4984 [CLKID_MIPI_ISP_DIV] = &g12b_mipi_isp_div.hw,
4985 [CLKID_MIPI_ISP] = &g12b_mipi_isp.hw,
4986 [CLKID_MIPI_ISP_GATE] = &g12b_mipi_isp_gate.hw,
4987 [CLKID_MIPI_ISP_CSI_PHY0] = &g12b_csi_phy0.hw,
4988 [CLKID_MIPI_ISP_CSI_PHY1] = &g12b_csi_phy1.hw,
4989 };
4990
4991 static struct clk_hw *sm1_hw_clks[] = {
4992 [CLKID_SYS_PLL] = &g12a_sys_pll.hw,
4993 [CLKID_FIXED_PLL] = &g12a_fixed_pll.hw,
4994 [CLKID_FCLK_DIV2] = &g12a_fclk_div2.hw,
4995 [CLKID_FCLK_DIV3] = &g12a_fclk_div3.hw,
4996 [CLKID_FCLK_DIV4] = &g12a_fclk_div4.hw,
4997 [CLKID_FCLK_DIV5] = &g12a_fclk_div5.hw,
4998 [CLKID_FCLK_DIV7] = &g12a_fclk_div7.hw,
4999 [CLKID_FCLK_DIV2P5] = &g12a_fclk_div2p5.hw,
5000 [CLKID_GP0_PLL] = &g12a_gp0_pll.hw,
5001 [CLKID_MPEG_SEL] = &g12a_mpeg_clk_sel.hw,
5002 [CLKID_MPEG_DIV] = &g12a_mpeg_clk_div.hw,
5003 [CLKID_CLK81] = &g12a_clk81.hw,
5004 [CLKID_MPLL0] = &g12a_mpll0.hw,
5005 [CLKID_MPLL1] = &g12a_mpll1.hw,
5006 [CLKID_MPLL2] = &g12a_mpll2.hw,
5007 [CLKID_MPLL3] = &g12a_mpll3.hw,
5008 [CLKID_DDR] = &g12a_ddr.hw,
5009 [CLKID_DOS] = &g12a_dos.hw,
5010 [CLKID_AUDIO_LOCKER] = &g12a_audio_locker.hw,
5011 [CLKID_MIPI_DSI_HOST] = &g12a_mipi_dsi_host.hw,
5012 [CLKID_ETH_PHY] = &g12a_eth_phy.hw,
5013 [CLKID_ISA] = &g12a_isa.hw,
5014 [CLKID_PL301] = &g12a_pl301.hw,
5015 [CLKID_PERIPHS] = &g12a_periphs.hw,
5016 [CLKID_SPICC0] = &g12a_spicc_0.hw,
5017 [CLKID_I2C] = &g12a_i2c.hw,
5018 [CLKID_SANA] = &g12a_sana.hw,
5019 [CLKID_SD] = &g12a_sd.hw,
5020 [CLKID_RNG0] = &g12a_rng0.hw,
5021 [CLKID_UART0] = &g12a_uart0.hw,
5022 [CLKID_SPICC1] = &g12a_spicc_1.hw,
5023 [CLKID_HIU_IFACE] = &g12a_hiu_reg.hw,
5024 [CLKID_MIPI_DSI_PHY] = &g12a_mipi_dsi_phy.hw,
5025 [CLKID_ASSIST_MISC] = &g12a_assist_misc.hw,
5026 [CLKID_SD_EMMC_A] = &g12a_emmc_a.hw,
5027 [CLKID_SD_EMMC_B] = &g12a_emmc_b.hw,
5028 [CLKID_SD_EMMC_C] = &g12a_emmc_c.hw,
5029 [CLKID_AUDIO_CODEC] = &g12a_audio_codec.hw,
5030 [CLKID_AUDIO] = &g12a_audio.hw,
5031 [CLKID_ETH] = &g12a_eth_core.hw,
5032 [CLKID_DEMUX] = &g12a_demux.hw,
5033 [CLKID_AUDIO_IFIFO] = &g12a_audio_ififo.hw,
5034 [CLKID_ADC] = &g12a_adc.hw,
5035 [CLKID_UART1] = &g12a_uart1.hw,
5036 [CLKID_G2D] = &g12a_g2d.hw,
5037 [CLKID_RESET] = &g12a_reset.hw,
5038 [CLKID_PCIE_COMB] = &g12a_pcie_comb.hw,
5039 [CLKID_PARSER] = &g12a_parser.hw,
5040 [CLKID_USB] = &g12a_usb_general.hw,
5041 [CLKID_PCIE_PHY] = &g12a_pcie_phy.hw,
5042 [CLKID_AHB_ARB0] = &g12a_ahb_arb0.hw,
5043 [CLKID_AHB_DATA_BUS] = &g12a_ahb_data_bus.hw,
5044 [CLKID_AHB_CTRL_BUS] = &g12a_ahb_ctrl_bus.hw,
5045 [CLKID_HTX_HDCP22] = &g12a_htx_hdcp22.hw,
5046 [CLKID_HTX_PCLK] = &g12a_htx_pclk.hw,
5047 [CLKID_BT656] = &g12a_bt656.hw,
5048 [CLKID_USB1_DDR_BRIDGE] = &g12a_usb1_to_ddr.hw,
5049 [CLKID_MMC_PCLK] = &g12a_mmc_pclk.hw,
5050 [CLKID_UART2] = &g12a_uart2.hw,
5051 [CLKID_VPU_INTR] = &g12a_vpu_intr.hw,
5052 [CLKID_GIC] = &g12a_gic.hw,
5053 [CLKID_SD_EMMC_A_CLK0_SEL] = &g12a_sd_emmc_a_clk0_sel.hw,
5054 [CLKID_SD_EMMC_A_CLK0_DIV] = &g12a_sd_emmc_a_clk0_div.hw,
5055 [CLKID_SD_EMMC_A_CLK0] = &g12a_sd_emmc_a_clk0.hw,
5056 [CLKID_SD_EMMC_B_CLK0_SEL] = &g12a_sd_emmc_b_clk0_sel.hw,
5057 [CLKID_SD_EMMC_B_CLK0_DIV] = &g12a_sd_emmc_b_clk0_div.hw,
5058 [CLKID_SD_EMMC_B_CLK0] = &g12a_sd_emmc_b_clk0.hw,
5059 [CLKID_SD_EMMC_C_CLK0_SEL] = &g12a_sd_emmc_c_clk0_sel.hw,
5060 [CLKID_SD_EMMC_C_CLK0_DIV] = &g12a_sd_emmc_c_clk0_div.hw,
5061 [CLKID_SD_EMMC_C_CLK0] = &g12a_sd_emmc_c_clk0.hw,
5062 [CLKID_MPLL0_DIV] = &g12a_mpll0_div.hw,
5063 [CLKID_MPLL1_DIV] = &g12a_mpll1_div.hw,
5064 [CLKID_MPLL2_DIV] = &g12a_mpll2_div.hw,
5065 [CLKID_MPLL3_DIV] = &g12a_mpll3_div.hw,
5066 [CLKID_FCLK_DIV2_DIV] = &g12a_fclk_div2_div.hw,
5067 [CLKID_FCLK_DIV3_DIV] = &g12a_fclk_div3_div.hw,
5068 [CLKID_FCLK_DIV4_DIV] = &g12a_fclk_div4_div.hw,
5069 [CLKID_FCLK_DIV5_DIV] = &g12a_fclk_div5_div.hw,
5070 [CLKID_FCLK_DIV7_DIV] = &g12a_fclk_div7_div.hw,
5071 [CLKID_FCLK_DIV2P5_DIV] = &g12a_fclk_div2p5_div.hw,
5072 [CLKID_HIFI_PLL] = &g12a_hifi_pll.hw,
5073 [CLKID_VCLK2_VENCI0] = &g12a_vclk2_venci0.hw,
5074 [CLKID_VCLK2_VENCI1] = &g12a_vclk2_venci1.hw,
5075 [CLKID_VCLK2_VENCP0] = &g12a_vclk2_vencp0.hw,
5076 [CLKID_VCLK2_VENCP1] = &g12a_vclk2_vencp1.hw,
5077 [CLKID_VCLK2_VENCT0] = &g12a_vclk2_venct0.hw,
5078 [CLKID_VCLK2_VENCT1] = &g12a_vclk2_venct1.hw,
5079 [CLKID_VCLK2_OTHER] = &g12a_vclk2_other.hw,
5080 [CLKID_VCLK2_ENCI] = &g12a_vclk2_enci.hw,
5081 [CLKID_VCLK2_ENCP] = &g12a_vclk2_encp.hw,
5082 [CLKID_DAC_CLK] = &g12a_dac_clk.hw,
5083 [CLKID_AOCLK] = &g12a_aoclk_gate.hw,
5084 [CLKID_IEC958] = &g12a_iec958_gate.hw,
5085 [CLKID_ENC480P] = &g12a_enc480p.hw,
5086 [CLKID_RNG1] = &g12a_rng1.hw,
5087 [CLKID_VCLK2_ENCT] = &g12a_vclk2_enct.hw,
5088 [CLKID_VCLK2_ENCL] = &g12a_vclk2_encl.hw,
5089 [CLKID_VCLK2_VENCLMMC] = &g12a_vclk2_venclmmc.hw,
5090 [CLKID_VCLK2_VENCL] = &g12a_vclk2_vencl.hw,
5091 [CLKID_VCLK2_OTHER1] = &g12a_vclk2_other1.hw,
5092 [CLKID_FIXED_PLL_DCO] = &g12a_fixed_pll_dco.hw,
5093 [CLKID_SYS_PLL_DCO] = &g12a_sys_pll_dco.hw,
5094 [CLKID_GP0_PLL_DCO] = &g12a_gp0_pll_dco.hw,
5095 [CLKID_HIFI_PLL_DCO] = &g12a_hifi_pll_dco.hw,
5096 [CLKID_DMA] = &g12a_dma.hw,
5097 [CLKID_EFUSE] = &g12a_efuse.hw,
5098 [CLKID_ROM_BOOT] = &g12a_rom_boot.hw,
5099 [CLKID_RESET_SEC] = &g12a_reset_sec.hw,
5100 [CLKID_SEC_AHB_APB3] = &g12a_sec_ahb_apb3.hw,
5101 [CLKID_MPLL_PREDIV] = &g12a_mpll_prediv.hw,
5102 [CLKID_VPU_0_SEL] = &g12a_vpu_0_sel.hw,
5103 [CLKID_VPU_0_DIV] = &g12a_vpu_0_div.hw,
5104 [CLKID_VPU_0] = &g12a_vpu_0.hw,
5105 [CLKID_VPU_1_SEL] = &g12a_vpu_1_sel.hw,
5106 [CLKID_VPU_1_DIV] = &g12a_vpu_1_div.hw,
5107 [CLKID_VPU_1] = &g12a_vpu_1.hw,
5108 [CLKID_VPU] = &g12a_vpu.hw,
5109 [CLKID_VAPB_0_SEL] = &g12a_vapb_0_sel.hw,
5110 [CLKID_VAPB_0_DIV] = &g12a_vapb_0_div.hw,
5111 [CLKID_VAPB_0] = &g12a_vapb_0.hw,
5112 [CLKID_VAPB_1_SEL] = &g12a_vapb_1_sel.hw,
5113 [CLKID_VAPB_1_DIV] = &g12a_vapb_1_div.hw,
5114 [CLKID_VAPB_1] = &g12a_vapb_1.hw,
5115 [CLKID_VAPB_SEL] = &g12a_vapb_sel.hw,
5116 [CLKID_VAPB] = &g12a_vapb.hw,
5117 [CLKID_HDMI_PLL_DCO] = &g12a_hdmi_pll_dco.hw,
5118 [CLKID_HDMI_PLL_OD] = &g12a_hdmi_pll_od.hw,
5119 [CLKID_HDMI_PLL_OD2] = &g12a_hdmi_pll_od2.hw,
5120 [CLKID_HDMI_PLL] = &g12a_hdmi_pll.hw,
5121 [CLKID_VID_PLL] = &g12a_vid_pll_div.hw,
5122 [CLKID_VID_PLL_SEL] = &g12a_vid_pll_sel.hw,
5123 [CLKID_VID_PLL_DIV] = &g12a_vid_pll.hw,
5124 [CLKID_VCLK_SEL] = &g12a_vclk_sel.hw,
5125 [CLKID_VCLK2_SEL] = &g12a_vclk2_sel.hw,
5126 [CLKID_VCLK_INPUT] = &g12a_vclk_input.hw,
5127 [CLKID_VCLK2_INPUT] = &g12a_vclk2_input.hw,
5128 [CLKID_VCLK_DIV] = &g12a_vclk_div.hw,
5129 [CLKID_VCLK2_DIV] = &g12a_vclk2_div.hw,
5130 [CLKID_VCLK] = &g12a_vclk.hw,
5131 [CLKID_VCLK2] = &g12a_vclk2.hw,
5132 [CLKID_VCLK_DIV1] = &g12a_vclk_div1.hw,
5133 [CLKID_VCLK_DIV2_EN] = &g12a_vclk_div2_en.hw,
5134 [CLKID_VCLK_DIV4_EN] = &g12a_vclk_div4_en.hw,
5135 [CLKID_VCLK_DIV6_EN] = &g12a_vclk_div6_en.hw,
5136 [CLKID_VCLK_DIV12_EN] = &g12a_vclk_div12_en.hw,
5137 [CLKID_VCLK2_DIV1] = &g12a_vclk2_div1.hw,
5138 [CLKID_VCLK2_DIV2_EN] = &g12a_vclk2_div2_en.hw,
5139 [CLKID_VCLK2_DIV4_EN] = &g12a_vclk2_div4_en.hw,
5140 [CLKID_VCLK2_DIV6_EN] = &g12a_vclk2_div6_en.hw,
5141 [CLKID_VCLK2_DIV12_EN] = &g12a_vclk2_div12_en.hw,
5142 [CLKID_VCLK_DIV2] = &g12a_vclk_div2.hw,
5143 [CLKID_VCLK_DIV4] = &g12a_vclk_div4.hw,
5144 [CLKID_VCLK_DIV6] = &g12a_vclk_div6.hw,
5145 [CLKID_VCLK_DIV12] = &g12a_vclk_div12.hw,
5146 [CLKID_VCLK2_DIV2] = &g12a_vclk2_div2.hw,
5147 [CLKID_VCLK2_DIV4] = &g12a_vclk2_div4.hw,
5148 [CLKID_VCLK2_DIV6] = &g12a_vclk2_div6.hw,
5149 [CLKID_VCLK2_DIV12] = &g12a_vclk2_div12.hw,
5150 [CLKID_CTS_ENCI_SEL] = &g12a_cts_enci_sel.hw,
5151 [CLKID_CTS_ENCP_SEL] = &g12a_cts_encp_sel.hw,
5152 [CLKID_CTS_ENCL_SEL] = &g12a_cts_encl_sel.hw,
5153 [CLKID_CTS_VDAC_SEL] = &g12a_cts_vdac_sel.hw,
5154 [CLKID_HDMI_TX_SEL] = &g12a_hdmi_tx_sel.hw,
5155 [CLKID_CTS_ENCI] = &g12a_cts_enci.hw,
5156 [CLKID_CTS_ENCP] = &g12a_cts_encp.hw,
5157 [CLKID_CTS_ENCL] = &g12a_cts_encl.hw,
5158 [CLKID_CTS_VDAC] = &g12a_cts_vdac.hw,
5159 [CLKID_HDMI_TX] = &g12a_hdmi_tx.hw,
5160 [CLKID_HDMI_SEL] = &g12a_hdmi_sel.hw,
5161 [CLKID_HDMI_DIV] = &g12a_hdmi_div.hw,
5162 [CLKID_HDMI] = &g12a_hdmi.hw,
5163 [CLKID_MALI_0_SEL] = &g12a_mali_0_sel.hw,
5164 [CLKID_MALI_0_DIV] = &g12a_mali_0_div.hw,
5165 [CLKID_MALI_0] = &g12a_mali_0.hw,
5166 [CLKID_MALI_1_SEL] = &g12a_mali_1_sel.hw,
5167 [CLKID_MALI_1_DIV] = &g12a_mali_1_div.hw,
5168 [CLKID_MALI_1] = &g12a_mali_1.hw,
5169 [CLKID_MALI] = &g12a_mali.hw,
5170 [CLKID_MPLL_50M_DIV] = &g12a_mpll_50m_div.hw,
5171 [CLKID_MPLL_50M] = &g12a_mpll_50m.hw,
5172 [CLKID_SYS_PLL_DIV16_EN] = &g12a_sys_pll_div16_en.hw,
5173 [CLKID_SYS_PLL_DIV16] = &g12a_sys_pll_div16.hw,
5174 [CLKID_CPU_CLK_DYN0_SEL] = &g12a_cpu_clk_premux0.hw,
5175 [CLKID_CPU_CLK_DYN0_DIV] = &g12a_cpu_clk_mux0_div.hw,
5176 [CLKID_CPU_CLK_DYN0] = &g12a_cpu_clk_postmux0.hw,
5177 [CLKID_CPU_CLK_DYN1_SEL] = &g12a_cpu_clk_premux1.hw,
5178 [CLKID_CPU_CLK_DYN1_DIV] = &g12a_cpu_clk_mux1_div.hw,
5179 [CLKID_CPU_CLK_DYN1] = &g12a_cpu_clk_postmux1.hw,
5180 [CLKID_CPU_CLK_DYN] = &g12a_cpu_clk_dyn.hw,
5181 [CLKID_CPU_CLK] = &g12a_cpu_clk.hw,
5182 [CLKID_CPU_CLK_DIV16_EN] = &g12a_cpu_clk_div16_en.hw,
5183 [CLKID_CPU_CLK_DIV16] = &g12a_cpu_clk_div16.hw,
5184 [CLKID_CPU_CLK_APB_DIV] = &g12a_cpu_clk_apb_div.hw,
5185 [CLKID_CPU_CLK_APB] = &g12a_cpu_clk_apb.hw,
5186 [CLKID_CPU_CLK_ATB_DIV] = &g12a_cpu_clk_atb_div.hw,
5187 [CLKID_CPU_CLK_ATB] = &g12a_cpu_clk_atb.hw,
5188 [CLKID_CPU_CLK_AXI_DIV] = &g12a_cpu_clk_axi_div.hw,
5189 [CLKID_CPU_CLK_AXI] = &g12a_cpu_clk_axi.hw,
5190 [CLKID_CPU_CLK_TRACE_DIV] = &g12a_cpu_clk_trace_div.hw,
5191 [CLKID_CPU_CLK_TRACE] = &g12a_cpu_clk_trace.hw,
5192 [CLKID_PCIE_PLL_DCO] = &g12a_pcie_pll_dco.hw,
5193 [CLKID_PCIE_PLL_DCO_DIV2] = &g12a_pcie_pll_dco_div2.hw,
5194 [CLKID_PCIE_PLL_OD] = &g12a_pcie_pll_od.hw,
5195 [CLKID_PCIE_PLL] = &g12a_pcie_pll.hw,
5196 [CLKID_VDEC_1_SEL] = &g12a_vdec_1_sel.hw,
5197 [CLKID_VDEC_1_DIV] = &g12a_vdec_1_div.hw,
5198 [CLKID_VDEC_1] = &g12a_vdec_1.hw,
5199 [CLKID_VDEC_HEVC_SEL] = &g12a_vdec_hevc_sel.hw,
5200 [CLKID_VDEC_HEVC_DIV] = &g12a_vdec_hevc_div.hw,
5201 [CLKID_VDEC_HEVC] = &g12a_vdec_hevc.hw,
5202 [CLKID_VDEC_HEVCF_SEL] = &g12a_vdec_hevcf_sel.hw,
5203 [CLKID_VDEC_HEVCF_DIV] = &g12a_vdec_hevcf_div.hw,
5204 [CLKID_VDEC_HEVCF] = &g12a_vdec_hevcf.hw,
5205 [CLKID_TS_DIV] = &g12a_ts_div.hw,
5206 [CLKID_TS] = &g12a_ts.hw,
5207 [CLKID_GP1_PLL_DCO] = &sm1_gp1_pll_dco.hw,
5208 [CLKID_GP1_PLL] = &sm1_gp1_pll.hw,
5209 [CLKID_DSU_CLK_DYN0_SEL] = &sm1_dsu_clk_premux0.hw,
5210 [CLKID_DSU_CLK_DYN0_DIV] = &sm1_dsu_clk_premux1.hw,
5211 [CLKID_DSU_CLK_DYN0] = &sm1_dsu_clk_mux0_div.hw,
5212 [CLKID_DSU_CLK_DYN1_SEL] = &sm1_dsu_clk_postmux0.hw,
5213 [CLKID_DSU_CLK_DYN1_DIV] = &sm1_dsu_clk_mux1_div.hw,
5214 [CLKID_DSU_CLK_DYN1] = &sm1_dsu_clk_postmux1.hw,
5215 [CLKID_DSU_CLK_DYN] = &sm1_dsu_clk_dyn.hw,
5216 [CLKID_DSU_CLK_FINAL] = &sm1_dsu_final_clk.hw,
5217 [CLKID_DSU_CLK] = &sm1_dsu_clk.hw,
5218 [CLKID_CPU1_CLK] = &sm1_cpu1_clk.hw,
5219 [CLKID_CPU2_CLK] = &sm1_cpu2_clk.hw,
5220 [CLKID_CPU3_CLK] = &sm1_cpu3_clk.hw,
5221 [CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
5222 [CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
5223 [CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
5224 [CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
5225 [CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
5226 [CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
5227 [CLKID_NNA_AXI_CLK_SEL] = &sm1_nna_axi_clk_sel.hw,
5228 [CLKID_NNA_AXI_CLK_DIV] = &sm1_nna_axi_clk_div.hw,
5229 [CLKID_NNA_AXI_CLK] = &sm1_nna_axi_clk.hw,
5230 [CLKID_NNA_CORE_CLK_SEL] = &sm1_nna_core_clk_sel.hw,
5231 [CLKID_NNA_CORE_CLK_DIV] = &sm1_nna_core_clk_div.hw,
5232 [CLKID_NNA_CORE_CLK] = &sm1_nna_core_clk.hw,
5233 [CLKID_MIPI_DSI_PXCLK_SEL] = &g12a_mipi_dsi_pxclk_sel.hw,
5234 [CLKID_MIPI_DSI_PXCLK_DIV] = &g12a_mipi_dsi_pxclk_div.hw,
5235 [CLKID_MIPI_DSI_PXCLK] = &g12a_mipi_dsi_pxclk.hw,
5236 };
5237
5238 static const struct reg_sequence g12a_init_regs[] = {
5239 { .reg = HHI_MPLL_CNTL0, .def = 0x00000543 },
5240 };
5241
5242 #define DVFS_CON_ID "dvfs"
5243
meson_g12a_dvfs_setup_common(struct device * dev,struct clk_hw ** hws)5244 static int meson_g12a_dvfs_setup_common(struct device *dev,
5245 struct clk_hw **hws)
5246 {
5247 struct clk *notifier_clk;
5248 struct clk_hw *xtal;
5249 int ret;
5250
5251 xtal = clk_hw_get_parent_by_index(hws[CLKID_CPU_CLK_DYN1_SEL], 0);
5252
5253 /* Setup clock notifier for cpu_clk_postmux0 */
5254 g12a_cpu_clk_postmux0_nb_data.xtal = xtal;
5255 notifier_clk = devm_clk_hw_get_clk(dev, &g12a_cpu_clk_postmux0.hw,
5256 DVFS_CON_ID);
5257 ret = devm_clk_notifier_register(dev, notifier_clk,
5258 &g12a_cpu_clk_postmux0_nb_data.nb);
5259 if (ret) {
5260 dev_err(dev, "failed to register the cpu_clk_postmux0 notifier\n");
5261 return ret;
5262 }
5263
5264 /* Setup clock notifier for cpu_clk_dyn mux */
5265 notifier_clk = devm_clk_hw_get_clk(dev, &g12a_cpu_clk_dyn.hw,
5266 DVFS_CON_ID);
5267 ret = devm_clk_notifier_register(dev, notifier_clk,
5268 &g12a_cpu_clk_mux_nb);
5269 if (ret) {
5270 dev_err(dev, "failed to register the cpu_clk_dyn notifier\n");
5271 return ret;
5272 }
5273
5274 return 0;
5275 }
5276
meson_g12b_dvfs_setup(struct platform_device * pdev)5277 static int meson_g12b_dvfs_setup(struct platform_device *pdev)
5278 {
5279 struct clk_hw **hws = g12b_hw_clks;
5280 struct device *dev = &pdev->dev;
5281 struct clk *notifier_clk;
5282 struct clk_hw *xtal;
5283 int ret;
5284
5285 ret = meson_g12a_dvfs_setup_common(dev, hws);
5286 if (ret)
5287 return ret;
5288
5289 xtal = clk_hw_get_parent_by_index(hws[CLKID_CPU_CLK_DYN1_SEL], 0);
5290
5291 /* Setup clock notifier for cpu_clk mux */
5292 notifier_clk = devm_clk_hw_get_clk(dev, &g12b_cpu_clk.hw,
5293 DVFS_CON_ID);
5294 ret = devm_clk_notifier_register(dev, notifier_clk,
5295 &g12a_cpu_clk_mux_nb);
5296 if (ret) {
5297 dev_err(dev, "failed to register the cpu_clk notifier\n");
5298 return ret;
5299 }
5300
5301 /* Setup clock notifier for sys1_pll */
5302 notifier_clk = devm_clk_hw_get_clk(dev, &g12b_sys1_pll.hw,
5303 DVFS_CON_ID);
5304 ret = devm_clk_notifier_register(dev, notifier_clk,
5305 &g12b_cpu_clk_sys1_pll_nb_data.nb);
5306 if (ret) {
5307 dev_err(dev, "failed to register the sys1_pll notifier\n");
5308 return ret;
5309 }
5310
5311 /* Add notifiers for the second CPU cluster */
5312
5313 /* Setup clock notifier for cpub_clk_postmux0 */
5314 g12b_cpub_clk_postmux0_nb_data.xtal = xtal;
5315 notifier_clk = devm_clk_hw_get_clk(dev, &g12b_cpub_clk_postmux0.hw,
5316 DVFS_CON_ID);
5317 ret = devm_clk_notifier_register(dev, notifier_clk,
5318 &g12b_cpub_clk_postmux0_nb_data.nb);
5319 if (ret) {
5320 dev_err(dev, "failed to register the cpub_clk_postmux0 notifier\n");
5321 return ret;
5322 }
5323
5324 /* Setup clock notifier for cpub_clk_dyn mux */
5325 notifier_clk = devm_clk_hw_get_clk(dev, &g12b_cpub_clk_dyn.hw, "dvfs");
5326 ret = devm_clk_notifier_register(dev, notifier_clk,
5327 &g12a_cpu_clk_mux_nb);
5328 if (ret) {
5329 dev_err(dev, "failed to register the cpub_clk_dyn notifier\n");
5330 return ret;
5331 }
5332
5333 /* Setup clock notifier for cpub_clk mux */
5334 notifier_clk = devm_clk_hw_get_clk(dev, &g12b_cpub_clk.hw, DVFS_CON_ID);
5335 ret = devm_clk_notifier_register(dev, notifier_clk,
5336 &g12a_cpu_clk_mux_nb);
5337 if (ret) {
5338 dev_err(dev, "failed to register the cpub_clk notifier\n");
5339 return ret;
5340 }
5341
5342 /* Setup clock notifier for sys_pll */
5343 notifier_clk = devm_clk_hw_get_clk(dev, &g12a_sys_pll.hw, DVFS_CON_ID);
5344 ret = devm_clk_notifier_register(dev, notifier_clk,
5345 &g12b_cpub_clk_sys_pll_nb_data.nb);
5346 if (ret) {
5347 dev_err(dev, "failed to register the sys_pll notifier\n");
5348 return ret;
5349 }
5350
5351 return 0;
5352 }
5353
meson_g12a_dvfs_setup(struct platform_device * pdev)5354 static int meson_g12a_dvfs_setup(struct platform_device *pdev)
5355 {
5356 struct clk_hw **hws = g12a_hw_clks;
5357 struct device *dev = &pdev->dev;
5358 struct clk *notifier_clk;
5359 int ret;
5360
5361 ret = meson_g12a_dvfs_setup_common(dev, hws);
5362 if (ret)
5363 return ret;
5364
5365 /* Setup clock notifier for cpu_clk mux */
5366 notifier_clk = devm_clk_hw_get_clk(dev, &g12a_cpu_clk.hw, DVFS_CON_ID);
5367 ret = devm_clk_notifier_register(dev, notifier_clk,
5368 &g12a_cpu_clk_mux_nb);
5369 if (ret) {
5370 dev_err(dev, "failed to register the cpu_clk notifier\n");
5371 return ret;
5372 }
5373
5374 /* Setup clock notifier for sys_pll */
5375 notifier_clk = devm_clk_hw_get_clk(dev, &g12a_sys_pll.hw, DVFS_CON_ID);
5376 ret = devm_clk_notifier_register(dev, notifier_clk,
5377 &g12a_sys_pll_nb_data.nb);
5378 if (ret) {
5379 dev_err(dev, "failed to register the sys_pll notifier\n");
5380 return ret;
5381 }
5382
5383 return 0;
5384 }
5385
5386 struct meson_g12a_data {
5387 const struct meson_eeclkc_data eeclkc_data;
5388 int (*dvfs_setup)(struct platform_device *pdev);
5389 };
5390
meson_g12a_probe(struct platform_device * pdev)5391 static int meson_g12a_probe(struct platform_device *pdev)
5392 {
5393 const struct meson_eeclkc_data *eeclkc_data;
5394 const struct meson_g12a_data *g12a_data;
5395 int ret;
5396
5397 eeclkc_data = of_device_get_match_data(&pdev->dev);
5398 if (!eeclkc_data)
5399 return -EINVAL;
5400
5401 ret = meson_eeclkc_probe(pdev);
5402 if (ret)
5403 return ret;
5404
5405 g12a_data = container_of(eeclkc_data, struct meson_g12a_data,
5406 eeclkc_data);
5407
5408 if (g12a_data->dvfs_setup)
5409 return g12a_data->dvfs_setup(pdev);
5410
5411 return 0;
5412 }
5413
5414 static const struct meson_g12a_data g12a_clkc_data = {
5415 .eeclkc_data = {
5416 .hw_clks = {
5417 .hws = g12a_hw_clks,
5418 .num = ARRAY_SIZE(g12a_hw_clks),
5419 },
5420 .init_regs = g12a_init_regs,
5421 .init_count = ARRAY_SIZE(g12a_init_regs),
5422 },
5423 .dvfs_setup = meson_g12a_dvfs_setup,
5424 };
5425
5426 static const struct meson_g12a_data g12b_clkc_data = {
5427 .eeclkc_data = {
5428 .hw_clks = {
5429 .hws = g12b_hw_clks,
5430 .num = ARRAY_SIZE(g12b_hw_clks),
5431 },
5432 },
5433 .dvfs_setup = meson_g12b_dvfs_setup,
5434 };
5435
5436 static const struct meson_g12a_data sm1_clkc_data = {
5437 .eeclkc_data = {
5438 .hw_clks = {
5439 .hws = sm1_hw_clks,
5440 .num = ARRAY_SIZE(sm1_hw_clks),
5441 },
5442 },
5443 .dvfs_setup = meson_g12a_dvfs_setup,
5444 };
5445
5446 static const struct of_device_id clkc_match_table[] = {
5447 {
5448 .compatible = "amlogic,g12a-clkc",
5449 .data = &g12a_clkc_data.eeclkc_data
5450 },
5451 {
5452 .compatible = "amlogic,g12b-clkc",
5453 .data = &g12b_clkc_data.eeclkc_data
5454 },
5455 {
5456 .compatible = "amlogic,sm1-clkc",
5457 .data = &sm1_clkc_data.eeclkc_data
5458 },
5459 {}
5460 };
5461 MODULE_DEVICE_TABLE(of, clkc_match_table);
5462
5463 static struct platform_driver g12a_driver = {
5464 .probe = meson_g12a_probe,
5465 .driver = {
5466 .name = "g12a-clkc",
5467 .of_match_table = clkc_match_table,
5468 },
5469 };
5470 module_platform_driver(g12a_driver);
5471
5472 MODULE_DESCRIPTION("Amlogic G12/SM1 Main Clock Controller driver");
5473 MODULE_LICENSE("GPL");
5474 MODULE_IMPORT_NS("CLK_MESON");
5475