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-sun50i-a64.h" 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistatic struct ccu_nkmp pll_cpux_clk = { 2762306a36Sopenharmony_ci .enable = BIT(31), 2862306a36Sopenharmony_ci .lock = BIT(28), 2962306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT(8, 5), 3062306a36Sopenharmony_ci .k = _SUNXI_CCU_MULT(4, 2), 3162306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(0, 2), 3262306a36Sopenharmony_ci .p = _SUNXI_CCU_DIV_MAX(16, 2, 4), 3362306a36Sopenharmony_ci .common = { 3462306a36Sopenharmony_ci .reg = 0x000, 3562306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-cpux", 3662306a36Sopenharmony_ci "osc24M", 3762306a36Sopenharmony_ci &ccu_nkmp_ops, 3862306a36Sopenharmony_ci CLK_SET_RATE_UNGATE), 3962306a36Sopenharmony_ci }, 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from 4462306a36Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true 4562306a36Sopenharmony_ci * pll audio). 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL, 4862306a36Sopenharmony_ci * we have to use specific dividers. This means the variable divider 4962306a36Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock 5062306a36Sopenharmony_ci * rates we support through this mechanism. So we now hard code the 5162306a36Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer 5262306a36Sopenharmony_ci * match the clock names. 5362306a36Sopenharmony_ci */ 5462306a36Sopenharmony_ci#define SUN50I_A64_PLL_AUDIO_REG 0x008 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = { 5762306a36Sopenharmony_ci { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 }, 5862306a36Sopenharmony_ci { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 }, 5962306a36Sopenharmony_ci}; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", 6262306a36Sopenharmony_ci "osc24M", 0x008, 6362306a36Sopenharmony_ci 8, 7, /* N */ 6462306a36Sopenharmony_ci 0, 5, /* M */ 6562306a36Sopenharmony_ci pll_audio_sdm_table, BIT(24), 6662306a36Sopenharmony_ci 0x284, BIT(31), 6762306a36Sopenharmony_ci BIT(31), /* gate */ 6862306a36Sopenharmony_ci BIT(28), /* lock */ 6962306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_CLOSEST(pll_video0_clk, "pll-video0", 7262306a36Sopenharmony_ci "osc24M", 0x010, 7362306a36Sopenharmony_ci 192000000, /* Minimum rate */ 7462306a36Sopenharmony_ci 1008000000, /* Maximum rate */ 7562306a36Sopenharmony_ci 8, 7, /* N */ 7662306a36Sopenharmony_ci 0, 4, /* M */ 7762306a36Sopenharmony_ci BIT(24), /* frac enable */ 7862306a36Sopenharmony_ci BIT(25), /* frac select */ 7962306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 8062306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 8162306a36Sopenharmony_ci BIT(31), /* gate */ 8262306a36Sopenharmony_ci BIT(28), /* lock */ 8362306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", 8662306a36Sopenharmony_ci "osc24M", 0x018, 8762306a36Sopenharmony_ci 8, 7, /* N */ 8862306a36Sopenharmony_ci 0, 4, /* M */ 8962306a36Sopenharmony_ci BIT(24), /* frac enable */ 9062306a36Sopenharmony_ci BIT(25), /* frac select */ 9162306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 9262306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 9362306a36Sopenharmony_ci BIT(31), /* gate */ 9462306a36Sopenharmony_ci BIT(28), /* lock */ 9562306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", 9862306a36Sopenharmony_ci "osc24M", 0x020, 9962306a36Sopenharmony_ci 8, 5, /* N */ 10062306a36Sopenharmony_ci 4, 2, /* K */ 10162306a36Sopenharmony_ci 0, 2, /* M */ 10262306a36Sopenharmony_ci BIT(31), /* gate */ 10362306a36Sopenharmony_ci BIT(28), /* lock */ 10462306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_cistatic struct ccu_nk pll_periph0_clk = { 10762306a36Sopenharmony_ci .enable = BIT(31), 10862306a36Sopenharmony_ci .lock = BIT(28), 10962306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT(8, 5), 11062306a36Sopenharmony_ci .k = _SUNXI_CCU_MULT_MIN(4, 2, 2), 11162306a36Sopenharmony_ci .fixed_post_div = 2, 11262306a36Sopenharmony_ci .common = { 11362306a36Sopenharmony_ci .reg = 0x028, 11462306a36Sopenharmony_ci .features = CCU_FEATURE_FIXED_POSTDIV, 11562306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-periph0", "osc24M", 11662306a36Sopenharmony_ci &ccu_nk_ops, CLK_SET_RATE_UNGATE), 11762306a36Sopenharmony_ci }, 11862306a36Sopenharmony_ci}; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistatic struct ccu_nk pll_periph1_clk = { 12162306a36Sopenharmony_ci .enable = BIT(31), 12262306a36Sopenharmony_ci .lock = BIT(28), 12362306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT(8, 5), 12462306a36Sopenharmony_ci .k = _SUNXI_CCU_MULT_MIN(4, 2, 2), 12562306a36Sopenharmony_ci .fixed_post_div = 2, 12662306a36Sopenharmony_ci .common = { 12762306a36Sopenharmony_ci .reg = 0x02c, 12862306a36Sopenharmony_ci .features = CCU_FEATURE_FIXED_POSTDIV, 12962306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-periph1", "osc24M", 13062306a36Sopenharmony_ci &ccu_nk_ops, CLK_SET_RATE_UNGATE), 13162306a36Sopenharmony_ci }, 13262306a36Sopenharmony_ci}; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1", 13562306a36Sopenharmony_ci "osc24M", 0x030, 13662306a36Sopenharmony_ci 192000000, /* Minimum rate */ 13762306a36Sopenharmony_ci 1008000000, /* Maximum rate */ 13862306a36Sopenharmony_ci 8, 7, /* N */ 13962306a36Sopenharmony_ci 0, 4, /* M */ 14062306a36Sopenharmony_ci BIT(24), /* frac enable */ 14162306a36Sopenharmony_ci BIT(25), /* frac select */ 14262306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 14362306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 14462306a36Sopenharmony_ci BIT(31), /* gate */ 14562306a36Sopenharmony_ci BIT(28), /* lock */ 14662306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu", 14962306a36Sopenharmony_ci "osc24M", 0x038, 15062306a36Sopenharmony_ci 8, 7, /* N */ 15162306a36Sopenharmony_ci 0, 4, /* M */ 15262306a36Sopenharmony_ci BIT(24), /* frac enable */ 15362306a36Sopenharmony_ci BIT(25), /* frac select */ 15462306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 15562306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 15662306a36Sopenharmony_ci BIT(31), /* gate */ 15762306a36Sopenharmony_ci BIT(28), /* lock */ 15862306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* 16162306a36Sopenharmony_ci * The output function can be changed to something more complex that 16262306a36Sopenharmony_ci * we do not handle yet. 16362306a36Sopenharmony_ci * 16462306a36Sopenharmony_ci * Hardcode the mode so that we don't fall in that case. 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_ci#define SUN50I_A64_PLL_MIPI_REG 0x040 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_cistatic struct ccu_nkm pll_mipi_clk = { 16962306a36Sopenharmony_ci /* 17062306a36Sopenharmony_ci * The bit 23 and 22 are called "LDO{1,2}_EN" on the SoC's 17162306a36Sopenharmony_ci * user manual, and by experiments the PLL doesn't work without 17262306a36Sopenharmony_ci * these bits toggled. 17362306a36Sopenharmony_ci */ 17462306a36Sopenharmony_ci .enable = BIT(31) | BIT(23) | BIT(22), 17562306a36Sopenharmony_ci .lock = BIT(28), 17662306a36Sopenharmony_ci .n = _SUNXI_CCU_MULT(8, 4), 17762306a36Sopenharmony_ci .k = _SUNXI_CCU_MULT_MIN(4, 2, 2), 17862306a36Sopenharmony_ci .m = _SUNXI_CCU_DIV(0, 4), 17962306a36Sopenharmony_ci .common = { 18062306a36Sopenharmony_ci .reg = 0x040, 18162306a36Sopenharmony_ci .hw.init = CLK_HW_INIT("pll-mipi", "pll-video0", 18262306a36Sopenharmony_ci &ccu_nkm_ops, 18362306a36Sopenharmony_ci CLK_SET_RATE_UNGATE | CLK_SET_RATE_PARENT), 18462306a36Sopenharmony_ci .features = CCU_FEATURE_CLOSEST_RATE, 18562306a36Sopenharmony_ci }, 18662306a36Sopenharmony_ci}; 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_hsic_clk, "pll-hsic", 18962306a36Sopenharmony_ci "osc24M", 0x044, 19062306a36Sopenharmony_ci 8, 7, /* N */ 19162306a36Sopenharmony_ci 0, 4, /* M */ 19262306a36Sopenharmony_ci BIT(24), /* frac enable */ 19362306a36Sopenharmony_ci BIT(25), /* frac select */ 19462306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 19562306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 19662306a36Sopenharmony_ci BIT(31), /* gate */ 19762306a36Sopenharmony_ci BIT(28), /* lock */ 19862306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de", 20162306a36Sopenharmony_ci "osc24M", 0x048, 20262306a36Sopenharmony_ci 8, 7, /* N */ 20362306a36Sopenharmony_ci 0, 4, /* M */ 20462306a36Sopenharmony_ci BIT(24), /* frac enable */ 20562306a36Sopenharmony_ci BIT(25), /* frac select */ 20662306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 20762306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 20862306a36Sopenharmony_ci BIT(31), /* gate */ 20962306a36Sopenharmony_ci BIT(28), /* lock */ 21062306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", 21362306a36Sopenharmony_ci "osc24M", 0x04c, 21462306a36Sopenharmony_ci 8, 7, /* N */ 21562306a36Sopenharmony_ci 0, 2, /* M */ 21662306a36Sopenharmony_ci BIT(31), /* gate */ 21762306a36Sopenharmony_ci BIT(28), /* lock */ 21862306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistatic const char * const cpux_parents[] = { "osc32k", "osc24M", 22162306a36Sopenharmony_ci "pll-cpux", "pll-cpux" }; 22262306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents, 22362306a36Sopenharmony_ci 0x050, 16, 2, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0); 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M", 22862306a36Sopenharmony_ci "axi", "pll-periph0" }; 22962306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = { 23062306a36Sopenharmony_ci { .index = 3, .shift = 6, .width = 2 }, 23162306a36Sopenharmony_ci}; 23262306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = { 23362306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci .mux = { 23662306a36Sopenharmony_ci .shift = 12, 23762306a36Sopenharmony_ci .width = 2, 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci .var_predivs = ahb1_predivs, 24062306a36Sopenharmony_ci .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 24162306a36Sopenharmony_ci }, 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci .common = { 24462306a36Sopenharmony_ci .reg = 0x054, 24562306a36Sopenharmony_ci .features = CCU_FEATURE_VARIABLE_PREDIV, 24662306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb1", 24762306a36Sopenharmony_ci ahb1_parents, 24862306a36Sopenharmony_ci &ccu_div_ops, 24962306a36Sopenharmony_ci 0), 25062306a36Sopenharmony_ci }, 25162306a36Sopenharmony_ci}; 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = { 25462306a36Sopenharmony_ci { .val = 0, .div = 2 }, 25562306a36Sopenharmony_ci { .val = 1, .div = 2 }, 25662306a36Sopenharmony_ci { .val = 2, .div = 4 }, 25762306a36Sopenharmony_ci { .val = 3, .div = 8 }, 25862306a36Sopenharmony_ci { /* Sentinel */ }, 25962306a36Sopenharmony_ci}; 26062306a36Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1", 26162306a36Sopenharmony_ci 0x054, 8, 2, apb1_div_table, 0); 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M", 26462306a36Sopenharmony_ci "pll-periph0-2x", 26562306a36Sopenharmony_ci "pll-periph0-2x" }; 26662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 26762306a36Sopenharmony_ci 0, 5, /* M */ 26862306a36Sopenharmony_ci 16, 2, /* P */ 26962306a36Sopenharmony_ci 24, 2, /* mux */ 27062306a36Sopenharmony_ci 0); 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_cistatic const char * const ahb2_parents[] = { "ahb1", "pll-periph0" }; 27362306a36Sopenharmony_cistatic const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = { 27462306a36Sopenharmony_ci { .index = 1, .div = 2 }, 27562306a36Sopenharmony_ci}; 27662306a36Sopenharmony_cistatic struct ccu_mux ahb2_clk = { 27762306a36Sopenharmony_ci .mux = { 27862306a36Sopenharmony_ci .shift = 0, 27962306a36Sopenharmony_ci .width = 1, 28062306a36Sopenharmony_ci .fixed_predivs = ahb2_fixed_predivs, 28162306a36Sopenharmony_ci .n_predivs = ARRAY_SIZE(ahb2_fixed_predivs), 28262306a36Sopenharmony_ci }, 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci .common = { 28562306a36Sopenharmony_ci .reg = 0x05c, 28662306a36Sopenharmony_ci .features = CCU_FEATURE_FIXED_PREDIV, 28762306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb2", 28862306a36Sopenharmony_ci ahb2_parents, 28962306a36Sopenharmony_ci &ccu_mux_ops, 29062306a36Sopenharmony_ci 0), 29162306a36Sopenharmony_ci }, 29262306a36Sopenharmony_ci}; 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb1", 29562306a36Sopenharmony_ci 0x060, BIT(1), 0); 29662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1", 29762306a36Sopenharmony_ci 0x060, BIT(5), 0); 29862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 29962306a36Sopenharmony_ci 0x060, BIT(6), 0); 30062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 30162306a36Sopenharmony_ci 0x060, BIT(8), 0); 30262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 30362306a36Sopenharmony_ci 0x060, BIT(9), 0); 30462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 30562306a36Sopenharmony_ci 0x060, BIT(10), 0); 30662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1", 30762306a36Sopenharmony_ci 0x060, BIT(13), 0); 30862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 30962306a36Sopenharmony_ci 0x060, BIT(14), 0); 31062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2", 31162306a36Sopenharmony_ci 0x060, BIT(17), 0); 31262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb1", 31362306a36Sopenharmony_ci 0x060, BIT(18), 0); 31462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 31562306a36Sopenharmony_ci 0x060, BIT(19), 0); 31662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 31762306a36Sopenharmony_ci 0x060, BIT(20), 0); 31862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1", 31962306a36Sopenharmony_ci 0x060, BIT(21), 0); 32062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 32162306a36Sopenharmony_ci 0x060, BIT(23), 0); 32262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1", 32362306a36Sopenharmony_ci 0x060, BIT(24), 0); 32462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb2", 32562306a36Sopenharmony_ci 0x060, BIT(25), 0); 32662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1", 32762306a36Sopenharmony_ci 0x060, BIT(28), 0); 32862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci1_clk, "bus-ohci1", "ahb2", 32962306a36Sopenharmony_ci 0x060, BIT(29), 0); 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 33262306a36Sopenharmony_ci 0x064, BIT(0), 0); 33362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1", 33462306a36Sopenharmony_ci 0x064, BIT(3), 0); 33562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon1_clk, "bus-tcon1", "ahb1", 33662306a36Sopenharmony_ci 0x064, BIT(4), 0); 33762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "ahb1", 33862306a36Sopenharmony_ci 0x064, BIT(5), 0); 33962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1", 34062306a36Sopenharmony_ci 0x064, BIT(8), 0); 34162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi_clk, "bus-hdmi", "ahb1", 34262306a36Sopenharmony_ci 0x064, BIT(11), 0); 34362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 34462306a36Sopenharmony_ci 0x064, BIT(12), 0); 34562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 34662306a36Sopenharmony_ci 0x064, BIT(20), 0); 34762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", 34862306a36Sopenharmony_ci 0x064, BIT(21), 0); 34962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 35062306a36Sopenharmony_ci 0x064, BIT(22), 0); 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1", 35362306a36Sopenharmony_ci 0x068, BIT(0), 0); 35462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1", 35562306a36Sopenharmony_ci 0x068, BIT(1), 0); 35662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 35762306a36Sopenharmony_ci 0x068, BIT(5), 0); 35862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1", 35962306a36Sopenharmony_ci 0x068, BIT(8), 0); 36062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 36162306a36Sopenharmony_ci 0x068, BIT(12), 0); 36262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 36362306a36Sopenharmony_ci 0x068, BIT(13), 0); 36462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1", 36562306a36Sopenharmony_ci 0x068, BIT(14), 0); 36662306a36Sopenharmony_ci 36762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 36862306a36Sopenharmony_ci 0x06c, BIT(0), 0); 36962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 37062306a36Sopenharmony_ci 0x06c, BIT(1), 0); 37162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 37262306a36Sopenharmony_ci 0x06c, BIT(2), 0); 37362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_scr_clk, "bus-scr", "apb2", 37462306a36Sopenharmony_ci 0x06c, BIT(5), 0); 37562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 37662306a36Sopenharmony_ci 0x06c, BIT(16), 0); 37762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 37862306a36Sopenharmony_ci 0x06c, BIT(17), 0); 37962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 38062306a36Sopenharmony_ci 0x06c, BIT(18), 0); 38162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 38262306a36Sopenharmony_ci 0x06c, BIT(19), 0); 38362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2", 38462306a36Sopenharmony_ci 0x06c, BIT(20), 0); 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1", 38762306a36Sopenharmony_ci 0x070, BIT(7), 0); 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_cistatic struct clk_div_table ths_div_table[] = { 39062306a36Sopenharmony_ci { .val = 0, .div = 1 }, 39162306a36Sopenharmony_ci { .val = 1, .div = 2 }, 39262306a36Sopenharmony_ci { .val = 2, .div = 4 }, 39362306a36Sopenharmony_ci { .val = 3, .div = 6 }, 39462306a36Sopenharmony_ci { /* Sentinel */ }, 39562306a36Sopenharmony_ci}; 39662306a36Sopenharmony_cistatic const char * const ths_parents[] = { "osc24M" }; 39762306a36Sopenharmony_cistatic struct ccu_div ths_clk = { 39862306a36Sopenharmony_ci .enable = BIT(31), 39962306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_TABLE(0, 2, ths_div_table), 40062306a36Sopenharmony_ci .mux = _SUNXI_CCU_MUX(24, 2), 40162306a36Sopenharmony_ci .common = { 40262306a36Sopenharmony_ci .reg = 0x074, 40362306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ths", 40462306a36Sopenharmony_ci ths_parents, 40562306a36Sopenharmony_ci &ccu_div_ops, 40662306a36Sopenharmony_ci 0), 40762306a36Sopenharmony_ci }, 40862306a36Sopenharmony_ci}; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph0", 41162306a36Sopenharmony_ci "pll-periph1" }; 41262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080, 41362306a36Sopenharmony_ci 0, 4, /* M */ 41462306a36Sopenharmony_ci 16, 2, /* P */ 41562306a36Sopenharmony_ci 24, 2, /* mux */ 41662306a36Sopenharmony_ci BIT(31), /* gate */ 41762306a36Sopenharmony_ci 0); 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci/* 42062306a36Sopenharmony_ci * MMC clocks are the new timing mode (see A83T & H3) variety, but without 42162306a36Sopenharmony_ci * the mode switch. This means they have a 2x post divider between the clock 42262306a36Sopenharmony_ci * and the MMC module. This is not documented in the manual, but is taken 42362306a36Sopenharmony_ci * into consideration when setting the mmc module clocks in the BSP kernel. 42462306a36Sopenharmony_ci * Without it, MMC performance is degraded. 42562306a36Sopenharmony_ci * 42662306a36Sopenharmony_ci * We model it here to be consistent with other SoCs supporting this mode. 42762306a36Sopenharmony_ci * The alternative would be to add the 2x multiplier when setting the MMC 42862306a36Sopenharmony_ci * module clock in the MMC driver, just for the A64. 42962306a36Sopenharmony_ci */ 43062306a36Sopenharmony_cistatic const char * const mmc_default_parents[] = { "osc24M", "pll-periph0-2x", 43162306a36Sopenharmony_ci "pll-periph1-2x" }; 43262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0", 43362306a36Sopenharmony_ci mmc_default_parents, 0x088, 43462306a36Sopenharmony_ci 0, 4, /* M */ 43562306a36Sopenharmony_ci 16, 2, /* P */ 43662306a36Sopenharmony_ci 24, 2, /* mux */ 43762306a36Sopenharmony_ci BIT(31), /* gate */ 43862306a36Sopenharmony_ci 2, /* post-div */ 43962306a36Sopenharmony_ci 0); 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1", 44262306a36Sopenharmony_ci mmc_default_parents, 0x08c, 44362306a36Sopenharmony_ci 0, 4, /* M */ 44462306a36Sopenharmony_ci 16, 2, /* P */ 44562306a36Sopenharmony_ci 24, 2, /* mux */ 44662306a36Sopenharmony_ci BIT(31), /* gate */ 44762306a36Sopenharmony_ci 2, /* post-div */ 44862306a36Sopenharmony_ci 0); 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2", 45162306a36Sopenharmony_ci mmc_default_parents, 0x090, 45262306a36Sopenharmony_ci 0, 4, /* M */ 45362306a36Sopenharmony_ci 16, 2, /* P */ 45462306a36Sopenharmony_ci 24, 2, /* mux */ 45562306a36Sopenharmony_ci BIT(31), /* gate */ 45662306a36Sopenharmony_ci 2, /* post-div */ 45762306a36Sopenharmony_ci 0); 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_cistatic const char * const ts_parents[] = { "osc24M", "pll-periph0", }; 46062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098, 46162306a36Sopenharmony_ci 0, 4, /* M */ 46262306a36Sopenharmony_ci 16, 2, /* P */ 46362306a36Sopenharmony_ci 24, 4, /* mux */ 46462306a36Sopenharmony_ci BIT(31), /* gate */ 46562306a36Sopenharmony_ci 0); 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", mmc_default_parents, 0x09c, 46862306a36Sopenharmony_ci 0, 4, /* M */ 46962306a36Sopenharmony_ci 16, 2, /* P */ 47062306a36Sopenharmony_ci 24, 2, /* mux */ 47162306a36Sopenharmony_ci BIT(31), /* gate */ 47262306a36Sopenharmony_ci 0); 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, 47562306a36Sopenharmony_ci 0, 4, /* M */ 47662306a36Sopenharmony_ci 16, 2, /* P */ 47762306a36Sopenharmony_ci 24, 2, /* mux */ 47862306a36Sopenharmony_ci BIT(31), /* gate */ 47962306a36Sopenharmony_ci 0); 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4, 48262306a36Sopenharmony_ci 0, 4, /* M */ 48362306a36Sopenharmony_ci 16, 2, /* P */ 48462306a36Sopenharmony_ci 24, 2, /* mux */ 48562306a36Sopenharmony_ci BIT(31), /* gate */ 48662306a36Sopenharmony_ci 0); 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", 48962306a36Sopenharmony_ci "pll-audio-2x", "pll-audio" }; 49062306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, 49162306a36Sopenharmony_ci 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents, 49462306a36Sopenharmony_ci 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents, 49762306a36Sopenharmony_ci 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio", 50062306a36Sopenharmony_ci 0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT); 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 50362306a36Sopenharmony_ci 0x0cc, BIT(8), 0); 50462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M", 50562306a36Sopenharmony_ci 0x0cc, BIT(9), 0); 50662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_clk, "usb-hsic", "pll-hsic", 50762306a36Sopenharmony_ci 0x0cc, BIT(10), 0); 50862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_12m_clk, "usb-hsic-12M", "osc12M", 50962306a36Sopenharmony_ci 0x0cc, BIT(11), 0); 51062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc12M", 51162306a36Sopenharmony_ci 0x0cc, BIT(16), 0); 51262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "usb-ohci0", 51362306a36Sopenharmony_ci 0x0cc, BIT(17), 0); 51462306a36Sopenharmony_ci 51562306a36Sopenharmony_cistatic const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" }; 51662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, 51762306a36Sopenharmony_ci 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL); 51862306a36Sopenharmony_ci 51962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 52062306a36Sopenharmony_ci 0x100, BIT(0), 0); 52162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram", 52262306a36Sopenharmony_ci 0x100, BIT(1), 0); 52362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_deinterlace_clk, "dram-deinterlace", "dram", 52462306a36Sopenharmony_ci 0x100, BIT(2), 0); 52562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "dram", 52662306a36Sopenharmony_ci 0x100, BIT(3), 0); 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-periph0-2x", "pll-de" }; 52962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, 53062306a36Sopenharmony_ci 0x104, 0, 4, 24, 3, BIT(31), 53162306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci/* 53462306a36Sopenharmony_ci * DSI output seems to work only when PLL_MIPI selected. Set it and prevent 53562306a36Sopenharmony_ci * the mux from reparenting. 53662306a36Sopenharmony_ci */ 53762306a36Sopenharmony_ci#define SUN50I_A64_TCON0_CLK_REG 0x118 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_cistatic const char * const tcon0_parents[] = { "pll-mipi", "pll-video0-2x" }; 54062306a36Sopenharmony_cistatic const u8 tcon0_table[] = { 0, 2, }; 54162306a36Sopenharmony_cistatic SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(tcon0_clk, "tcon0", tcon0_parents, 54262306a36Sopenharmony_ci tcon0_table, 0x118, 24, 3, BIT(31), 54362306a36Sopenharmony_ci CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT); 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_cistatic const char * const tcon1_parents[] = { "pll-video0", "pll-video1" }; 54662306a36Sopenharmony_cistatic const u8 tcon1_table[] = { 0, 2, }; 54762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(tcon1_clk, "tcon1", tcon1_parents, 54862306a36Sopenharmony_ci tcon1_table, 0x11c, 54962306a36Sopenharmony_ci 0, 4, /* M */ 55062306a36Sopenharmony_ci 24, 2, /* mux */ 55162306a36Sopenharmony_ci BIT(31), /* gate */ 55262306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_cistatic const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" }; 55562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", deinterlace_parents, 55662306a36Sopenharmony_ci 0x124, 0, 4, 24, 3, BIT(31), 0); 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M", 55962306a36Sopenharmony_ci 0x130, BIT(31), 0); 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" }; 56262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents, 56362306a36Sopenharmony_ci 0x134, 16, 4, 24, 3, BIT(31), 0); 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "osc24M", "pll-video1", "pll-periph1" }; 56662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents, 56762306a36Sopenharmony_ci 0x134, 0, 5, 8, 3, BIT(15), 0); 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 57062306a36Sopenharmony_ci 0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT); 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio", 57362306a36Sopenharmony_ci 0x140, BIT(31), CLK_SET_RATE_PARENT); 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_4x_clk, "ac-dig-4x", "pll-audio-4x", 57662306a36Sopenharmony_ci 0x140, BIT(30), CLK_SET_RATE_PARENT); 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 57962306a36Sopenharmony_ci 0x144, BIT(31), 0); 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_cistatic const char * const hdmi_parents[] = { "pll-video0", "pll-video1" }; 58262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE_CLOSEST(hdmi_clk, "hdmi", hdmi_parents, 58362306a36Sopenharmony_ci 0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT); 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 58662306a36Sopenharmony_ci 0x154, BIT(31), 0); 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", 58962306a36Sopenharmony_ci "pll-ddr0", "pll-ddr1" }; 59062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 59162306a36Sopenharmony_ci 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL); 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video0", "pll-periph0" }; 59462306a36Sopenharmony_cistatic const u8 dsi_dphy_table[] = { 0, 2, }; 59562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(dsi_dphy_clk, "dsi-dphy", 59662306a36Sopenharmony_ci dsi_dphy_parents, dsi_dphy_table, 59762306a36Sopenharmony_ci 0x168, 0, 4, 8, 2, BIT(15), CLK_SET_RATE_PARENT); 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu", 60062306a36Sopenharmony_ci 0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT); 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_ci/* Fixed Factor clocks */ 60362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_FW_NAME(osc12M_clk, "osc12M", "hosc", 2, 1, 0); 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = { 60662306a36Sopenharmony_ci &pll_audio_base_clk.common.hw 60762306a36Sopenharmony_ci}; 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci/* We hardcode the divider to 1 for now */ 61062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", 61162306a36Sopenharmony_ci clk_parent_pll_audio, 61262306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 61362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", 61462306a36Sopenharmony_ci clk_parent_pll_audio, 61562306a36Sopenharmony_ci 2, 1, CLK_SET_RATE_PARENT); 61662306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x", 61762306a36Sopenharmony_ci clk_parent_pll_audio, 61862306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 61962306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x", 62062306a36Sopenharmony_ci clk_parent_pll_audio, 62162306a36Sopenharmony_ci 1, 2, CLK_SET_RATE_PARENT); 62262306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x", 62362306a36Sopenharmony_ci &pll_periph0_clk.common.hw, 62462306a36Sopenharmony_ci 1, 2, 0); 62562306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph1_2x_clk, "pll-periph1-2x", 62662306a36Sopenharmony_ci &pll_periph1_clk.common.hw, 62762306a36Sopenharmony_ci 1, 2, 0); 62862306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x", 62962306a36Sopenharmony_ci &pll_video0_clk.common.hw, 63062306a36Sopenharmony_ci 1, 2, CLK_SET_RATE_PARENT); 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_cistatic struct ccu_common *sun50i_a64_ccu_clks[] = { 63362306a36Sopenharmony_ci &pll_cpux_clk.common, 63462306a36Sopenharmony_ci &pll_audio_base_clk.common, 63562306a36Sopenharmony_ci &pll_video0_clk.common, 63662306a36Sopenharmony_ci &pll_ve_clk.common, 63762306a36Sopenharmony_ci &pll_ddr0_clk.common, 63862306a36Sopenharmony_ci &pll_periph0_clk.common, 63962306a36Sopenharmony_ci &pll_periph1_clk.common, 64062306a36Sopenharmony_ci &pll_video1_clk.common, 64162306a36Sopenharmony_ci &pll_gpu_clk.common, 64262306a36Sopenharmony_ci &pll_mipi_clk.common, 64362306a36Sopenharmony_ci &pll_hsic_clk.common, 64462306a36Sopenharmony_ci &pll_de_clk.common, 64562306a36Sopenharmony_ci &pll_ddr1_clk.common, 64662306a36Sopenharmony_ci &cpux_clk.common, 64762306a36Sopenharmony_ci &axi_clk.common, 64862306a36Sopenharmony_ci &ahb1_clk.common, 64962306a36Sopenharmony_ci &apb1_clk.common, 65062306a36Sopenharmony_ci &apb2_clk.common, 65162306a36Sopenharmony_ci &ahb2_clk.common, 65262306a36Sopenharmony_ci &bus_mipi_dsi_clk.common, 65362306a36Sopenharmony_ci &bus_ce_clk.common, 65462306a36Sopenharmony_ci &bus_dma_clk.common, 65562306a36Sopenharmony_ci &bus_mmc0_clk.common, 65662306a36Sopenharmony_ci &bus_mmc1_clk.common, 65762306a36Sopenharmony_ci &bus_mmc2_clk.common, 65862306a36Sopenharmony_ci &bus_nand_clk.common, 65962306a36Sopenharmony_ci &bus_dram_clk.common, 66062306a36Sopenharmony_ci &bus_emac_clk.common, 66162306a36Sopenharmony_ci &bus_ts_clk.common, 66262306a36Sopenharmony_ci &bus_hstimer_clk.common, 66362306a36Sopenharmony_ci &bus_spi0_clk.common, 66462306a36Sopenharmony_ci &bus_spi1_clk.common, 66562306a36Sopenharmony_ci &bus_otg_clk.common, 66662306a36Sopenharmony_ci &bus_ehci0_clk.common, 66762306a36Sopenharmony_ci &bus_ehci1_clk.common, 66862306a36Sopenharmony_ci &bus_ohci0_clk.common, 66962306a36Sopenharmony_ci &bus_ohci1_clk.common, 67062306a36Sopenharmony_ci &bus_ve_clk.common, 67162306a36Sopenharmony_ci &bus_tcon0_clk.common, 67262306a36Sopenharmony_ci &bus_tcon1_clk.common, 67362306a36Sopenharmony_ci &bus_deinterlace_clk.common, 67462306a36Sopenharmony_ci &bus_csi_clk.common, 67562306a36Sopenharmony_ci &bus_hdmi_clk.common, 67662306a36Sopenharmony_ci &bus_de_clk.common, 67762306a36Sopenharmony_ci &bus_gpu_clk.common, 67862306a36Sopenharmony_ci &bus_msgbox_clk.common, 67962306a36Sopenharmony_ci &bus_spinlock_clk.common, 68062306a36Sopenharmony_ci &bus_codec_clk.common, 68162306a36Sopenharmony_ci &bus_spdif_clk.common, 68262306a36Sopenharmony_ci &bus_pio_clk.common, 68362306a36Sopenharmony_ci &bus_ths_clk.common, 68462306a36Sopenharmony_ci &bus_i2s0_clk.common, 68562306a36Sopenharmony_ci &bus_i2s1_clk.common, 68662306a36Sopenharmony_ci &bus_i2s2_clk.common, 68762306a36Sopenharmony_ci &bus_i2c0_clk.common, 68862306a36Sopenharmony_ci &bus_i2c1_clk.common, 68962306a36Sopenharmony_ci &bus_i2c2_clk.common, 69062306a36Sopenharmony_ci &bus_scr_clk.common, 69162306a36Sopenharmony_ci &bus_uart0_clk.common, 69262306a36Sopenharmony_ci &bus_uart1_clk.common, 69362306a36Sopenharmony_ci &bus_uart2_clk.common, 69462306a36Sopenharmony_ci &bus_uart3_clk.common, 69562306a36Sopenharmony_ci &bus_uart4_clk.common, 69662306a36Sopenharmony_ci &bus_dbg_clk.common, 69762306a36Sopenharmony_ci &ths_clk.common, 69862306a36Sopenharmony_ci &nand_clk.common, 69962306a36Sopenharmony_ci &mmc0_clk.common, 70062306a36Sopenharmony_ci &mmc1_clk.common, 70162306a36Sopenharmony_ci &mmc2_clk.common, 70262306a36Sopenharmony_ci &ts_clk.common, 70362306a36Sopenharmony_ci &ce_clk.common, 70462306a36Sopenharmony_ci &spi0_clk.common, 70562306a36Sopenharmony_ci &spi1_clk.common, 70662306a36Sopenharmony_ci &i2s0_clk.common, 70762306a36Sopenharmony_ci &i2s1_clk.common, 70862306a36Sopenharmony_ci &i2s2_clk.common, 70962306a36Sopenharmony_ci &spdif_clk.common, 71062306a36Sopenharmony_ci &usb_phy0_clk.common, 71162306a36Sopenharmony_ci &usb_phy1_clk.common, 71262306a36Sopenharmony_ci &usb_hsic_clk.common, 71362306a36Sopenharmony_ci &usb_hsic_12m_clk.common, 71462306a36Sopenharmony_ci &usb_ohci0_clk.common, 71562306a36Sopenharmony_ci &usb_ohci1_clk.common, 71662306a36Sopenharmony_ci &dram_clk.common, 71762306a36Sopenharmony_ci &dram_ve_clk.common, 71862306a36Sopenharmony_ci &dram_csi_clk.common, 71962306a36Sopenharmony_ci &dram_deinterlace_clk.common, 72062306a36Sopenharmony_ci &dram_ts_clk.common, 72162306a36Sopenharmony_ci &de_clk.common, 72262306a36Sopenharmony_ci &tcon0_clk.common, 72362306a36Sopenharmony_ci &tcon1_clk.common, 72462306a36Sopenharmony_ci &deinterlace_clk.common, 72562306a36Sopenharmony_ci &csi_misc_clk.common, 72662306a36Sopenharmony_ci &csi_sclk_clk.common, 72762306a36Sopenharmony_ci &csi_mclk_clk.common, 72862306a36Sopenharmony_ci &ve_clk.common, 72962306a36Sopenharmony_ci &ac_dig_clk.common, 73062306a36Sopenharmony_ci &ac_dig_4x_clk.common, 73162306a36Sopenharmony_ci &avs_clk.common, 73262306a36Sopenharmony_ci &hdmi_clk.common, 73362306a36Sopenharmony_ci &hdmi_ddc_clk.common, 73462306a36Sopenharmony_ci &mbus_clk.common, 73562306a36Sopenharmony_ci &dsi_dphy_clk.common, 73662306a36Sopenharmony_ci &gpu_clk.common, 73762306a36Sopenharmony_ci}; 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun50i_a64_hw_clks = { 74062306a36Sopenharmony_ci .hws = { 74162306a36Sopenharmony_ci [CLK_OSC_12M] = &osc12M_clk.hw, 74262306a36Sopenharmony_ci [CLK_PLL_CPUX] = &pll_cpux_clk.common.hw, 74362306a36Sopenharmony_ci [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 74462306a36Sopenharmony_ci [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 74562306a36Sopenharmony_ci [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 74662306a36Sopenharmony_ci [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 74762306a36Sopenharmony_ci [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 74862306a36Sopenharmony_ci [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw, 74962306a36Sopenharmony_ci [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw, 75062306a36Sopenharmony_ci [CLK_PLL_VE] = &pll_ve_clk.common.hw, 75162306a36Sopenharmony_ci [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 75262306a36Sopenharmony_ci [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 75362306a36Sopenharmony_ci [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 75462306a36Sopenharmony_ci [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 75562306a36Sopenharmony_ci [CLK_PLL_PERIPH1_2X] = &pll_periph1_2x_clk.hw, 75662306a36Sopenharmony_ci [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw, 75762306a36Sopenharmony_ci [CLK_PLL_GPU] = &pll_gpu_clk.common.hw, 75862306a36Sopenharmony_ci [CLK_PLL_MIPI] = &pll_mipi_clk.common.hw, 75962306a36Sopenharmony_ci [CLK_PLL_HSIC] = &pll_hsic_clk.common.hw, 76062306a36Sopenharmony_ci [CLK_PLL_DE] = &pll_de_clk.common.hw, 76162306a36Sopenharmony_ci [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 76262306a36Sopenharmony_ci [CLK_CPUX] = &cpux_clk.common.hw, 76362306a36Sopenharmony_ci [CLK_AXI] = &axi_clk.common.hw, 76462306a36Sopenharmony_ci [CLK_AHB1] = &ahb1_clk.common.hw, 76562306a36Sopenharmony_ci [CLK_APB1] = &apb1_clk.common.hw, 76662306a36Sopenharmony_ci [CLK_APB2] = &apb2_clk.common.hw, 76762306a36Sopenharmony_ci [CLK_AHB2] = &ahb2_clk.common.hw, 76862306a36Sopenharmony_ci [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw, 76962306a36Sopenharmony_ci [CLK_BUS_CE] = &bus_ce_clk.common.hw, 77062306a36Sopenharmony_ci [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 77162306a36Sopenharmony_ci [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 77262306a36Sopenharmony_ci [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 77362306a36Sopenharmony_ci [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 77462306a36Sopenharmony_ci [CLK_BUS_NAND] = &bus_nand_clk.common.hw, 77562306a36Sopenharmony_ci [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 77662306a36Sopenharmony_ci [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 77762306a36Sopenharmony_ci [CLK_BUS_TS] = &bus_ts_clk.common.hw, 77862306a36Sopenharmony_ci [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 77962306a36Sopenharmony_ci [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 78062306a36Sopenharmony_ci [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw, 78162306a36Sopenharmony_ci [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 78262306a36Sopenharmony_ci [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 78362306a36Sopenharmony_ci [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw, 78462306a36Sopenharmony_ci [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 78562306a36Sopenharmony_ci [CLK_BUS_OHCI1] = &bus_ohci1_clk.common.hw, 78662306a36Sopenharmony_ci [CLK_BUS_VE] = &bus_ve_clk.common.hw, 78762306a36Sopenharmony_ci [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 78862306a36Sopenharmony_ci [CLK_BUS_TCON1] = &bus_tcon1_clk.common.hw, 78962306a36Sopenharmony_ci [CLK_BUS_DEINTERLACE] = &bus_deinterlace_clk.common.hw, 79062306a36Sopenharmony_ci [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 79162306a36Sopenharmony_ci [CLK_BUS_HDMI] = &bus_hdmi_clk.common.hw, 79262306a36Sopenharmony_ci [CLK_BUS_DE] = &bus_de_clk.common.hw, 79362306a36Sopenharmony_ci [CLK_BUS_GPU] = &bus_gpu_clk.common.hw, 79462306a36Sopenharmony_ci [CLK_BUS_MSGBOX] = &bus_msgbox_clk.common.hw, 79562306a36Sopenharmony_ci [CLK_BUS_SPINLOCK] = &bus_spinlock_clk.common.hw, 79662306a36Sopenharmony_ci [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 79762306a36Sopenharmony_ci [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw, 79862306a36Sopenharmony_ci [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 79962306a36Sopenharmony_ci [CLK_BUS_THS] = &bus_ths_clk.common.hw, 80062306a36Sopenharmony_ci [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 80162306a36Sopenharmony_ci [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw, 80262306a36Sopenharmony_ci [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw, 80362306a36Sopenharmony_ci [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 80462306a36Sopenharmony_ci [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 80562306a36Sopenharmony_ci [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw, 80662306a36Sopenharmony_ci [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 80762306a36Sopenharmony_ci [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 80862306a36Sopenharmony_ci [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 80962306a36Sopenharmony_ci [CLK_BUS_UART3] = &bus_uart3_clk.common.hw, 81062306a36Sopenharmony_ci [CLK_BUS_UART4] = &bus_uart4_clk.common.hw, 81162306a36Sopenharmony_ci [CLK_BUS_SCR] = &bus_scr_clk.common.hw, 81262306a36Sopenharmony_ci [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 81362306a36Sopenharmony_ci [CLK_THS] = &ths_clk.common.hw, 81462306a36Sopenharmony_ci [CLK_NAND] = &nand_clk.common.hw, 81562306a36Sopenharmony_ci [CLK_MMC0] = &mmc0_clk.common.hw, 81662306a36Sopenharmony_ci [CLK_MMC1] = &mmc1_clk.common.hw, 81762306a36Sopenharmony_ci [CLK_MMC2] = &mmc2_clk.common.hw, 81862306a36Sopenharmony_ci [CLK_TS] = &ts_clk.common.hw, 81962306a36Sopenharmony_ci [CLK_CE] = &ce_clk.common.hw, 82062306a36Sopenharmony_ci [CLK_SPI0] = &spi0_clk.common.hw, 82162306a36Sopenharmony_ci [CLK_SPI1] = &spi1_clk.common.hw, 82262306a36Sopenharmony_ci [CLK_I2S0] = &i2s0_clk.common.hw, 82362306a36Sopenharmony_ci [CLK_I2S1] = &i2s1_clk.common.hw, 82462306a36Sopenharmony_ci [CLK_I2S2] = &i2s2_clk.common.hw, 82562306a36Sopenharmony_ci [CLK_SPDIF] = &spdif_clk.common.hw, 82662306a36Sopenharmony_ci [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 82762306a36Sopenharmony_ci [CLK_USB_PHY1] = &usb_phy1_clk.common.hw, 82862306a36Sopenharmony_ci [CLK_USB_HSIC] = &usb_hsic_clk.common.hw, 82962306a36Sopenharmony_ci [CLK_USB_HSIC_12M] = &usb_hsic_12m_clk.common.hw, 83062306a36Sopenharmony_ci [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 83162306a36Sopenharmony_ci [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw, 83262306a36Sopenharmony_ci [CLK_DRAM] = &dram_clk.common.hw, 83362306a36Sopenharmony_ci [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 83462306a36Sopenharmony_ci [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 83562306a36Sopenharmony_ci [CLK_DRAM_DEINTERLACE] = &dram_deinterlace_clk.common.hw, 83662306a36Sopenharmony_ci [CLK_DRAM_TS] = &dram_ts_clk.common.hw, 83762306a36Sopenharmony_ci [CLK_DE] = &de_clk.common.hw, 83862306a36Sopenharmony_ci [CLK_TCON0] = &tcon0_clk.common.hw, 83962306a36Sopenharmony_ci [CLK_TCON1] = &tcon1_clk.common.hw, 84062306a36Sopenharmony_ci [CLK_DEINTERLACE] = &deinterlace_clk.common.hw, 84162306a36Sopenharmony_ci [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 84262306a36Sopenharmony_ci [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw, 84362306a36Sopenharmony_ci [CLK_CSI_MCLK] = &csi_mclk_clk.common.hw, 84462306a36Sopenharmony_ci [CLK_VE] = &ve_clk.common.hw, 84562306a36Sopenharmony_ci [CLK_AC_DIG] = &ac_dig_clk.common.hw, 84662306a36Sopenharmony_ci [CLK_AC_DIG_4X] = &ac_dig_4x_clk.common.hw, 84762306a36Sopenharmony_ci [CLK_AVS] = &avs_clk.common.hw, 84862306a36Sopenharmony_ci [CLK_HDMI] = &hdmi_clk.common.hw, 84962306a36Sopenharmony_ci [CLK_HDMI_DDC] = &hdmi_ddc_clk.common.hw, 85062306a36Sopenharmony_ci [CLK_MBUS] = &mbus_clk.common.hw, 85162306a36Sopenharmony_ci [CLK_DSI_DPHY] = &dsi_dphy_clk.common.hw, 85262306a36Sopenharmony_ci [CLK_GPU] = &gpu_clk.common.hw, 85362306a36Sopenharmony_ci }, 85462306a36Sopenharmony_ci .num = CLK_NUMBER, 85562306a36Sopenharmony_ci}; 85662306a36Sopenharmony_ci 85762306a36Sopenharmony_cistatic struct ccu_reset_map sun50i_a64_ccu_resets[] = { 85862306a36Sopenharmony_ci [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 85962306a36Sopenharmony_ci [RST_USB_PHY1] = { 0x0cc, BIT(1) }, 86062306a36Sopenharmony_ci [RST_USB_HSIC] = { 0x0cc, BIT(2) }, 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_ci [RST_DRAM] = { 0x0f4, BIT(31) }, 86362306a36Sopenharmony_ci [RST_MBUS] = { 0x0fc, BIT(31) }, 86462306a36Sopenharmony_ci 86562306a36Sopenharmony_ci [RST_BUS_MIPI_DSI] = { 0x2c0, BIT(1) }, 86662306a36Sopenharmony_ci [RST_BUS_CE] = { 0x2c0, BIT(5) }, 86762306a36Sopenharmony_ci [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 86862306a36Sopenharmony_ci [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 86962306a36Sopenharmony_ci [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 87062306a36Sopenharmony_ci [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 87162306a36Sopenharmony_ci [RST_BUS_NAND] = { 0x2c0, BIT(13) }, 87262306a36Sopenharmony_ci [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 87362306a36Sopenharmony_ci [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 87462306a36Sopenharmony_ci [RST_BUS_TS] = { 0x2c0, BIT(18) }, 87562306a36Sopenharmony_ci [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 87662306a36Sopenharmony_ci [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 87762306a36Sopenharmony_ci [RST_BUS_SPI1] = { 0x2c0, BIT(21) }, 87862306a36Sopenharmony_ci [RST_BUS_OTG] = { 0x2c0, BIT(23) }, 87962306a36Sopenharmony_ci [RST_BUS_EHCI0] = { 0x2c0, BIT(24) }, 88062306a36Sopenharmony_ci [RST_BUS_EHCI1] = { 0x2c0, BIT(25) }, 88162306a36Sopenharmony_ci [RST_BUS_OHCI0] = { 0x2c0, BIT(28) }, 88262306a36Sopenharmony_ci [RST_BUS_OHCI1] = { 0x2c0, BIT(29) }, 88362306a36Sopenharmony_ci 88462306a36Sopenharmony_ci [RST_BUS_VE] = { 0x2c4, BIT(0) }, 88562306a36Sopenharmony_ci [RST_BUS_TCON0] = { 0x2c4, BIT(3) }, 88662306a36Sopenharmony_ci [RST_BUS_TCON1] = { 0x2c4, BIT(4) }, 88762306a36Sopenharmony_ci [RST_BUS_DEINTERLACE] = { 0x2c4, BIT(5) }, 88862306a36Sopenharmony_ci [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 88962306a36Sopenharmony_ci [RST_BUS_HDMI0] = { 0x2c4, BIT(10) }, 89062306a36Sopenharmony_ci [RST_BUS_HDMI1] = { 0x2c4, BIT(11) }, 89162306a36Sopenharmony_ci [RST_BUS_DE] = { 0x2c4, BIT(12) }, 89262306a36Sopenharmony_ci [RST_BUS_GPU] = { 0x2c4, BIT(20) }, 89362306a36Sopenharmony_ci [RST_BUS_MSGBOX] = { 0x2c4, BIT(21) }, 89462306a36Sopenharmony_ci [RST_BUS_SPINLOCK] = { 0x2c4, BIT(22) }, 89562306a36Sopenharmony_ci [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 89662306a36Sopenharmony_ci 89762306a36Sopenharmony_ci [RST_BUS_LVDS] = { 0x2c8, BIT(0) }, 89862306a36Sopenharmony_ci 89962306a36Sopenharmony_ci [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 90062306a36Sopenharmony_ci [RST_BUS_SPDIF] = { 0x2d0, BIT(1) }, 90162306a36Sopenharmony_ci [RST_BUS_THS] = { 0x2d0, BIT(8) }, 90262306a36Sopenharmony_ci [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 90362306a36Sopenharmony_ci [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, 90462306a36Sopenharmony_ci [RST_BUS_I2S2] = { 0x2d0, BIT(14) }, 90562306a36Sopenharmony_ci 90662306a36Sopenharmony_ci [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 90762306a36Sopenharmony_ci [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 90862306a36Sopenharmony_ci [RST_BUS_I2C2] = { 0x2d8, BIT(2) }, 90962306a36Sopenharmony_ci [RST_BUS_SCR] = { 0x2d8, BIT(5) }, 91062306a36Sopenharmony_ci [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 91162306a36Sopenharmony_ci [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 91262306a36Sopenharmony_ci [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 91362306a36Sopenharmony_ci [RST_BUS_UART3] = { 0x2d8, BIT(19) }, 91462306a36Sopenharmony_ci [RST_BUS_UART4] = { 0x2d8, BIT(20) }, 91562306a36Sopenharmony_ci}; 91662306a36Sopenharmony_ci 91762306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun50i_a64_ccu_desc = { 91862306a36Sopenharmony_ci .ccu_clks = sun50i_a64_ccu_clks, 91962306a36Sopenharmony_ci .num_ccu_clks = ARRAY_SIZE(sun50i_a64_ccu_clks), 92062306a36Sopenharmony_ci 92162306a36Sopenharmony_ci .hw_clks = &sun50i_a64_hw_clks, 92262306a36Sopenharmony_ci 92362306a36Sopenharmony_ci .resets = sun50i_a64_ccu_resets, 92462306a36Sopenharmony_ci .num_resets = ARRAY_SIZE(sun50i_a64_ccu_resets), 92562306a36Sopenharmony_ci}; 92662306a36Sopenharmony_ci 92762306a36Sopenharmony_cistatic struct ccu_pll_nb sun50i_a64_pll_cpu_nb = { 92862306a36Sopenharmony_ci .common = &pll_cpux_clk.common, 92962306a36Sopenharmony_ci /* copy from pll_cpux_clk */ 93062306a36Sopenharmony_ci .enable = BIT(31), 93162306a36Sopenharmony_ci .lock = BIT(28), 93262306a36Sopenharmony_ci}; 93362306a36Sopenharmony_ci 93462306a36Sopenharmony_cistatic struct ccu_mux_nb sun50i_a64_cpu_nb = { 93562306a36Sopenharmony_ci .common = &cpux_clk.common, 93662306a36Sopenharmony_ci .cm = &cpux_clk.mux, 93762306a36Sopenharmony_ci .delay_us = 1, /* > 8 clock cycles at 24 MHz */ 93862306a36Sopenharmony_ci .bypass_index = 1, /* index of 24 MHz oscillator */ 93962306a36Sopenharmony_ci}; 94062306a36Sopenharmony_ci 94162306a36Sopenharmony_cistatic int sun50i_a64_ccu_probe(struct platform_device *pdev) 94262306a36Sopenharmony_ci{ 94362306a36Sopenharmony_ci void __iomem *reg; 94462306a36Sopenharmony_ci u32 val; 94562306a36Sopenharmony_ci int ret; 94662306a36Sopenharmony_ci 94762306a36Sopenharmony_ci reg = devm_platform_ioremap_resource(pdev, 0); 94862306a36Sopenharmony_ci if (IS_ERR(reg)) 94962306a36Sopenharmony_ci return PTR_ERR(reg); 95062306a36Sopenharmony_ci 95162306a36Sopenharmony_ci /* Force the PLL-Audio-1x divider to 1 */ 95262306a36Sopenharmony_ci val = readl(reg + SUN50I_A64_PLL_AUDIO_REG); 95362306a36Sopenharmony_ci val &= ~GENMASK(19, 16); 95462306a36Sopenharmony_ci writel(val | (0 << 16), reg + SUN50I_A64_PLL_AUDIO_REG); 95562306a36Sopenharmony_ci 95662306a36Sopenharmony_ci writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG); 95762306a36Sopenharmony_ci 95862306a36Sopenharmony_ci /* Set PLL MIPI as parent for TCON0 */ 95962306a36Sopenharmony_ci val = readl(reg + SUN50I_A64_TCON0_CLK_REG); 96062306a36Sopenharmony_ci val &= ~GENMASK(26, 24); 96162306a36Sopenharmony_ci writel(val | (0 << 24), reg + SUN50I_A64_TCON0_CLK_REG); 96262306a36Sopenharmony_ci 96362306a36Sopenharmony_ci ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a64_ccu_desc); 96462306a36Sopenharmony_ci if (ret) 96562306a36Sopenharmony_ci return ret; 96662306a36Sopenharmony_ci 96762306a36Sopenharmony_ci /* Gate then ungate PLL CPU after any rate changes */ 96862306a36Sopenharmony_ci ccu_pll_notifier_register(&sun50i_a64_pll_cpu_nb); 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_ci /* Reparent CPU during PLL CPU rate changes */ 97162306a36Sopenharmony_ci ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, 97262306a36Sopenharmony_ci &sun50i_a64_cpu_nb); 97362306a36Sopenharmony_ci 97462306a36Sopenharmony_ci return 0; 97562306a36Sopenharmony_ci} 97662306a36Sopenharmony_ci 97762306a36Sopenharmony_cistatic const struct of_device_id sun50i_a64_ccu_ids[] = { 97862306a36Sopenharmony_ci { .compatible = "allwinner,sun50i-a64-ccu" }, 97962306a36Sopenharmony_ci { } 98062306a36Sopenharmony_ci}; 98162306a36Sopenharmony_ci 98262306a36Sopenharmony_cistatic struct platform_driver sun50i_a64_ccu_driver = { 98362306a36Sopenharmony_ci .probe = sun50i_a64_ccu_probe, 98462306a36Sopenharmony_ci .driver = { 98562306a36Sopenharmony_ci .name = "sun50i-a64-ccu", 98662306a36Sopenharmony_ci .suppress_bind_attrs = true, 98762306a36Sopenharmony_ci .of_match_table = sun50i_a64_ccu_ids, 98862306a36Sopenharmony_ci }, 98962306a36Sopenharmony_ci}; 99062306a36Sopenharmony_cimodule_platform_driver(sun50i_a64_ccu_driver); 99162306a36Sopenharmony_ci 99262306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU); 99362306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 994