162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2016 Maxime Ripard. All rights reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/clk-provider.h> 762306a36Sopenharmony_ci#include <linux/io.h> 862306a36Sopenharmony_ci#include <linux/module.h> 962306a36Sopenharmony_ci#include <linux/platform_device.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "ccu_common.h" 1262306a36Sopenharmony_ci#include "ccu_reset.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include "ccu_div.h" 1562306a36Sopenharmony_ci#include "ccu_gate.h" 1662306a36Sopenharmony_ci#include "ccu_mp.h" 1762306a36Sopenharmony_ci#include "ccu_mult.h" 1862306a36Sopenharmony_ci#include "ccu_nk.h" 1962306a36Sopenharmony_ci#include "ccu_nkm.h" 2062306a36Sopenharmony_ci#include "ccu_nkmp.h" 2162306a36Sopenharmony_ci#include "ccu_nm.h" 2262306a36Sopenharmony_ci#include "ccu_phase.h" 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#include "ccu-sun8i-a23-a33.h" 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistatic struct ccu_nkmp pll_cpux_clk = { 2762306a36Sopenharmony_ci .enable = BIT(31), 2862306a36Sopenharmony_ci .lock = BIT(28), 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT(8, 5), 3162306a36Sopenharmony_ci .k = _SUNXI_CCU_MULT(4, 2), 3262306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(0, 2), 3362306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV_MAX(16, 2, 4), 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci .common = { 3662306a36Sopenharmony_ci .reg = 0x000, 3762306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-cpux", "osc24M", 3862306a36Sopenharmony_ci &ccu_nkmp_ops, 3962306a36Sopenharmony_ci 0), 4062306a36Sopenharmony_ci }, 4162306a36Sopenharmony_ci}; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* 4462306a36Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from 4562306a36Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true 4662306a36Sopenharmony_ci * pll audio). 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL, 4962306a36Sopenharmony_ci * we have to use specific dividers. This means the variable divider 5062306a36Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock 5162306a36Sopenharmony_ci * rates we support through this mechanism. So we now hard code the 5262306a36Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer 5362306a36Sopenharmony_ci * match the clock names. 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ci#define SUN8I_A33_PLL_AUDIO_REG 0x008 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = { 5862306a36Sopenharmony_ci { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 }, 5962306a36Sopenharmony_ci { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 }, 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", 6362306a36Sopenharmony_ci "osc24M", 0x008, 6462306a36Sopenharmony_ci 8, 7, /* N */ 6562306a36Sopenharmony_ci 0, 5, /* M */ 6662306a36Sopenharmony_ci pll_audio_sdm_table, BIT(24), 6762306a36Sopenharmony_ci 0x284, BIT(31), 6862306a36Sopenharmony_ci BIT(31), /* gate */ 6962306a36Sopenharmony_ci BIT(28), /* lock */ 7062306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video", 7362306a36Sopenharmony_ci "osc24M", 0x010, 7462306a36Sopenharmony_ci 8, 7, /* N */ 7562306a36Sopenharmony_ci 0, 4, /* M */ 7662306a36Sopenharmony_ci BIT(24), /* frac enable */ 7762306a36Sopenharmony_ci BIT(25), /* frac select */ 7862306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 7962306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 8062306a36Sopenharmony_ci BIT(31), /* gate */ 8162306a36Sopenharmony_ci BIT(28), /* lock */ 8262306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", 8562306a36Sopenharmony_ci "osc24M", 0x018, 8662306a36Sopenharmony_ci 8, 7, /* N */ 8762306a36Sopenharmony_ci 0, 4, /* M */ 8862306a36Sopenharmony_ci BIT(24), /* frac enable */ 8962306a36Sopenharmony_ci BIT(25), /* frac select */ 9062306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 9162306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 9262306a36Sopenharmony_ci BIT(31), /* gate */ 9362306a36Sopenharmony_ci BIT(28), /* lock */ 9462306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", 9762306a36Sopenharmony_ci "osc24M", 0x020, 9862306a36Sopenharmony_ci 8, 5, /* N */ 9962306a36Sopenharmony_ci 4, 2, /* K */ 10062306a36Sopenharmony_ci 0, 2, /* M */ 10162306a36Sopenharmony_ci BIT(31), /* gate */ 10262306a36Sopenharmony_ci BIT(28), /* lock */ 10362306a36Sopenharmony_ci 0); 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cistatic SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph_clk, "pll-periph", 10662306a36Sopenharmony_ci "osc24M", 0x028, 10762306a36Sopenharmony_ci 8, 5, /* N */ 10862306a36Sopenharmony_ci 4, 2, /* K */ 10962306a36Sopenharmony_ci BIT(31), /* gate */ 11062306a36Sopenharmony_ci BIT(28), /* lock */ 11162306a36Sopenharmony_ci 2, /* post-div */ 11262306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu", 11562306a36Sopenharmony_ci "osc24M", 0x038, 11662306a36Sopenharmony_ci 8, 7, /* N */ 11762306a36Sopenharmony_ci 0, 4, /* M */ 11862306a36Sopenharmony_ci BIT(24), /* frac enable */ 11962306a36Sopenharmony_ci BIT(25), /* frac select */ 12062306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 12162306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 12262306a36Sopenharmony_ci BIT(31), /* gate */ 12362306a36Sopenharmony_ci BIT(28), /* lock */ 12462306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* 12762306a36Sopenharmony_ci * The MIPI PLL has 2 modes: "MIPI" and "HDMI". 12862306a36Sopenharmony_ci * 12962306a36Sopenharmony_ci * The MIPI mode is a standard NKM-style clock. The HDMI mode is an 13062306a36Sopenharmony_ci * integer / fractional clock with switchable multipliers and dividers. 13162306a36Sopenharmony_ci * This is not supported here. We hardcode the PLL to MIPI mode. 13262306a36Sopenharmony_ci */ 13362306a36Sopenharmony_ci#define SUN8I_A33_PLL_MIPI_REG 0x040 13462306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi", 13562306a36Sopenharmony_ci "pll-video", 0x040, 13662306a36Sopenharmony_ci 8, 4, /* N */ 13762306a36Sopenharmony_ci 4, 2, /* K */ 13862306a36Sopenharmony_ci 0, 4, /* M */ 13962306a36Sopenharmony_ci BIT(31) | BIT(23) | BIT(22), /* gate */ 14062306a36Sopenharmony_ci BIT(28), /* lock */ 14162306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_hsic_clk, "pll-hsic", 14462306a36Sopenharmony_ci "osc24M", 0x044, 14562306a36Sopenharmony_ci 8, 7, /* N */ 14662306a36Sopenharmony_ci 0, 4, /* M */ 14762306a36Sopenharmony_ci BIT(24), /* frac enable */ 14862306a36Sopenharmony_ci BIT(25), /* frac select */ 14962306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 15062306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 15162306a36Sopenharmony_ci BIT(31), /* gate */ 15262306a36Sopenharmony_ci BIT(28), /* lock */ 15362306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de", 15662306a36Sopenharmony_ci "osc24M", 0x048, 15762306a36Sopenharmony_ci 8, 7, /* N */ 15862306a36Sopenharmony_ci 0, 4, /* M */ 15962306a36Sopenharmony_ci BIT(24), /* frac enable */ 16062306a36Sopenharmony_ci BIT(25), /* frac select */ 16162306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 16262306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 16362306a36Sopenharmony_ci BIT(31), /* gate */ 16462306a36Sopenharmony_ci BIT(28), /* lock */ 16562306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_cistatic struct ccu_mult pll_ddr1_clk = { 16862306a36Sopenharmony_ci .enable = BIT(31), 16962306a36Sopenharmony_ci .lock = BIT(28), 17062306a36Sopenharmony_ci .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 6, 0, 12, 0), 17162306a36Sopenharmony_ci .common = { 17262306a36Sopenharmony_ci .reg = 0x04c, 17362306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-ddr1", "osc24M", 17462306a36Sopenharmony_ci &ccu_mult_ops, 17562306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 17662306a36Sopenharmony_ci }, 17762306a36Sopenharmony_ci}; 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_cistatic const char * const cpux_parents[] = { "osc32k", "osc24M", 18062306a36Sopenharmony_ci "pll-cpux" , "pll-cpux" }; 18162306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents, 18262306a36Sopenharmony_ci 0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT); 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M", 18762306a36Sopenharmony_ci "axi" , "pll-periph" }; 18862306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = { 18962306a36Sopenharmony_ci { .index = 3, .shift = 6, .width = 2 }, 19062306a36Sopenharmony_ci}; 19162306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = { 19262306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci .mux = { 19562306a36Sopenharmony_ci .shift = 12, 19662306a36Sopenharmony_ci .width = 2, 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci .var_predivs = ahb1_predivs, 19962306a36Sopenharmony_ci .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 20062306a36Sopenharmony_ci }, 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci .common = { 20362306a36Sopenharmony_ci .reg = 0x054, 20462306a36Sopenharmony_ci .features = CCU_FEATURE_VARIABLE_PREDIV, 20562306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb1", 20662306a36Sopenharmony_ci ahb1_parents, 20762306a36Sopenharmony_ci &ccu_div_ops, 20862306a36Sopenharmony_ci 0), 20962306a36Sopenharmony_ci }, 21062306a36Sopenharmony_ci}; 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = { 21362306a36Sopenharmony_ci { .val = 0, .div = 2 }, 21462306a36Sopenharmony_ci { .val = 1, .div = 2 }, 21562306a36Sopenharmony_ci { .val = 2, .div = 4 }, 21662306a36Sopenharmony_ci { .val = 3, .div = 8 }, 21762306a36Sopenharmony_ci { /* Sentinel */ }, 21862306a36Sopenharmony_ci}; 21962306a36Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1", 22062306a36Sopenharmony_ci 0x054, 8, 2, apb1_div_table, 0); 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M", 22362306a36Sopenharmony_ci "pll-periph" , "pll-periph" }; 22462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 22562306a36Sopenharmony_ci 0, 5, /* M */ 22662306a36Sopenharmony_ci 16, 2, /* P */ 22762306a36Sopenharmony_ci 24, 2, /* mux */ 22862306a36Sopenharmony_ci 0); 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb1", 23162306a36Sopenharmony_ci 0x060, BIT(1), 0); 23262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ss_clk, "bus-ss", "ahb1", 23362306a36Sopenharmony_ci 0x060, BIT(5), 0); 23462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 23562306a36Sopenharmony_ci 0x060, BIT(6), 0); 23662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 23762306a36Sopenharmony_ci 0x060, BIT(8), 0); 23862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 23962306a36Sopenharmony_ci 0x060, BIT(9), 0); 24062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 24162306a36Sopenharmony_ci 0x060, BIT(10), 0); 24262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1", 24362306a36Sopenharmony_ci 0x060, BIT(13), 0); 24462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 24562306a36Sopenharmony_ci 0x060, BIT(14), 0); 24662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 24762306a36Sopenharmony_ci 0x060, BIT(19), 0); 24862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 24962306a36Sopenharmony_ci 0x060, BIT(20), 0); 25062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1", 25162306a36Sopenharmony_ci 0x060, BIT(21), 0); 25262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 25362306a36Sopenharmony_ci 0x060, BIT(24), 0); 25462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci_clk, "bus-ehci", "ahb1", 25562306a36Sopenharmony_ci 0x060, BIT(26), 0); 25662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci_clk, "bus-ohci", "ahb1", 25762306a36Sopenharmony_ci 0x060, BIT(29), 0); 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 26062306a36Sopenharmony_ci 0x064, BIT(0), 0); 26162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_lcd_clk, "bus-lcd", "ahb1", 26262306a36Sopenharmony_ci 0x064, BIT(4), 0); 26362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1", 26462306a36Sopenharmony_ci 0x064, BIT(8), 0); 26562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_be_clk, "bus-de-be", "ahb1", 26662306a36Sopenharmony_ci 0x064, BIT(12), 0); 26762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_fe_clk, "bus-de-fe", "ahb1", 26862306a36Sopenharmony_ci 0x064, BIT(14), 0); 26962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 27062306a36Sopenharmony_ci 0x064, BIT(20), 0); 27162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", 27262306a36Sopenharmony_ci 0x064, BIT(21), 0); 27362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 27462306a36Sopenharmony_ci 0x064, BIT(22), 0); 27562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_drc_clk, "bus-drc", "ahb1", 27662306a36Sopenharmony_ci 0x064, BIT(25), 0); 27762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_sat_clk, "bus-sat", "ahb1", 27862306a36Sopenharmony_ci 0x064, BIT(26), 0); 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1", 28162306a36Sopenharmony_ci 0x068, BIT(0), 0); 28262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 28362306a36Sopenharmony_ci 0x068, BIT(5), 0); 28462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 28562306a36Sopenharmony_ci 0x068, BIT(12), 0); 28662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 28762306a36Sopenharmony_ci 0x068, BIT(13), 0); 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 29062306a36Sopenharmony_ci 0x06c, BIT(0), 0); 29162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 29262306a36Sopenharmony_ci 0x06c, BIT(1), 0); 29362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 29462306a36Sopenharmony_ci 0x06c, BIT(2), 0); 29562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 29662306a36Sopenharmony_ci 0x06c, BIT(16), 0); 29762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 29862306a36Sopenharmony_ci 0x06c, BIT(17), 0); 29962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 30062306a36Sopenharmony_ci 0x06c, BIT(18), 0); 30162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 30262306a36Sopenharmony_ci 0x06c, BIT(19), 0); 30362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2", 30462306a36Sopenharmony_ci 0x06c, BIT(20), 0); 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph" }; 30762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080, 30862306a36Sopenharmony_ci 0, 4, /* M */ 30962306a36Sopenharmony_ci 16, 2, /* P */ 31062306a36Sopenharmony_ci 24, 2, /* mux */ 31162306a36Sopenharmony_ci BIT(31), /* gate */ 31262306a36Sopenharmony_ci 0); 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088, 31562306a36Sopenharmony_ci 0, 4, /* M */ 31662306a36Sopenharmony_ci 16, 2, /* P */ 31762306a36Sopenharmony_ci 24, 2, /* mux */ 31862306a36Sopenharmony_ci BIT(31), /* gate */ 31962306a36Sopenharmony_ci 0); 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0", 32262306a36Sopenharmony_ci 0x088, 20, 3, 0); 32362306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0", 32462306a36Sopenharmony_ci 0x088, 8, 3, 0); 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c, 32762306a36Sopenharmony_ci 0, 4, /* M */ 32862306a36Sopenharmony_ci 16, 2, /* P */ 32962306a36Sopenharmony_ci 24, 2, /* mux */ 33062306a36Sopenharmony_ci BIT(31), /* gate */ 33162306a36Sopenharmony_ci 0); 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1", 33462306a36Sopenharmony_ci 0x08c, 20, 3, 0); 33562306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1", 33662306a36Sopenharmony_ci 0x08c, 8, 3, 0); 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090, 33962306a36Sopenharmony_ci 0, 4, /* M */ 34062306a36Sopenharmony_ci 16, 2, /* P */ 34162306a36Sopenharmony_ci 24, 2, /* mux */ 34262306a36Sopenharmony_ci BIT(31), /* gate */ 34362306a36Sopenharmony_ci 0); 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2", 34662306a36Sopenharmony_ci 0x090, 20, 3, 0); 34762306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2", 34862306a36Sopenharmony_ci 0x090, 8, 3, 0); 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ss_clk, "ss", mod0_default_parents, 0x09c, 35162306a36Sopenharmony_ci 0, 4, /* M */ 35262306a36Sopenharmony_ci 16, 2, /* P */ 35362306a36Sopenharmony_ci 24, 2, /* mux */ 35462306a36Sopenharmony_ci BIT(31), /* gate */ 35562306a36Sopenharmony_ci 0); 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, 35862306a36Sopenharmony_ci 0, 4, /* M */ 35962306a36Sopenharmony_ci 16, 2, /* P */ 36062306a36Sopenharmony_ci 24, 2, /* mux */ 36162306a36Sopenharmony_ci BIT(31), /* gate */ 36262306a36Sopenharmony_ci 0); 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4, 36562306a36Sopenharmony_ci 0, 4, /* M */ 36662306a36Sopenharmony_ci 16, 2, /* P */ 36762306a36Sopenharmony_ci 24, 2, /* mux */ 36862306a36Sopenharmony_ci BIT(31), /* gate */ 36962306a36Sopenharmony_ci 0); 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", 37262306a36Sopenharmony_ci "pll-audio-2x", "pll-audio" }; 37362306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, 37462306a36Sopenharmony_ci 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents, 37762306a36Sopenharmony_ci 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci/* TODO: the parent for most of the USB clocks is not known */ 38062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 38162306a36Sopenharmony_ci 0x0cc, BIT(8), 0); 38262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M", 38362306a36Sopenharmony_ci 0x0cc, BIT(9), 0); 38462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_clk, "usb-hsic", "pll-hsic", 38562306a36Sopenharmony_ci 0x0cc, BIT(10), 0); 38662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_12M_clk, "usb-hsic-12M", "osc24M", 38762306a36Sopenharmony_ci 0x0cc, BIT(11), 0); 38862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci_clk, "usb-ohci", "osc24M", 38962306a36Sopenharmony_ci 0x0cc, BIT(16), 0); 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cistatic SUNXI_CCU_M(dram_clk, "dram", "pll-ddr", 39262306a36Sopenharmony_ci 0x0f4, 0, 4, CLK_IS_CRITICAL); 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cistatic const char * const pll_ddr_parents[] = { "pll-ddr0", "pll-ddr1" }; 39562306a36Sopenharmony_cistatic SUNXI_CCU_MUX(pll_ddr_clk, "pll-ddr", pll_ddr_parents, 39662306a36Sopenharmony_ci 0x0f8, 16, 1, 0); 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 39962306a36Sopenharmony_ci 0x100, BIT(0), 0); 40062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram", 40162306a36Sopenharmony_ci 0x100, BIT(1), 0); 40262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_drc_clk, "dram-drc", "dram", 40362306a36Sopenharmony_ci 0x100, BIT(16), 0); 40462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_fe_clk, "dram-de-fe", "dram", 40562306a36Sopenharmony_ci 0x100, BIT(24), 0); 40662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_be_clk, "dram-de-be", "dram", 40762306a36Sopenharmony_ci 0x100, BIT(26), 0); 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-video", "pll-periph-2x", 41062306a36Sopenharmony_ci "pll-gpu", "pll-de" }; 41162306a36Sopenharmony_cistatic const u8 de_table[] = { 0, 2, 3, 5 }; 41262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_be_clk, "de-be", 41362306a36Sopenharmony_ci de_parents, de_table, 41462306a36Sopenharmony_ci 0x104, 0, 4, 24, 3, BIT(31), 0); 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_fe_clk, "de-fe", 41762306a36Sopenharmony_ci de_parents, de_table, 41862306a36Sopenharmony_ci 0x10c, 0, 4, 24, 3, BIT(31), 0); 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_cistatic const char * const lcd_ch0_parents[] = { "pll-video", "pll-video-2x", 42162306a36Sopenharmony_ci "pll-mipi" }; 42262306a36Sopenharmony_cistatic const u8 lcd_ch0_table[] = { 0, 2, 4 }; 42362306a36Sopenharmony_cistatic SUNXI_CCU_MUX_TABLE_WITH_GATE(lcd_ch0_clk, "lcd-ch0", 42462306a36Sopenharmony_ci lcd_ch0_parents, lcd_ch0_table, 42562306a36Sopenharmony_ci 0x118, 24, 3, BIT(31), 42662306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_cistatic const char * const lcd_ch1_parents[] = { "pll-video", "pll-video-2x" }; 42962306a36Sopenharmony_cistatic const u8 lcd_ch1_table[] = { 0, 2 }; 43062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(lcd_ch1_clk, "lcd-ch1", 43162306a36Sopenharmony_ci lcd_ch1_parents, lcd_ch1_table, 43262306a36Sopenharmony_ci 0x12c, 0, 4, 24, 2, BIT(31), 0); 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-video", "pll-de", 43562306a36Sopenharmony_ci "pll-mipi", "pll-ve" }; 43662306a36Sopenharmony_cistatic const u8 csi_sclk_table[] = { 0, 3, 4, 5 }; 43762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_sclk_clk, "csi-sclk", 43862306a36Sopenharmony_ci csi_sclk_parents, csi_sclk_table, 43962306a36Sopenharmony_ci 0x134, 16, 4, 24, 3, BIT(31), 0); 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "pll-video", "pll-de", 44262306a36Sopenharmony_ci "osc24M" }; 44362306a36Sopenharmony_cistatic const u8 csi_mclk_table[] = { 0, 3, 5 }; 44462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_mclk_clk, "csi-mclk", 44562306a36Sopenharmony_ci csi_mclk_parents, csi_mclk_table, 44662306a36Sopenharmony_ci 0x134, 0, 5, 8, 3, BIT(15), 0); 44762306a36Sopenharmony_ci 44862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 44962306a36Sopenharmony_ci 0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT); 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio", 45262306a36Sopenharmony_ci 0x140, BIT(31), CLK_SET_RATE_PARENT); 45362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_4x_clk, "ac-dig-4x", "pll-audio-4x", 45462306a36Sopenharmony_ci 0x140, BIT(30), CLK_SET_RATE_PARENT); 45562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 45662306a36Sopenharmony_ci 0x144, BIT(31), 0); 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph-2x", 45962306a36Sopenharmony_ci "pll-ddr0", "pll-ddr1" }; 46062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 46162306a36Sopenharmony_ci 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL); 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_cistatic const char * const dsi_sclk_parents[] = { "pll-video", "pll-video-2x" }; 46462306a36Sopenharmony_cistatic const u8 dsi_sclk_table[] = { 0, 2 }; 46562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_sclk_clk, "dsi-sclk", 46662306a36Sopenharmony_ci dsi_sclk_parents, dsi_sclk_table, 46762306a36Sopenharmony_ci 0x168, 16, 4, 24, 2, BIT(31), 0); 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video", "pll-periph" }; 47062306a36Sopenharmony_cistatic const u8 dsi_dphy_table[] = { 0, 2 }; 47162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_dphy_clk, "dsi-dphy", 47262306a36Sopenharmony_ci dsi_dphy_parents, dsi_dphy_table, 47362306a36Sopenharmony_ci 0x168, 0, 4, 8, 2, BIT(15), 0); 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(drc_clk, "drc", 47662306a36Sopenharmony_ci de_parents, de_table, 47762306a36Sopenharmony_ci 0x180, 0, 4, 24, 3, BIT(31), 0); 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu", 48062306a36Sopenharmony_ci 0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT); 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_cistatic const char * const ats_parents[] = { "osc24M", "pll-periph" }; 48362306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(ats_clk, "ats", ats_parents, 48462306a36Sopenharmony_ci 0x1b0, 0, 3, 24, 2, BIT(31), 0); 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_cistatic struct ccu_common *sun8i_a33_ccu_clks[] = { 48762306a36Sopenharmony_ci &pll_cpux_clk.common, 48862306a36Sopenharmony_ci &pll_audio_base_clk.common, 48962306a36Sopenharmony_ci &pll_video_clk.common, 49062306a36Sopenharmony_ci &pll_ve_clk.common, 49162306a36Sopenharmony_ci &pll_ddr0_clk.common, 49262306a36Sopenharmony_ci &pll_periph_clk.common, 49362306a36Sopenharmony_ci &pll_gpu_clk.common, 49462306a36Sopenharmony_ci &pll_mipi_clk.common, 49562306a36Sopenharmony_ci &pll_hsic_clk.common, 49662306a36Sopenharmony_ci &pll_de_clk.common, 49762306a36Sopenharmony_ci &pll_ddr1_clk.common, 49862306a36Sopenharmony_ci &pll_ddr_clk.common, 49962306a36Sopenharmony_ci &cpux_clk.common, 50062306a36Sopenharmony_ci &axi_clk.common, 50162306a36Sopenharmony_ci &ahb1_clk.common, 50262306a36Sopenharmony_ci &apb1_clk.common, 50362306a36Sopenharmony_ci &apb2_clk.common, 50462306a36Sopenharmony_ci &bus_mipi_dsi_clk.common, 50562306a36Sopenharmony_ci &bus_ss_clk.common, 50662306a36Sopenharmony_ci &bus_dma_clk.common, 50762306a36Sopenharmony_ci &bus_mmc0_clk.common, 50862306a36Sopenharmony_ci &bus_mmc1_clk.common, 50962306a36Sopenharmony_ci &bus_mmc2_clk.common, 51062306a36Sopenharmony_ci &bus_nand_clk.common, 51162306a36Sopenharmony_ci &bus_dram_clk.common, 51262306a36Sopenharmony_ci &bus_hstimer_clk.common, 51362306a36Sopenharmony_ci &bus_spi0_clk.common, 51462306a36Sopenharmony_ci &bus_spi1_clk.common, 51562306a36Sopenharmony_ci &bus_otg_clk.common, 51662306a36Sopenharmony_ci &bus_ehci_clk.common, 51762306a36Sopenharmony_ci &bus_ohci_clk.common, 51862306a36Sopenharmony_ci &bus_ve_clk.common, 51962306a36Sopenharmony_ci &bus_lcd_clk.common, 52062306a36Sopenharmony_ci &bus_csi_clk.common, 52162306a36Sopenharmony_ci &bus_de_fe_clk.common, 52262306a36Sopenharmony_ci &bus_de_be_clk.common, 52362306a36Sopenharmony_ci &bus_gpu_clk.common, 52462306a36Sopenharmony_ci &bus_msgbox_clk.common, 52562306a36Sopenharmony_ci &bus_spinlock_clk.common, 52662306a36Sopenharmony_ci &bus_drc_clk.common, 52762306a36Sopenharmony_ci &bus_sat_clk.common, 52862306a36Sopenharmony_ci &bus_codec_clk.common, 52962306a36Sopenharmony_ci &bus_pio_clk.common, 53062306a36Sopenharmony_ci &bus_i2s0_clk.common, 53162306a36Sopenharmony_ci &bus_i2s1_clk.common, 53262306a36Sopenharmony_ci &bus_i2c0_clk.common, 53362306a36Sopenharmony_ci &bus_i2c1_clk.common, 53462306a36Sopenharmony_ci &bus_i2c2_clk.common, 53562306a36Sopenharmony_ci &bus_uart0_clk.common, 53662306a36Sopenharmony_ci &bus_uart1_clk.common, 53762306a36Sopenharmony_ci &bus_uart2_clk.common, 53862306a36Sopenharmony_ci &bus_uart3_clk.common, 53962306a36Sopenharmony_ci &bus_uart4_clk.common, 54062306a36Sopenharmony_ci &nand_clk.common, 54162306a36Sopenharmony_ci &mmc0_clk.common, 54262306a36Sopenharmony_ci &mmc0_sample_clk.common, 54362306a36Sopenharmony_ci &mmc0_output_clk.common, 54462306a36Sopenharmony_ci &mmc1_clk.common, 54562306a36Sopenharmony_ci &mmc1_sample_clk.common, 54662306a36Sopenharmony_ci &mmc1_output_clk.common, 54762306a36Sopenharmony_ci &mmc2_clk.common, 54862306a36Sopenharmony_ci &mmc2_sample_clk.common, 54962306a36Sopenharmony_ci &mmc2_output_clk.common, 55062306a36Sopenharmony_ci &ss_clk.common, 55162306a36Sopenharmony_ci &spi0_clk.common, 55262306a36Sopenharmony_ci &spi1_clk.common, 55362306a36Sopenharmony_ci &i2s0_clk.common, 55462306a36Sopenharmony_ci &i2s1_clk.common, 55562306a36Sopenharmony_ci &usb_phy0_clk.common, 55662306a36Sopenharmony_ci &usb_phy1_clk.common, 55762306a36Sopenharmony_ci &usb_hsic_clk.common, 55862306a36Sopenharmony_ci &usb_hsic_12M_clk.common, 55962306a36Sopenharmony_ci &usb_ohci_clk.common, 56062306a36Sopenharmony_ci &dram_clk.common, 56162306a36Sopenharmony_ci &dram_ve_clk.common, 56262306a36Sopenharmony_ci &dram_csi_clk.common, 56362306a36Sopenharmony_ci &dram_drc_clk.common, 56462306a36Sopenharmony_ci &dram_de_fe_clk.common, 56562306a36Sopenharmony_ci &dram_de_be_clk.common, 56662306a36Sopenharmony_ci &de_be_clk.common, 56762306a36Sopenharmony_ci &de_fe_clk.common, 56862306a36Sopenharmony_ci &lcd_ch0_clk.common, 56962306a36Sopenharmony_ci &lcd_ch1_clk.common, 57062306a36Sopenharmony_ci &csi_sclk_clk.common, 57162306a36Sopenharmony_ci &csi_mclk_clk.common, 57262306a36Sopenharmony_ci &ve_clk.common, 57362306a36Sopenharmony_ci &ac_dig_clk.common, 57462306a36Sopenharmony_ci &ac_dig_4x_clk.common, 57562306a36Sopenharmony_ci &avs_clk.common, 57662306a36Sopenharmony_ci &mbus_clk.common, 57762306a36Sopenharmony_ci &dsi_sclk_clk.common, 57862306a36Sopenharmony_ci &dsi_dphy_clk.common, 57962306a36Sopenharmony_ci &drc_clk.common, 58062306a36Sopenharmony_ci &gpu_clk.common, 58162306a36Sopenharmony_ci &ats_clk.common, 58262306a36Sopenharmony_ci}; 58362306a36Sopenharmony_ci 58462306a36Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = { 58562306a36Sopenharmony_ci &pll_audio_base_clk.common.hw 58662306a36Sopenharmony_ci}; 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_ci/* We hardcode the divider to 1 for now */ 58962306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", 59062306a36Sopenharmony_ci clk_parent_pll_audio, 59162306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 59262306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", 59362306a36Sopenharmony_ci clk_parent_pll_audio, 59462306a36Sopenharmony_ci 2, 1, CLK_SET_RATE_PARENT); 59562306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x", 59662306a36Sopenharmony_ci clk_parent_pll_audio, 59762306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 59862306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x", 59962306a36Sopenharmony_ci clk_parent_pll_audio, 60062306a36Sopenharmony_ci 1, 2, CLK_SET_RATE_PARENT); 60162306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph_2x_clk, "pll-periph-2x", 60262306a36Sopenharmony_ci &pll_periph_clk.common.hw, 60362306a36Sopenharmony_ci 1, 2, 0); 60462306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video_2x_clk, "pll-video-2x", 60562306a36Sopenharmony_ci &pll_video_clk.common.hw, 60662306a36Sopenharmony_ci 1, 2, 0); 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_a33_hw_clks = { 60962306a36Sopenharmony_ci .hws = { 61062306a36Sopenharmony_ci [CLK_PLL_CPUX] = &pll_cpux_clk.common.hw, 61162306a36Sopenharmony_ci [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 61262306a36Sopenharmony_ci [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 61362306a36Sopenharmony_ci [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 61462306a36Sopenharmony_ci [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 61562306a36Sopenharmony_ci [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 61662306a36Sopenharmony_ci [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, 61762306a36Sopenharmony_ci [CLK_PLL_VIDEO_2X] = &pll_video_2x_clk.hw, 61862306a36Sopenharmony_ci [CLK_PLL_VE] = &pll_ve_clk.common.hw, 61962306a36Sopenharmony_ci [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 62062306a36Sopenharmony_ci [CLK_PLL_PERIPH] = &pll_periph_clk.common.hw, 62162306a36Sopenharmony_ci [CLK_PLL_PERIPH_2X] = &pll_periph_2x_clk.hw, 62262306a36Sopenharmony_ci [CLK_PLL_GPU] = &pll_gpu_clk.common.hw, 62362306a36Sopenharmony_ci [CLK_PLL_MIPI] = &pll_mipi_clk.common.hw, 62462306a36Sopenharmony_ci [CLK_PLL_HSIC] = &pll_hsic_clk.common.hw, 62562306a36Sopenharmony_ci [CLK_PLL_DE] = &pll_de_clk.common.hw, 62662306a36Sopenharmony_ci [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 62762306a36Sopenharmony_ci [CLK_PLL_DDR] = &pll_ddr_clk.common.hw, 62862306a36Sopenharmony_ci [CLK_CPUX] = &cpux_clk.common.hw, 62962306a36Sopenharmony_ci [CLK_AXI] = &axi_clk.common.hw, 63062306a36Sopenharmony_ci [CLK_AHB1] = &ahb1_clk.common.hw, 63162306a36Sopenharmony_ci [CLK_APB1] = &apb1_clk.common.hw, 63262306a36Sopenharmony_ci [CLK_APB2] = &apb2_clk.common.hw, 63362306a36Sopenharmony_ci [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw, 63462306a36Sopenharmony_ci [CLK_BUS_SS] = &bus_ss_clk.common.hw, 63562306a36Sopenharmony_ci [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 63662306a36Sopenharmony_ci [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 63762306a36Sopenharmony_ci [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 63862306a36Sopenharmony_ci [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 63962306a36Sopenharmony_ci [CLK_BUS_NAND] = &bus_nand_clk.common.hw, 64062306a36Sopenharmony_ci [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 64162306a36Sopenharmony_ci [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 64262306a36Sopenharmony_ci [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 64362306a36Sopenharmony_ci [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw, 64462306a36Sopenharmony_ci [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 64562306a36Sopenharmony_ci [CLK_BUS_EHCI] = &bus_ehci_clk.common.hw, 64662306a36Sopenharmony_ci [CLK_BUS_OHCI] = &bus_ohci_clk.common.hw, 64762306a36Sopenharmony_ci [CLK_BUS_VE] = &bus_ve_clk.common.hw, 64862306a36Sopenharmony_ci [CLK_BUS_LCD] = &bus_lcd_clk.common.hw, 64962306a36Sopenharmony_ci [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 65062306a36Sopenharmony_ci [CLK_BUS_DE_BE] = &bus_de_be_clk.common.hw, 65162306a36Sopenharmony_ci [CLK_BUS_DE_FE] = &bus_de_fe_clk.common.hw, 65262306a36Sopenharmony_ci [CLK_BUS_GPU] = &bus_gpu_clk.common.hw, 65362306a36Sopenharmony_ci [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw, 65462306a36Sopenharmony_ci [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw, 65562306a36Sopenharmony_ci [CLK_BUS_DRC] = &bus_drc_clk.common.hw, 65662306a36Sopenharmony_ci [CLK_BUS_SAT] = &bus_sat_clk.common.hw, 65762306a36Sopenharmony_ci [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 65862306a36Sopenharmony_ci [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 65962306a36Sopenharmony_ci [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 66062306a36Sopenharmony_ci [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw, 66162306a36Sopenharmony_ci [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 66262306a36Sopenharmony_ci [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 66362306a36Sopenharmony_ci [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw, 66462306a36Sopenharmony_ci [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 66562306a36Sopenharmony_ci [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 66662306a36Sopenharmony_ci [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 66762306a36Sopenharmony_ci [CLK_BUS_UART3] = &bus_uart3_clk.common.hw, 66862306a36Sopenharmony_ci [CLK_BUS_UART4] = &bus_uart4_clk.common.hw, 66962306a36Sopenharmony_ci [CLK_NAND] = &nand_clk.common.hw, 67062306a36Sopenharmony_ci [CLK_MMC0] = &mmc0_clk.common.hw, 67162306a36Sopenharmony_ci [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 67262306a36Sopenharmony_ci [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 67362306a36Sopenharmony_ci [CLK_MMC1] = &mmc1_clk.common.hw, 67462306a36Sopenharmony_ci [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 67562306a36Sopenharmony_ci [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 67662306a36Sopenharmony_ci [CLK_MMC2] = &mmc2_clk.common.hw, 67762306a36Sopenharmony_ci [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw, 67862306a36Sopenharmony_ci [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw, 67962306a36Sopenharmony_ci [CLK_SS] = &ss_clk.common.hw, 68062306a36Sopenharmony_ci [CLK_SPI0] = &spi0_clk.common.hw, 68162306a36Sopenharmony_ci [CLK_SPI1] = &spi1_clk.common.hw, 68262306a36Sopenharmony_ci [CLK_I2S0] = &i2s0_clk.common.hw, 68362306a36Sopenharmony_ci [CLK_I2S1] = &i2s1_clk.common.hw, 68462306a36Sopenharmony_ci [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 68562306a36Sopenharmony_ci [CLK_USB_PHY1] = &usb_phy1_clk.common.hw, 68662306a36Sopenharmony_ci [CLK_USB_HSIC] = &usb_hsic_clk.common.hw, 68762306a36Sopenharmony_ci [CLK_USB_HSIC_12M] = &usb_hsic_12M_clk.common.hw, 68862306a36Sopenharmony_ci [CLK_USB_OHCI] = &usb_ohci_clk.common.hw, 68962306a36Sopenharmony_ci [CLK_DRAM] = &dram_clk.common.hw, 69062306a36Sopenharmony_ci [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 69162306a36Sopenharmony_ci [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 69262306a36Sopenharmony_ci [CLK_DRAM_DRC] = &dram_drc_clk.common.hw, 69362306a36Sopenharmony_ci [CLK_DRAM_DE_FE] = &dram_de_fe_clk.common.hw, 69462306a36Sopenharmony_ci [CLK_DRAM_DE_BE] = &dram_de_be_clk.common.hw, 69562306a36Sopenharmony_ci [CLK_DE_BE] = &de_be_clk.common.hw, 69662306a36Sopenharmony_ci [CLK_DE_FE] = &de_fe_clk.common.hw, 69762306a36Sopenharmony_ci [CLK_LCD_CH0] = &lcd_ch0_clk.common.hw, 69862306a36Sopenharmony_ci [CLK_LCD_CH1] = &lcd_ch1_clk.common.hw, 69962306a36Sopenharmony_ci [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw, 70062306a36Sopenharmony_ci [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw, 70162306a36Sopenharmony_ci [CLK_VE] = &ve_clk.common.hw, 70262306a36Sopenharmony_ci [CLK_AC_DIG] = &ac_dig_clk.common.hw, 70362306a36Sopenharmony_ci [CLK_AC_DIG_4X] = &ac_dig_4x_clk.common.hw, 70462306a36Sopenharmony_ci [CLK_AVS] = &avs_clk.common.hw, 70562306a36Sopenharmony_ci [CLK_MBUS] = &mbus_clk.common.hw, 70662306a36Sopenharmony_ci [CLK_DSI_SCLK] = &dsi_sclk_clk.common.hw, 70762306a36Sopenharmony_ci [CLK_DSI_DPHY] = &dsi_dphy_clk.common.hw, 70862306a36Sopenharmony_ci [CLK_DRC] = &drc_clk.common.hw, 70962306a36Sopenharmony_ci [CLK_GPU] = &gpu_clk.common.hw, 71062306a36Sopenharmony_ci [CLK_ATS] = &ats_clk.common.hw, 71162306a36Sopenharmony_ci }, 71262306a36Sopenharmony_ci .num = CLK_NUMBER, 71362306a36Sopenharmony_ci}; 71462306a36Sopenharmony_ci 71562306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_a33_ccu_resets[] = { 71662306a36Sopenharmony_ci [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 71762306a36Sopenharmony_ci [RST_USB_PHY1] = { 0x0cc, BIT(1) }, 71862306a36Sopenharmony_ci [RST_USB_HSIC] = { 0x0cc, BIT(2) }, 71962306a36Sopenharmony_ci 72062306a36Sopenharmony_ci [RST_MBUS] = { 0x0fc, BIT(31) }, 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_ci [RST_BUS_MIPI_DSI] = { 0x2c0, BIT(1) }, 72362306a36Sopenharmony_ci [RST_BUS_SS] = { 0x2c0, BIT(5) }, 72462306a36Sopenharmony_ci [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 72562306a36Sopenharmony_ci [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 72662306a36Sopenharmony_ci [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 72762306a36Sopenharmony_ci [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 72862306a36Sopenharmony_ci [RST_BUS_NAND] = { 0x2c0, BIT(13) }, 72962306a36Sopenharmony_ci [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 73062306a36Sopenharmony_ci [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 73162306a36Sopenharmony_ci [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 73262306a36Sopenharmony_ci [RST_BUS_SPI1] = { 0x2c0, BIT(21) }, 73362306a36Sopenharmony_ci [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 73462306a36Sopenharmony_ci [RST_BUS_EHCI] = { 0x2c0, BIT(26) }, 73562306a36Sopenharmony_ci [RST_BUS_OHCI] = { 0x2c0, BIT(29) }, 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci [RST_BUS_VE] = { 0x2c4, BIT(0) }, 73862306a36Sopenharmony_ci [RST_BUS_LCD] = { 0x2c4, BIT(4) }, 73962306a36Sopenharmony_ci [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 74062306a36Sopenharmony_ci [RST_BUS_DE_BE] = { 0x2c4, BIT(12) }, 74162306a36Sopenharmony_ci [RST_BUS_DE_FE] = { 0x2c4, BIT(14) }, 74262306a36Sopenharmony_ci [RST_BUS_GPU] = { 0x2c4, BIT(20) }, 74362306a36Sopenharmony_ci [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) }, 74462306a36Sopenharmony_ci [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) }, 74562306a36Sopenharmony_ci [RST_BUS_DRC] = { 0x2c4, BIT(25) }, 74662306a36Sopenharmony_ci [RST_BUS_SAT] = { 0x2c4, BIT(26) }, 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci [RST_BUS_LVDS] = { 0x2c8, BIT(0) }, 74962306a36Sopenharmony_ci 75062306a36Sopenharmony_ci [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 75162306a36Sopenharmony_ci [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 75262306a36Sopenharmony_ci [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ci [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 75562306a36Sopenharmony_ci [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 75662306a36Sopenharmony_ci [RST_BUS_I2C2] = { 0x2d8, BIT(2) }, 75762306a36Sopenharmony_ci [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 75862306a36Sopenharmony_ci [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 75962306a36Sopenharmony_ci [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 76062306a36Sopenharmony_ci [RST_BUS_UART3] = { 0x2d8, BIT(19) }, 76162306a36Sopenharmony_ci [RST_BUS_UART4] = { 0x2d8, BIT(20) }, 76262306a36Sopenharmony_ci}; 76362306a36Sopenharmony_ci 76462306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_a33_ccu_desc = { 76562306a36Sopenharmony_ci .ccu_clks = sun8i_a33_ccu_clks, 76662306a36Sopenharmony_ci .num_ccu_clks = ARRAY_SIZE(sun8i_a33_ccu_clks), 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci .hw_clks = &sun8i_a33_hw_clks, 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_ci .resets = sun8i_a33_ccu_resets, 77162306a36Sopenharmony_ci .num_resets = ARRAY_SIZE(sun8i_a33_ccu_resets), 77262306a36Sopenharmony_ci}; 77362306a36Sopenharmony_ci 77462306a36Sopenharmony_cistatic struct ccu_pll_nb sun8i_a33_pll_cpu_nb = { 77562306a36Sopenharmony_ci .common = &pll_cpux_clk.common, 77662306a36Sopenharmony_ci /* copy from pll_cpux_clk */ 77762306a36Sopenharmony_ci .enable = BIT(31), 77862306a36Sopenharmony_ci .lock = BIT(28), 77962306a36Sopenharmony_ci}; 78062306a36Sopenharmony_ci 78162306a36Sopenharmony_cistatic struct ccu_mux_nb sun8i_a33_cpu_nb = { 78262306a36Sopenharmony_ci .common = &cpux_clk.common, 78362306a36Sopenharmony_ci .cm = &cpux_clk.mux, 78462306a36Sopenharmony_ci .delay_us = 1, /* > 8 clock cycles at 24 MHz */ 78562306a36Sopenharmony_ci .bypass_index = 1, /* index of 24 MHz oscillator */ 78662306a36Sopenharmony_ci}; 78762306a36Sopenharmony_ci 78862306a36Sopenharmony_cistatic int sun8i_a33_ccu_probe(struct platform_device *pdev) 78962306a36Sopenharmony_ci{ 79062306a36Sopenharmony_ci void __iomem *reg; 79162306a36Sopenharmony_ci int ret; 79262306a36Sopenharmony_ci u32 val; 79362306a36Sopenharmony_ci 79462306a36Sopenharmony_ci reg = devm_platform_ioremap_resource(pdev, 0); 79562306a36Sopenharmony_ci if (IS_ERR(reg)) 79662306a36Sopenharmony_ci return PTR_ERR(reg); 79762306a36Sopenharmony_ci 79862306a36Sopenharmony_ci /* Force the PLL-Audio-1x divider to 1 */ 79962306a36Sopenharmony_ci val = readl(reg + SUN8I_A33_PLL_AUDIO_REG); 80062306a36Sopenharmony_ci val &= ~GENMASK(19, 16); 80162306a36Sopenharmony_ci writel(val | (0 << 16), reg + SUN8I_A33_PLL_AUDIO_REG); 80262306a36Sopenharmony_ci 80362306a36Sopenharmony_ci /* Force PLL-MIPI to MIPI mode */ 80462306a36Sopenharmony_ci val = readl(reg + SUN8I_A33_PLL_MIPI_REG); 80562306a36Sopenharmony_ci val &= ~BIT(16); 80662306a36Sopenharmony_ci writel(val, reg + SUN8I_A33_PLL_MIPI_REG); 80762306a36Sopenharmony_ci 80862306a36Sopenharmony_ci ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_a33_ccu_desc); 80962306a36Sopenharmony_ci if (ret) 81062306a36Sopenharmony_ci return ret; 81162306a36Sopenharmony_ci 81262306a36Sopenharmony_ci /* Gate then ungate PLL CPU after any rate changes */ 81362306a36Sopenharmony_ci ccu_pll_notifier_register(&sun8i_a33_pll_cpu_nb); 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci /* Reparent CPU during PLL CPU rate changes */ 81662306a36Sopenharmony_ci ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, 81762306a36Sopenharmony_ci &sun8i_a33_cpu_nb); 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci return 0; 82062306a36Sopenharmony_ci} 82162306a36Sopenharmony_ci 82262306a36Sopenharmony_cistatic const struct of_device_id sun8i_a33_ccu_ids[] = { 82362306a36Sopenharmony_ci { .compatible = "allwinner,sun8i-a33-ccu" }, 82462306a36Sopenharmony_ci { } 82562306a36Sopenharmony_ci}; 82662306a36Sopenharmony_ci 82762306a36Sopenharmony_cistatic struct platform_driver sun8i_a33_ccu_driver = { 82862306a36Sopenharmony_ci .probe = sun8i_a33_ccu_probe, 82962306a36Sopenharmony_ci .driver = { 83062306a36Sopenharmony_ci .name = "sun8i-a33-ccu", 83162306a36Sopenharmony_ci .suppress_bind_attrs = true, 83262306a36Sopenharmony_ci .of_match_table = sun8i_a33_ccu_ids, 83362306a36Sopenharmony_ci }, 83462306a36Sopenharmony_ci}; 83562306a36Sopenharmony_cimodule_platform_driver(sun8i_a33_ccu_driver); 83662306a36Sopenharmony_ci 83762306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU); 83862306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 839