162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2017 Chen-Yu Tsai. 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_mux.h" 1862306a36Sopenharmony_ci#include "ccu_nkmp.h" 1962306a36Sopenharmony_ci#include "ccu_nm.h" 2062306a36Sopenharmony_ci#include "ccu_phase.h" 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#include "ccu-sun8i-a83t.h" 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#define CCU_SUN8I_A83T_LOCK_REG 0x20c 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * The CPU PLLs are actually NP clocks, with P being /1 or /4. However 2862306a36Sopenharmony_ci * P should only be used for output frequencies lower than 228 MHz. 2962306a36Sopenharmony_ci * Neither mainline Linux, U-boot, nor the vendor BSPs use these. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * For now we can just model it as a multiplier clock, and force P to /1. 3262306a36Sopenharmony_ci */ 3362306a36Sopenharmony_ci#define SUN8I_A83T_PLL_C0CPUX_REG 0x000 3462306a36Sopenharmony_ci#define SUN8I_A83T_PLL_C1CPUX_REG 0x004 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic struct ccu_mult pll_c0cpux_clk = { 3762306a36Sopenharmony_ci .enable = BIT(31), 3862306a36Sopenharmony_ci .lock = BIT(0), 3962306a36Sopenharmony_ci .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 4062306a36Sopenharmony_ci .common = { 4162306a36Sopenharmony_ci .reg = SUN8I_A83T_PLL_C0CPUX_REG, 4262306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 4362306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 4462306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-c0cpux", "osc24M", 4562306a36Sopenharmony_ci &ccu_mult_ops, 4662306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 4762306a36Sopenharmony_ci }, 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic struct ccu_mult pll_c1cpux_clk = { 5162306a36Sopenharmony_ci .enable = BIT(31), 5262306a36Sopenharmony_ci .lock = BIT(1), 5362306a36Sopenharmony_ci .mult = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 5462306a36Sopenharmony_ci .common = { 5562306a36Sopenharmony_ci .reg = SUN8I_A83T_PLL_C1CPUX_REG, 5662306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 5762306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 5862306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-c1cpux", "osc24M", 5962306a36Sopenharmony_ci &ccu_mult_ops, 6062306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 6162306a36Sopenharmony_ci }, 6262306a36Sopenharmony_ci}; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* 6562306a36Sopenharmony_ci * The Audio PLL has d1, d2 dividers in addition to the usual N, M 6662306a36Sopenharmony_ci * factors. Since we only need 2 frequencies from this PLL: 22.5792 MHz 6762306a36Sopenharmony_ci * and 24.576 MHz, ignore them for now. Enforce the default for them, 6862306a36Sopenharmony_ci * which is d1 = 0, d2 = 1. 6962306a36Sopenharmony_ci */ 7062306a36Sopenharmony_ci#define SUN8I_A83T_PLL_AUDIO_REG 0x008 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* clock rates doubled for post divider */ 7362306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = { 7462306a36Sopenharmony_ci { .rate = 45158400, .pattern = 0xc00121ff, .m = 29, .n = 54 }, 7562306a36Sopenharmony_ci { .rate = 49152000, .pattern = 0xc000e147, .m = 30, .n = 61 }, 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistatic struct ccu_nm pll_audio_clk = { 7962306a36Sopenharmony_ci .enable = BIT(31), 8062306a36Sopenharmony_ci .lock = BIT(2), 8162306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 8262306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(0, 6), 8362306a36Sopenharmony_ci .fixed_post_div = 2, 8462306a36Sopenharmony_ci .sdm = _SUNXI_CCU_SDM(pll_audio_sdm_table, BIT(24), 8562306a36Sopenharmony_ci 0x284, BIT(31)), 8662306a36Sopenharmony_ci .common = { 8762306a36Sopenharmony_ci .reg = SUN8I_A83T_PLL_AUDIO_REG, 8862306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 8962306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG | 9062306a36Sopenharmony_ci CCU_FEATURE_FIXED_POSTDIV | 9162306a36Sopenharmony_ci CCU_FEATURE_SIGMA_DELTA_MOD, 9262306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-audio", "osc24M", 9362306a36Sopenharmony_ci &ccu_nm_ops, CLK_SET_RATE_UNGATE), 9462306a36Sopenharmony_ci }, 9562306a36Sopenharmony_ci}; 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* Some PLLs are input * N / div1 / P. Model them as NKMP with no K */ 9862306a36Sopenharmony_cistatic struct ccu_nkmp pll_video0_clk = { 9962306a36Sopenharmony_ci .enable = BIT(31), 10062306a36Sopenharmony_ci .lock = BIT(3), 10162306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 10262306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 10362306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(0, 2), /* output divider */ 10462306a36Sopenharmony_ci .max_rate = 3000000000UL, 10562306a36Sopenharmony_ci .common = { 10662306a36Sopenharmony_ci .reg = 0x010, 10762306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 10862306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 10962306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-video0", "osc24M", 11062306a36Sopenharmony_ci &ccu_nkmp_ops, 11162306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 11262306a36Sopenharmony_ci }, 11362306a36Sopenharmony_ci}; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cistatic struct ccu_nkmp pll_ve_clk = { 11662306a36Sopenharmony_ci .enable = BIT(31), 11762306a36Sopenharmony_ci .lock = BIT(4), 11862306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 11962306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 12062306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 12162306a36Sopenharmony_ci .common = { 12262306a36Sopenharmony_ci .reg = 0x018, 12362306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 12462306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 12562306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-ve", "osc24M", 12662306a36Sopenharmony_ci &ccu_nkmp_ops, 12762306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 12862306a36Sopenharmony_ci }, 12962306a36Sopenharmony_ci}; 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cistatic struct ccu_nkmp pll_ddr_clk = { 13262306a36Sopenharmony_ci .enable = BIT(31), 13362306a36Sopenharmony_ci .lock = BIT(5), 13462306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_MIN(8, 8, 12), 13562306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 13662306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 13762306a36Sopenharmony_ci .common = { 13862306a36Sopenharmony_ci .reg = 0x020, 13962306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 14062306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 14162306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-ddr", "osc24M", 14262306a36Sopenharmony_ci &ccu_nkmp_ops, 14362306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 14462306a36Sopenharmony_ci }, 14562306a36Sopenharmony_ci}; 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_cistatic struct ccu_nkmp pll_periph_clk = { 14862306a36Sopenharmony_ci .enable = BIT(31), 14962306a36Sopenharmony_ci .lock = BIT(6), 15062306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 15162306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 15262306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 15362306a36Sopenharmony_ci .common = { 15462306a36Sopenharmony_ci .reg = 0x028, 15562306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 15662306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 15762306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-periph", "osc24M", 15862306a36Sopenharmony_ci &ccu_nkmp_ops, 15962306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 16062306a36Sopenharmony_ci }, 16162306a36Sopenharmony_ci}; 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_cistatic struct ccu_nkmp pll_gpu_clk = { 16462306a36Sopenharmony_ci .enable = BIT(31), 16562306a36Sopenharmony_ci .lock = BIT(7), 16662306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 16762306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 16862306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 16962306a36Sopenharmony_ci .common = { 17062306a36Sopenharmony_ci .reg = 0x038, 17162306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 17262306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 17362306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-gpu", "osc24M", 17462306a36Sopenharmony_ci &ccu_nkmp_ops, 17562306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 17662306a36Sopenharmony_ci }, 17762306a36Sopenharmony_ci}; 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_cistatic struct ccu_nkmp pll_hsic_clk = { 18062306a36Sopenharmony_ci .enable = BIT(31), 18162306a36Sopenharmony_ci .lock = BIT(8), 18262306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 18362306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 18462306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 18562306a36Sopenharmony_ci .common = { 18662306a36Sopenharmony_ci .reg = 0x044, 18762306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 18862306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 18962306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-hsic", "osc24M", 19062306a36Sopenharmony_ci &ccu_nkmp_ops, 19162306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 19262306a36Sopenharmony_ci }, 19362306a36Sopenharmony_ci}; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_cistatic struct ccu_nkmp pll_de_clk = { 19662306a36Sopenharmony_ci .enable = BIT(31), 19762306a36Sopenharmony_ci .lock = BIT(9), 19862306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 19962306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 20062306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(18, 1), /* output divider */ 20162306a36Sopenharmony_ci .common = { 20262306a36Sopenharmony_ci .reg = 0x048, 20362306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 20462306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 20562306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-de", "osc24M", 20662306a36Sopenharmony_ci &ccu_nkmp_ops, 20762306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 20862306a36Sopenharmony_ci }, 20962306a36Sopenharmony_ci}; 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cistatic struct ccu_nkmp pll_video1_clk = { 21262306a36Sopenharmony_ci .enable = BIT(31), 21362306a36Sopenharmony_ci .lock = BIT(10), 21462306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT_OFFSET_MIN_MAX(8, 8, 0, 12, 0), 21562306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(16, 1), /* input divider */ 21662306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV(0, 2), /* external divider p */ 21762306a36Sopenharmony_ci .max_rate = 3000000000UL, 21862306a36Sopenharmony_ci .common = { 21962306a36Sopenharmony_ci .reg = 0x04c, 22062306a36Sopenharmony_ci .lock_reg = CCU_SUN8I_A83T_LOCK_REG, 22162306a36Sopenharmony_ci .features = CCU_FEATURE_LOCK_REG, 22262306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-video1", "osc24M", 22362306a36Sopenharmony_ci &ccu_nkmp_ops, 22462306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 22562306a36Sopenharmony_ci }, 22662306a36Sopenharmony_ci}; 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_cistatic const char * const c0cpux_parents[] = { "osc24M", "pll-c0cpux" }; 22962306a36Sopenharmony_cistatic SUNXI_CCU_MUX(c0cpux_clk, "c0cpux", c0cpux_parents, 23062306a36Sopenharmony_ci 0x50, 12, 1, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_cistatic const char * const c1cpux_parents[] = { "osc24M", "pll-c1cpux" }; 23362306a36Sopenharmony_cistatic SUNXI_CCU_MUX(c1cpux_clk, "c1cpux", c1cpux_parents, 23462306a36Sopenharmony_ci 0x50, 28, 1, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_cistatic SUNXI_CCU_M(axi0_clk, "axi0", "c0cpux", 0x050, 0, 2, 0); 23762306a36Sopenharmony_cistatic SUNXI_CCU_M(axi1_clk, "axi1", "c1cpux", 0x050, 16, 2, 0); 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc16M-d512", "osc24M", 24062306a36Sopenharmony_ci "pll-periph", 24162306a36Sopenharmony_ci "pll-periph" }; 24262306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = { 24362306a36Sopenharmony_ci { .index = 2, .shift = 6, .width = 2 }, 24462306a36Sopenharmony_ci { .index = 3, .shift = 6, .width = 2 }, 24562306a36Sopenharmony_ci}; 24662306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = { 24762306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 24862306a36Sopenharmony_ci .mux = { 24962306a36Sopenharmony_ci .shift = 12, 25062306a36Sopenharmony_ci .width = 2, 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ci .var_predivs = ahb1_predivs, 25362306a36Sopenharmony_ci .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 25462306a36Sopenharmony_ci }, 25562306a36Sopenharmony_ci .common = { 25662306a36Sopenharmony_ci .reg = 0x054, 25762306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb1", 25862306a36Sopenharmony_ci ahb1_parents, 25962306a36Sopenharmony_ci &ccu_div_ops, 26062306a36Sopenharmony_ci 0), 26162306a36Sopenharmony_ci }, 26262306a36Sopenharmony_ci}; 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_cistatic SUNXI_CCU_M(apb1_clk, "apb1", "ahb1", 0x054, 8, 2, 0); 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc16M-d512", "osc24M", 26762306a36Sopenharmony_ci "pll-periph", "pll-periph" }; 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 27062306a36Sopenharmony_ci 0, 5, /* M */ 27162306a36Sopenharmony_ci 16, 2, /* P */ 27262306a36Sopenharmony_ci 24, 2, /* mux */ 27362306a36Sopenharmony_ci 0); 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_cistatic const char * const ahb2_parents[] = { "ahb1", "pll-periph" }; 27662306a36Sopenharmony_cistatic const struct ccu_mux_fixed_prediv ahb2_prediv = { 27762306a36Sopenharmony_ci .index = 1, .div = 2 27862306a36Sopenharmony_ci}; 27962306a36Sopenharmony_cistatic struct ccu_mux ahb2_clk = { 28062306a36Sopenharmony_ci .mux = { 28162306a36Sopenharmony_ci .shift = 0, 28262306a36Sopenharmony_ci .width = 2, 28362306a36Sopenharmony_ci .fixed_predivs = &ahb2_prediv, 28462306a36Sopenharmony_ci .n_predivs = 1, 28562306a36Sopenharmony_ci }, 28662306a36Sopenharmony_ci .common = { 28762306a36Sopenharmony_ci .reg = 0x05c, 28862306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb2", 28962306a36Sopenharmony_ci ahb2_parents, 29062306a36Sopenharmony_ci &ccu_mux_ops, 29162306a36Sopenharmony_ci 0), 29262306a36Sopenharmony_ci }, 29362306a36Sopenharmony_ci}; 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb1", 29662306a36Sopenharmony_ci 0x060, BIT(1), 0); 29762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ss_clk, "bus-ss", "ahb1", 29862306a36Sopenharmony_ci 0x060, BIT(5), 0); 29962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 30062306a36Sopenharmony_ci 0x060, BIT(6), 0); 30162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 30262306a36Sopenharmony_ci 0x060, BIT(8), 0); 30362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 30462306a36Sopenharmony_ci 0x060, BIT(9), 0); 30562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 30662306a36Sopenharmony_ci 0x060, BIT(10), 0); 30762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1", 30862306a36Sopenharmony_ci 0x060, BIT(13), 0); 30962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 31062306a36Sopenharmony_ci 0x060, BIT(14), 0); 31162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2", 31262306a36Sopenharmony_ci 0x060, BIT(17), 0); 31362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 31462306a36Sopenharmony_ci 0x060, BIT(19), 0); 31562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 31662306a36Sopenharmony_ci 0x060, BIT(20), 0); 31762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1", 31862306a36Sopenharmony_ci 0x060, BIT(21), 0); 31962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 32062306a36Sopenharmony_ci 0x060, BIT(24), 0); 32162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb2", 32262306a36Sopenharmony_ci 0x060, BIT(26), 0); 32362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb2", 32462306a36Sopenharmony_ci 0x060, BIT(27), 0); 32562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb2", 32662306a36Sopenharmony_ci 0x060, BIT(29), 0); 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 32962306a36Sopenharmony_ci 0x064, BIT(0), 0); 33062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1", 33162306a36Sopenharmony_ci 0x064, BIT(4), 0); 33262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon1_clk, "bus-tcon1", "ahb1", 33362306a36Sopenharmony_ci 0x064, BIT(5), 0); 33462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1", 33562306a36Sopenharmony_ci 0x064, BIT(8), 0); 33662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb1", 33762306a36Sopenharmony_ci 0x064, BIT(11), 0); 33862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 33962306a36Sopenharmony_ci 0x064, BIT(12), 0); 34062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 34162306a36Sopenharmony_ci 0x064, BIT(20), 0); 34262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", 34362306a36Sopenharmony_ci 0x064, BIT(21), 0); 34462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 34562306a36Sopenharmony_ci 0x064, BIT(22), 0); 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1", 34862306a36Sopenharmony_ci 0x068, BIT(1), 0); 34962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 35062306a36Sopenharmony_ci 0x068, BIT(5), 0); 35162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 35262306a36Sopenharmony_ci 0x068, BIT(12), 0); 35362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 35462306a36Sopenharmony_ci 0x068, BIT(13), 0); 35562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1", 35662306a36Sopenharmony_ci 0x068, BIT(14), 0); 35762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tdm_clk, "bus-tdm", "apb1", 35862306a36Sopenharmony_ci 0x068, BIT(15), 0); 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 36162306a36Sopenharmony_ci 0x06c, BIT(0), 0); 36262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 36362306a36Sopenharmony_ci 0x06c, BIT(1), 0); 36462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 36562306a36Sopenharmony_ci 0x06c, BIT(2), 0); 36662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 36762306a36Sopenharmony_ci 0x06c, BIT(16), 0); 36862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 36962306a36Sopenharmony_ci 0x06c, BIT(17), 0); 37062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 37162306a36Sopenharmony_ci 0x06c, BIT(18), 0); 37262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 37362306a36Sopenharmony_ci 0x06c, BIT(19), 0); 37462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2", 37562306a36Sopenharmony_ci 0x06c, BIT(20), 0); 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_cistatic const char * const cci400_parents[] = { "osc24M", "pll-periph", 37862306a36Sopenharmony_ci "pll-hsic" }; 37962306a36Sopenharmony_cistatic struct ccu_div cci400_clk = { 38062306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_FLAGS(0, 2, 0), 38162306a36Sopenharmony_ci .mux = _SUNXI_CCU_MUX(24, 2), 38262306a36Sopenharmony_ci .common = { 38362306a36Sopenharmony_ci .reg = 0x078, 38462306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("cci400", 38562306a36Sopenharmony_ci cci400_parents, 38662306a36Sopenharmony_ci &ccu_div_ops, 38762306a36Sopenharmony_ci CLK_IS_CRITICAL), 38862306a36Sopenharmony_ci }, 38962306a36Sopenharmony_ci}; 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph" }; 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 39462306a36Sopenharmony_ci 0x080, 39562306a36Sopenharmony_ci 0, 4, /* M */ 39662306a36Sopenharmony_ci 16, 2, /* P */ 39762306a36Sopenharmony_ci 24, 2, /* mux */ 39862306a36Sopenharmony_ci BIT(31), /* gate */ 39962306a36Sopenharmony_ci 0); 40062306a36Sopenharmony_ci 40162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 40262306a36Sopenharmony_ci 0x088, 40362306a36Sopenharmony_ci 0, 4, /* M */ 40462306a36Sopenharmony_ci 16, 2, /* P */ 40562306a36Sopenharmony_ci 24, 2, /* mux */ 40662306a36Sopenharmony_ci BIT(31), /* gate */ 40762306a36Sopenharmony_ci 0); 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0-sample", "mmc0", 41062306a36Sopenharmony_ci 0x088, 20, 3, 0); 41162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0-output", "mmc0", 41262306a36Sopenharmony_ci 0x088, 8, 3, 0); 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 41562306a36Sopenharmony_ci 0x08c, 41662306a36Sopenharmony_ci 0, 4, /* M */ 41762306a36Sopenharmony_ci 16, 2, /* P */ 41862306a36Sopenharmony_ci 24, 2, /* mux */ 41962306a36Sopenharmony_ci BIT(31), /* gate */ 42062306a36Sopenharmony_ci 0); 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1-sample", "mmc1", 42362306a36Sopenharmony_ci 0x08c, 20, 3, 0); 42462306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1-output", "mmc1", 42562306a36Sopenharmony_ci 0x08c, 8, 3, 0); 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_cistatic SUNXI_CCU_MP_MMC_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 42862306a36Sopenharmony_ci 0x090, 0); 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2-sample", "mmc2", 43162306a36Sopenharmony_ci 0x090, 20, 3, 0); 43262306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2-output", "mmc2", 43362306a36Sopenharmony_ci 0x090, 8, 3, 0); 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ss_clk, "ss", mod0_default_parents, 43662306a36Sopenharmony_ci 0x09c, 43762306a36Sopenharmony_ci 0, 4, /* M */ 43862306a36Sopenharmony_ci 16, 2, /* P */ 43962306a36Sopenharmony_ci 24, 2, /* mux */ 44062306a36Sopenharmony_ci BIT(31), /* gate */ 44162306a36Sopenharmony_ci 0); 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 44462306a36Sopenharmony_ci 0x0a0, 44562306a36Sopenharmony_ci 0, 4, /* M */ 44662306a36Sopenharmony_ci 16, 2, /* P */ 44762306a36Sopenharmony_ci 24, 4, /* mux */ 44862306a36Sopenharmony_ci BIT(31), /* gate */ 44962306a36Sopenharmony_ci 0); 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 45262306a36Sopenharmony_ci 0x0a4, 45362306a36Sopenharmony_ci 0, 4, /* M */ 45462306a36Sopenharmony_ci 16, 2, /* P */ 45562306a36Sopenharmony_ci 24, 4, /* mux */ 45662306a36Sopenharmony_ci BIT(31), /* gate */ 45762306a36Sopenharmony_ci 0); 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(i2s0_clk, "i2s0", "pll-audio", 46062306a36Sopenharmony_ci 0x0b0, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 46162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(i2s1_clk, "i2s1", "pll-audio", 46262306a36Sopenharmony_ci 0x0b4, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 46362306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(i2s2_clk, "i2s2", "pll-audio", 46462306a36Sopenharmony_ci 0x0b8, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 46562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(tdm_clk, "tdm", "pll-audio", 46662306a36Sopenharmony_ci 0x0bc, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 46762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio", 46862306a36Sopenharmony_ci 0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 47162306a36Sopenharmony_ci 0x0cc, BIT(8), 0); 47262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M", 47362306a36Sopenharmony_ci 0x0cc, BIT(9), 0); 47462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_clk, "usb-hsic", "pll-hsic", 47562306a36Sopenharmony_ci 0x0cc, BIT(10), 0); 47662306a36Sopenharmony_cistatic struct ccu_gate usb_hsic_12m_clk = { 47762306a36Sopenharmony_ci .enable = BIT(11), 47862306a36Sopenharmony_ci .common = { 47962306a36Sopenharmony_ci .reg = 0x0cc, 48062306a36Sopenharmony_ci .prediv = 2, 48162306a36Sopenharmony_ci .features = CCU_FEATURE_ALL_PREDIV, 48262306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("usb-hsic-12m", "osc24M", 48362306a36Sopenharmony_ci &ccu_gate_ops, 0), 48462306a36Sopenharmony_ci } 48562306a36Sopenharmony_ci}; 48662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc24M", 48762306a36Sopenharmony_ci 0x0cc, BIT(16), 0); 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_ci/* TODO divider has minimum of 2 */ 49062306a36Sopenharmony_cistatic SUNXI_CCU_M(dram_clk, "dram", "pll-ddr", 0x0f4, 0, 4, CLK_IS_CRITICAL); 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 49362306a36Sopenharmony_ci 0x100, BIT(0), 0); 49462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram", 49562306a36Sopenharmony_ci 0x100, BIT(1), 0); 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_cistatic const char * const tcon0_parents[] = { "pll-video0" }; 49862306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents, 49962306a36Sopenharmony_ci 0x118, 24, 3, BIT(31), CLK_SET_RATE_PARENT); 50062306a36Sopenharmony_ci 50162306a36Sopenharmony_cistatic const char * const tcon1_parents[] = { "pll-video1" }; 50262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon1_clk, "tcon1", tcon1_parents, 50362306a36Sopenharmony_ci 0x11c, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT); 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M", 0x130, BIT(16), 0); 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mipi_csi_clk, "mipi-csi", "osc24M", 0x130, BIT(31), 0); 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "pll-video0", "pll-de", 51062306a36Sopenharmony_ci "osc24M" }; 51162306a36Sopenharmony_cistatic const u8 csi_mclk_table[] = { 0, 3, 5 }; 51262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_mclk_clk, "csi-mclk", 51362306a36Sopenharmony_ci csi_mclk_parents, csi_mclk_table, 51462306a36Sopenharmony_ci 0x134, 51562306a36Sopenharmony_ci 0, 5, /* M */ 51662306a36Sopenharmony_ci 8, 3, /* mux */ 51762306a36Sopenharmony_ci BIT(15), /* gate */ 51862306a36Sopenharmony_ci 0); 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-periph", "pll-ve" }; 52162306a36Sopenharmony_cistatic const u8 csi_sclk_table[] = { 0, 5 }; 52262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_sclk_clk, "csi-sclk", 52362306a36Sopenharmony_ci csi_sclk_parents, csi_sclk_table, 52462306a36Sopenharmony_ci 0x134, 52562306a36Sopenharmony_ci 16, 4, /* M */ 52662306a36Sopenharmony_ci 24, 3, /* mux */ 52762306a36Sopenharmony_ci BIT(31), /* gate */ 52862306a36Sopenharmony_ci 0); 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 0x13c, 53162306a36Sopenharmony_ci 16, 3, BIT(31), CLK_SET_RATE_PARENT); 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 0x144, BIT(31), 0); 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_cistatic const char * const hdmi_parents[] = { "pll-video1" }; 53662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents, 53762306a36Sopenharmony_ci 0x150, 53862306a36Sopenharmony_ci 0, 4, /* M */ 53962306a36Sopenharmony_ci 24, 2, /* mux */ 54062306a36Sopenharmony_ci BIT(31), /* gate */ 54162306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(hdmi_slow_clk, "hdmi-slow", "osc24M", 0x154, BIT(31), 0); 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph", 54662306a36Sopenharmony_ci "pll-ddr" }; 54762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 54862306a36Sopenharmony_ci 0x15c, 54962306a36Sopenharmony_ci 0, 3, /* M */ 55062306a36Sopenharmony_ci 24, 2, /* mux */ 55162306a36Sopenharmony_ci BIT(31), /* gate */ 55262306a36Sopenharmony_ci CLK_IS_CRITICAL); 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_cistatic const char * const mipi_dsi0_parents[] = { "pll-video0" }; 55562306a36Sopenharmony_cistatic const u8 mipi_dsi0_table[] = { 8 }; 55662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(mipi_dsi0_clk, "mipi-dsi0", 55762306a36Sopenharmony_ci mipi_dsi0_parents, mipi_dsi0_table, 55862306a36Sopenharmony_ci 0x168, 55962306a36Sopenharmony_ci 0, 4, /* M */ 56062306a36Sopenharmony_ci 24, 4, /* mux */ 56162306a36Sopenharmony_ci BIT(31), /* gate */ 56262306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 56362306a36Sopenharmony_ci 56462306a36Sopenharmony_cistatic const char * const mipi_dsi1_parents[] = { "osc24M", "pll-video0" }; 56562306a36Sopenharmony_cistatic const u8 mipi_dsi1_table[] = { 0, 9 }; 56662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(mipi_dsi1_clk, "mipi-dsi1", 56762306a36Sopenharmony_ci mipi_dsi1_parents, mipi_dsi1_table, 56862306a36Sopenharmony_ci 0x16c, 56962306a36Sopenharmony_ci 0, 4, /* M */ 57062306a36Sopenharmony_ci 24, 4, /* mux */ 57162306a36Sopenharmony_ci BIT(31), /* gate */ 57262306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 57362306a36Sopenharmony_ci 57462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_core_clk, "gpu-core", "pll-gpu", 0x1a0, 57562306a36Sopenharmony_ci 0, 3, BIT(31), CLK_SET_RATE_PARENT); 57662306a36Sopenharmony_ci 57762306a36Sopenharmony_cistatic const char * const gpu_memory_parents[] = { "pll-gpu", "pll-ddr" }; 57862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(gpu_memory_clk, "gpu-memory", 57962306a36Sopenharmony_ci gpu_memory_parents, 58062306a36Sopenharmony_ci 0x1a4, 58162306a36Sopenharmony_ci 0, 3, /* M */ 58262306a36Sopenharmony_ci 24, 1, /* mux */ 58362306a36Sopenharmony_ci BIT(31), /* gate */ 58462306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_hyd_clk, "gpu-hyd", "pll-gpu", 0x1a8, 58762306a36Sopenharmony_ci 0, 3, BIT(31), CLK_SET_RATE_PARENT); 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_cistatic struct ccu_common *sun8i_a83t_ccu_clks[] = { 59062306a36Sopenharmony_ci &pll_c0cpux_clk.common, 59162306a36Sopenharmony_ci &pll_c1cpux_clk.common, 59262306a36Sopenharmony_ci &pll_audio_clk.common, 59362306a36Sopenharmony_ci &pll_video0_clk.common, 59462306a36Sopenharmony_ci &pll_ve_clk.common, 59562306a36Sopenharmony_ci &pll_ddr_clk.common, 59662306a36Sopenharmony_ci &pll_periph_clk.common, 59762306a36Sopenharmony_ci &pll_gpu_clk.common, 59862306a36Sopenharmony_ci &pll_hsic_clk.common, 59962306a36Sopenharmony_ci &pll_de_clk.common, 60062306a36Sopenharmony_ci &pll_video1_clk.common, 60162306a36Sopenharmony_ci &c0cpux_clk.common, 60262306a36Sopenharmony_ci &c1cpux_clk.common, 60362306a36Sopenharmony_ci &axi0_clk.common, 60462306a36Sopenharmony_ci &axi1_clk.common, 60562306a36Sopenharmony_ci &ahb1_clk.common, 60662306a36Sopenharmony_ci &ahb2_clk.common, 60762306a36Sopenharmony_ci &apb1_clk.common, 60862306a36Sopenharmony_ci &apb2_clk.common, 60962306a36Sopenharmony_ci &bus_mipi_dsi_clk.common, 61062306a36Sopenharmony_ci &bus_ss_clk.common, 61162306a36Sopenharmony_ci &bus_dma_clk.common, 61262306a36Sopenharmony_ci &bus_mmc0_clk.common, 61362306a36Sopenharmony_ci &bus_mmc1_clk.common, 61462306a36Sopenharmony_ci &bus_mmc2_clk.common, 61562306a36Sopenharmony_ci &bus_nand_clk.common, 61662306a36Sopenharmony_ci &bus_dram_clk.common, 61762306a36Sopenharmony_ci &bus_emac_clk.common, 61862306a36Sopenharmony_ci &bus_hstimer_clk.common, 61962306a36Sopenharmony_ci &bus_spi0_clk.common, 62062306a36Sopenharmony_ci &bus_spi1_clk.common, 62162306a36Sopenharmony_ci &bus_otg_clk.common, 62262306a36Sopenharmony_ci &bus_ehci0_clk.common, 62362306a36Sopenharmony_ci &bus_ehci1_clk.common, 62462306a36Sopenharmony_ci &bus_ohci0_clk.common, 62562306a36Sopenharmony_ci &bus_ve_clk.common, 62662306a36Sopenharmony_ci &bus_tcon0_clk.common, 62762306a36Sopenharmony_ci &bus_tcon1_clk.common, 62862306a36Sopenharmony_ci &bus_csi_clk.common, 62962306a36Sopenharmony_ci &bus_hdmi_clk.common, 63062306a36Sopenharmony_ci &bus_de_clk.common, 63162306a36Sopenharmony_ci &bus_gpu_clk.common, 63262306a36Sopenharmony_ci &bus_msgbox_clk.common, 63362306a36Sopenharmony_ci &bus_spinlock_clk.common, 63462306a36Sopenharmony_ci &bus_spdif_clk.common, 63562306a36Sopenharmony_ci &bus_pio_clk.common, 63662306a36Sopenharmony_ci &bus_i2s0_clk.common, 63762306a36Sopenharmony_ci &bus_i2s1_clk.common, 63862306a36Sopenharmony_ci &bus_i2s2_clk.common, 63962306a36Sopenharmony_ci &bus_tdm_clk.common, 64062306a36Sopenharmony_ci &bus_i2c0_clk.common, 64162306a36Sopenharmony_ci &bus_i2c1_clk.common, 64262306a36Sopenharmony_ci &bus_i2c2_clk.common, 64362306a36Sopenharmony_ci &bus_uart0_clk.common, 64462306a36Sopenharmony_ci &bus_uart1_clk.common, 64562306a36Sopenharmony_ci &bus_uart2_clk.common, 64662306a36Sopenharmony_ci &bus_uart3_clk.common, 64762306a36Sopenharmony_ci &bus_uart4_clk.common, 64862306a36Sopenharmony_ci &cci400_clk.common, 64962306a36Sopenharmony_ci &nand_clk.common, 65062306a36Sopenharmony_ci &mmc0_clk.common, 65162306a36Sopenharmony_ci &mmc0_sample_clk.common, 65262306a36Sopenharmony_ci &mmc0_output_clk.common, 65362306a36Sopenharmony_ci &mmc1_clk.common, 65462306a36Sopenharmony_ci &mmc1_sample_clk.common, 65562306a36Sopenharmony_ci &mmc1_output_clk.common, 65662306a36Sopenharmony_ci &mmc2_clk.common, 65762306a36Sopenharmony_ci &mmc2_sample_clk.common, 65862306a36Sopenharmony_ci &mmc2_output_clk.common, 65962306a36Sopenharmony_ci &ss_clk.common, 66062306a36Sopenharmony_ci &spi0_clk.common, 66162306a36Sopenharmony_ci &spi1_clk.common, 66262306a36Sopenharmony_ci &i2s0_clk.common, 66362306a36Sopenharmony_ci &i2s1_clk.common, 66462306a36Sopenharmony_ci &i2s2_clk.common, 66562306a36Sopenharmony_ci &tdm_clk.common, 66662306a36Sopenharmony_ci &spdif_clk.common, 66762306a36Sopenharmony_ci &usb_phy0_clk.common, 66862306a36Sopenharmony_ci &usb_phy1_clk.common, 66962306a36Sopenharmony_ci &usb_hsic_clk.common, 67062306a36Sopenharmony_ci &usb_hsic_12m_clk.common, 67162306a36Sopenharmony_ci &usb_ohci0_clk.common, 67262306a36Sopenharmony_ci &dram_clk.common, 67362306a36Sopenharmony_ci &dram_ve_clk.common, 67462306a36Sopenharmony_ci &dram_csi_clk.common, 67562306a36Sopenharmony_ci &tcon0_clk.common, 67662306a36Sopenharmony_ci &tcon1_clk.common, 67762306a36Sopenharmony_ci &csi_misc_clk.common, 67862306a36Sopenharmony_ci &mipi_csi_clk.common, 67962306a36Sopenharmony_ci &csi_mclk_clk.common, 68062306a36Sopenharmony_ci &csi_sclk_clk.common, 68162306a36Sopenharmony_ci &ve_clk.common, 68262306a36Sopenharmony_ci &avs_clk.common, 68362306a36Sopenharmony_ci &hdmi_clk.common, 68462306a36Sopenharmony_ci &hdmi_slow_clk.common, 68562306a36Sopenharmony_ci &mbus_clk.common, 68662306a36Sopenharmony_ci &mipi_dsi0_clk.common, 68762306a36Sopenharmony_ci &mipi_dsi1_clk.common, 68862306a36Sopenharmony_ci &gpu_core_clk.common, 68962306a36Sopenharmony_ci &gpu_memory_clk.common, 69062306a36Sopenharmony_ci &gpu_hyd_clk.common, 69162306a36Sopenharmony_ci}; 69262306a36Sopenharmony_ci 69362306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_a83t_hw_clks = { 69462306a36Sopenharmony_ci .hws = { 69562306a36Sopenharmony_ci [CLK_PLL_C0CPUX] = &pll_c0cpux_clk.common.hw, 69662306a36Sopenharmony_ci [CLK_PLL_C1CPUX] = &pll_c1cpux_clk.common.hw, 69762306a36Sopenharmony_ci [CLK_PLL_AUDIO] = &pll_audio_clk.common.hw, 69862306a36Sopenharmony_ci [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw, 69962306a36Sopenharmony_ci [CLK_PLL_VE] = &pll_ve_clk.common.hw, 70062306a36Sopenharmony_ci [CLK_PLL_DDR] = &pll_ddr_clk.common.hw, 70162306a36Sopenharmony_ci [CLK_PLL_PERIPH] = &pll_periph_clk.common.hw, 70262306a36Sopenharmony_ci [CLK_PLL_GPU] = &pll_gpu_clk.common.hw, 70362306a36Sopenharmony_ci [CLK_PLL_HSIC] = &pll_hsic_clk.common.hw, 70462306a36Sopenharmony_ci [CLK_PLL_DE] = &pll_de_clk.common.hw, 70562306a36Sopenharmony_ci [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw, 70662306a36Sopenharmony_ci [CLK_C0CPUX] = &c0cpux_clk.common.hw, 70762306a36Sopenharmony_ci [CLK_C1CPUX] = &c1cpux_clk.common.hw, 70862306a36Sopenharmony_ci [CLK_AXI0] = &axi0_clk.common.hw, 70962306a36Sopenharmony_ci [CLK_AXI1] = &axi1_clk.common.hw, 71062306a36Sopenharmony_ci [CLK_AHB1] = &ahb1_clk.common.hw, 71162306a36Sopenharmony_ci [CLK_AHB2] = &ahb2_clk.common.hw, 71262306a36Sopenharmony_ci [CLK_APB1] = &apb1_clk.common.hw, 71362306a36Sopenharmony_ci [CLK_APB2] = &apb2_clk.common.hw, 71462306a36Sopenharmony_ci [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw, 71562306a36Sopenharmony_ci [CLK_BUS_SS] = &bus_ss_clk.common.hw, 71662306a36Sopenharmony_ci [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 71762306a36Sopenharmony_ci [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 71862306a36Sopenharmony_ci [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 71962306a36Sopenharmony_ci [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 72062306a36Sopenharmony_ci [CLK_BUS_NAND] = &bus_nand_clk.common.hw, 72162306a36Sopenharmony_ci [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 72262306a36Sopenharmony_ci [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 72362306a36Sopenharmony_ci [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 72462306a36Sopenharmony_ci [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 72562306a36Sopenharmony_ci [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw, 72662306a36Sopenharmony_ci [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 72762306a36Sopenharmony_ci [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 72862306a36Sopenharmony_ci [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw, 72962306a36Sopenharmony_ci [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 73062306a36Sopenharmony_ci [CLK_BUS_VE] = &bus_ve_clk.common.hw, 73162306a36Sopenharmony_ci [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 73262306a36Sopenharmony_ci [CLK_BUS_TCON1] = &bus_tcon1_clk.common.hw, 73362306a36Sopenharmony_ci [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 73462306a36Sopenharmony_ci [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw, 73562306a36Sopenharmony_ci [CLK_BUS_DE] = &bus_de_clk.common.hw, 73662306a36Sopenharmony_ci [CLK_BUS_GPU] = &bus_gpu_clk.common.hw, 73762306a36Sopenharmony_ci [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw, 73862306a36Sopenharmony_ci [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw, 73962306a36Sopenharmony_ci [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw, 74062306a36Sopenharmony_ci [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 74162306a36Sopenharmony_ci [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 74262306a36Sopenharmony_ci [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw, 74362306a36Sopenharmony_ci [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw, 74462306a36Sopenharmony_ci [CLK_BUS_TDM] = &bus_tdm_clk.common.hw, 74562306a36Sopenharmony_ci [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 74662306a36Sopenharmony_ci [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 74762306a36Sopenharmony_ci [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw, 74862306a36Sopenharmony_ci [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 74962306a36Sopenharmony_ci [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 75062306a36Sopenharmony_ci [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 75162306a36Sopenharmony_ci [CLK_BUS_UART3] = &bus_uart3_clk.common.hw, 75262306a36Sopenharmony_ci [CLK_BUS_UART4] = &bus_uart4_clk.common.hw, 75362306a36Sopenharmony_ci [CLK_CCI400] = &cci400_clk.common.hw, 75462306a36Sopenharmony_ci [CLK_NAND] = &nand_clk.common.hw, 75562306a36Sopenharmony_ci [CLK_MMC0] = &mmc0_clk.common.hw, 75662306a36Sopenharmony_ci [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 75762306a36Sopenharmony_ci [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 75862306a36Sopenharmony_ci [CLK_MMC1] = &mmc1_clk.common.hw, 75962306a36Sopenharmony_ci [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 76062306a36Sopenharmony_ci [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 76162306a36Sopenharmony_ci [CLK_MMC2] = &mmc2_clk.common.hw, 76262306a36Sopenharmony_ci [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw, 76362306a36Sopenharmony_ci [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw, 76462306a36Sopenharmony_ci [CLK_SS] = &ss_clk.common.hw, 76562306a36Sopenharmony_ci [CLK_SPI0] = &spi0_clk.common.hw, 76662306a36Sopenharmony_ci [CLK_SPI1] = &spi1_clk.common.hw, 76762306a36Sopenharmony_ci [CLK_I2S0] = &i2s0_clk.common.hw, 76862306a36Sopenharmony_ci [CLK_I2S1] = &i2s1_clk.common.hw, 76962306a36Sopenharmony_ci [CLK_I2S2] = &i2s2_clk.common.hw, 77062306a36Sopenharmony_ci [CLK_TDM] = &tdm_clk.common.hw, 77162306a36Sopenharmony_ci [CLK_SPDIF] = &spdif_clk.common.hw, 77262306a36Sopenharmony_ci [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 77362306a36Sopenharmony_ci [CLK_USB_PHY1] = &usb_phy1_clk.common.hw, 77462306a36Sopenharmony_ci [CLK_USB_HSIC] = &usb_hsic_clk.common.hw, 77562306a36Sopenharmony_ci [CLK_USB_HSIC_12M] = &usb_hsic_12m_clk.common.hw, 77662306a36Sopenharmony_ci [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 77762306a36Sopenharmony_ci [CLK_DRAM] = &dram_clk.common.hw, 77862306a36Sopenharmony_ci [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 77962306a36Sopenharmony_ci [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 78062306a36Sopenharmony_ci [CLK_TCON0] = &tcon0_clk.common.hw, 78162306a36Sopenharmony_ci [CLK_TCON1] = &tcon1_clk.common.hw, 78262306a36Sopenharmony_ci [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 78362306a36Sopenharmony_ci [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw, 78462306a36Sopenharmony_ci [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw, 78562306a36Sopenharmony_ci [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw, 78662306a36Sopenharmony_ci [CLK_VE] = &ve_clk.common.hw, 78762306a36Sopenharmony_ci [CLK_AVS] = &avs_clk.common.hw, 78862306a36Sopenharmony_ci [CLK_HDMI] = &hdmi_clk.common.hw, 78962306a36Sopenharmony_ci [CLK_HDMI_SLOW] = &hdmi_slow_clk.common.hw, 79062306a36Sopenharmony_ci [CLK_MBUS] = &mbus_clk.common.hw, 79162306a36Sopenharmony_ci [CLK_MIPI_DSI0] = &mipi_dsi0_clk.common.hw, 79262306a36Sopenharmony_ci [CLK_MIPI_DSI1] = &mipi_dsi1_clk.common.hw, 79362306a36Sopenharmony_ci [CLK_GPU_CORE] = &gpu_core_clk.common.hw, 79462306a36Sopenharmony_ci [CLK_GPU_MEMORY] = &gpu_memory_clk.common.hw, 79562306a36Sopenharmony_ci [CLK_GPU_HYD] = &gpu_hyd_clk.common.hw, 79662306a36Sopenharmony_ci }, 79762306a36Sopenharmony_ci .num = CLK_NUMBER, 79862306a36Sopenharmony_ci}; 79962306a36Sopenharmony_ci 80062306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_a83t_ccu_resets[] = { 80162306a36Sopenharmony_ci [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 80262306a36Sopenharmony_ci [RST_USB_PHY1] = { 0x0cc, BIT(1) }, 80362306a36Sopenharmony_ci [RST_USB_HSIC] = { 0x0cc, BIT(2) }, 80462306a36Sopenharmony_ci [RST_DRAM] = { 0x0f4, BIT(31) }, 80562306a36Sopenharmony_ci [RST_MBUS] = { 0x0fc, BIT(31) }, 80662306a36Sopenharmony_ci [RST_BUS_MIPI_DSI] = { 0x2c0, BIT(1) }, 80762306a36Sopenharmony_ci [RST_BUS_SS] = { 0x2c0, BIT(5) }, 80862306a36Sopenharmony_ci [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 80962306a36Sopenharmony_ci [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 81062306a36Sopenharmony_ci [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 81162306a36Sopenharmony_ci [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 81262306a36Sopenharmony_ci [RST_BUS_NAND] = { 0x2c0, BIT(13) }, 81362306a36Sopenharmony_ci [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 81462306a36Sopenharmony_ci [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 81562306a36Sopenharmony_ci [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 81662306a36Sopenharmony_ci [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 81762306a36Sopenharmony_ci [RST_BUS_SPI1] = { 0x2c0, BIT(21) }, 81862306a36Sopenharmony_ci [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 81962306a36Sopenharmony_ci [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 82062306a36Sopenharmony_ci [RST_BUS_EHCI1] = { 0x2c0, BIT(27) }, 82162306a36Sopenharmony_ci [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 82262306a36Sopenharmony_ci [RST_BUS_VE] = { 0x2c4, BIT(0) }, 82362306a36Sopenharmony_ci [RST_BUS_TCON0] = { 0x2c4, BIT(4) }, 82462306a36Sopenharmony_ci [RST_BUS_TCON1] = { 0x2c4, BIT(5) }, 82562306a36Sopenharmony_ci [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 82662306a36Sopenharmony_ci [RST_BUS_HDMI0] = { 0x2c4, BIT(10) }, 82762306a36Sopenharmony_ci [RST_BUS_HDMI1] = { 0x2c4, BIT(11) }, 82862306a36Sopenharmony_ci [RST_BUS_DE] = { 0x2c4, BIT(12) }, 82962306a36Sopenharmony_ci [RST_BUS_GPU] = { 0x2c4, BIT(20) }, 83062306a36Sopenharmony_ci [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) }, 83162306a36Sopenharmony_ci [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) }, 83262306a36Sopenharmony_ci [RST_BUS_LVDS] = { 0x2c8, BIT(0) }, 83362306a36Sopenharmony_ci [RST_BUS_SPDIF] = { 0x2d0, BIT(1) }, 83462306a36Sopenharmony_ci [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 83562306a36Sopenharmony_ci [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, 83662306a36Sopenharmony_ci [RST_BUS_I2S2] = { 0x2d0, BIT(14) }, 83762306a36Sopenharmony_ci [RST_BUS_TDM] = { 0x2d0, BIT(15) }, 83862306a36Sopenharmony_ci [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 83962306a36Sopenharmony_ci [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 84062306a36Sopenharmony_ci [RST_BUS_I2C2] = { 0x2d8, BIT(2) }, 84162306a36Sopenharmony_ci [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 84262306a36Sopenharmony_ci [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 84362306a36Sopenharmony_ci [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 84462306a36Sopenharmony_ci [RST_BUS_UART3] = { 0x2d8, BIT(19) }, 84562306a36Sopenharmony_ci [RST_BUS_UART4] = { 0x2d8, BIT(20) }, 84662306a36Sopenharmony_ci}; 84762306a36Sopenharmony_ci 84862306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_a83t_ccu_desc = { 84962306a36Sopenharmony_ci .ccu_clks = sun8i_a83t_ccu_clks, 85062306a36Sopenharmony_ci .num_ccu_clks = ARRAY_SIZE(sun8i_a83t_ccu_clks), 85162306a36Sopenharmony_ci 85262306a36Sopenharmony_ci .hw_clks = &sun8i_a83t_hw_clks, 85362306a36Sopenharmony_ci 85462306a36Sopenharmony_ci .resets = sun8i_a83t_ccu_resets, 85562306a36Sopenharmony_ci .num_resets = ARRAY_SIZE(sun8i_a83t_ccu_resets), 85662306a36Sopenharmony_ci}; 85762306a36Sopenharmony_ci 85862306a36Sopenharmony_ci#define SUN8I_A83T_PLL_P_SHIFT 16 85962306a36Sopenharmony_ci#define SUN8I_A83T_PLL_N_SHIFT 8 86062306a36Sopenharmony_ci#define SUN8I_A83T_PLL_N_WIDTH 8 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_cistatic void sun8i_a83t_cpu_pll_fixup(void __iomem *reg) 86362306a36Sopenharmony_ci{ 86462306a36Sopenharmony_ci u32 val = readl(reg); 86562306a36Sopenharmony_ci 86662306a36Sopenharmony_ci /* bail out if P divider is not used */ 86762306a36Sopenharmony_ci if (!(val & BIT(SUN8I_A83T_PLL_P_SHIFT))) 86862306a36Sopenharmony_ci return; 86962306a36Sopenharmony_ci 87062306a36Sopenharmony_ci /* 87162306a36Sopenharmony_ci * If P is used, output should be less than 288 MHz. When we 87262306a36Sopenharmony_ci * set P to 1, we should also decrease the multiplier so the 87362306a36Sopenharmony_ci * output doesn't go out of range, but not too much such that 87462306a36Sopenharmony_ci * the multiplier stays above 12, the minimal operation value. 87562306a36Sopenharmony_ci * 87662306a36Sopenharmony_ci * To keep it simple, set the multiplier to 17, the reset value. 87762306a36Sopenharmony_ci */ 87862306a36Sopenharmony_ci val &= ~GENMASK(SUN8I_A83T_PLL_N_SHIFT + SUN8I_A83T_PLL_N_WIDTH - 1, 87962306a36Sopenharmony_ci SUN8I_A83T_PLL_N_SHIFT); 88062306a36Sopenharmony_ci val |= 17 << SUN8I_A83T_PLL_N_SHIFT; 88162306a36Sopenharmony_ci 88262306a36Sopenharmony_ci /* And clear P */ 88362306a36Sopenharmony_ci val &= ~BIT(SUN8I_A83T_PLL_P_SHIFT); 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_ci writel(val, reg); 88662306a36Sopenharmony_ci} 88762306a36Sopenharmony_ci 88862306a36Sopenharmony_cistatic int sun8i_a83t_ccu_probe(struct platform_device *pdev) 88962306a36Sopenharmony_ci{ 89062306a36Sopenharmony_ci void __iomem *reg; 89162306a36Sopenharmony_ci u32 val; 89262306a36Sopenharmony_ci 89362306a36Sopenharmony_ci reg = devm_platform_ioremap_resource(pdev, 0); 89462306a36Sopenharmony_ci if (IS_ERR(reg)) 89562306a36Sopenharmony_ci return PTR_ERR(reg); 89662306a36Sopenharmony_ci 89762306a36Sopenharmony_ci /* Enforce d1 = 0, d2 = 1 for Audio PLL */ 89862306a36Sopenharmony_ci val = readl(reg + SUN8I_A83T_PLL_AUDIO_REG); 89962306a36Sopenharmony_ci val &= ~BIT(16); 90062306a36Sopenharmony_ci val |= BIT(18); 90162306a36Sopenharmony_ci writel(val, reg + SUN8I_A83T_PLL_AUDIO_REG); 90262306a36Sopenharmony_ci 90362306a36Sopenharmony_ci /* Enforce P = 1 for both CPU cluster PLLs */ 90462306a36Sopenharmony_ci sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C0CPUX_REG); 90562306a36Sopenharmony_ci sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C1CPUX_REG); 90662306a36Sopenharmony_ci 90762306a36Sopenharmony_ci return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_a83t_ccu_desc); 90862306a36Sopenharmony_ci} 90962306a36Sopenharmony_ci 91062306a36Sopenharmony_cistatic const struct of_device_id sun8i_a83t_ccu_ids[] = { 91162306a36Sopenharmony_ci { .compatible = "allwinner,sun8i-a83t-ccu" }, 91262306a36Sopenharmony_ci { } 91362306a36Sopenharmony_ci}; 91462306a36Sopenharmony_ci 91562306a36Sopenharmony_cistatic struct platform_driver sun8i_a83t_ccu_driver = { 91662306a36Sopenharmony_ci .probe = sun8i_a83t_ccu_probe, 91762306a36Sopenharmony_ci .driver = { 91862306a36Sopenharmony_ci .name = "sun8i-a83t-ccu", 91962306a36Sopenharmony_ci .suppress_bind_attrs = true, 92062306a36Sopenharmony_ci .of_match_table = sun8i_a83t_ccu_ids, 92162306a36Sopenharmony_ci }, 92262306a36Sopenharmony_ci}; 92362306a36Sopenharmony_cimodule_platform_driver(sun8i_a83t_ccu_driver); 92462306a36Sopenharmony_ci 92562306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU); 92662306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 927