1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2016 Icenowy Zheng <icenowy@aosc.xyz>
5 * Based on ccu-sun8i-h3.c, which is:
6 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
9 #include <linux/clk-provider.h>
11 #include <linux/module.h>
13 #include <linux/platform_device.h>
15 #include "ccu_common.h"
16 #include "ccu_reset.h"
26 #include "ccu_phase.h"
28 #include "ccu-sun8i-v3s.h"
30 static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk
, "pll-cpu",
41 * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
42 * the base (2x, 4x and 8x), and one variable divider (the one true
45 * With sigma-delta modulation for fractional-N on the audio PLL,
46 * we have to use specific dividers. This means the variable divider
47 * can no longer be used, as the audio codec requests the exact clock
48 * rates we support through this mechanism. So we now hard code the
49 * variable divider to 1. This means the clock rates will no longer
50 * match the clock names.
52 #define SUN8I_V3S_PLL_AUDIO_REG 0x008
54 static struct ccu_sdm_setting pll_audio_sdm_table
[] = {
55 { .rate
= 22579200, .pattern
= 0xc0010d84, .m
= 8, .n
= 7 },
56 { .rate
= 24576000, .pattern
= 0xc000ac02, .m
= 14, .n
= 14 },
59 static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk
, "pll-audio-base",
63 pll_audio_sdm_table
, BIT(24),
69 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk
, "pll-video",
73 BIT(24), /* frac enable */
74 BIT(25), /* frac select */
75 270000000, /* frac rate 0 */
76 297000000, /* frac rate 1 */
81 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk
, "pll-ve",
85 BIT(24), /* frac enable */
86 BIT(25), /* frac select */
87 270000000, /* frac rate 0 */
88 297000000, /* frac rate 1 */
93 static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk
, "pll-ddr0",
102 static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph0_clk
, "pll-periph0",
111 static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_isp_clk
, "pll-isp",
115 BIT(24), /* frac enable */
116 BIT(25), /* frac select */
117 270000000, /* frac rate 0 */
118 297000000, /* frac rate 1 */
123 static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk
, "pll-periph1",
132 static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk
, "pll-ddr1",
140 static const char * const cpu_parents
[] = { "osc32k", "osc24M",
141 "pll-cpu", "pll-cpu" };
142 static SUNXI_CCU_MUX(cpu_clk
, "cpu", cpu_parents
,
143 0x050, 16, 2, CLK_IS_CRITICAL
);
145 static SUNXI_CCU_M(axi_clk
, "axi", "cpu", 0x050, 0, 2, 0);
147 static const char * const ahb1_parents
[] = { "osc32k", "osc24M",
148 "axi", "pll-periph0" };
149 static const struct ccu_mux_var_prediv ahb1_predivs
[] = {
150 { .index
= 3, .shift
= 6, .width
= 2 },
152 static struct ccu_div ahb1_clk
= {
153 .div
= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO
),
159 .var_predivs
= ahb1_predivs
,
160 .n_var_predivs
= ARRAY_SIZE(ahb1_predivs
),
165 .features
= CCU_FEATURE_VARIABLE_PREDIV
,
166 .hw
.init
= CLK_HW_INIT_PARENTS("ahb1",
173 static struct clk_div_table apb1_div_table
[] = {
174 { .val
= 0, .div
= 2 },
175 { .val
= 1, .div
= 2 },
176 { .val
= 2, .div
= 4 },
177 { .val
= 3, .div
= 8 },
180 static SUNXI_CCU_DIV_TABLE(apb1_clk
, "apb1", "ahb1",
181 0x054, 8, 2, apb1_div_table
, 0);
183 static const char * const apb2_parents
[] = { "osc32k", "osc24M",
184 "pll-periph0", "pll-periph0" };
185 static SUNXI_CCU_MP_WITH_MUX(apb2_clk
, "apb2", apb2_parents
, 0x058,
191 static const char * const ahb2_parents
[] = { "ahb1", "pll-periph0" };
192 static const struct ccu_mux_fixed_prediv ahb2_fixed_predivs
[] = {
193 { .index
= 1, .div
= 2 },
195 static struct ccu_mux ahb2_clk
= {
199 .fixed_predivs
= ahb2_fixed_predivs
,
200 .n_predivs
= ARRAY_SIZE(ahb2_fixed_predivs
),
205 .features
= CCU_FEATURE_FIXED_PREDIV
,
206 .hw
.init
= CLK_HW_INIT_PARENTS("ahb2",
213 static SUNXI_CCU_GATE(bus_ce_clk
, "bus-ce", "ahb1",
215 static SUNXI_CCU_GATE(bus_dma_clk
, "bus-dma", "ahb1",
217 static SUNXI_CCU_GATE(bus_mmc0_clk
, "bus-mmc0", "ahb1",
219 static SUNXI_CCU_GATE(bus_mmc1_clk
, "bus-mmc1", "ahb1",
221 static SUNXI_CCU_GATE(bus_mmc2_clk
, "bus-mmc2", "ahb1",
223 static SUNXI_CCU_GATE(bus_dram_clk
, "bus-dram", "ahb1",
225 static SUNXI_CCU_GATE(bus_emac_clk
, "bus-emac", "ahb2",
227 static SUNXI_CCU_GATE(bus_hstimer_clk
, "bus-hstimer", "ahb1",
229 static SUNXI_CCU_GATE(bus_spi0_clk
, "bus-spi0", "ahb1",
231 static SUNXI_CCU_GATE(bus_otg_clk
, "bus-otg", "ahb1",
233 static SUNXI_CCU_GATE(bus_ehci0_clk
, "bus-ehci0", "ahb1",
235 static SUNXI_CCU_GATE(bus_ohci0_clk
, "bus-ohci0", "ahb1",
238 static SUNXI_CCU_GATE(bus_ve_clk
, "bus-ve", "ahb1",
240 static SUNXI_CCU_GATE(bus_tcon0_clk
, "bus-tcon0", "ahb1",
242 static SUNXI_CCU_GATE(bus_csi_clk
, "bus-csi", "ahb1",
244 static SUNXI_CCU_GATE(bus_de_clk
, "bus-de", "ahb1",
247 static SUNXI_CCU_GATE(bus_codec_clk
, "bus-codec", "apb1",
249 static SUNXI_CCU_GATE(bus_pio_clk
, "bus-pio", "apb1",
251 static SUNXI_CCU_GATE(bus_i2s0_clk
, "bus-i2s0", "apb1",
254 static SUNXI_CCU_GATE(bus_i2c0_clk
, "bus-i2c0", "apb2",
256 static SUNXI_CCU_GATE(bus_i2c1_clk
, "bus-i2c1", "apb2",
258 static SUNXI_CCU_GATE(bus_uart0_clk
, "bus-uart0", "apb2",
260 static SUNXI_CCU_GATE(bus_uart1_clk
, "bus-uart1", "apb2",
262 static SUNXI_CCU_GATE(bus_uart2_clk
, "bus-uart2", "apb2",
265 static SUNXI_CCU_GATE(bus_ephy_clk
, "bus-ephy", "ahb1",
267 static SUNXI_CCU_GATE(bus_dbg_clk
, "bus-dbg", "ahb1",
270 static const char * const mod0_default_parents
[] = { "osc24M", "pll-periph0",
272 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk
, "mmc0", mod0_default_parents
, 0x088,
279 static SUNXI_CCU_PHASE(mmc0_sample_clk
, "mmc0_sample", "mmc0",
281 static SUNXI_CCU_PHASE(mmc0_output_clk
, "mmc0_output", "mmc0",
284 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk
, "mmc1", mod0_default_parents
, 0x08c,
291 static SUNXI_CCU_PHASE(mmc1_sample_clk
, "mmc1_sample", "mmc1",
293 static SUNXI_CCU_PHASE(mmc1_output_clk
, "mmc1_output", "mmc1",
296 static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk
, "mmc2", mod0_default_parents
, 0x090,
303 static SUNXI_CCU_PHASE(mmc2_sample_clk
, "mmc2_sample", "mmc2",
305 static SUNXI_CCU_PHASE(mmc2_output_clk
, "mmc2_output", "mmc2",
308 static const char * const ce_parents
[] = { "osc24M", "pll-periph0", };
310 static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk
, "ce", ce_parents
, 0x09c,
317 static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk
, "spi0", mod0_default_parents
, 0x0a0,
324 static const char * const i2s_parents
[] = { "pll-audio-8x", "pll-audio-4x",
325 "pll-audio-2x", "pll-audio" };
326 static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk
, "i2s0", i2s_parents
,
327 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT
);
329 static SUNXI_CCU_GATE(usb_phy0_clk
, "usb-phy0", "osc24M",
331 static SUNXI_CCU_GATE(usb_ohci0_clk
, "usb-ohci0", "osc24M",
334 static const char * const dram_parents
[] = { "pll-ddr0", "pll-ddr1",
336 static SUNXI_CCU_M_WITH_MUX(dram_clk
, "dram", dram_parents
,
337 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL
);
339 static SUNXI_CCU_GATE(dram_ve_clk
, "dram-ve", "dram",
341 static SUNXI_CCU_GATE(dram_csi_clk
, "dram-csi", "dram",
343 static SUNXI_CCU_GATE(dram_ehci_clk
, "dram-ehci", "dram",
345 static SUNXI_CCU_GATE(dram_ohci_clk
, "dram-ohci", "dram",
348 static const char * const de_parents
[] = { "pll-video", "pll-periph0" };
349 static SUNXI_CCU_M_WITH_MUX_GATE(de_clk
, "de", de_parents
,
350 0x104, 0, 4, 24, 2, BIT(31),
351 CLK_SET_RATE_PARENT
);
353 static const char * const tcon_parents
[] = { "pll-video" };
354 static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk
, "tcon", tcon_parents
,
355 0x118, 0, 4, 24, 3, BIT(31), 0);
357 static SUNXI_CCU_GATE(csi_misc_clk
, "csi-misc", "osc24M",
360 static const char * const csi_mclk_parents
[] = { "osc24M", "pll-video",
361 "pll-periph0", "pll-periph1" };
362 static SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk
, "csi0-mclk", csi_mclk_parents
,
363 0x130, 0, 5, 8, 3, BIT(15), 0);
365 static const char * const csi1_sclk_parents
[] = { "pll-video", "pll-isp" };
366 static SUNXI_CCU_M_WITH_MUX_GATE(csi1_sclk_clk
, "csi-sclk", csi1_sclk_parents
,
367 0x134, 16, 4, 24, 3, BIT(31), 0);
369 static SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk
, "csi-mclk", csi_mclk_parents
,
370 0x134, 0, 5, 8, 3, BIT(15), 0);
372 static SUNXI_CCU_M_WITH_GATE(ve_clk
, "ve", "pll-ve",
373 0x13c, 16, 3, BIT(31), 0);
375 static SUNXI_CCU_GATE(ac_dig_clk
, "ac-dig", "pll-audio",
376 0x140, BIT(31), CLK_SET_RATE_PARENT
);
377 static SUNXI_CCU_GATE(avs_clk
, "avs", "osc24M",
380 static const char * const mbus_parents
[] = { "osc24M", "pll-periph0-2x",
382 static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk
, "mbus", mbus_parents
,
383 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL
);
385 static const char * const mipi_csi_parents
[] = { "pll-video", "pll-periph0",
387 static SUNXI_CCU_M_WITH_MUX_GATE(mipi_csi_clk
, "mipi-csi", mipi_csi_parents
,
388 0x16c, 0, 3, 24, 2, BIT(31), 0);
390 static struct ccu_common
*sun8i_v3s_ccu_clks
[] = {
392 &pll_audio_base_clk
.common
,
393 &pll_video_clk
.common
,
395 &pll_ddr0_clk
.common
,
396 &pll_periph0_clk
.common
,
398 &pll_periph1_clk
.common
,
399 &pll_ddr1_clk
.common
,
408 &bus_mmc0_clk
.common
,
409 &bus_mmc1_clk
.common
,
410 &bus_mmc2_clk
.common
,
411 &bus_dram_clk
.common
,
412 &bus_emac_clk
.common
,
413 &bus_hstimer_clk
.common
,
414 &bus_spi0_clk
.common
,
416 &bus_ehci0_clk
.common
,
417 &bus_ohci0_clk
.common
,
419 &bus_tcon0_clk
.common
,
422 &bus_codec_clk
.common
,
424 &bus_i2s0_clk
.common
,
425 &bus_i2c0_clk
.common
,
426 &bus_i2c1_clk
.common
,
427 &bus_uart0_clk
.common
,
428 &bus_uart1_clk
.common
,
429 &bus_uart2_clk
.common
,
430 &bus_ephy_clk
.common
,
433 &mmc0_sample_clk
.common
,
434 &mmc0_output_clk
.common
,
436 &mmc1_sample_clk
.common
,
437 &mmc1_output_clk
.common
,
439 &mmc2_sample_clk
.common
,
440 &mmc2_output_clk
.common
,
444 &usb_phy0_clk
.common
,
445 &usb_ohci0_clk
.common
,
448 &dram_csi_clk
.common
,
449 &dram_ohci_clk
.common
,
450 &dram_ehci_clk
.common
,
453 &csi_misc_clk
.common
,
454 &csi0_mclk_clk
.common
,
455 &csi1_sclk_clk
.common
,
456 &csi1_mclk_clk
.common
,
461 &mipi_csi_clk
.common
,
464 static const struct clk_hw
*clk_parent_pll_audio
[] = {
465 &pll_audio_base_clk
.common
.hw
468 /* We hardcode the divider to 1 for SDM support */
469 static CLK_FIXED_FACTOR_HWS(pll_audio_clk
, "pll-audio",
470 clk_parent_pll_audio
,
471 1, 1, CLK_SET_RATE_PARENT
);
472 static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk
, "pll-audio-2x",
473 clk_parent_pll_audio
,
474 2, 1, CLK_SET_RATE_PARENT
);
475 static CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk
, "pll-audio-4x",
476 clk_parent_pll_audio
,
477 1, 1, CLK_SET_RATE_PARENT
);
478 static CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk
, "pll-audio-8x",
479 clk_parent_pll_audio
,
480 1, 2, CLK_SET_RATE_PARENT
);
481 static CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk
, "pll-periph0-2x",
482 &pll_periph0_clk
.common
.hw
,
485 static struct clk_hw_onecell_data sun8i_v3s_hw_clks
= {
487 [CLK_PLL_CPU
] = &pll_cpu_clk
.common
.hw
,
488 [CLK_PLL_AUDIO_BASE
] = &pll_audio_base_clk
.common
.hw
,
489 [CLK_PLL_AUDIO
] = &pll_audio_clk
.hw
,
490 [CLK_PLL_AUDIO_2X
] = &pll_audio_2x_clk
.hw
,
491 [CLK_PLL_AUDIO_4X
] = &pll_audio_4x_clk
.hw
,
492 [CLK_PLL_AUDIO_8X
] = &pll_audio_8x_clk
.hw
,
493 [CLK_PLL_VIDEO
] = &pll_video_clk
.common
.hw
,
494 [CLK_PLL_VE
] = &pll_ve_clk
.common
.hw
,
495 [CLK_PLL_DDR0
] = &pll_ddr0_clk
.common
.hw
,
496 [CLK_PLL_PERIPH0
] = &pll_periph0_clk
.common
.hw
,
497 [CLK_PLL_PERIPH0_2X
] = &pll_periph0_2x_clk
.hw
,
498 [CLK_PLL_ISP
] = &pll_isp_clk
.common
.hw
,
499 [CLK_PLL_PERIPH1
] = &pll_periph1_clk
.common
.hw
,
500 [CLK_PLL_DDR1
] = &pll_ddr1_clk
.common
.hw
,
501 [CLK_CPU
] = &cpu_clk
.common
.hw
,
502 [CLK_AXI
] = &axi_clk
.common
.hw
,
503 [CLK_AHB1
] = &ahb1_clk
.common
.hw
,
504 [CLK_APB1
] = &apb1_clk
.common
.hw
,
505 [CLK_APB2
] = &apb2_clk
.common
.hw
,
506 [CLK_AHB2
] = &ahb2_clk
.common
.hw
,
507 [CLK_BUS_CE
] = &bus_ce_clk
.common
.hw
,
508 [CLK_BUS_DMA
] = &bus_dma_clk
.common
.hw
,
509 [CLK_BUS_MMC0
] = &bus_mmc0_clk
.common
.hw
,
510 [CLK_BUS_MMC1
] = &bus_mmc1_clk
.common
.hw
,
511 [CLK_BUS_MMC2
] = &bus_mmc2_clk
.common
.hw
,
512 [CLK_BUS_DRAM
] = &bus_dram_clk
.common
.hw
,
513 [CLK_BUS_EMAC
] = &bus_emac_clk
.common
.hw
,
514 [CLK_BUS_HSTIMER
] = &bus_hstimer_clk
.common
.hw
,
515 [CLK_BUS_SPI0
] = &bus_spi0_clk
.common
.hw
,
516 [CLK_BUS_OTG
] = &bus_otg_clk
.common
.hw
,
517 [CLK_BUS_EHCI0
] = &bus_ehci0_clk
.common
.hw
,
518 [CLK_BUS_OHCI0
] = &bus_ohci0_clk
.common
.hw
,
519 [CLK_BUS_VE
] = &bus_ve_clk
.common
.hw
,
520 [CLK_BUS_TCON0
] = &bus_tcon0_clk
.common
.hw
,
521 [CLK_BUS_CSI
] = &bus_csi_clk
.common
.hw
,
522 [CLK_BUS_DE
] = &bus_de_clk
.common
.hw
,
523 [CLK_BUS_CODEC
] = &bus_codec_clk
.common
.hw
,
524 [CLK_BUS_PIO
] = &bus_pio_clk
.common
.hw
,
525 [CLK_BUS_I2C0
] = &bus_i2c0_clk
.common
.hw
,
526 [CLK_BUS_I2C1
] = &bus_i2c1_clk
.common
.hw
,
527 [CLK_BUS_UART0
] = &bus_uart0_clk
.common
.hw
,
528 [CLK_BUS_UART1
] = &bus_uart1_clk
.common
.hw
,
529 [CLK_BUS_UART2
] = &bus_uart2_clk
.common
.hw
,
530 [CLK_BUS_EPHY
] = &bus_ephy_clk
.common
.hw
,
531 [CLK_BUS_DBG
] = &bus_dbg_clk
.common
.hw
,
532 [CLK_MMC0
] = &mmc0_clk
.common
.hw
,
533 [CLK_MMC0_SAMPLE
] = &mmc0_sample_clk
.common
.hw
,
534 [CLK_MMC0_OUTPUT
] = &mmc0_output_clk
.common
.hw
,
535 [CLK_MMC1
] = &mmc1_clk
.common
.hw
,
536 [CLK_MMC1_SAMPLE
] = &mmc1_sample_clk
.common
.hw
,
537 [CLK_MMC1_OUTPUT
] = &mmc1_output_clk
.common
.hw
,
538 [CLK_MMC2
] = &mmc2_clk
.common
.hw
,
539 [CLK_MMC2_SAMPLE
] = &mmc2_sample_clk
.common
.hw
,
540 [CLK_MMC2_OUTPUT
] = &mmc2_output_clk
.common
.hw
,
541 [CLK_CE
] = &ce_clk
.common
.hw
,
542 [CLK_SPI0
] = &spi0_clk
.common
.hw
,
543 [CLK_USB_PHY0
] = &usb_phy0_clk
.common
.hw
,
544 [CLK_USB_OHCI0
] = &usb_ohci0_clk
.common
.hw
,
545 [CLK_DRAM
] = &dram_clk
.common
.hw
,
546 [CLK_DRAM_VE
] = &dram_ve_clk
.common
.hw
,
547 [CLK_DRAM_CSI
] = &dram_csi_clk
.common
.hw
,
548 [CLK_DRAM_EHCI
] = &dram_ehci_clk
.common
.hw
,
549 [CLK_DRAM_OHCI
] = &dram_ohci_clk
.common
.hw
,
550 [CLK_DE
] = &de_clk
.common
.hw
,
551 [CLK_TCON0
] = &tcon_clk
.common
.hw
,
552 [CLK_CSI_MISC
] = &csi_misc_clk
.common
.hw
,
553 [CLK_CSI0_MCLK
] = &csi0_mclk_clk
.common
.hw
,
554 [CLK_CSI1_SCLK
] = &csi1_sclk_clk
.common
.hw
,
555 [CLK_CSI1_MCLK
] = &csi1_mclk_clk
.common
.hw
,
556 [CLK_VE
] = &ve_clk
.common
.hw
,
557 [CLK_AC_DIG
] = &ac_dig_clk
.common
.hw
,
558 [CLK_AVS
] = &avs_clk
.common
.hw
,
559 [CLK_MBUS
] = &mbus_clk
.common
.hw
,
560 [CLK_MIPI_CSI
] = &mipi_csi_clk
.common
.hw
,
562 .num
= CLK_PLL_DDR1
+ 1,
565 static struct clk_hw_onecell_data sun8i_v3_hw_clks
= {
567 [CLK_PLL_CPU
] = &pll_cpu_clk
.common
.hw
,
568 [CLK_PLL_AUDIO_BASE
] = &pll_audio_base_clk
.common
.hw
,
569 [CLK_PLL_AUDIO
] = &pll_audio_clk
.hw
,
570 [CLK_PLL_AUDIO_2X
] = &pll_audio_2x_clk
.hw
,
571 [CLK_PLL_AUDIO_4X
] = &pll_audio_4x_clk
.hw
,
572 [CLK_PLL_AUDIO_8X
] = &pll_audio_8x_clk
.hw
,
573 [CLK_PLL_VIDEO
] = &pll_video_clk
.common
.hw
,
574 [CLK_PLL_VE
] = &pll_ve_clk
.common
.hw
,
575 [CLK_PLL_DDR0
] = &pll_ddr0_clk
.common
.hw
,
576 [CLK_PLL_PERIPH0
] = &pll_periph0_clk
.common
.hw
,
577 [CLK_PLL_PERIPH0_2X
] = &pll_periph0_2x_clk
.hw
,
578 [CLK_PLL_ISP
] = &pll_isp_clk
.common
.hw
,
579 [CLK_PLL_PERIPH1
] = &pll_periph1_clk
.common
.hw
,
580 [CLK_PLL_DDR1
] = &pll_ddr1_clk
.common
.hw
,
581 [CLK_CPU
] = &cpu_clk
.common
.hw
,
582 [CLK_AXI
] = &axi_clk
.common
.hw
,
583 [CLK_AHB1
] = &ahb1_clk
.common
.hw
,
584 [CLK_APB1
] = &apb1_clk
.common
.hw
,
585 [CLK_APB2
] = &apb2_clk
.common
.hw
,
586 [CLK_AHB2
] = &ahb2_clk
.common
.hw
,
587 [CLK_BUS_CE
] = &bus_ce_clk
.common
.hw
,
588 [CLK_BUS_DMA
] = &bus_dma_clk
.common
.hw
,
589 [CLK_BUS_MMC0
] = &bus_mmc0_clk
.common
.hw
,
590 [CLK_BUS_MMC1
] = &bus_mmc1_clk
.common
.hw
,
591 [CLK_BUS_MMC2
] = &bus_mmc2_clk
.common
.hw
,
592 [CLK_BUS_DRAM
] = &bus_dram_clk
.common
.hw
,
593 [CLK_BUS_EMAC
] = &bus_emac_clk
.common
.hw
,
594 [CLK_BUS_HSTIMER
] = &bus_hstimer_clk
.common
.hw
,
595 [CLK_BUS_SPI0
] = &bus_spi0_clk
.common
.hw
,
596 [CLK_BUS_OTG
] = &bus_otg_clk
.common
.hw
,
597 [CLK_BUS_EHCI0
] = &bus_ehci0_clk
.common
.hw
,
598 [CLK_BUS_OHCI0
] = &bus_ohci0_clk
.common
.hw
,
599 [CLK_BUS_VE
] = &bus_ve_clk
.common
.hw
,
600 [CLK_BUS_TCON0
] = &bus_tcon0_clk
.common
.hw
,
601 [CLK_BUS_CSI
] = &bus_csi_clk
.common
.hw
,
602 [CLK_BUS_DE
] = &bus_de_clk
.common
.hw
,
603 [CLK_BUS_CODEC
] = &bus_codec_clk
.common
.hw
,
604 [CLK_BUS_PIO
] = &bus_pio_clk
.common
.hw
,
605 [CLK_BUS_I2S0
] = &bus_i2s0_clk
.common
.hw
,
606 [CLK_BUS_I2C0
] = &bus_i2c0_clk
.common
.hw
,
607 [CLK_BUS_I2C1
] = &bus_i2c1_clk
.common
.hw
,
608 [CLK_BUS_UART0
] = &bus_uart0_clk
.common
.hw
,
609 [CLK_BUS_UART1
] = &bus_uart1_clk
.common
.hw
,
610 [CLK_BUS_UART2
] = &bus_uart2_clk
.common
.hw
,
611 [CLK_BUS_EPHY
] = &bus_ephy_clk
.common
.hw
,
612 [CLK_BUS_DBG
] = &bus_dbg_clk
.common
.hw
,
613 [CLK_MMC0
] = &mmc0_clk
.common
.hw
,
614 [CLK_MMC0_SAMPLE
] = &mmc0_sample_clk
.common
.hw
,
615 [CLK_MMC0_OUTPUT
] = &mmc0_output_clk
.common
.hw
,
616 [CLK_MMC1
] = &mmc1_clk
.common
.hw
,
617 [CLK_MMC1_SAMPLE
] = &mmc1_sample_clk
.common
.hw
,
618 [CLK_MMC1_OUTPUT
] = &mmc1_output_clk
.common
.hw
,
619 [CLK_MMC2
] = &mmc2_clk
.common
.hw
,
620 [CLK_MMC2_SAMPLE
] = &mmc2_sample_clk
.common
.hw
,
621 [CLK_MMC2_OUTPUT
] = &mmc2_output_clk
.common
.hw
,
622 [CLK_CE
] = &ce_clk
.common
.hw
,
623 [CLK_SPI0
] = &spi0_clk
.common
.hw
,
624 [CLK_I2S0
] = &i2s0_clk
.common
.hw
,
625 [CLK_USB_PHY0
] = &usb_phy0_clk
.common
.hw
,
626 [CLK_USB_OHCI0
] = &usb_ohci0_clk
.common
.hw
,
627 [CLK_DRAM
] = &dram_clk
.common
.hw
,
628 [CLK_DRAM_VE
] = &dram_ve_clk
.common
.hw
,
629 [CLK_DRAM_CSI
] = &dram_csi_clk
.common
.hw
,
630 [CLK_DRAM_EHCI
] = &dram_ehci_clk
.common
.hw
,
631 [CLK_DRAM_OHCI
] = &dram_ohci_clk
.common
.hw
,
632 [CLK_DE
] = &de_clk
.common
.hw
,
633 [CLK_TCON0
] = &tcon_clk
.common
.hw
,
634 [CLK_CSI_MISC
] = &csi_misc_clk
.common
.hw
,
635 [CLK_CSI0_MCLK
] = &csi0_mclk_clk
.common
.hw
,
636 [CLK_CSI1_SCLK
] = &csi1_sclk_clk
.common
.hw
,
637 [CLK_CSI1_MCLK
] = &csi1_mclk_clk
.common
.hw
,
638 [CLK_VE
] = &ve_clk
.common
.hw
,
639 [CLK_AC_DIG
] = &ac_dig_clk
.common
.hw
,
640 [CLK_AVS
] = &avs_clk
.common
.hw
,
641 [CLK_MBUS
] = &mbus_clk
.common
.hw
,
642 [CLK_MIPI_CSI
] = &mipi_csi_clk
.common
.hw
,
647 static const struct ccu_reset_map sun8i_v3s_ccu_resets
[] = {
648 [RST_USB_PHY0
] = { 0x0cc, BIT(0) },
650 [RST_MBUS
] = { 0x0fc, BIT(31) },
652 [RST_BUS_CE
] = { 0x2c0, BIT(5) },
653 [RST_BUS_DMA
] = { 0x2c0, BIT(6) },
654 [RST_BUS_MMC0
] = { 0x2c0, BIT(8) },
655 [RST_BUS_MMC1
] = { 0x2c0, BIT(9) },
656 [RST_BUS_MMC2
] = { 0x2c0, BIT(10) },
657 [RST_BUS_DRAM
] = { 0x2c0, BIT(14) },
658 [RST_BUS_EMAC
] = { 0x2c0, BIT(17) },
659 [RST_BUS_HSTIMER
] = { 0x2c0, BIT(19) },
660 [RST_BUS_SPI0
] = { 0x2c0, BIT(20) },
661 [RST_BUS_OTG
] = { 0x2c0, BIT(24) },
662 [RST_BUS_EHCI0
] = { 0x2c0, BIT(26) },
663 [RST_BUS_OHCI0
] = { 0x2c0, BIT(29) },
665 [RST_BUS_VE
] = { 0x2c4, BIT(0) },
666 [RST_BUS_TCON0
] = { 0x2c4, BIT(4) },
667 [RST_BUS_CSI
] = { 0x2c4, BIT(8) },
668 [RST_BUS_DE
] = { 0x2c4, BIT(12) },
669 [RST_BUS_DBG
] = { 0x2c4, BIT(31) },
671 [RST_BUS_EPHY
] = { 0x2c8, BIT(2) },
673 [RST_BUS_CODEC
] = { 0x2d0, BIT(0) },
675 [RST_BUS_I2C0
] = { 0x2d8, BIT(0) },
676 [RST_BUS_I2C1
] = { 0x2d8, BIT(1) },
677 [RST_BUS_UART0
] = { 0x2d8, BIT(16) },
678 [RST_BUS_UART1
] = { 0x2d8, BIT(17) },
679 [RST_BUS_UART2
] = { 0x2d8, BIT(18) },
682 static const struct ccu_reset_map sun8i_v3_ccu_resets
[] = {
683 [RST_USB_PHY0
] = { 0x0cc, BIT(0) },
685 [RST_MBUS
] = { 0x0fc, BIT(31) },
687 [RST_BUS_CE
] = { 0x2c0, BIT(5) },
688 [RST_BUS_DMA
] = { 0x2c0, BIT(6) },
689 [RST_BUS_MMC0
] = { 0x2c0, BIT(8) },
690 [RST_BUS_MMC1
] = { 0x2c0, BIT(9) },
691 [RST_BUS_MMC2
] = { 0x2c0, BIT(10) },
692 [RST_BUS_DRAM
] = { 0x2c0, BIT(14) },
693 [RST_BUS_EMAC
] = { 0x2c0, BIT(17) },
694 [RST_BUS_HSTIMER
] = { 0x2c0, BIT(19) },
695 [RST_BUS_SPI0
] = { 0x2c0, BIT(20) },
696 [RST_BUS_OTG
] = { 0x2c0, BIT(24) },
697 [RST_BUS_EHCI0
] = { 0x2c0, BIT(26) },
698 [RST_BUS_OHCI0
] = { 0x2c0, BIT(29) },
700 [RST_BUS_VE
] = { 0x2c4, BIT(0) },
701 [RST_BUS_TCON0
] = { 0x2c4, BIT(4) },
702 [RST_BUS_CSI
] = { 0x2c4, BIT(8) },
703 [RST_BUS_DE
] = { 0x2c4, BIT(12) },
704 [RST_BUS_DBG
] = { 0x2c4, BIT(31) },
706 [RST_BUS_EPHY
] = { 0x2c8, BIT(2) },
708 [RST_BUS_CODEC
] = { 0x2d0, BIT(0) },
709 [RST_BUS_I2S0
] = { 0x2d0, BIT(12) },
711 [RST_BUS_I2C0
] = { 0x2d8, BIT(0) },
712 [RST_BUS_I2C1
] = { 0x2d8, BIT(1) },
713 [RST_BUS_UART0
] = { 0x2d8, BIT(16) },
714 [RST_BUS_UART1
] = { 0x2d8, BIT(17) },
715 [RST_BUS_UART2
] = { 0x2d8, BIT(18) },
718 static const struct sunxi_ccu_desc sun8i_v3s_ccu_desc
= {
719 .ccu_clks
= sun8i_v3s_ccu_clks
,
720 .num_ccu_clks
= ARRAY_SIZE(sun8i_v3s_ccu_clks
),
722 .hw_clks
= &sun8i_v3s_hw_clks
,
724 .resets
= sun8i_v3s_ccu_resets
,
725 .num_resets
= ARRAY_SIZE(sun8i_v3s_ccu_resets
),
728 static const struct sunxi_ccu_desc sun8i_v3_ccu_desc
= {
729 .ccu_clks
= sun8i_v3s_ccu_clks
,
730 .num_ccu_clks
= ARRAY_SIZE(sun8i_v3s_ccu_clks
),
732 .hw_clks
= &sun8i_v3_hw_clks
,
734 .resets
= sun8i_v3_ccu_resets
,
735 .num_resets
= ARRAY_SIZE(sun8i_v3_ccu_resets
),
738 static int sun8i_v3s_ccu_probe(struct platform_device
*pdev
)
740 const struct sunxi_ccu_desc
*desc
;
744 desc
= of_device_get_match_data(&pdev
->dev
);
748 reg
= devm_platform_ioremap_resource(pdev
, 0);
752 /* Force the PLL-Audio-1x divider to 1 */
753 val
= readl(reg
+ SUN8I_V3S_PLL_AUDIO_REG
);
754 val
&= ~GENMASK(19, 16);
755 writel(val
, reg
+ SUN8I_V3S_PLL_AUDIO_REG
);
757 return devm_sunxi_ccu_probe(&pdev
->dev
, reg
, desc
);
760 static const struct of_device_id sun8i_v3s_ccu_ids
[] = {
762 .compatible
= "allwinner,sun8i-v3-ccu",
763 .data
= &sun8i_v3_ccu_desc
,
766 .compatible
= "allwinner,sun8i-v3s-ccu",
767 .data
= &sun8i_v3s_ccu_desc
,
771 MODULE_DEVICE_TABLE(of
, sun8i_v3s_ccu_ids
);
773 static struct platform_driver sun8i_v3s_ccu_driver
= {
774 .probe
= sun8i_v3s_ccu_probe
,
776 .name
= "sun8i-v3s-ccu",
777 .suppress_bind_attrs
= true,
778 .of_match_table
= sun8i_v3s_ccu_ids
,
781 module_platform_driver(sun8i_v3s_ccu_driver
);
783 MODULE_IMPORT_NS(SUNXI_CCU
);
784 MODULE_DESCRIPTION("Support for the Allwinner V3s CCU");
785 MODULE_LICENSE("GPL");