1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2023 Inochi Amaoto <inochiama@outlook.com>
6 #include <linux/module.h>
7 #include <linux/clk-provider.h>
8 #include <linux/platform_device.h>
10 #include <linux/spinlock.h>
12 #include "clk-cv1800.h"
14 #include "clk-cv18xx-common.h"
15 #include "clk-cv18xx-ip.h"
16 #include "clk-cv18xx-pll.h"
18 struct cv1800_clk_ctrl
;
20 struct cv1800_clk_desc
{
21 struct clk_hw_onecell_data
*clks_data
;
23 int (*pre_init
)(struct device
*dev
, void __iomem
*base
,
24 struct cv1800_clk_ctrl
*ctrl
,
25 const struct cv1800_clk_desc
*desc
);
28 struct cv1800_clk_ctrl
{
29 const struct cv1800_clk_desc
*desc
;
33 #define CV1800_DIV_FLAG \
34 (CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLOSEST)
35 static const struct clk_parent_data osc_parents
[] = {
39 static const struct cv1800_clk_pll_limit pll_limits
[] = {
41 .pre_div
= _CV1800_PLL_LIMIT(1, 127),
42 .div
= _CV1800_PLL_LIMIT(6, 127),
43 .post_div
= _CV1800_PLL_LIMIT(1, 127),
44 .ictrl
= _CV1800_PLL_LIMIT(0, 7),
45 .mode
= _CV1800_PLL_LIMIT(0, 3),
48 .pre_div
= _CV1800_PLL_LIMIT(1, 127),
49 .div
= _CV1800_PLL_LIMIT(6, 127),
50 .post_div
= _CV1800_PLL_LIMIT(1, 127),
51 .ictrl
= _CV1800_PLL_LIMIT(0, 7),
52 .mode
= _CV1800_PLL_LIMIT(0, 3),
56 static CV1800_INTEGRAL_PLL(clk_fpll
, osc_parents
,
63 static CV1800_INTEGRAL_PLL(clk_mipimpll
, osc_parents
,
70 static const struct clk_parent_data clk_mipimpll_parents
[] = {
71 { .hw
= &clk_mipimpll
.common
.hw
},
73 static const struct clk_parent_data clk_bypass_mipimpll_parents
[] = {
75 { .hw
= &clk_mipimpll
.common
.hw
},
77 static const struct clk_parent_data clk_bypass_fpll_parents
[] = {
79 { .hw
= &clk_fpll
.common
.hw
},
82 static struct cv1800_clk_pll_synthesizer clk_mpll_synthesizer
= {
83 .en
= CV1800_CLK_BIT(REG_PLL_G6_SSC_SYN_CTRL
, 2),
84 .clk_half
= CV1800_CLK_BIT(REG_PLL_G6_SSC_SYN_CTRL
, 0),
85 .ctrl
= REG_MPLL_SSC_SYN_CTRL
,
86 .set
= REG_MPLL_SSC_SYN_SET
,
88 static CV1800_FACTIONAL_PLL(clk_mpll
, clk_bypass_mipimpll_parents
,
93 &clk_mpll_synthesizer
,
96 static struct cv1800_clk_pll_synthesizer clk_tpll_synthesizer
= {
97 .en
= CV1800_CLK_BIT(REG_PLL_G6_SSC_SYN_CTRL
, 3),
98 .clk_half
= CV1800_CLK_BIT(REG_PLL_G6_SSC_SYN_CTRL
, 0),
99 .ctrl
= REG_TPLL_SSC_SYN_CTRL
,
100 .set
= REG_TPLL_SSC_SYN_SET
,
102 static CV1800_FACTIONAL_PLL(clk_tpll
, clk_bypass_mipimpll_parents
,
105 REG_PLL_G6_STATUS
, 1,
107 &clk_tpll_synthesizer
,
110 static struct cv1800_clk_pll_synthesizer clk_a0pll_synthesizer
= {
111 .en
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 2),
112 .clk_half
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 0),
113 .ctrl
= REG_A0PLL_SSC_SYN_CTRL
,
114 .set
= REG_A0PLL_SSC_SYN_SET
,
116 static CV1800_FACTIONAL_PLL(clk_a0pll
, clk_bypass_mipimpll_parents
,
119 REG_PLL_G2_STATUS
, 1,
121 &clk_a0pll_synthesizer
,
124 static struct cv1800_clk_pll_synthesizer clk_disppll_synthesizer
= {
125 .en
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 3),
126 .clk_half
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 0),
127 .ctrl
= REG_DISPPLL_SSC_SYN_CTRL
,
128 .set
= REG_DISPPLL_SSC_SYN_SET
,
130 static CV1800_FACTIONAL_PLL(clk_disppll
, clk_bypass_mipimpll_parents
,
133 REG_PLL_G2_STATUS
, 2,
135 &clk_disppll_synthesizer
,
138 static struct cv1800_clk_pll_synthesizer clk_cam0pll_synthesizer
= {
139 .en
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 4),
140 .clk_half
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 0),
141 .ctrl
= REG_CAM0PLL_SSC_SYN_CTRL
,
142 .set
= REG_CAM0PLL_SSC_SYN_SET
,
144 static CV1800_FACTIONAL_PLL(clk_cam0pll
, clk_bypass_mipimpll_parents
,
147 REG_PLL_G2_STATUS
, 3,
149 &clk_cam0pll_synthesizer
,
152 static struct cv1800_clk_pll_synthesizer clk_cam1pll_synthesizer
= {
153 .en
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 5),
154 .clk_half
= CV1800_CLK_BIT(REG_PLL_G2_SSC_SYN_CTRL
, 0),
155 .ctrl
= REG_CAM1PLL_SSC_SYN_CTRL
,
156 .set
= REG_CAM1PLL_SSC_SYN_SET
,
158 static CV1800_FACTIONAL_PLL(clk_cam1pll
, clk_bypass_mipimpll_parents
,
161 REG_PLL_G2_STATUS
, 4,
163 &clk_cam1pll_synthesizer
,
166 static const struct clk_parent_data clk_cam0pll_parents
[] = {
167 { .hw
= &clk_cam0pll
.common
.hw
},
171 static CV1800_FIXED_DIV(clk_cam0pll_d2
, clk_cam0pll_parents
,
172 REG_CAM0PLL_CLK_CSR
, 1,
174 CLK_SET_RATE_PARENT
| CLK_IGNORE_UNUSED
);
175 static CV1800_FIXED_DIV(clk_cam0pll_d3
, clk_cam0pll_parents
,
176 REG_CAM0PLL_CLK_CSR
, 2,
178 CLK_SET_RATE_PARENT
| CLK_IGNORE_UNUSED
);
179 static CV1800_FIXED_DIV(clk_mipimpll_d3
, clk_mipimpll_parents
,
180 REG_MIPIMPLL_CLK_CSR
, 2,
182 CLK_SET_RATE_PARENT
| CLK_IGNORE_UNUSED
);
185 static const struct clk_parent_data clk_tpu_parents
[] = {
187 { .hw
= &clk_tpll
.common
.hw
},
188 { .hw
= &clk_a0pll
.common
.hw
},
189 { .hw
= &clk_mipimpll
.common
.hw
},
190 { .hw
= &clk_fpll
.common
.hw
},
193 static CV1800_BYPASS_MUX(clk_tpu
, clk_tpu_parents
,
195 REG_DIV_CLK_TPU
, 16, 4, 3, CV1800_DIV_FLAG
,
196 REG_DIV_CLK_TPU
, 8, 2,
199 static CV1800_GATE(clk_tpu_fab
, clk_mipimpll_parents
,
204 static CV1800_BYPASS_DIV(clk_axi6
, clk_bypass_fpll_parents
,
206 REG_DIV_CLK_AXI6
, 16, 4, 15, CV1800_DIV_FLAG
,
210 static const struct clk_parent_data clk_axi6_bus_parents
[] = {
211 { .hw
= &clk_axi6
.div
.common
.hw
},
213 static const struct clk_parent_data clk_bypass_axi6_bus_parents
[] = {
215 { .hw
= &clk_axi6
.div
.common
.hw
},
219 static const struct clk_parent_data clk_axi4_parents
[] = {
221 { .hw
= &clk_fpll
.common
.hw
},
222 { .hw
= &clk_disppll
.common
.hw
},
225 static CV1800_BYPASS_MUX(clk_axi4
, clk_axi4_parents
,
227 REG_DIV_CLK_AXI4
, 16, 4, 5, CV1800_DIV_FLAG
,
228 REG_DIV_CLK_AXI4
, 8, 2,
232 static const struct clk_parent_data clk_axi4_bus_parents
[] = {
233 { .hw
= &clk_axi4
.mux
.common
.hw
},
237 static CV1800_GATE(clk_xtal_misc
, osc_parents
,
241 static const struct clk_parent_data clk_timer_parents
[] = {
242 { .hw
= &clk_xtal_misc
.common
.hw
},
246 static const struct clk_parent_data clk_cam0_200_parents
[] = {
249 { .hw
= &clk_disppll
.common
.hw
},
252 static CV1800_BYPASS_MUX(clk_cam0_200
, clk_cam0_200_parents
,
254 REG_DIV_CLK_CAM0_200
, 16, 4, 1, CV1800_DIV_FLAG
,
255 REG_DIV_CLK_CAM0_200
, 8, 2,
258 static CV1800_DIV(clk_1m
, osc_parents
,
260 REG_DIV_CLK_1M
, 16, 6, 25, CV1800_DIV_FLAG
,
262 static CV1800_GATE(clk_pm
, clk_axi6_bus_parents
,
265 static CV1800_GATE(clk_timer0
, clk_timer_parents
,
268 static CV1800_GATE(clk_timer1
, clk_timer_parents
,
271 static CV1800_GATE(clk_timer2
, clk_timer_parents
,
274 static CV1800_GATE(clk_timer3
, clk_timer_parents
,
277 static CV1800_GATE(clk_timer4
, clk_timer_parents
,
280 static CV1800_GATE(clk_timer5
, clk_timer_parents
,
283 static CV1800_GATE(clk_timer6
, clk_timer_parents
,
286 static CV1800_GATE(clk_timer7
, clk_timer_parents
,
290 static const struct clk_parent_data clk_parents_1m
[] = {
291 { .hw
= &clk_1m
.common
.hw
},
293 static const struct clk_parent_data clk_uart_parents
[] = {
294 { .hw
= &clk_cam0_200
.mux
.common
.hw
},
298 static CV1800_GATE(clk_ahb_rom
, clk_axi4_bus_parents
,
303 static CV1800_GATE(clk_rtc_25m
, osc_parents
,
306 static CV1800_BYPASS_DIV(clk_src_rtc_sys_0
, clk_bypass_fpll_parents
,
308 REG_DIV_CLK_RTCSYS_SRC_0
, 16, 4, 5, CV1800_DIV_FLAG
,
313 static CV1800_GATE(clk_tempsen
, osc_parents
,
318 static CV1800_GATE(clk_saradc
, osc_parents
,
323 static CV1800_GATE(clk_efuse
, osc_parents
,
326 static CV1800_GATE(clk_apb_efuse
, osc_parents
,
331 static CV1800_GATE(clk_apb_wdt
, osc_parents
,
336 static CV1800_GATE(clk_wgn
, osc_parents
,
339 static CV1800_GATE(clk_wgn0
, osc_parents
,
342 static CV1800_GATE(clk_wgn1
, osc_parents
,
345 static CV1800_GATE(clk_wgn2
, osc_parents
,
350 static CV1800_GATE(clk_keyscan
, osc_parents
,
355 static CV1800_GATE(clk_axi4_emmc
, clk_axi4_bus_parents
,
358 static CV1800_BYPASS_MUX(clk_emmc
, clk_axi4_parents
,
360 REG_DIV_CLK_EMMC
, 16, 5, 15, CV1800_DIV_FLAG
,
361 REG_DIV_CLK_EMMC
, 8, 2,
364 static CV1800_DIV(clk_emmc_100k
, clk_parents_1m
,
366 REG_DIV_CLK_EMMC_100K
, 16, 8, 10, CV1800_DIV_FLAG
,
370 static CV1800_GATE(clk_axi4_sd0
, clk_axi4_bus_parents
,
373 static CV1800_BYPASS_MUX(clk_sd0
, clk_axi4_parents
,
375 REG_DIV_CLK_SD0
, 16, 5, 15, CV1800_DIV_FLAG
,
376 REG_DIV_CLK_SD0
, 8, 2,
379 static CV1800_DIV(clk_sd0_100k
, clk_parents_1m
,
381 REG_DIV_CLK_SD0_100K
, 16, 8, 10, CV1800_DIV_FLAG
,
383 static CV1800_GATE(clk_axi4_sd1
, clk_axi4_bus_parents
,
386 static CV1800_BYPASS_MUX(clk_sd1
, clk_axi4_parents
,
388 REG_DIV_CLK_SD1
, 16, 5, 15, CV1800_DIV_FLAG
,
389 REG_DIV_CLK_SD1
, 8, 2,
392 static CV1800_DIV(clk_sd1_100k
, clk_parents_1m
,
394 REG_DIV_CLK_SD1_100K
, 16, 8, 10, CV1800_DIV_FLAG
,
398 static CV1800_BYPASS_MUX(clk_spi_nand
, clk_axi4_parents
,
400 REG_DIV_CLK_SPI_NAND
, 16, 5, 8, CV1800_DIV_FLAG
,
401 REG_DIV_CLK_SPI_NAND
, 8, 2,
406 static CV1800_DIV(clk_gpio_db
, clk_parents_1m
,
408 REG_DIV_CLK_GPIO_DB
, 16, 16, 10, CV1800_DIV_FLAG
,
410 static CV1800_GATE(clk_apb_gpio
, clk_axi6_bus_parents
,
413 static CV1800_GATE(clk_apb_gpio_intr
, clk_axi6_bus_parents
,
418 static CV1800_BYPASS_DIV(clk_eth0_500m
, clk_bypass_fpll_parents
,
420 REG_DIV_CLK_GPIO_DB
, 16, 4, 3, CV1800_DIV_FLAG
,
423 static CV1800_GATE(clk_axi4_eth0
, clk_axi4_bus_parents
,
426 static CV1800_BYPASS_DIV(clk_eth1_500m
, clk_bypass_fpll_parents
,
428 REG_DIV_CLK_GPIO_DB
, 16, 4, 3, CV1800_DIV_FLAG
,
431 static CV1800_GATE(clk_axi4_eth1
, clk_axi4_bus_parents
,
436 static CV1800_GATE(clk_ahb_sf
, clk_axi4_bus_parents
,
439 static CV1800_GATE(clk_ahb_sf1
, clk_axi4_bus_parents
,
444 static CV1800_ACLK(clk_a24m
, clk_mipimpll_parents
,
445 REG_APLL_FRAC_DIV_CTRL
, 0,
446 REG_APLL_FRAC_DIV_CTRL
, 3,
447 REG_APLL_FRAC_DIV_CTRL
, 1,
448 REG_APLL_FRAC_DIV_CTRL
, 2,
449 REG_APLL_FRAC_DIV_M
, 0, 22, CV1800_DIV_FLAG
,
450 REG_APLL_FRAC_DIV_N
, 0, 22, CV1800_DIV_FLAG
,
454 static const struct clk_parent_data clk_aud_parents
[] = {
456 { .hw
= &clk_a0pll
.common
.hw
},
457 { .hw
= &clk_a24m
.common
.hw
},
460 static CV1800_BYPASS_MUX(clk_audsrc
, clk_aud_parents
,
462 REG_DIV_CLK_AUDSRC
, 16, 8, 18, CV1800_DIV_FLAG
,
463 REG_DIV_CLK_AUDSRC
, 8, 2,
466 static CV1800_GATE(clk_apb_audsrc
, clk_axi4_bus_parents
,
471 static CV1800_GATE(clk_sdma_axi
, clk_axi4_bus_parents
,
474 static CV1800_BYPASS_MUX(clk_sdma_aud0
, clk_aud_parents
,
476 REG_DIV_CLK_SDMA_AUD0
, 16, 8, 18, CV1800_DIV_FLAG
,
477 REG_DIV_CLK_SDMA_AUD0
, 8, 2,
480 static CV1800_BYPASS_MUX(clk_sdma_aud1
, clk_aud_parents
,
482 REG_DIV_CLK_SDMA_AUD1
, 16, 8, 18, CV1800_DIV_FLAG
,
483 REG_DIV_CLK_SDMA_AUD1
, 8, 2,
486 static CV1800_BYPASS_MUX(clk_sdma_aud2
, clk_aud_parents
,
488 REG_DIV_CLK_SDMA_AUD2
, 16, 8, 18, CV1800_DIV_FLAG
,
489 REG_DIV_CLK_SDMA_AUD2
, 8, 2,
492 static CV1800_BYPASS_MUX(clk_sdma_aud3
, clk_aud_parents
,
494 REG_DIV_CLK_SDMA_AUD3
, 16, 8, 18, CV1800_DIV_FLAG
,
495 REG_DIV_CLK_SDMA_AUD3
, 8, 2,
500 static CV1800_GATE(clk_apb_spi0
, clk_axi4_bus_parents
,
503 static CV1800_GATE(clk_apb_spi1
, clk_axi4_bus_parents
,
506 static CV1800_GATE(clk_apb_spi2
, clk_axi4_bus_parents
,
509 static CV1800_GATE(clk_apb_spi3
, clk_axi4_bus_parents
,
512 static CV1800_BYPASS_DIV(clk_spi
, clk_bypass_fpll_parents
,
514 REG_DIV_CLK_SPI
, 16, 6, 8, CV1800_DIV_FLAG
,
519 static CV1800_GATE(clk_uart0
, clk_uart_parents
,
522 static CV1800_GATE(clk_apb_uart0
, clk_axi4_bus_parents
,
525 static CV1800_GATE(clk_uart1
, clk_uart_parents
,
528 static CV1800_GATE(clk_apb_uart1
, clk_axi4_bus_parents
,
531 static CV1800_GATE(clk_uart2
, clk_uart_parents
,
534 static CV1800_GATE(clk_apb_uart2
, clk_axi4_bus_parents
,
537 static CV1800_GATE(clk_uart3
, clk_uart_parents
,
540 static CV1800_GATE(clk_apb_uart3
, clk_axi4_bus_parents
,
543 static CV1800_GATE(clk_uart4
, clk_uart_parents
,
546 static CV1800_GATE(clk_apb_uart4
, clk_axi4_bus_parents
,
551 static CV1800_GATE(clk_apb_i2s0
, clk_axi4_bus_parents
,
554 static CV1800_GATE(clk_apb_i2s1
, clk_axi4_bus_parents
,
557 static CV1800_GATE(clk_apb_i2s2
, clk_axi4_bus_parents
,
560 static CV1800_GATE(clk_apb_i2s3
, clk_axi4_bus_parents
,
565 static CV1800_GATE(clk_debug
, osc_parents
,
568 static CV1800_BYPASS_DIV(clk_ap_debug
, clk_bypass_fpll_parents
,
570 REG_DIV_CLK_AP_DEBUG
, 16, 4, 5, CV1800_DIV_FLAG
,
575 static CV1800_GATE(clk_ddr_axi_reg
, clk_axi6_bus_parents
,
580 static CV1800_GATE(clk_apb_i2c
, clk_axi4_bus_parents
,
583 static CV1800_BYPASS_DIV(clk_i2c
, clk_bypass_axi6_bus_parents
,
585 REG_DIV_CLK_I2C
, 16, 4, 1, CV1800_DIV_FLAG
,
588 static CV1800_GATE(clk_apb_i2c0
, clk_axi4_bus_parents
,
591 static CV1800_GATE(clk_apb_i2c1
, clk_axi4_bus_parents
,
594 static CV1800_GATE(clk_apb_i2c2
, clk_axi4_bus_parents
,
597 static CV1800_GATE(clk_apb_i2c3
, clk_axi4_bus_parents
,
600 static CV1800_GATE(clk_apb_i2c4
, clk_axi4_bus_parents
,
605 static CV1800_GATE(clk_axi4_usb
, clk_axi4_bus_parents
,
608 static CV1800_GATE(clk_apb_usb
, clk_axi4_bus_parents
,
611 static CV1800_BYPASS_FIXED_DIV(clk_usb_125m
, clk_bypass_fpll_parents
,
615 CLK_SET_RATE_PARENT
);
616 static CV1800_FIXED_DIV(clk_usb_33k
, clk_parents_1m
,
620 static CV1800_BYPASS_FIXED_DIV(clk_usb_12m
, clk_bypass_fpll_parents
,
624 CLK_SET_RATE_PARENT
);
627 static const struct clk_parent_data clk_vip_sys_parents
[] = {
629 { .hw
= &clk_mipimpll
.common
.hw
},
630 { .hw
= &clk_cam0pll
.common
.hw
},
631 { .hw
= &clk_disppll
.common
.hw
},
632 { .hw
= &clk_fpll
.common
.hw
},
634 static const struct clk_parent_data clk_disp_vip_parents
[] = {
636 { .hw
= &clk_disppll
.common
.hw
},
639 static CV1800_BYPASS_DIV(clk_dsi_esc
, clk_bypass_axi6_bus_parents
,
641 REG_DIV_CLK_DSI_ESC
, 16, 4, 5, CV1800_DIV_FLAG
,
644 static CV1800_BYPASS_MUX(clk_axi_vip
, clk_vip_sys_parents
,
646 REG_DIV_CLK_AXI_VIP
, 16, 4, 3, CV1800_DIV_FLAG
,
647 REG_DIV_CLK_AXI_VIP
, 8, 2,
651 static const struct clk_parent_data clk_axi_vip_bus_parents
[] = {
652 { .hw
= &clk_axi_vip
.mux
.common
.hw
},
655 static CV1800_BYPASS_MUX(clk_src_vip_sys_0
, clk_vip_sys_parents
,
657 REG_DIV_CLK_SRC_VIP_SYS_0
, 16, 4, 6, CV1800_DIV_FLAG
,
658 REG_DIV_CLK_SRC_VIP_SYS_0
, 8, 2,
661 static CV1800_BYPASS_MUX(clk_src_vip_sys_1
, clk_vip_sys_parents
,
663 REG_DIV_CLK_SRC_VIP_SYS_1
, 16, 4, 6, CV1800_DIV_FLAG
,
664 REG_DIV_CLK_SRC_VIP_SYS_1
, 8, 2,
667 static CV1800_BYPASS_DIV(clk_disp_src_vip
, clk_disp_vip_parents
,
669 REG_DIV_CLK_DISP_SRC_VIP
, 16, 4, 8, CV1800_DIV_FLAG
,
672 static CV1800_BYPASS_MUX(clk_src_vip_sys_2
, clk_vip_sys_parents
,
674 REG_DIV_CLK_SRC_VIP_SYS_2
, 16, 4, 2, CV1800_DIV_FLAG
,
675 REG_DIV_CLK_SRC_VIP_SYS_2
, 8, 2,
678 static CV1800_GATE(clk_csi_mac0_vip
, clk_axi_vip_bus_parents
,
681 static CV1800_GATE(clk_csi_mac1_vip
, clk_axi_vip_bus_parents
,
684 static CV1800_GATE(clk_isp_top_vip
, clk_axi_vip_bus_parents
,
687 static CV1800_GATE(clk_img_d_vip
, clk_axi_vip_bus_parents
,
690 static CV1800_GATE(clk_img_v_vip
, clk_axi_vip_bus_parents
,
693 static CV1800_GATE(clk_sc_top_vip
, clk_axi_vip_bus_parents
,
696 static CV1800_GATE(clk_sc_d_vip
, clk_axi_vip_bus_parents
,
699 static CV1800_GATE(clk_sc_v1_vip
, clk_axi_vip_bus_parents
,
702 static CV1800_GATE(clk_sc_v2_vip
, clk_axi_vip_bus_parents
,
705 static CV1800_GATE(clk_sc_v3_vip
, clk_axi_vip_bus_parents
,
708 static CV1800_GATE(clk_dwa_vip
, clk_axi_vip_bus_parents
,
711 static CV1800_GATE(clk_bt_vip
, clk_axi_vip_bus_parents
,
714 static CV1800_GATE(clk_disp_vip
, clk_axi_vip_bus_parents
,
717 static CV1800_GATE(clk_dsi_mac_vip
, clk_axi_vip_bus_parents
,
720 static CV1800_GATE(clk_lvds0_vip
, clk_axi_vip_bus_parents
,
723 static CV1800_GATE(clk_lvds1_vip
, clk_axi_vip_bus_parents
,
726 static CV1800_GATE(clk_csi0_rx_vip
, clk_axi_vip_bus_parents
,
729 static CV1800_GATE(clk_csi1_rx_vip
, clk_axi_vip_bus_parents
,
732 static CV1800_GATE(clk_pad_vi_vip
, clk_axi_vip_bus_parents
,
735 static CV1800_GATE(clk_pad_vi1_vip
, clk_axi_vip_bus_parents
,
738 static CV1800_GATE(clk_cfg_reg_vip
, clk_axi6_bus_parents
,
741 static CV1800_GATE(clk_pad_vi2_vip
, clk_axi_vip_bus_parents
,
744 static CV1800_GATE(clk_csi_be_vip
, clk_axi_vip_bus_parents
,
747 static CV1800_GATE(clk_vip_ip0
, clk_axi_vip_bus_parents
,
750 static CV1800_GATE(clk_vip_ip1
, clk_axi_vip_bus_parents
,
753 static CV1800_GATE(clk_vip_ip2
, clk_axi_vip_bus_parents
,
756 static CV1800_GATE(clk_vip_ip3
, clk_axi_vip_bus_parents
,
759 static CV1800_BYPASS_MUX(clk_src_vip_sys_3
, clk_vip_sys_parents
,
761 REG_DIV_CLK_SRC_VIP_SYS_3
, 16, 4, 2, CV1800_DIV_FLAG
,
762 REG_DIV_CLK_SRC_VIP_SYS_3
, 8, 2,
765 static CV1800_BYPASS_MUX(clk_src_vip_sys_4
, clk_vip_sys_parents
,
767 REG_DIV_CLK_SRC_VIP_SYS_4
, 16, 4, 3, CV1800_DIV_FLAG
,
768 REG_DIV_CLK_SRC_VIP_SYS_4
, 8, 2,
771 static CV1800_GATE(clk_ive_vip
, clk_axi_vip_bus_parents
,
774 static CV1800_GATE(clk_raw_vip
, clk_axi_vip_bus_parents
,
777 static CV1800_GATE(clk_osdc_vip
, clk_axi_vip_bus_parents
,
780 static CV1800_GATE(clk_csi_mac2_vip
, clk_axi_vip_bus_parents
,
783 static CV1800_GATE(clk_cam0_vip
, clk_axi_vip_bus_parents
,
788 static const struct clk_parent_data clk_cam_parents
[] = {
789 { .hw
= &clk_cam0pll
.common
.hw
},
790 { .hw
= &clk_cam0pll_d2
.common
.hw
},
791 { .hw
= &clk_cam0pll_d3
.common
.hw
},
792 { .hw
= &clk_mipimpll_d3
.common
.hw
},
795 static CV1800_MUX(clk_cam0
, clk_cam_parents
,
797 REG_CLK_CAM0_SRC_DIV
, 16, 6, 0, CV1800_DIV_FLAG
,
798 REG_CLK_CAM0_SRC_DIV
, 8, 2,
800 static CV1800_MUX(clk_cam1
, clk_cam_parents
,
802 REG_CLK_CAM1_SRC_DIV
, 16, 6, 0, CV1800_DIV_FLAG
,
803 REG_CLK_CAM1_SRC_DIV
, 8, 2,
807 static const struct clk_parent_data clk_axi_video_codec_parents
[] = {
809 { .hw
= &clk_a0pll
.common
.hw
},
810 { .hw
= &clk_mipimpll
.common
.hw
},
811 { .hw
= &clk_cam1pll
.common
.hw
},
812 { .hw
= &clk_fpll
.common
.hw
},
814 static const struct clk_parent_data clk_vc_src0_parents
[] = {
816 { .hw
= &clk_disppll
.common
.hw
},
817 { .hw
= &clk_mipimpll
.common
.hw
},
818 { .hw
= &clk_cam1pll
.common
.hw
},
819 { .hw
= &clk_fpll
.common
.hw
},
821 static const struct clk_parent_data clk_vc_src1_parents
[] = {
823 { .hw
= &clk_cam1pll
.common
.hw
},
826 static CV1800_BYPASS_MUX(clk_axi_video_codec
, clk_axi_video_codec_parents
,
828 REG_DIV_CLK_AXI_VIDEO_CODEC
, 16, 4, 2, CV1800_DIV_FLAG
,
829 REG_DIV_CLK_AXI_VIDEO_CODEC
, 8, 2,
833 static const struct clk_parent_data clk_axi_video_codec_bus_parents
[] = {
834 { .hw
= &clk_axi_video_codec
.mux
.common
.hw
},
837 static CV1800_BYPASS_MUX(clk_vc_src0
, clk_vc_src0_parents
,
839 REG_DIV_CLK_VC_SRC0
, 16, 4, 2, CV1800_DIV_FLAG
,
840 REG_DIV_CLK_VC_SRC0
, 8, 2,
844 static CV1800_GATE(clk_h264c
, clk_axi_video_codec_bus_parents
,
847 static CV1800_GATE(clk_h265c
, clk_axi_video_codec_bus_parents
,
850 static CV1800_GATE(clk_jpeg
, clk_axi_video_codec_bus_parents
,
853 static CV1800_GATE(clk_apb_jpeg
, clk_axi6_bus_parents
,
856 static CV1800_GATE(clk_apb_h264c
, clk_axi6_bus_parents
,
859 static CV1800_GATE(clk_apb_h265c
, clk_axi6_bus_parents
,
862 static CV1800_BYPASS_FIXED_DIV(clk_vc_src1
, clk_vc_src1_parents
,
866 CLK_SET_RATE_PARENT
);
867 static CV1800_BYPASS_FIXED_DIV(clk_vc_src2
, clk_bypass_fpll_parents
,
871 CLK_SET_RATE_PARENT
);
874 static CV1800_GATE(clk_cfg_reg_vc
, clk_axi6_bus_parents
,
879 static CV1800_BYPASS_MUX(clk_pwm_src
, clk_axi4_parents
,
881 REG_DIV_CLK_PWM_SRC_0
, 16, 6, 10, CV1800_DIV_FLAG
,
882 REG_DIV_CLK_PWM_SRC_0
, 8, 2,
886 static const struct clk_parent_data clk_pwm_parents
[] = {
887 { .hw
= &clk_pwm_src
.mux
.common
.hw
},
890 static CV1800_GATE(clk_pwm
, clk_pwm_parents
,
895 static const struct clk_parent_data clk_c906_0_parents
[] = {
897 { .hw
= &clk_tpll
.common
.hw
},
898 { .hw
= &clk_a0pll
.common
.hw
},
899 { .hw
= &clk_mipimpll
.common
.hw
},
900 { .hw
= &clk_mpll
.common
.hw
},
901 { .hw
= &clk_fpll
.common
.hw
},
903 static const struct clk_parent_data clk_c906_1_parents
[] = {
905 { .hw
= &clk_tpll
.common
.hw
},
906 { .hw
= &clk_a0pll
.common
.hw
},
907 { .hw
= &clk_disppll
.common
.hw
},
908 { .hw
= &clk_mpll
.common
.hw
},
909 { .hw
= &clk_fpll
.common
.hw
},
912 static const s8 clk_c906_parent2sel
[] = {
914 0, /* mux 0: clk_tpll(c906_0), clk_tpll(c906_1) */
915 0, /* mux 0: clk_a0pll(c906_0), clk_a0pll(c906_1) */
916 0, /* mux 0: clk_mipimpll(c906_0), clk_disppll(c906_1) */
917 0, /* mux 0: clk_mpll(c906_0), clk_mpll(c906_1) */
918 1 /* mux 1: clk_fpll(c906_0), clk_fpll(c906_1) */
921 static const u8 clk_c906_sel2parent
[2][4] = {
936 static CV1800_MMUX(clk_c906_0
, clk_c906_0_parents
,
938 REG_DIV_CLK_C906_0_0
, 16, 4, 1, CV1800_DIV_FLAG
,
939 REG_DIV_CLK_C906_0_1
, 16, 4, 2, CV1800_DIV_FLAG
,
940 REG_DIV_CLK_C906_0_0
, 8, 2,
941 REG_DIV_CLK_C906_0_1
, 8, 2,
945 clk_c906_sel2parent
[0], clk_c906_sel2parent
[1],
946 CLK_IS_CRITICAL
| CLK_GET_RATE_NOCACHE
);
947 static CV1800_MMUX(clk_c906_1
, clk_c906_1_parents
,
949 REG_DIV_CLK_C906_1_0
, 16, 4, 2, CV1800_DIV_FLAG
,
950 REG_DIV_CLK_C906_1_1
, 16, 4, 3, CV1800_DIV_FLAG
,
951 REG_DIV_CLK_C906_1_0
, 8, 2,
952 REG_DIV_CLK_C906_1_1
, 8, 2,
956 clk_c906_sel2parent
[0], clk_c906_sel2parent
[1],
957 CLK_IS_CRITICAL
| CLK_GET_RATE_NOCACHE
);
960 static CV1800_BYPASS_DIV(clk_cpu_axi0
, clk_axi4_parents
,
962 REG_DIV_CLK_CPU_AXI0
, 16, 4, 3, CV1800_DIV_FLAG
,
965 static CV1800_BYPASS_DIV(clk_cpu_gic
, clk_bypass_fpll_parents
,
967 REG_DIV_CLK_CPU_GIC
, 16, 4, 5, CV1800_DIV_FLAG
,
970 static CV1800_GATE(clk_xtal_ap
, osc_parents
,
974 static const struct clk_parent_data clk_a53_parents
[] = {
976 { .hw
= &clk_tpll
.common
.hw
},
977 { .hw
= &clk_a0pll
.common
.hw
},
978 { .hw
= &clk_mipimpll
.common
.hw
},
979 { .hw
= &clk_mpll
.common
.hw
},
980 { .hw
= &clk_fpll
.common
.hw
},
983 static const s8 clk_a53_parent2sel
[] = {
985 0, /* mux 0: clk_tpll */
986 0, /* mux 0: clk_a0pll */
987 0, /* mux 0: clk_mipimpll */
988 0, /* mux 0: clk_mpll */
989 1 /* mux 1: clk_fpll */
992 static const u8 clk_a53_sel2parent
[2][4] = {
1008 * Clock for A53 cpu in the CV18XX/SG200X series.
1009 * For CV180X and CV181X series, this clock is not used, but can not
1010 * be set to bypass mode, or the SoC will hang.
1012 static CV1800_MMUX(clk_a53
, clk_a53_parents
,
1014 REG_DIV_CLK_A53_0
, 16, 4, 1, CV1800_DIV_FLAG
,
1015 REG_DIV_CLK_A53_1
, 16, 4, 2, CV1800_DIV_FLAG
,
1016 REG_DIV_CLK_A53_0
, 8, 2,
1017 REG_DIV_CLK_A53_1
, 8, 2,
1021 clk_a53_sel2parent
[0], clk_a53_sel2parent
[1],
1022 CLK_IS_CRITICAL
| CLK_GET_RATE_NOCACHE
);
1024 static struct clk_hw_onecell_data cv1800_hw_clks
= {
1025 .num
= CV1800_CLK_MAX
,
1027 [CLK_MPLL
] = &clk_mpll
.common
.hw
,
1028 [CLK_TPLL
] = &clk_tpll
.common
.hw
,
1029 [CLK_FPLL
] = &clk_fpll
.common
.hw
,
1030 [CLK_MIPIMPLL
] = &clk_mipimpll
.common
.hw
,
1031 [CLK_A0PLL
] = &clk_a0pll
.common
.hw
,
1032 [CLK_DISPPLL
] = &clk_disppll
.common
.hw
,
1033 [CLK_CAM0PLL
] = &clk_cam0pll
.common
.hw
,
1034 [CLK_CAM1PLL
] = &clk_cam1pll
.common
.hw
,
1036 [CLK_MIPIMPLL_D3
] = &clk_mipimpll_d3
.common
.hw
,
1037 [CLK_CAM0PLL_D2
] = &clk_cam0pll_d2
.common
.hw
,
1038 [CLK_CAM0PLL_D3
] = &clk_cam0pll_d3
.common
.hw
,
1040 [CLK_TPU
] = &clk_tpu
.mux
.common
.hw
,
1041 [CLK_TPU_FAB
] = &clk_tpu_fab
.common
.hw
,
1042 [CLK_AHB_ROM
] = &clk_ahb_rom
.common
.hw
,
1043 [CLK_DDR_AXI_REG
] = &clk_ddr_axi_reg
.common
.hw
,
1044 [CLK_RTC_25M
] = &clk_rtc_25m
.common
.hw
,
1045 [CLK_SRC_RTC_SYS_0
] = &clk_src_rtc_sys_0
.div
.common
.hw
,
1046 [CLK_TEMPSEN
] = &clk_tempsen
.common
.hw
,
1047 [CLK_SARADC
] = &clk_saradc
.common
.hw
,
1048 [CLK_EFUSE
] = &clk_efuse
.common
.hw
,
1049 [CLK_APB_EFUSE
] = &clk_apb_efuse
.common
.hw
,
1050 [CLK_DEBUG
] = &clk_debug
.common
.hw
,
1051 [CLK_AP_DEBUG
] = &clk_ap_debug
.div
.common
.hw
,
1052 [CLK_XTAL_MISC
] = &clk_xtal_misc
.common
.hw
,
1053 [CLK_AXI4_EMMC
] = &clk_axi4_emmc
.common
.hw
,
1054 [CLK_EMMC
] = &clk_emmc
.mux
.common
.hw
,
1055 [CLK_EMMC_100K
] = &clk_emmc_100k
.common
.hw
,
1056 [CLK_AXI4_SD0
] = &clk_axi4_sd0
.common
.hw
,
1057 [CLK_SD0
] = &clk_sd0
.mux
.common
.hw
,
1058 [CLK_SD0_100K
] = &clk_sd0_100k
.common
.hw
,
1059 [CLK_AXI4_SD1
] = &clk_axi4_sd1
.common
.hw
,
1060 [CLK_SD1
] = &clk_sd1
.mux
.common
.hw
,
1061 [CLK_SD1_100K
] = &clk_sd1_100k
.common
.hw
,
1062 [CLK_SPI_NAND
] = &clk_spi_nand
.mux
.common
.hw
,
1063 [CLK_ETH0_500M
] = &clk_eth0_500m
.div
.common
.hw
,
1064 [CLK_AXI4_ETH0
] = &clk_axi4_eth0
.common
.hw
,
1065 [CLK_ETH1_500M
] = &clk_eth1_500m
.div
.common
.hw
,
1066 [CLK_AXI4_ETH1
] = &clk_axi4_eth1
.common
.hw
,
1067 [CLK_APB_GPIO
] = &clk_apb_gpio
.common
.hw
,
1068 [CLK_APB_GPIO_INTR
] = &clk_apb_gpio_intr
.common
.hw
,
1069 [CLK_GPIO_DB
] = &clk_gpio_db
.common
.hw
,
1070 [CLK_AHB_SF
] = &clk_ahb_sf
.common
.hw
,
1071 [CLK_AHB_SF1
] = &clk_ahb_sf1
.common
.hw
,
1072 [CLK_A24M
] = &clk_a24m
.common
.hw
,
1073 [CLK_AUDSRC
] = &clk_audsrc
.mux
.common
.hw
,
1074 [CLK_APB_AUDSRC
] = &clk_apb_audsrc
.common
.hw
,
1075 [CLK_SDMA_AXI
] = &clk_sdma_axi
.common
.hw
,
1076 [CLK_SDMA_AUD0
] = &clk_sdma_aud0
.mux
.common
.hw
,
1077 [CLK_SDMA_AUD1
] = &clk_sdma_aud1
.mux
.common
.hw
,
1078 [CLK_SDMA_AUD2
] = &clk_sdma_aud2
.mux
.common
.hw
,
1079 [CLK_SDMA_AUD3
] = &clk_sdma_aud3
.mux
.common
.hw
,
1080 [CLK_I2C
] = &clk_i2c
.div
.common
.hw
,
1081 [CLK_APB_I2C
] = &clk_apb_i2c
.common
.hw
,
1082 [CLK_APB_I2C0
] = &clk_apb_i2c0
.common
.hw
,
1083 [CLK_APB_I2C1
] = &clk_apb_i2c1
.common
.hw
,
1084 [CLK_APB_I2C2
] = &clk_apb_i2c2
.common
.hw
,
1085 [CLK_APB_I2C3
] = &clk_apb_i2c3
.common
.hw
,
1086 [CLK_APB_I2C4
] = &clk_apb_i2c4
.common
.hw
,
1087 [CLK_APB_WDT
] = &clk_apb_wdt
.common
.hw
,
1088 [CLK_PWM_SRC
] = &clk_pwm_src
.mux
.common
.hw
,
1089 [CLK_PWM
] = &clk_pwm
.common
.hw
,
1090 [CLK_SPI
] = &clk_spi
.div
.common
.hw
,
1091 [CLK_APB_SPI0
] = &clk_apb_spi0
.common
.hw
,
1092 [CLK_APB_SPI1
] = &clk_apb_spi1
.common
.hw
,
1093 [CLK_APB_SPI2
] = &clk_apb_spi2
.common
.hw
,
1094 [CLK_APB_SPI3
] = &clk_apb_spi3
.common
.hw
,
1095 [CLK_1M
] = &clk_1m
.common
.hw
,
1096 [CLK_CAM0_200
] = &clk_cam0_200
.mux
.common
.hw
,
1097 [CLK_PM
] = &clk_pm
.common
.hw
,
1098 [CLK_TIMER0
] = &clk_timer0
.common
.hw
,
1099 [CLK_TIMER1
] = &clk_timer1
.common
.hw
,
1100 [CLK_TIMER2
] = &clk_timer2
.common
.hw
,
1101 [CLK_TIMER3
] = &clk_timer3
.common
.hw
,
1102 [CLK_TIMER4
] = &clk_timer4
.common
.hw
,
1103 [CLK_TIMER5
] = &clk_timer5
.common
.hw
,
1104 [CLK_TIMER6
] = &clk_timer6
.common
.hw
,
1105 [CLK_TIMER7
] = &clk_timer7
.common
.hw
,
1106 [CLK_UART0
] = &clk_uart0
.common
.hw
,
1107 [CLK_APB_UART0
] = &clk_apb_uart0
.common
.hw
,
1108 [CLK_UART1
] = &clk_uart1
.common
.hw
,
1109 [CLK_APB_UART1
] = &clk_apb_uart1
.common
.hw
,
1110 [CLK_UART2
] = &clk_uart2
.common
.hw
,
1111 [CLK_APB_UART2
] = &clk_apb_uart2
.common
.hw
,
1112 [CLK_UART3
] = &clk_uart3
.common
.hw
,
1113 [CLK_APB_UART3
] = &clk_apb_uart3
.common
.hw
,
1114 [CLK_UART4
] = &clk_uart4
.common
.hw
,
1115 [CLK_APB_UART4
] = &clk_apb_uart4
.common
.hw
,
1116 [CLK_APB_I2S0
] = &clk_apb_i2s0
.common
.hw
,
1117 [CLK_APB_I2S1
] = &clk_apb_i2s1
.common
.hw
,
1118 [CLK_APB_I2S2
] = &clk_apb_i2s2
.common
.hw
,
1119 [CLK_APB_I2S3
] = &clk_apb_i2s3
.common
.hw
,
1120 [CLK_AXI4_USB
] = &clk_axi4_usb
.common
.hw
,
1121 [CLK_APB_USB
] = &clk_apb_usb
.common
.hw
,
1122 [CLK_USB_125M
] = &clk_usb_125m
.div
.common
.hw
,
1123 [CLK_USB_33K
] = &clk_usb_33k
.common
.hw
,
1124 [CLK_USB_12M
] = &clk_usb_12m
.div
.common
.hw
,
1125 [CLK_AXI4
] = &clk_axi4
.mux
.common
.hw
,
1126 [CLK_AXI6
] = &clk_axi6
.div
.common
.hw
,
1127 [CLK_DSI_ESC
] = &clk_dsi_esc
.div
.common
.hw
,
1128 [CLK_AXI_VIP
] = &clk_axi_vip
.mux
.common
.hw
,
1129 [CLK_SRC_VIP_SYS_0
] = &clk_src_vip_sys_0
.mux
.common
.hw
,
1130 [CLK_SRC_VIP_SYS_1
] = &clk_src_vip_sys_1
.mux
.common
.hw
,
1131 [CLK_SRC_VIP_SYS_2
] = &clk_src_vip_sys_2
.mux
.common
.hw
,
1132 [CLK_SRC_VIP_SYS_3
] = &clk_src_vip_sys_3
.mux
.common
.hw
,
1133 [CLK_SRC_VIP_SYS_4
] = &clk_src_vip_sys_4
.mux
.common
.hw
,
1134 [CLK_CSI_BE_VIP
] = &clk_csi_be_vip
.common
.hw
,
1135 [CLK_CSI_MAC0_VIP
] = &clk_csi_mac0_vip
.common
.hw
,
1136 [CLK_CSI_MAC1_VIP
] = &clk_csi_mac1_vip
.common
.hw
,
1137 [CLK_CSI_MAC2_VIP
] = &clk_csi_mac2_vip
.common
.hw
,
1138 [CLK_CSI0_RX_VIP
] = &clk_csi0_rx_vip
.common
.hw
,
1139 [CLK_CSI1_RX_VIP
] = &clk_csi1_rx_vip
.common
.hw
,
1140 [CLK_ISP_TOP_VIP
] = &clk_isp_top_vip
.common
.hw
,
1141 [CLK_IMG_D_VIP
] = &clk_img_d_vip
.common
.hw
,
1142 [CLK_IMG_V_VIP
] = &clk_img_v_vip
.common
.hw
,
1143 [CLK_SC_TOP_VIP
] = &clk_sc_top_vip
.common
.hw
,
1144 [CLK_SC_D_VIP
] = &clk_sc_d_vip
.common
.hw
,
1145 [CLK_SC_V1_VIP
] = &clk_sc_v1_vip
.common
.hw
,
1146 [CLK_SC_V2_VIP
] = &clk_sc_v2_vip
.common
.hw
,
1147 [CLK_SC_V3_VIP
] = &clk_sc_v3_vip
.common
.hw
,
1148 [CLK_DWA_VIP
] = &clk_dwa_vip
.common
.hw
,
1149 [CLK_BT_VIP
] = &clk_bt_vip
.common
.hw
,
1150 [CLK_DISP_VIP
] = &clk_disp_vip
.common
.hw
,
1151 [CLK_DSI_MAC_VIP
] = &clk_dsi_mac_vip
.common
.hw
,
1152 [CLK_LVDS0_VIP
] = &clk_lvds0_vip
.common
.hw
,
1153 [CLK_LVDS1_VIP
] = &clk_lvds1_vip
.common
.hw
,
1154 [CLK_PAD_VI_VIP
] = &clk_pad_vi_vip
.common
.hw
,
1155 [CLK_PAD_VI1_VIP
] = &clk_pad_vi1_vip
.common
.hw
,
1156 [CLK_PAD_VI2_VIP
] = &clk_pad_vi2_vip
.common
.hw
,
1157 [CLK_CFG_REG_VIP
] = &clk_cfg_reg_vip
.common
.hw
,
1158 [CLK_VIP_IP0
] = &clk_vip_ip0
.common
.hw
,
1159 [CLK_VIP_IP1
] = &clk_vip_ip1
.common
.hw
,
1160 [CLK_VIP_IP2
] = &clk_vip_ip2
.common
.hw
,
1161 [CLK_VIP_IP3
] = &clk_vip_ip3
.common
.hw
,
1162 [CLK_IVE_VIP
] = &clk_ive_vip
.common
.hw
,
1163 [CLK_RAW_VIP
] = &clk_raw_vip
.common
.hw
,
1164 [CLK_OSDC_VIP
] = &clk_osdc_vip
.common
.hw
,
1165 [CLK_CAM0_VIP
] = &clk_cam0_vip
.common
.hw
,
1166 [CLK_AXI_VIDEO_CODEC
] = &clk_axi_video_codec
.mux
.common
.hw
,
1167 [CLK_VC_SRC0
] = &clk_vc_src0
.mux
.common
.hw
,
1168 [CLK_VC_SRC1
] = &clk_vc_src1
.div
.common
.hw
,
1169 [CLK_VC_SRC2
] = &clk_vc_src2
.div
.common
.hw
,
1170 [CLK_H264C
] = &clk_h264c
.common
.hw
,
1171 [CLK_APB_H264C
] = &clk_apb_h264c
.common
.hw
,
1172 [CLK_H265C
] = &clk_h265c
.common
.hw
,
1173 [CLK_APB_H265C
] = &clk_apb_h265c
.common
.hw
,
1174 [CLK_JPEG
] = &clk_jpeg
.common
.hw
,
1175 [CLK_APB_JPEG
] = &clk_apb_jpeg
.common
.hw
,
1176 [CLK_CAM0
] = &clk_cam0
.common
.hw
,
1177 [CLK_CAM1
] = &clk_cam1
.common
.hw
,
1178 [CLK_WGN
] = &clk_wgn
.common
.hw
,
1179 [CLK_WGN0
] = &clk_wgn0
.common
.hw
,
1180 [CLK_WGN1
] = &clk_wgn1
.common
.hw
,
1181 [CLK_WGN2
] = &clk_wgn2
.common
.hw
,
1182 [CLK_KEYSCAN
] = &clk_keyscan
.common
.hw
,
1183 [CLK_CFG_REG_VC
] = &clk_cfg_reg_vc
.common
.hw
,
1184 [CLK_C906_0
] = &clk_c906_0
.common
.hw
,
1185 [CLK_C906_1
] = &clk_c906_1
.common
.hw
,
1186 [CLK_A53
] = &clk_a53
.common
.hw
,
1187 [CLK_CPU_AXI0
] = &clk_cpu_axi0
.div
.common
.hw
,
1188 [CLK_CPU_GIC
] = &clk_cpu_gic
.div
.common
.hw
,
1189 [CLK_XTAL_AP
] = &clk_xtal_ap
.common
.hw
,
1193 static void cv18xx_clk_disable_auto_pd(void __iomem
*base
)
1195 static const u16 CV1800_PD_CLK
[] = {
1196 REG_MIPIMPLL_CLK_CSR
,
1198 REG_DISPPLL_CLK_CSR
,
1199 REG_CAM0PLL_CLK_CSR
,
1200 REG_CAM1PLL_CLK_CSR
,
1206 /* disable auto power down */
1207 for (i
= 0; i
< ARRAY_SIZE(CV1800_PD_CLK
); i
++) {
1208 u32 reg
= CV1800_PD_CLK
[i
];
1210 val
= readl(base
+ reg
);
1211 val
|= GENMASK(12, 9);
1213 writel(val
, base
+ reg
);
1217 static void cv18xx_clk_disable_a53(void __iomem
*base
)
1219 u32 val
= readl(base
+ REG_CLK_BYP_0
);
1221 /* Set bypass clock for clk_a53 */
1224 /* Set bypass clock for clk_cpu_axi0 */
1227 /* Set bypass clock for clk_cpu_gic */
1230 writel(val
, base
+ REG_CLK_BYP_0
);
1233 static int cv1800_pre_init(struct device
*dev
, void __iomem
*base
,
1234 struct cv1800_clk_ctrl
*ctrl
,
1235 const struct cv1800_clk_desc
*desc
)
1237 u32 val
= readl(base
+ REG_CLK_EN_2
);
1239 /* disable unsupported clk_disp_src_vip */
1242 writel(val
, base
+ REG_CLK_EN_2
);
1244 cv18xx_clk_disable_a53(base
);
1245 cv18xx_clk_disable_auto_pd(base
);
1250 static const struct cv1800_clk_desc cv1800_desc
= {
1251 .clks_data
= &cv1800_hw_clks
,
1252 .pre_init
= cv1800_pre_init
,
1255 static struct clk_hw_onecell_data cv1810_hw_clks
= {
1256 .num
= CV1810_CLK_MAX
,
1258 [CLK_MPLL
] = &clk_mpll
.common
.hw
,
1259 [CLK_TPLL
] = &clk_tpll
.common
.hw
,
1260 [CLK_FPLL
] = &clk_fpll
.common
.hw
,
1261 [CLK_MIPIMPLL
] = &clk_mipimpll
.common
.hw
,
1262 [CLK_A0PLL
] = &clk_a0pll
.common
.hw
,
1263 [CLK_DISPPLL
] = &clk_disppll
.common
.hw
,
1264 [CLK_CAM0PLL
] = &clk_cam0pll
.common
.hw
,
1265 [CLK_CAM1PLL
] = &clk_cam1pll
.common
.hw
,
1267 [CLK_MIPIMPLL_D3
] = &clk_mipimpll_d3
.common
.hw
,
1268 [CLK_CAM0PLL_D2
] = &clk_cam0pll_d2
.common
.hw
,
1269 [CLK_CAM0PLL_D3
] = &clk_cam0pll_d3
.common
.hw
,
1271 [CLK_TPU
] = &clk_tpu
.mux
.common
.hw
,
1272 [CLK_TPU_FAB
] = &clk_tpu_fab
.common
.hw
,
1273 [CLK_AHB_ROM
] = &clk_ahb_rom
.common
.hw
,
1274 [CLK_DDR_AXI_REG
] = &clk_ddr_axi_reg
.common
.hw
,
1275 [CLK_RTC_25M
] = &clk_rtc_25m
.common
.hw
,
1276 [CLK_SRC_RTC_SYS_0
] = &clk_src_rtc_sys_0
.div
.common
.hw
,
1277 [CLK_TEMPSEN
] = &clk_tempsen
.common
.hw
,
1278 [CLK_SARADC
] = &clk_saradc
.common
.hw
,
1279 [CLK_EFUSE
] = &clk_efuse
.common
.hw
,
1280 [CLK_APB_EFUSE
] = &clk_apb_efuse
.common
.hw
,
1281 [CLK_DEBUG
] = &clk_debug
.common
.hw
,
1282 [CLK_AP_DEBUG
] = &clk_ap_debug
.div
.common
.hw
,
1283 [CLK_XTAL_MISC
] = &clk_xtal_misc
.common
.hw
,
1284 [CLK_AXI4_EMMC
] = &clk_axi4_emmc
.common
.hw
,
1285 [CLK_EMMC
] = &clk_emmc
.mux
.common
.hw
,
1286 [CLK_EMMC_100K
] = &clk_emmc_100k
.common
.hw
,
1287 [CLK_AXI4_SD0
] = &clk_axi4_sd0
.common
.hw
,
1288 [CLK_SD0
] = &clk_sd0
.mux
.common
.hw
,
1289 [CLK_SD0_100K
] = &clk_sd0_100k
.common
.hw
,
1290 [CLK_AXI4_SD1
] = &clk_axi4_sd1
.common
.hw
,
1291 [CLK_SD1
] = &clk_sd1
.mux
.common
.hw
,
1292 [CLK_SD1_100K
] = &clk_sd1_100k
.common
.hw
,
1293 [CLK_SPI_NAND
] = &clk_spi_nand
.mux
.common
.hw
,
1294 [CLK_ETH0_500M
] = &clk_eth0_500m
.div
.common
.hw
,
1295 [CLK_AXI4_ETH0
] = &clk_axi4_eth0
.common
.hw
,
1296 [CLK_ETH1_500M
] = &clk_eth1_500m
.div
.common
.hw
,
1297 [CLK_AXI4_ETH1
] = &clk_axi4_eth1
.common
.hw
,
1298 [CLK_APB_GPIO
] = &clk_apb_gpio
.common
.hw
,
1299 [CLK_APB_GPIO_INTR
] = &clk_apb_gpio_intr
.common
.hw
,
1300 [CLK_GPIO_DB
] = &clk_gpio_db
.common
.hw
,
1301 [CLK_AHB_SF
] = &clk_ahb_sf
.common
.hw
,
1302 [CLK_AHB_SF1
] = &clk_ahb_sf1
.common
.hw
,
1303 [CLK_A24M
] = &clk_a24m
.common
.hw
,
1304 [CLK_AUDSRC
] = &clk_audsrc
.mux
.common
.hw
,
1305 [CLK_APB_AUDSRC
] = &clk_apb_audsrc
.common
.hw
,
1306 [CLK_SDMA_AXI
] = &clk_sdma_axi
.common
.hw
,
1307 [CLK_SDMA_AUD0
] = &clk_sdma_aud0
.mux
.common
.hw
,
1308 [CLK_SDMA_AUD1
] = &clk_sdma_aud1
.mux
.common
.hw
,
1309 [CLK_SDMA_AUD2
] = &clk_sdma_aud2
.mux
.common
.hw
,
1310 [CLK_SDMA_AUD3
] = &clk_sdma_aud3
.mux
.common
.hw
,
1311 [CLK_I2C
] = &clk_i2c
.div
.common
.hw
,
1312 [CLK_APB_I2C
] = &clk_apb_i2c
.common
.hw
,
1313 [CLK_APB_I2C0
] = &clk_apb_i2c0
.common
.hw
,
1314 [CLK_APB_I2C1
] = &clk_apb_i2c1
.common
.hw
,
1315 [CLK_APB_I2C2
] = &clk_apb_i2c2
.common
.hw
,
1316 [CLK_APB_I2C3
] = &clk_apb_i2c3
.common
.hw
,
1317 [CLK_APB_I2C4
] = &clk_apb_i2c4
.common
.hw
,
1318 [CLK_APB_WDT
] = &clk_apb_wdt
.common
.hw
,
1319 [CLK_PWM_SRC
] = &clk_pwm_src
.mux
.common
.hw
,
1320 [CLK_PWM
] = &clk_pwm
.common
.hw
,
1321 [CLK_SPI
] = &clk_spi
.div
.common
.hw
,
1322 [CLK_APB_SPI0
] = &clk_apb_spi0
.common
.hw
,
1323 [CLK_APB_SPI1
] = &clk_apb_spi1
.common
.hw
,
1324 [CLK_APB_SPI2
] = &clk_apb_spi2
.common
.hw
,
1325 [CLK_APB_SPI3
] = &clk_apb_spi3
.common
.hw
,
1326 [CLK_1M
] = &clk_1m
.common
.hw
,
1327 [CLK_CAM0_200
] = &clk_cam0_200
.mux
.common
.hw
,
1328 [CLK_PM
] = &clk_pm
.common
.hw
,
1329 [CLK_TIMER0
] = &clk_timer0
.common
.hw
,
1330 [CLK_TIMER1
] = &clk_timer1
.common
.hw
,
1331 [CLK_TIMER2
] = &clk_timer2
.common
.hw
,
1332 [CLK_TIMER3
] = &clk_timer3
.common
.hw
,
1333 [CLK_TIMER4
] = &clk_timer4
.common
.hw
,
1334 [CLK_TIMER5
] = &clk_timer5
.common
.hw
,
1335 [CLK_TIMER6
] = &clk_timer6
.common
.hw
,
1336 [CLK_TIMER7
] = &clk_timer7
.common
.hw
,
1337 [CLK_UART0
] = &clk_uart0
.common
.hw
,
1338 [CLK_APB_UART0
] = &clk_apb_uart0
.common
.hw
,
1339 [CLK_UART1
] = &clk_uart1
.common
.hw
,
1340 [CLK_APB_UART1
] = &clk_apb_uart1
.common
.hw
,
1341 [CLK_UART2
] = &clk_uart2
.common
.hw
,
1342 [CLK_APB_UART2
] = &clk_apb_uart2
.common
.hw
,
1343 [CLK_UART3
] = &clk_uart3
.common
.hw
,
1344 [CLK_APB_UART3
] = &clk_apb_uart3
.common
.hw
,
1345 [CLK_UART4
] = &clk_uart4
.common
.hw
,
1346 [CLK_APB_UART4
] = &clk_apb_uart4
.common
.hw
,
1347 [CLK_APB_I2S0
] = &clk_apb_i2s0
.common
.hw
,
1348 [CLK_APB_I2S1
] = &clk_apb_i2s1
.common
.hw
,
1349 [CLK_APB_I2S2
] = &clk_apb_i2s2
.common
.hw
,
1350 [CLK_APB_I2S3
] = &clk_apb_i2s3
.common
.hw
,
1351 [CLK_AXI4_USB
] = &clk_axi4_usb
.common
.hw
,
1352 [CLK_APB_USB
] = &clk_apb_usb
.common
.hw
,
1353 [CLK_USB_125M
] = &clk_usb_125m
.div
.common
.hw
,
1354 [CLK_USB_33K
] = &clk_usb_33k
.common
.hw
,
1355 [CLK_USB_12M
] = &clk_usb_12m
.div
.common
.hw
,
1356 [CLK_AXI4
] = &clk_axi4
.mux
.common
.hw
,
1357 [CLK_AXI6
] = &clk_axi6
.div
.common
.hw
,
1358 [CLK_DSI_ESC
] = &clk_dsi_esc
.div
.common
.hw
,
1359 [CLK_AXI_VIP
] = &clk_axi_vip
.mux
.common
.hw
,
1360 [CLK_SRC_VIP_SYS_0
] = &clk_src_vip_sys_0
.mux
.common
.hw
,
1361 [CLK_SRC_VIP_SYS_1
] = &clk_src_vip_sys_1
.mux
.common
.hw
,
1362 [CLK_SRC_VIP_SYS_2
] = &clk_src_vip_sys_2
.mux
.common
.hw
,
1363 [CLK_SRC_VIP_SYS_3
] = &clk_src_vip_sys_3
.mux
.common
.hw
,
1364 [CLK_SRC_VIP_SYS_4
] = &clk_src_vip_sys_4
.mux
.common
.hw
,
1365 [CLK_CSI_BE_VIP
] = &clk_csi_be_vip
.common
.hw
,
1366 [CLK_CSI_MAC0_VIP
] = &clk_csi_mac0_vip
.common
.hw
,
1367 [CLK_CSI_MAC1_VIP
] = &clk_csi_mac1_vip
.common
.hw
,
1368 [CLK_CSI_MAC2_VIP
] = &clk_csi_mac2_vip
.common
.hw
,
1369 [CLK_CSI0_RX_VIP
] = &clk_csi0_rx_vip
.common
.hw
,
1370 [CLK_CSI1_RX_VIP
] = &clk_csi1_rx_vip
.common
.hw
,
1371 [CLK_ISP_TOP_VIP
] = &clk_isp_top_vip
.common
.hw
,
1372 [CLK_IMG_D_VIP
] = &clk_img_d_vip
.common
.hw
,
1373 [CLK_IMG_V_VIP
] = &clk_img_v_vip
.common
.hw
,
1374 [CLK_SC_TOP_VIP
] = &clk_sc_top_vip
.common
.hw
,
1375 [CLK_SC_D_VIP
] = &clk_sc_d_vip
.common
.hw
,
1376 [CLK_SC_V1_VIP
] = &clk_sc_v1_vip
.common
.hw
,
1377 [CLK_SC_V2_VIP
] = &clk_sc_v2_vip
.common
.hw
,
1378 [CLK_SC_V3_VIP
] = &clk_sc_v3_vip
.common
.hw
,
1379 [CLK_DWA_VIP
] = &clk_dwa_vip
.common
.hw
,
1380 [CLK_BT_VIP
] = &clk_bt_vip
.common
.hw
,
1381 [CLK_DISP_VIP
] = &clk_disp_vip
.common
.hw
,
1382 [CLK_DSI_MAC_VIP
] = &clk_dsi_mac_vip
.common
.hw
,
1383 [CLK_LVDS0_VIP
] = &clk_lvds0_vip
.common
.hw
,
1384 [CLK_LVDS1_VIP
] = &clk_lvds1_vip
.common
.hw
,
1385 [CLK_PAD_VI_VIP
] = &clk_pad_vi_vip
.common
.hw
,
1386 [CLK_PAD_VI1_VIP
] = &clk_pad_vi1_vip
.common
.hw
,
1387 [CLK_PAD_VI2_VIP
] = &clk_pad_vi2_vip
.common
.hw
,
1388 [CLK_CFG_REG_VIP
] = &clk_cfg_reg_vip
.common
.hw
,
1389 [CLK_VIP_IP0
] = &clk_vip_ip0
.common
.hw
,
1390 [CLK_VIP_IP1
] = &clk_vip_ip1
.common
.hw
,
1391 [CLK_VIP_IP2
] = &clk_vip_ip2
.common
.hw
,
1392 [CLK_VIP_IP3
] = &clk_vip_ip3
.common
.hw
,
1393 [CLK_IVE_VIP
] = &clk_ive_vip
.common
.hw
,
1394 [CLK_RAW_VIP
] = &clk_raw_vip
.common
.hw
,
1395 [CLK_OSDC_VIP
] = &clk_osdc_vip
.common
.hw
,
1396 [CLK_CAM0_VIP
] = &clk_cam0_vip
.common
.hw
,
1397 [CLK_AXI_VIDEO_CODEC
] = &clk_axi_video_codec
.mux
.common
.hw
,
1398 [CLK_VC_SRC0
] = &clk_vc_src0
.mux
.common
.hw
,
1399 [CLK_VC_SRC1
] = &clk_vc_src1
.div
.common
.hw
,
1400 [CLK_VC_SRC2
] = &clk_vc_src2
.div
.common
.hw
,
1401 [CLK_H264C
] = &clk_h264c
.common
.hw
,
1402 [CLK_APB_H264C
] = &clk_apb_h264c
.common
.hw
,
1403 [CLK_H265C
] = &clk_h265c
.common
.hw
,
1404 [CLK_APB_H265C
] = &clk_apb_h265c
.common
.hw
,
1405 [CLK_JPEG
] = &clk_jpeg
.common
.hw
,
1406 [CLK_APB_JPEG
] = &clk_apb_jpeg
.common
.hw
,
1407 [CLK_CAM0
] = &clk_cam0
.common
.hw
,
1408 [CLK_CAM1
] = &clk_cam1
.common
.hw
,
1409 [CLK_WGN
] = &clk_wgn
.common
.hw
,
1410 [CLK_WGN0
] = &clk_wgn0
.common
.hw
,
1411 [CLK_WGN1
] = &clk_wgn1
.common
.hw
,
1412 [CLK_WGN2
] = &clk_wgn2
.common
.hw
,
1413 [CLK_KEYSCAN
] = &clk_keyscan
.common
.hw
,
1414 [CLK_CFG_REG_VC
] = &clk_cfg_reg_vc
.common
.hw
,
1415 [CLK_C906_0
] = &clk_c906_0
.common
.hw
,
1416 [CLK_C906_1
] = &clk_c906_1
.common
.hw
,
1417 [CLK_A53
] = &clk_a53
.common
.hw
,
1418 [CLK_CPU_AXI0
] = &clk_cpu_axi0
.div
.common
.hw
,
1419 [CLK_CPU_GIC
] = &clk_cpu_gic
.div
.common
.hw
,
1420 [CLK_XTAL_AP
] = &clk_xtal_ap
.common
.hw
,
1421 [CLK_DISP_SRC_VIP
] = &clk_disp_src_vip
.div
.common
.hw
,
1425 static int cv1810_pre_init(struct device
*dev
, void __iomem
*base
,
1426 struct cv1800_clk_ctrl
*ctrl
,
1427 const struct cv1800_clk_desc
*desc
)
1429 cv18xx_clk_disable_a53(base
);
1430 cv18xx_clk_disable_auto_pd(base
);
1435 static const struct cv1800_clk_desc cv1810_desc
= {
1436 .clks_data
= &cv1810_hw_clks
,
1437 .pre_init
= cv1810_pre_init
,
1440 static int sg2000_pre_init(struct device
*dev
, void __iomem
*base
,
1441 struct cv1800_clk_ctrl
*ctrl
,
1442 const struct cv1800_clk_desc
*desc
)
1444 cv18xx_clk_disable_auto_pd(base
);
1449 static const struct cv1800_clk_desc sg2000_desc
= {
1450 .clks_data
= &cv1810_hw_clks
,
1451 .pre_init
= sg2000_pre_init
,
1454 static int cv1800_clk_init_ctrl(struct device
*dev
, void __iomem
*reg
,
1455 struct cv1800_clk_ctrl
*ctrl
,
1456 const struct cv1800_clk_desc
*desc
)
1461 spin_lock_init(&ctrl
->lock
);
1463 for (i
= 0; i
< desc
->clks_data
->num
; i
++) {
1464 struct clk_hw
*hw
= desc
->clks_data
->hws
[i
];
1465 struct cv1800_clk_common
*common
;
1471 name
= hw
->init
->name
;
1473 common
= hw_to_cv1800_clk_common(hw
);
1475 common
->lock
= &ctrl
->lock
;
1477 ret
= devm_clk_hw_register(dev
, hw
);
1479 dev_err(dev
, "Couldn't register clock %d - %s\n",
1485 return devm_of_clk_add_hw_provider(dev
, of_clk_hw_onecell_get
,
1489 static int cv1800_clk_probe(struct platform_device
*pdev
)
1491 struct device
*dev
= &pdev
->dev
;
1494 const struct cv1800_clk_desc
*desc
;
1495 struct cv1800_clk_ctrl
*ctrl
;
1497 reg
= devm_platform_ioremap_resource(pdev
, 0);
1499 return PTR_ERR(reg
);
1501 desc
= device_get_match_data(dev
);
1503 dev_err(dev
, "no match data for platform\n");
1507 ctrl
= devm_kzalloc(dev
, sizeof(*ctrl
), GFP_KERNEL
);
1511 if (desc
->pre_init
) {
1512 ret
= desc
->pre_init(dev
, reg
, ctrl
, desc
);
1517 return cv1800_clk_init_ctrl(dev
, reg
, ctrl
, desc
);
1520 static const struct of_device_id cv1800_clk_ids
[] = {
1521 { .compatible
= "sophgo,cv1800-clk", .data
= &cv1800_desc
},
1522 { .compatible
= "sophgo,cv1810-clk", .data
= &cv1810_desc
},
1523 { .compatible
= "sophgo,sg2000-clk", .data
= &sg2000_desc
},
1526 MODULE_DEVICE_TABLE(of
, cv1800_clk_ids
);
1528 static struct platform_driver cv1800_clk_driver
= {
1529 .probe
= cv1800_clk_probe
,
1531 .name
= "cv1800-clk",
1532 .suppress_bind_attrs
= true,
1533 .of_match_table
= cv1800_clk_ids
,
1536 module_platform_driver(cv1800_clk_driver
);
1537 MODULE_DESCRIPTION("Sophgo CV1800 series SoCs clock controller");
1538 MODULE_LICENSE("GPL");