1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
6 #include <linux/clk-provider.h>
7 #include <linux/of_address.h>
8 #include <linux/platform_device.h>
10 #include "ccu_common.h"
11 #include "ccu_reset.h"
22 #include "ccu-sun50i-h6.h"
25 * The CPU PLL is actually NP clock, with P being /1, /2 or /4. However
26 * P should only be used for output frequencies lower than 288 MHz.
28 * For now we can just model it as a multiplier clock, and force P to /1.
30 * The M factor is present in the register's description, but not in the
31 * frequency formula, and it's documented as "M is only used for backdoor
32 * testing", so it's not modelled and then force to 0.
34 #define SUN50I_H6_PLL_CPUX_REG 0x000
35 static struct ccu_mult pll_cpux_clk
= {
38 .mult
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
41 .hw
.init
= CLK_HW_INIT("pll-cpux", "osc24M",
47 /* Some PLLs are input * N / div1 / P. Model them as NKMP with no K */
48 #define SUN50I_H6_PLL_DDR0_REG 0x010
49 static struct ccu_nkmp pll_ddr0_clk
= {
52 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
53 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
54 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
57 .hw
.init
= CLK_HW_INIT("pll-ddr0", "osc24M",
63 #define SUN50I_H6_PLL_PERIPH0_REG 0x020
64 static struct ccu_nkmp pll_periph0_clk
= {
67 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
68 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
69 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
73 .features
= CCU_FEATURE_FIXED_POSTDIV
,
74 .hw
.init
= CLK_HW_INIT("pll-periph0", "osc24M",
80 #define SUN50I_H6_PLL_PERIPH1_REG 0x028
81 static struct ccu_nkmp pll_periph1_clk
= {
84 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
85 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
86 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
90 .features
= CCU_FEATURE_FIXED_POSTDIV
,
91 .hw
.init
= CLK_HW_INIT("pll-periph1", "osc24M",
97 #define SUN50I_H6_PLL_GPU_REG 0x030
98 static struct ccu_nkmp pll_gpu_clk
= {
101 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
102 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
103 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
106 .hw
.init
= CLK_HW_INIT("pll-gpu", "osc24M",
108 CLK_SET_RATE_UNGATE
),
113 * For Video PLLs, the output divider is described as "used for testing"
114 * in the user manual. So it's not modelled and forced to 0.
116 #define SUN50I_H6_PLL_VIDEO0_REG 0x040
117 static struct ccu_nm pll_video0_clk
= {
120 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
121 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
125 .features
= CCU_FEATURE_FIXED_POSTDIV
,
126 .hw
.init
= CLK_HW_INIT("pll-video0", "osc24M",
128 CLK_SET_RATE_UNGATE
),
132 #define SUN50I_H6_PLL_VIDEO1_REG 0x048
133 static struct ccu_nm pll_video1_clk
= {
136 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
137 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
141 .features
= CCU_FEATURE_FIXED_POSTDIV
,
142 .hw
.init
= CLK_HW_INIT("pll-video1", "osc24M",
144 CLK_SET_RATE_UNGATE
),
148 #define SUN50I_H6_PLL_VE_REG 0x058
149 static struct ccu_nkmp pll_ve_clk
= {
152 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
153 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
154 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
157 .hw
.init
= CLK_HW_INIT("pll-ve", "osc24M",
159 CLK_SET_RATE_UNGATE
),
163 #define SUN50I_H6_PLL_DE_REG 0x060
164 static struct ccu_nkmp pll_de_clk
= {
167 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
168 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
169 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
172 .hw
.init
= CLK_HW_INIT("pll-de", "osc24M",
174 CLK_SET_RATE_UNGATE
),
178 #define SUN50I_H6_PLL_HSIC_REG 0x070
179 static struct ccu_nkmp pll_hsic_clk
= {
182 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
183 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
184 .p
= _SUNXI_CCU_DIV(0, 1), /* output divider */
187 .hw
.init
= CLK_HW_INIT("pll-hsic", "osc24M",
189 CLK_SET_RATE_UNGATE
),
194 * The Audio PLL is supposed to have 3 outputs: 2 fixed factors from
195 * the base (2x and 4x), and one variable divider (the one true pll audio).
197 * We don't have any need for the variable divider for now, so we just
198 * hardcode it to match with the clock names.
200 #define SUN50I_H6_PLL_AUDIO_REG 0x078
201 static struct ccu_nm pll_audio_base_clk
= {
204 .n
= _SUNXI_CCU_MULT_MIN(8, 8, 12),
205 .m
= _SUNXI_CCU_DIV(1, 1), /* input divider */
208 .hw
.init
= CLK_HW_INIT("pll-audio-base", "osc24M",
210 CLK_SET_RATE_UNGATE
),
214 static const char * const cpux_parents
[] = { "osc24M", "osc32k",
215 "iosc", "pll-cpux" };
216 static SUNXI_CCU_MUX(cpux_clk
, "cpux", cpux_parents
,
217 0x500, 24, 2, CLK_SET_RATE_PARENT
| CLK_IS_CRITICAL
);
218 static SUNXI_CCU_M(axi_clk
, "axi", "cpux", 0x500, 0, 2, 0);
219 static SUNXI_CCU_M(cpux_apb_clk
, "cpux-apb", "cpux", 0x500, 8, 2, 0);
221 static const char * const psi_ahb1_ahb2_parents
[] = { "osc24M", "osc32k",
222 "iosc", "pll-periph0" };
223 static SUNXI_CCU_MP_WITH_MUX(psi_ahb1_ahb2_clk
, "psi-ahb1-ahb2",
224 psi_ahb1_ahb2_parents
,
231 static const char * const ahb3_apb1_apb2_parents
[] = { "osc24M", "osc32k",
234 static SUNXI_CCU_MP_WITH_MUX(ahb3_clk
, "ahb3", ahb3_apb1_apb2_parents
, 0x51c,
240 static SUNXI_CCU_MP_WITH_MUX(apb1_clk
, "apb1", ahb3_apb1_apb2_parents
, 0x520,
246 static SUNXI_CCU_MP_WITH_MUX(apb2_clk
, "apb2", ahb3_apb1_apb2_parents
, 0x524,
252 static const char * const mbus_parents
[] = { "osc24M", "pll-periph0-2x",
253 "pll-ddr0", "pll-periph0-4x" };
254 static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk
, "mbus", mbus_parents
, 0x540,
260 static const char * const de_parents
[] = { "pll-de", "pll-periph0-2x" };
261 static SUNXI_CCU_M_WITH_MUX_GATE(de_clk
, "de", de_parents
, 0x600,
267 static SUNXI_CCU_GATE(bus_de_clk
, "bus-de", "psi-ahb1-ahb2",
270 static const char * const deinterlace_parents
[] = { "pll-periph0",
272 static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk
, "deinterlace",
280 static SUNXI_CCU_GATE(bus_deinterlace_clk
, "bus-deinterlace", "psi-ahb1-ahb2",
283 static const char * const gpu_parents
[] = { "pll-gpu" };
284 static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk
, "gpu", gpu_parents
, 0x670,
290 static SUNXI_CCU_GATE(bus_gpu_clk
, "bus-gpu", "psi-ahb1-ahb2",
293 /* Also applies to EMCE */
294 static const char * const ce_parents
[] = { "osc24M", "pll-periph0-2x" };
295 static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk
, "ce", ce_parents
, 0x680,
302 static SUNXI_CCU_GATE(bus_ce_clk
, "bus-ce", "psi-ahb1-ahb2",
305 static const char * const ve_parents
[] = { "pll-ve" };
306 static SUNXI_CCU_M_WITH_MUX_GATE(ve_clk
, "ve", ve_parents
, 0x690,
312 static SUNXI_CCU_GATE(bus_ve_clk
, "bus-ve", "psi-ahb1-ahb2",
315 static SUNXI_CCU_MP_WITH_MUX_GATE(emce_clk
, "emce", ce_parents
, 0x6b0,
322 static SUNXI_CCU_GATE(bus_emce_clk
, "bus-emce", "psi-ahb1-ahb2",
325 static const char * const vp9_parents
[] = { "pll-ve", "pll-periph0-2x" };
326 static SUNXI_CCU_M_WITH_MUX_GATE(vp9_clk
, "vp9", vp9_parents
, 0x6c0,
332 static SUNXI_CCU_GATE(bus_vp9_clk
, "bus-vp9", "psi-ahb1-ahb2",
335 static SUNXI_CCU_GATE(bus_dma_clk
, "bus-dma", "psi-ahb1-ahb2",
338 static SUNXI_CCU_GATE(bus_msgbox_clk
, "bus-msgbox", "psi-ahb1-ahb2",
341 static SUNXI_CCU_GATE(bus_spinlock_clk
, "bus-spinlock", "psi-ahb1-ahb2",
344 static SUNXI_CCU_GATE(bus_hstimer_clk
, "bus-hstimer", "psi-ahb1-ahb2",
347 static SUNXI_CCU_GATE(avs_clk
, "avs", "osc24M", 0x740, BIT(31), 0);
349 static SUNXI_CCU_GATE(bus_dbg_clk
, "bus-dbg", "psi-ahb1-ahb2",
352 static SUNXI_CCU_GATE(bus_psi_clk
, "bus-psi", "psi-ahb1-ahb2",
355 static SUNXI_CCU_GATE(bus_pwm_clk
, "bus-pwm", "apb1", 0x79c, BIT(0), 0);
357 static SUNXI_CCU_GATE(bus_iommu_clk
, "bus-iommu", "apb1", 0x7bc, BIT(0), 0);
359 static const char * const dram_parents
[] = { "pll-ddr0" };
360 static struct ccu_div dram_clk
= {
361 .div
= _SUNXI_CCU_DIV(0, 2),
362 .mux
= _SUNXI_CCU_MUX(24, 2),
365 .hw
.init
= CLK_HW_INIT_PARENTS("dram",
372 static SUNXI_CCU_GATE(mbus_dma_clk
, "mbus-dma", "mbus",
374 static SUNXI_CCU_GATE(mbus_ve_clk
, "mbus-ve", "mbus",
376 static SUNXI_CCU_GATE(mbus_ce_clk
, "mbus-ce", "mbus",
378 static SUNXI_CCU_GATE(mbus_ts_clk
, "mbus-ts", "mbus",
380 static SUNXI_CCU_GATE(mbus_nand_clk
, "mbus-nand", "mbus",
382 static SUNXI_CCU_GATE(mbus_csi_clk
, "mbus-csi", "mbus",
384 static SUNXI_CCU_GATE(mbus_deinterlace_clk
, "mbus-deinterlace", "mbus",
387 static SUNXI_CCU_GATE(bus_dram_clk
, "bus-dram", "psi-ahb1-ahb2",
388 0x80c, BIT(0), CLK_IS_CRITICAL
);
390 static const char * const nand_spi_parents
[] = { "osc24M", "pll-periph0",
391 "pll-periph1", "pll-periph0-2x",
393 static SUNXI_CCU_MP_WITH_MUX_GATE(nand0_clk
, "nand0", nand_spi_parents
, 0x810,
400 static SUNXI_CCU_MP_WITH_MUX_GATE(nand1_clk
, "nand1", nand_spi_parents
, 0x814,
407 static SUNXI_CCU_GATE(bus_nand_clk
, "bus-nand", "ahb3", 0x82c, BIT(0), 0);
409 static const char * const mmc_parents
[] = { "osc24M", "pll-periph0-2x",
411 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk
, "mmc0", mmc_parents
, 0x830,
418 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk
, "mmc1", mmc_parents
, 0x834,
425 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk
, "mmc2", mmc_parents
, 0x838,
432 static SUNXI_CCU_GATE(bus_mmc0_clk
, "bus-mmc0", "ahb3", 0x84c, BIT(0), 0);
433 static SUNXI_CCU_GATE(bus_mmc1_clk
, "bus-mmc1", "ahb3", 0x84c, BIT(1), 0);
434 static SUNXI_CCU_GATE(bus_mmc2_clk
, "bus-mmc2", "ahb3", 0x84c, BIT(2), 0);
436 static SUNXI_CCU_GATE(bus_uart0_clk
, "bus-uart0", "apb2", 0x90c, BIT(0), 0);
437 static SUNXI_CCU_GATE(bus_uart1_clk
, "bus-uart1", "apb2", 0x90c, BIT(1), 0);
438 static SUNXI_CCU_GATE(bus_uart2_clk
, "bus-uart2", "apb2", 0x90c, BIT(2), 0);
439 static SUNXI_CCU_GATE(bus_uart3_clk
, "bus-uart3", "apb2", 0x90c, BIT(3), 0);
441 static SUNXI_CCU_GATE(bus_i2c0_clk
, "bus-i2c0", "apb2", 0x91c, BIT(0), 0);
442 static SUNXI_CCU_GATE(bus_i2c1_clk
, "bus-i2c1", "apb2", 0x91c, BIT(1), 0);
443 static SUNXI_CCU_GATE(bus_i2c2_clk
, "bus-i2c2", "apb2", 0x91c, BIT(2), 0);
444 static SUNXI_CCU_GATE(bus_i2c3_clk
, "bus-i2c3", "apb2", 0x91c, BIT(3), 0);
446 static SUNXI_CCU_GATE(bus_scr0_clk
, "bus-scr0", "apb2", 0x93c, BIT(0), 0);
447 static SUNXI_CCU_GATE(bus_scr1_clk
, "bus-scr1", "apb2", 0x93c, BIT(1), 0);
449 static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk
, "spi0", nand_spi_parents
, 0x940,
456 static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk
, "spi1", nand_spi_parents
, 0x944,
463 static SUNXI_CCU_GATE(bus_spi0_clk
, "bus-spi0", "ahb3", 0x96c, BIT(0), 0);
464 static SUNXI_CCU_GATE(bus_spi1_clk
, "bus-spi1", "ahb3", 0x96c, BIT(1), 0);
466 static SUNXI_CCU_GATE(bus_emac_clk
, "bus-emac", "ahb3", 0x97c, BIT(0), 0);
468 static const char * const ts_parents
[] = { "osc24M", "pll-periph0" };
469 static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk
, "ts", ts_parents
, 0x9b0,
476 static SUNXI_CCU_GATE(bus_ts_clk
, "bus-ts", "ahb3", 0x9bc, BIT(0), 0);
478 static const char * const ir_tx_parents
[] = { "osc32k", "osc24M" };
479 static SUNXI_CCU_MP_WITH_MUX_GATE(ir_tx_clk
, "ir-tx", ir_tx_parents
, 0x9c0,
486 static SUNXI_CCU_GATE(bus_ir_tx_clk
, "bus-ir-tx", "apb1", 0x9cc, BIT(0), 0);
488 static SUNXI_CCU_GATE(bus_ths_clk
, "bus-ths", "apb1", 0x9fc, BIT(0), 0);
490 static const char * const audio_parents
[] = { "pll-audio", "pll-audio-2x", "pll-audio-4x" };
491 static struct ccu_div i2s3_clk
= {
493 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
494 .mux
= _SUNXI_CCU_MUX(24, 2),
497 .hw
.init
= CLK_HW_INIT_PARENTS("i2s3",
504 static struct ccu_div i2s0_clk
= {
506 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
507 .mux
= _SUNXI_CCU_MUX(24, 2),
510 .hw
.init
= CLK_HW_INIT_PARENTS("i2s0",
517 static struct ccu_div i2s1_clk
= {
519 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
520 .mux
= _SUNXI_CCU_MUX(24, 2),
523 .hw
.init
= CLK_HW_INIT_PARENTS("i2s1",
530 static struct ccu_div i2s2_clk
= {
532 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
533 .mux
= _SUNXI_CCU_MUX(24, 2),
536 .hw
.init
= CLK_HW_INIT_PARENTS("i2s2",
543 static SUNXI_CCU_GATE(bus_i2s0_clk
, "bus-i2s0", "apb1", 0xa1c, BIT(0), 0);
544 static SUNXI_CCU_GATE(bus_i2s1_clk
, "bus-i2s1", "apb1", 0xa1c, BIT(1), 0);
545 static SUNXI_CCU_GATE(bus_i2s2_clk
, "bus-i2s2", "apb1", 0xa1c, BIT(2), 0);
546 static SUNXI_CCU_GATE(bus_i2s3_clk
, "bus-i2s3", "apb1", 0xa1c, BIT(3), 0);
548 static struct ccu_div spdif_clk
= {
550 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
551 .mux
= _SUNXI_CCU_MUX(24, 2),
554 .hw
.init
= CLK_HW_INIT_PARENTS("spdif",
561 static SUNXI_CCU_GATE(bus_spdif_clk
, "bus-spdif", "apb1", 0xa2c, BIT(0), 0);
563 static struct ccu_div dmic_clk
= {
565 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
566 .mux
= _SUNXI_CCU_MUX(24, 2),
569 .hw
.init
= CLK_HW_INIT_PARENTS("dmic",
576 static SUNXI_CCU_GATE(bus_dmic_clk
, "bus-dmic", "apb1", 0xa4c, BIT(0), 0);
578 static struct ccu_div audio_hub_clk
= {
580 .div
= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO
),
581 .mux
= _SUNXI_CCU_MUX(24, 2),
584 .hw
.init
= CLK_HW_INIT_PARENTS("audio-hub",
591 static SUNXI_CCU_GATE(bus_audio_hub_clk
, "bus-audio-hub", "apb1", 0xa6c, BIT(0), 0);
594 * There are OHCI 12M clock source selection bits for 2 USB 2.0 ports.
595 * We will force them to 0 (12M divided from 48M).
597 #define SUN50I_H6_USB0_CLK_REG 0xa70
598 #define SUN50I_H6_USB3_CLK_REG 0xa7c
600 static SUNXI_CCU_GATE(usb_ohci0_clk
, "usb-ohci0", "osc12M", 0xa70, BIT(31), 0);
601 static SUNXI_CCU_GATE(usb_phy0_clk
, "usb-phy0", "osc24M", 0xa70, BIT(29), 0);
603 static SUNXI_CCU_GATE(usb_phy1_clk
, "usb-phy1", "osc24M", 0xa74, BIT(29), 0);
605 static SUNXI_CCU_GATE(usb_ohci3_clk
, "usb-ohci3", "osc12M", 0xa7c, BIT(31), 0);
606 static SUNXI_CCU_GATE(usb_phy3_clk
, "usb-phy3", "osc12M", 0xa7c, BIT(29), 0);
607 static SUNXI_CCU_GATE(usb_hsic_12m_clk
, "usb-hsic-12M", "osc12M", 0xa7c, BIT(27), 0);
608 static SUNXI_CCU_GATE(usb_hsic_clk
, "usb-hsic", "pll-hsic", 0xa7c, BIT(26), 0);
610 static SUNXI_CCU_GATE(bus_ohci0_clk
, "bus-ohci0", "ahb3", 0xa8c, BIT(0), 0);
611 static SUNXI_CCU_GATE(bus_ohci3_clk
, "bus-ohci3", "ahb3", 0xa8c, BIT(3), 0);
612 static SUNXI_CCU_GATE(bus_ehci0_clk
, "bus-ehci0", "ahb3", 0xa8c, BIT(4), 0);
613 static SUNXI_CCU_GATE(bus_xhci_clk
, "bus-xhci", "ahb3", 0xa8c, BIT(5), 0);
614 static SUNXI_CCU_GATE(bus_ehci3_clk
, "bus-ehci3", "ahb3", 0xa8c, BIT(7), 0);
615 static SUNXI_CCU_GATE(bus_otg_clk
, "bus-otg", "ahb3", 0xa8c, BIT(8), 0);
617 static CLK_FIXED_FACTOR(pcie_ref_100m_clk
, "pcie-ref-100M",
618 "pll-periph0-4x", 24, 1, 0);
619 static SUNXI_CCU_GATE(pcie_ref_clk
, "pcie-ref", "pcie-ref-100M",
621 static SUNXI_CCU_GATE(pcie_ref_out_clk
, "pcie-ref-out", "pcie-ref",
624 static SUNXI_CCU_M_WITH_GATE(pcie_maxi_clk
, "pcie-maxi",
625 "pll-periph0", 0xab4,
630 static SUNXI_CCU_M_WITH_GATE(pcie_aux_clk
, "pcie-aux", "osc24M", 0xab8,
635 static SUNXI_CCU_GATE(bus_pcie_clk
, "bus-pcie", "psi-ahb1-ahb2",
638 static const char * const hdmi_parents
[] = { "pll-video0", "pll-video1",
640 static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk
, "hdmi", hdmi_parents
, 0xb00,
646 static SUNXI_CCU_GATE(hdmi_slow_clk
, "hdmi-slow", "osc24M", 0xb04, BIT(31), 0);
648 static const char * const hdmi_cec_parents
[] = { "osc32k", "pll-periph0-2x" };
649 static const struct ccu_mux_fixed_prediv hdmi_cec_predivs
[] = {
650 { .index
= 1, .div
= 36621 },
652 static struct ccu_mux hdmi_cec_clk
= {
659 .fixed_predivs
= hdmi_cec_predivs
,
660 .n_predivs
= ARRAY_SIZE(hdmi_cec_predivs
),
665 .features
= CCU_FEATURE_VARIABLE_PREDIV
,
666 .hw
.init
= CLK_HW_INIT_PARENTS("hdmi-cec",
673 static SUNXI_CCU_GATE(bus_hdmi_clk
, "bus-hdmi", "ahb3", 0xb1c, BIT(0), 0);
675 static SUNXI_CCU_GATE(bus_tcon_top_clk
, "bus-tcon-top", "ahb3",
678 static const char * const tcon_lcd0_parents
[] = { "pll-video0",
681 static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk
, "tcon-lcd0",
682 tcon_lcd0_parents
, 0xb60,
687 static SUNXI_CCU_GATE(bus_tcon_lcd0_clk
, "bus-tcon-lcd0", "ahb3",
690 static const char * const tcon_tv0_parents
[] = { "pll-video0",
694 static SUNXI_CCU_MP_WITH_MUX_GATE(tcon_tv0_clk
, "tcon-tv0",
695 tcon_tv0_parents
, 0xb80,
702 static SUNXI_CCU_GATE(bus_tcon_tv0_clk
, "bus-tcon-tv0", "ahb3",
705 static SUNXI_CCU_GATE(csi_cci_clk
, "csi-cci", "osc24M", 0xc00, BIT(0), 0);
707 static const char * const csi_top_parents
[] = { "pll-video0", "pll-ve",
709 static const u8 csi_top_table
[] = { 0, 2, 3 };
710 static SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_top_clk
, "csi-top",
711 csi_top_parents
, csi_top_table
, 0xc04,
717 static const char * const csi_mclk_parents
[] = { "osc24M", "pll-video0",
718 "pll-periph0", "pll-periph1" };
719 static SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk
, "csi-mclk",
720 csi_mclk_parents
, 0xc08,
726 static SUNXI_CCU_GATE(bus_csi_clk
, "bus-csi", "ahb3", 0xc2c, BIT(0), 0);
728 static const char * const hdcp_parents
[] = { "pll-periph0", "pll-periph1" };
729 static SUNXI_CCU_M_WITH_MUX_GATE(hdcp_clk
, "hdcp", hdcp_parents
, 0xc40,
735 static SUNXI_CCU_GATE(bus_hdcp_clk
, "bus-hdcp", "ahb3", 0xc4c, BIT(0), 0);
737 /* Fixed factor clocks */
738 static CLK_FIXED_FACTOR(osc12M_clk
, "osc12M", "osc24M", 2, 1, 0);
741 * The divider of pll-audio is fixed to 8 now, as pll-audio-4x has a
742 * fixed post-divider 2.
744 static CLK_FIXED_FACTOR(pll_audio_clk
, "pll-audio",
745 "pll-audio-base", 8, 1, CLK_SET_RATE_PARENT
);
746 static CLK_FIXED_FACTOR(pll_audio_2x_clk
, "pll-audio-2x",
747 "pll-audio-base", 4, 1, CLK_SET_RATE_PARENT
);
748 static CLK_FIXED_FACTOR(pll_audio_4x_clk
, "pll-audio-4x",
749 "pll-audio-base", 2, 1, CLK_SET_RATE_PARENT
);
751 static CLK_FIXED_FACTOR(pll_periph0_4x_clk
, "pll-periph0-4x",
752 "pll-periph0", 1, 4, 0);
753 static CLK_FIXED_FACTOR(pll_periph0_2x_clk
, "pll-periph0-2x",
754 "pll-periph0", 1, 2, 0);
756 static CLK_FIXED_FACTOR(pll_periph1_4x_clk
, "pll-periph1-4x",
757 "pll-periph1", 1, 4, 0);
758 static CLK_FIXED_FACTOR(pll_periph1_2x_clk
, "pll-periph1-2x",
759 "pll-periph1", 1, 2, 0);
761 static CLK_FIXED_FACTOR(pll_video0_4x_clk
, "pll-video0-4x",
762 "pll-video0", 1, 4, CLK_SET_RATE_PARENT
);
764 static CLK_FIXED_FACTOR(pll_video1_4x_clk
, "pll-video1-4x",
765 "pll-video1", 1, 4, CLK_SET_RATE_PARENT
);
767 static struct ccu_common
*sun50i_h6_ccu_clks
[] = {
768 &pll_cpux_clk
.common
,
769 &pll_ddr0_clk
.common
,
770 &pll_periph0_clk
.common
,
771 &pll_periph1_clk
.common
,
773 &pll_video0_clk
.common
,
774 &pll_video1_clk
.common
,
777 &pll_hsic_clk
.common
,
778 &pll_audio_base_clk
.common
,
781 &cpux_apb_clk
.common
,
782 &psi_ahb1_ahb2_clk
.common
,
789 &deinterlace_clk
.common
,
790 &bus_deinterlace_clk
.common
,
798 &bus_emce_clk
.common
,
802 &bus_msgbox_clk
.common
,
803 &bus_spinlock_clk
.common
,
804 &bus_hstimer_clk
.common
,
809 &bus_iommu_clk
.common
,
811 &mbus_dma_clk
.common
,
815 &mbus_nand_clk
.common
,
816 &mbus_csi_clk
.common
,
817 &mbus_deinterlace_clk
.common
,
818 &bus_dram_clk
.common
,
821 &bus_nand_clk
.common
,
825 &bus_mmc0_clk
.common
,
826 &bus_mmc1_clk
.common
,
827 &bus_mmc2_clk
.common
,
828 &bus_uart0_clk
.common
,
829 &bus_uart1_clk
.common
,
830 &bus_uart2_clk
.common
,
831 &bus_uart3_clk
.common
,
832 &bus_i2c0_clk
.common
,
833 &bus_i2c1_clk
.common
,
834 &bus_i2c2_clk
.common
,
835 &bus_i2c3_clk
.common
,
836 &bus_scr0_clk
.common
,
837 &bus_scr1_clk
.common
,
840 &bus_spi0_clk
.common
,
841 &bus_spi1_clk
.common
,
842 &bus_emac_clk
.common
,
846 &bus_ir_tx_clk
.common
,
852 &bus_i2s0_clk
.common
,
853 &bus_i2s1_clk
.common
,
854 &bus_i2s2_clk
.common
,
855 &bus_i2s3_clk
.common
,
857 &bus_spdif_clk
.common
,
859 &bus_dmic_clk
.common
,
860 &audio_hub_clk
.common
,
861 &bus_audio_hub_clk
.common
,
862 &usb_ohci0_clk
.common
,
863 &usb_phy0_clk
.common
,
864 &usb_phy1_clk
.common
,
865 &usb_ohci3_clk
.common
,
866 &usb_phy3_clk
.common
,
867 &usb_hsic_12m_clk
.common
,
868 &usb_hsic_clk
.common
,
869 &bus_ohci0_clk
.common
,
870 &bus_ohci3_clk
.common
,
871 &bus_ehci0_clk
.common
,
872 &bus_xhci_clk
.common
,
873 &bus_ehci3_clk
.common
,
875 &pcie_ref_clk
.common
,
876 &pcie_ref_out_clk
.common
,
877 &pcie_maxi_clk
.common
,
878 &pcie_aux_clk
.common
,
879 &bus_pcie_clk
.common
,
881 &hdmi_slow_clk
.common
,
882 &hdmi_cec_clk
.common
,
883 &bus_hdmi_clk
.common
,
884 &bus_tcon_top_clk
.common
,
885 &tcon_lcd0_clk
.common
,
886 &bus_tcon_lcd0_clk
.common
,
887 &tcon_tv0_clk
.common
,
888 &bus_tcon_tv0_clk
.common
,
891 &csi_mclk_clk
.common
,
894 &bus_hdcp_clk
.common
,
897 static struct clk_hw_onecell_data sun50i_h6_hw_clks
= {
899 [CLK_OSC12M
] = &osc12M_clk
.hw
,
900 [CLK_PLL_CPUX
] = &pll_cpux_clk
.common
.hw
,
901 [CLK_PLL_DDR0
] = &pll_ddr0_clk
.common
.hw
,
902 [CLK_PLL_PERIPH0
] = &pll_periph0_clk
.common
.hw
,
903 [CLK_PLL_PERIPH0_2X
] = &pll_periph0_2x_clk
.hw
,
904 [CLK_PLL_PERIPH0_4X
] = &pll_periph0_4x_clk
.hw
,
905 [CLK_PLL_PERIPH1
] = &pll_periph1_clk
.common
.hw
,
906 [CLK_PLL_PERIPH1_2X
] = &pll_periph1_2x_clk
.hw
,
907 [CLK_PLL_PERIPH1_4X
] = &pll_periph1_4x_clk
.hw
,
908 [CLK_PLL_GPU
] = &pll_gpu_clk
.common
.hw
,
909 [CLK_PLL_VIDEO0
] = &pll_video0_clk
.common
.hw
,
910 [CLK_PLL_VIDEO0_4X
] = &pll_video0_4x_clk
.hw
,
911 [CLK_PLL_VIDEO1
] = &pll_video1_clk
.common
.hw
,
912 [CLK_PLL_VIDEO1_4X
] = &pll_video1_4x_clk
.hw
,
913 [CLK_PLL_VE
] = &pll_ve_clk
.common
.hw
,
914 [CLK_PLL_DE
] = &pll_de_clk
.common
.hw
,
915 [CLK_PLL_HSIC
] = &pll_hsic_clk
.common
.hw
,
916 [CLK_PLL_AUDIO_BASE
] = &pll_audio_base_clk
.common
.hw
,
917 [CLK_PLL_AUDIO
] = &pll_audio_clk
.hw
,
918 [CLK_PLL_AUDIO_2X
] = &pll_audio_2x_clk
.hw
,
919 [CLK_PLL_AUDIO_4X
] = &pll_audio_4x_clk
.hw
,
920 [CLK_CPUX
] = &cpux_clk
.common
.hw
,
921 [CLK_AXI
] = &axi_clk
.common
.hw
,
922 [CLK_CPUX_APB
] = &cpux_apb_clk
.common
.hw
,
923 [CLK_PSI_AHB1_AHB2
] = &psi_ahb1_ahb2_clk
.common
.hw
,
924 [CLK_AHB3
] = &ahb3_clk
.common
.hw
,
925 [CLK_APB1
] = &apb1_clk
.common
.hw
,
926 [CLK_APB2
] = &apb2_clk
.common
.hw
,
927 [CLK_MBUS
] = &mbus_clk
.common
.hw
,
928 [CLK_DE
] = &de_clk
.common
.hw
,
929 [CLK_BUS_DE
] = &bus_de_clk
.common
.hw
,
930 [CLK_DEINTERLACE
] = &deinterlace_clk
.common
.hw
,
931 [CLK_BUS_DEINTERLACE
] = &bus_deinterlace_clk
.common
.hw
,
932 [CLK_GPU
] = &gpu_clk
.common
.hw
,
933 [CLK_BUS_GPU
] = &bus_gpu_clk
.common
.hw
,
934 [CLK_CE
] = &ce_clk
.common
.hw
,
935 [CLK_BUS_CE
] = &bus_ce_clk
.common
.hw
,
936 [CLK_VE
] = &ve_clk
.common
.hw
,
937 [CLK_BUS_VE
] = &bus_ve_clk
.common
.hw
,
938 [CLK_EMCE
] = &emce_clk
.common
.hw
,
939 [CLK_BUS_EMCE
] = &bus_emce_clk
.common
.hw
,
940 [CLK_VP9
] = &vp9_clk
.common
.hw
,
941 [CLK_BUS_VP9
] = &bus_vp9_clk
.common
.hw
,
942 [CLK_BUS_DMA
] = &bus_dma_clk
.common
.hw
,
943 [CLK_BUS_MSGBOX
] = &bus_msgbox_clk
.common
.hw
,
944 [CLK_BUS_SPINLOCK
] = &bus_spinlock_clk
.common
.hw
,
945 [CLK_BUS_HSTIMER
] = &bus_hstimer_clk
.common
.hw
,
946 [CLK_AVS
] = &avs_clk
.common
.hw
,
947 [CLK_BUS_DBG
] = &bus_dbg_clk
.common
.hw
,
948 [CLK_BUS_PSI
] = &bus_psi_clk
.common
.hw
,
949 [CLK_BUS_PWM
] = &bus_pwm_clk
.common
.hw
,
950 [CLK_BUS_IOMMU
] = &bus_iommu_clk
.common
.hw
,
951 [CLK_DRAM
] = &dram_clk
.common
.hw
,
952 [CLK_MBUS_DMA
] = &mbus_dma_clk
.common
.hw
,
953 [CLK_MBUS_VE
] = &mbus_ve_clk
.common
.hw
,
954 [CLK_MBUS_CE
] = &mbus_ce_clk
.common
.hw
,
955 [CLK_MBUS_TS
] = &mbus_ts_clk
.common
.hw
,
956 [CLK_MBUS_NAND
] = &mbus_nand_clk
.common
.hw
,
957 [CLK_MBUS_CSI
] = &mbus_csi_clk
.common
.hw
,
958 [CLK_MBUS_DEINTERLACE
] = &mbus_deinterlace_clk
.common
.hw
,
959 [CLK_BUS_DRAM
] = &bus_dram_clk
.common
.hw
,
960 [CLK_NAND0
] = &nand0_clk
.common
.hw
,
961 [CLK_NAND1
] = &nand1_clk
.common
.hw
,
962 [CLK_BUS_NAND
] = &bus_nand_clk
.common
.hw
,
963 [CLK_MMC0
] = &mmc0_clk
.common
.hw
,
964 [CLK_MMC1
] = &mmc1_clk
.common
.hw
,
965 [CLK_MMC2
] = &mmc2_clk
.common
.hw
,
966 [CLK_BUS_MMC0
] = &bus_mmc0_clk
.common
.hw
,
967 [CLK_BUS_MMC1
] = &bus_mmc1_clk
.common
.hw
,
968 [CLK_BUS_MMC2
] = &bus_mmc2_clk
.common
.hw
,
969 [CLK_BUS_UART0
] = &bus_uart0_clk
.common
.hw
,
970 [CLK_BUS_UART1
] = &bus_uart1_clk
.common
.hw
,
971 [CLK_BUS_UART2
] = &bus_uart2_clk
.common
.hw
,
972 [CLK_BUS_UART3
] = &bus_uart3_clk
.common
.hw
,
973 [CLK_BUS_I2C0
] = &bus_i2c0_clk
.common
.hw
,
974 [CLK_BUS_I2C1
] = &bus_i2c1_clk
.common
.hw
,
975 [CLK_BUS_I2C2
] = &bus_i2c2_clk
.common
.hw
,
976 [CLK_BUS_I2C3
] = &bus_i2c3_clk
.common
.hw
,
977 [CLK_BUS_SCR0
] = &bus_scr0_clk
.common
.hw
,
978 [CLK_BUS_SCR1
] = &bus_scr1_clk
.common
.hw
,
979 [CLK_SPI0
] = &spi0_clk
.common
.hw
,
980 [CLK_SPI1
] = &spi1_clk
.common
.hw
,
981 [CLK_BUS_SPI0
] = &bus_spi0_clk
.common
.hw
,
982 [CLK_BUS_SPI1
] = &bus_spi1_clk
.common
.hw
,
983 [CLK_BUS_EMAC
] = &bus_emac_clk
.common
.hw
,
984 [CLK_TS
] = &ts_clk
.common
.hw
,
985 [CLK_BUS_TS
] = &bus_ts_clk
.common
.hw
,
986 [CLK_IR_TX
] = &ir_tx_clk
.common
.hw
,
987 [CLK_BUS_IR_TX
] = &bus_ir_tx_clk
.common
.hw
,
988 [CLK_BUS_THS
] = &bus_ths_clk
.common
.hw
,
989 [CLK_I2S3
] = &i2s3_clk
.common
.hw
,
990 [CLK_I2S0
] = &i2s0_clk
.common
.hw
,
991 [CLK_I2S1
] = &i2s1_clk
.common
.hw
,
992 [CLK_I2S2
] = &i2s2_clk
.common
.hw
,
993 [CLK_BUS_I2S0
] = &bus_i2s0_clk
.common
.hw
,
994 [CLK_BUS_I2S1
] = &bus_i2s1_clk
.common
.hw
,
995 [CLK_BUS_I2S2
] = &bus_i2s2_clk
.common
.hw
,
996 [CLK_BUS_I2S3
] = &bus_i2s3_clk
.common
.hw
,
997 [CLK_SPDIF
] = &spdif_clk
.common
.hw
,
998 [CLK_BUS_SPDIF
] = &bus_spdif_clk
.common
.hw
,
999 [CLK_DMIC
] = &dmic_clk
.common
.hw
,
1000 [CLK_BUS_DMIC
] = &bus_dmic_clk
.common
.hw
,
1001 [CLK_AUDIO_HUB
] = &audio_hub_clk
.common
.hw
,
1002 [CLK_BUS_AUDIO_HUB
] = &bus_audio_hub_clk
.common
.hw
,
1003 [CLK_USB_OHCI0
] = &usb_ohci0_clk
.common
.hw
,
1004 [CLK_USB_PHY0
] = &usb_phy0_clk
.common
.hw
,
1005 [CLK_USB_PHY1
] = &usb_phy1_clk
.common
.hw
,
1006 [CLK_USB_OHCI3
] = &usb_ohci3_clk
.common
.hw
,
1007 [CLK_USB_PHY3
] = &usb_phy3_clk
.common
.hw
,
1008 [CLK_USB_HSIC_12M
] = &usb_hsic_12m_clk
.common
.hw
,
1009 [CLK_USB_HSIC
] = &usb_hsic_clk
.common
.hw
,
1010 [CLK_BUS_OHCI0
] = &bus_ohci0_clk
.common
.hw
,
1011 [CLK_BUS_OHCI3
] = &bus_ohci3_clk
.common
.hw
,
1012 [CLK_BUS_EHCI0
] = &bus_ehci0_clk
.common
.hw
,
1013 [CLK_BUS_XHCI
] = &bus_xhci_clk
.common
.hw
,
1014 [CLK_BUS_EHCI3
] = &bus_ehci3_clk
.common
.hw
,
1015 [CLK_BUS_OTG
] = &bus_otg_clk
.common
.hw
,
1016 [CLK_PCIE_REF_100M
] = &pcie_ref_100m_clk
.hw
,
1017 [CLK_PCIE_REF
] = &pcie_ref_clk
.common
.hw
,
1018 [CLK_PCIE_REF_OUT
] = &pcie_ref_out_clk
.common
.hw
,
1019 [CLK_PCIE_MAXI
] = &pcie_maxi_clk
.common
.hw
,
1020 [CLK_PCIE_AUX
] = &pcie_aux_clk
.common
.hw
,
1021 [CLK_BUS_PCIE
] = &bus_pcie_clk
.common
.hw
,
1022 [CLK_HDMI
] = &hdmi_clk
.common
.hw
,
1023 [CLK_HDMI_SLOW
] = &hdmi_slow_clk
.common
.hw
,
1024 [CLK_HDMI_CEC
] = &hdmi_cec_clk
.common
.hw
,
1025 [CLK_BUS_HDMI
] = &bus_hdmi_clk
.common
.hw
,
1026 [CLK_BUS_TCON_TOP
] = &bus_tcon_top_clk
.common
.hw
,
1027 [CLK_TCON_LCD0
] = &tcon_lcd0_clk
.common
.hw
,
1028 [CLK_BUS_TCON_LCD0
] = &bus_tcon_lcd0_clk
.common
.hw
,
1029 [CLK_TCON_TV0
] = &tcon_tv0_clk
.common
.hw
,
1030 [CLK_BUS_TCON_TV0
] = &bus_tcon_tv0_clk
.common
.hw
,
1031 [CLK_CSI_CCI
] = &csi_cci_clk
.common
.hw
,
1032 [CLK_CSI_TOP
] = &csi_top_clk
.common
.hw
,
1033 [CLK_CSI_MCLK
] = &csi_mclk_clk
.common
.hw
,
1034 [CLK_BUS_CSI
] = &bus_csi_clk
.common
.hw
,
1035 [CLK_HDCP
] = &hdcp_clk
.common
.hw
,
1036 [CLK_BUS_HDCP
] = &bus_hdcp_clk
.common
.hw
,
1041 static struct ccu_reset_map sun50i_h6_ccu_resets
[] = {
1042 [RST_MBUS
] = { 0x540, BIT(30) },
1044 [RST_BUS_DE
] = { 0x60c, BIT(16) },
1045 [RST_BUS_DEINTERLACE
] = { 0x62c, BIT(16) },
1046 [RST_BUS_GPU
] = { 0x67c, BIT(16) },
1047 [RST_BUS_CE
] = { 0x68c, BIT(16) },
1048 [RST_BUS_VE
] = { 0x69c, BIT(16) },
1049 [RST_BUS_EMCE
] = { 0x6bc, BIT(16) },
1050 [RST_BUS_VP9
] = { 0x6cc, BIT(16) },
1051 [RST_BUS_DMA
] = { 0x70c, BIT(16) },
1052 [RST_BUS_MSGBOX
] = { 0x71c, BIT(16) },
1053 [RST_BUS_SPINLOCK
] = { 0x72c, BIT(16) },
1054 [RST_BUS_HSTIMER
] = { 0x73c, BIT(16) },
1055 [RST_BUS_DBG
] = { 0x78c, BIT(16) },
1056 [RST_BUS_PSI
] = { 0x79c, BIT(16) },
1057 [RST_BUS_PWM
] = { 0x7ac, BIT(16) },
1058 [RST_BUS_IOMMU
] = { 0x7bc, BIT(16) },
1059 [RST_BUS_DRAM
] = { 0x80c, BIT(16) },
1060 [RST_BUS_NAND
] = { 0x82c, BIT(16) },
1061 [RST_BUS_MMC0
] = { 0x84c, BIT(16) },
1062 [RST_BUS_MMC1
] = { 0x84c, BIT(17) },
1063 [RST_BUS_MMC2
] = { 0x84c, BIT(18) },
1064 [RST_BUS_UART0
] = { 0x90c, BIT(16) },
1065 [RST_BUS_UART1
] = { 0x90c, BIT(17) },
1066 [RST_BUS_UART2
] = { 0x90c, BIT(18) },
1067 [RST_BUS_UART3
] = { 0x90c, BIT(19) },
1068 [RST_BUS_I2C0
] = { 0x91c, BIT(16) },
1069 [RST_BUS_I2C1
] = { 0x91c, BIT(17) },
1070 [RST_BUS_I2C2
] = { 0x91c, BIT(18) },
1071 [RST_BUS_I2C3
] = { 0x91c, BIT(19) },
1072 [RST_BUS_SCR0
] = { 0x93c, BIT(16) },
1073 [RST_BUS_SCR1
] = { 0x93c, BIT(17) },
1074 [RST_BUS_SPI0
] = { 0x96c, BIT(16) },
1075 [RST_BUS_SPI1
] = { 0x96c, BIT(17) },
1076 [RST_BUS_EMAC
] = { 0x97c, BIT(16) },
1077 [RST_BUS_TS
] = { 0x9bc, BIT(16) },
1078 [RST_BUS_IR_TX
] = { 0x9cc, BIT(16) },
1079 [RST_BUS_THS
] = { 0x9fc, BIT(16) },
1080 [RST_BUS_I2S0
] = { 0xa1c, BIT(16) },
1081 [RST_BUS_I2S1
] = { 0xa1c, BIT(17) },
1082 [RST_BUS_I2S2
] = { 0xa1c, BIT(18) },
1083 [RST_BUS_I2S3
] = { 0xa1c, BIT(19) },
1084 [RST_BUS_SPDIF
] = { 0xa2c, BIT(16) },
1085 [RST_BUS_DMIC
] = { 0xa4c, BIT(16) },
1086 [RST_BUS_AUDIO_HUB
] = { 0xa6c, BIT(16) },
1088 [RST_USB_PHY0
] = { 0xa70, BIT(30) },
1089 [RST_USB_PHY1
] = { 0xa74, BIT(30) },
1090 [RST_USB_PHY3
] = { 0xa7c, BIT(30) },
1091 [RST_USB_HSIC
] = { 0xa7c, BIT(28) },
1093 [RST_BUS_OHCI0
] = { 0xa8c, BIT(16) },
1094 [RST_BUS_OHCI3
] = { 0xa8c, BIT(19) },
1095 [RST_BUS_EHCI0
] = { 0xa8c, BIT(20) },
1096 [RST_BUS_XHCI
] = { 0xa8c, BIT(21) },
1097 [RST_BUS_EHCI3
] = { 0xa8c, BIT(23) },
1098 [RST_BUS_OTG
] = { 0xa8c, BIT(24) },
1099 [RST_BUS_PCIE
] = { 0xabc, BIT(16) },
1101 [RST_PCIE_POWERUP
] = { 0xabc, BIT(17) },
1103 [RST_BUS_HDMI
] = { 0xb1c, BIT(16) },
1104 [RST_BUS_HDMI_SUB
] = { 0xb1c, BIT(17) },
1105 [RST_BUS_TCON_TOP
] = { 0xb5c, BIT(16) },
1106 [RST_BUS_TCON_LCD0
] = { 0xb7c, BIT(16) },
1107 [RST_BUS_TCON_TV0
] = { 0xb9c, BIT(16) },
1108 [RST_BUS_CSI
] = { 0xc2c, BIT(16) },
1109 [RST_BUS_HDCP
] = { 0xc4c, BIT(16) },
1112 static const struct sunxi_ccu_desc sun50i_h6_ccu_desc
= {
1113 .ccu_clks
= sun50i_h6_ccu_clks
,
1114 .num_ccu_clks
= ARRAY_SIZE(sun50i_h6_ccu_clks
),
1116 .hw_clks
= &sun50i_h6_hw_clks
,
1118 .resets
= sun50i_h6_ccu_resets
,
1119 .num_resets
= ARRAY_SIZE(sun50i_h6_ccu_resets
),
1122 static const u32 pll_regs
[] = {
1123 SUN50I_H6_PLL_CPUX_REG
,
1124 SUN50I_H6_PLL_DDR0_REG
,
1125 SUN50I_H6_PLL_PERIPH0_REG
,
1126 SUN50I_H6_PLL_PERIPH1_REG
,
1127 SUN50I_H6_PLL_GPU_REG
,
1128 SUN50I_H6_PLL_VIDEO0_REG
,
1129 SUN50I_H6_PLL_VIDEO1_REG
,
1130 SUN50I_H6_PLL_VE_REG
,
1131 SUN50I_H6_PLL_DE_REG
,
1132 SUN50I_H6_PLL_HSIC_REG
,
1133 SUN50I_H6_PLL_AUDIO_REG
,
1136 static const u32 pll_video_regs
[] = {
1137 SUN50I_H6_PLL_VIDEO0_REG
,
1138 SUN50I_H6_PLL_VIDEO1_REG
,
1141 static const u32 usb2_clk_regs
[] = {
1142 SUN50I_H6_USB0_CLK_REG
,
1143 SUN50I_H6_USB3_CLK_REG
,
1146 static int sun50i_h6_ccu_probe(struct platform_device
*pdev
)
1148 struct resource
*res
;
1153 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1154 reg
= devm_ioremap_resource(&pdev
->dev
, res
);
1156 return PTR_ERR(reg
);
1158 /* Enable the lock bits on all PLLs */
1159 for (i
= 0; i
< ARRAY_SIZE(pll_regs
); i
++) {
1160 val
= readl(reg
+ pll_regs
[i
]);
1162 writel(val
, reg
+ pll_regs
[i
]);
1166 * Force the output divider of video PLLs to 0.
1168 * See the comment before pll-video0 definition for the reason.
1170 for (i
= 0; i
< ARRAY_SIZE(pll_video_regs
); i
++) {
1171 val
= readl(reg
+ pll_video_regs
[i
]);
1173 writel(val
, reg
+ pll_video_regs
[i
]);
1177 * Force OHCI 12M clock sources to 00 (12MHz divided from 48MHz)
1179 * This clock mux is still mysterious, and the code just enforces
1180 * it to have a valid clock parent.
1182 for (i
= 0; i
< ARRAY_SIZE(usb2_clk_regs
); i
++) {
1183 val
= readl(reg
+ usb2_clk_regs
[i
]);
1184 val
&= ~GENMASK(25, 24);
1185 writel (val
, reg
+ usb2_clk_regs
[i
]);
1189 * Force the post-divider of pll-audio to 8 and the output divider
1190 * of it to 1, to make the clock name represents the real frequency.
1192 val
= readl(reg
+ SUN50I_H6_PLL_AUDIO_REG
);
1193 val
&= ~(GENMASK(21, 16) | BIT(0));
1194 writel(val
| (7 << 16), reg
+ SUN50I_H6_PLL_AUDIO_REG
);
1196 return sunxi_ccu_probe(pdev
->dev
.of_node
, reg
, &sun50i_h6_ccu_desc
);
1199 static const struct of_device_id sun50i_h6_ccu_ids
[] = {
1200 { .compatible
= "allwinner,sun50i-h6-ccu" },
1204 static struct platform_driver sun50i_h6_ccu_driver
= {
1205 .probe
= sun50i_h6_ccu_probe
,
1207 .name
= "sun50i-h6-ccu",
1208 .of_match_table
= sun50i_h6_ccu_ids
,
1211 builtin_platform_driver(sun50i_h6_ccu_driver
);