162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2016 Icenowy Zheng <icenowy@aosc.xyz> 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Based on ccu-sun8i-h3.c, which is: 662306a36Sopenharmony_ci * Copyright (c) 2016 Maxime Ripard. All rights reserved. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/clk-provider.h> 1062306a36Sopenharmony_ci#include <linux/io.h> 1162306a36Sopenharmony_ci#include <linux/module.h> 1262306a36Sopenharmony_ci#include <linux/of.h> 1362306a36Sopenharmony_ci#include <linux/platform_device.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include "ccu_common.h" 1662306a36Sopenharmony_ci#include "ccu_reset.h" 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#include "ccu_div.h" 1962306a36Sopenharmony_ci#include "ccu_gate.h" 2062306a36Sopenharmony_ci#include "ccu_mp.h" 2162306a36Sopenharmony_ci#include "ccu_mult.h" 2262306a36Sopenharmony_ci#include "ccu_nk.h" 2362306a36Sopenharmony_ci#include "ccu_nkm.h" 2462306a36Sopenharmony_ci#include "ccu_nkmp.h" 2562306a36Sopenharmony_ci#include "ccu_nm.h" 2662306a36Sopenharmony_ci#include "ccu_phase.h" 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#include "ccu-sun8i-v3s.h" 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cistatic SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk, "pll-cpu", 3162306a36Sopenharmony_ci "osc24M", 0x000, 3262306a36Sopenharmony_ci 8, 5, /* N */ 3362306a36Sopenharmony_ci 4, 2, /* K */ 3462306a36Sopenharmony_ci 0, 2, /* M */ 3562306a36Sopenharmony_ci 16, 2, /* P */ 3662306a36Sopenharmony_ci BIT(31), /* gate */ 3762306a36Sopenharmony_ci BIT(28), /* lock */ 3862306a36Sopenharmony_ci 0); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from 4262306a36Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true 4362306a36Sopenharmony_ci * pll audio). 4462306a36Sopenharmony_ci * 4562306a36Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL, 4662306a36Sopenharmony_ci * we have to use specific dividers. This means the variable divider 4762306a36Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock 4862306a36Sopenharmony_ci * rates we support through this mechanism. So we now hard code the 4962306a36Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer 5062306a36Sopenharmony_ci * match the clock names. 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_ci#define SUN8I_V3S_PLL_AUDIO_REG 0x008 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = { 5562306a36Sopenharmony_ci { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 }, 5662306a36Sopenharmony_ci { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 }, 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", 6062306a36Sopenharmony_ci "osc24M", 0x008, 6162306a36Sopenharmony_ci 8, 7, /* N */ 6262306a36Sopenharmony_ci 0, 5, /* M */ 6362306a36Sopenharmony_ci pll_audio_sdm_table, BIT(24), 6462306a36Sopenharmony_ci 0x284, BIT(31), 6562306a36Sopenharmony_ci BIT(31), /* gate */ 6662306a36Sopenharmony_ci BIT(28), /* lock */ 6762306a36Sopenharmony_ci CLK_SET_RATE_UNGATE); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video", 7062306a36Sopenharmony_ci "osc24M", 0x0010, 7162306a36Sopenharmony_ci 8, 7, /* N */ 7262306a36Sopenharmony_ci 0, 4, /* M */ 7362306a36Sopenharmony_ci BIT(24), /* frac enable */ 7462306a36Sopenharmony_ci BIT(25), /* frac select */ 7562306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 7662306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 7762306a36Sopenharmony_ci BIT(31), /* gate */ 7862306a36Sopenharmony_ci BIT(28), /* lock */ 7962306a36Sopenharmony_ci 0); 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", 8262306a36Sopenharmony_ci "osc24M", 0x0018, 8362306a36Sopenharmony_ci 8, 7, /* N */ 8462306a36Sopenharmony_ci 0, 4, /* M */ 8562306a36Sopenharmony_ci BIT(24), /* frac enable */ 8662306a36Sopenharmony_ci BIT(25), /* frac select */ 8762306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 8862306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 8962306a36Sopenharmony_ci BIT(31), /* gate */ 9062306a36Sopenharmony_ci BIT(28), /* lock */ 9162306a36Sopenharmony_ci 0); 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", 9462306a36Sopenharmony_ci "osc24M", 0x020, 9562306a36Sopenharmony_ci 8, 5, /* N */ 9662306a36Sopenharmony_ci 4, 2, /* K */ 9762306a36Sopenharmony_ci 0, 2, /* M */ 9862306a36Sopenharmony_ci BIT(31), /* gate */ 9962306a36Sopenharmony_ci BIT(28), /* lock */ 10062306a36Sopenharmony_ci 0); 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cistatic SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph0_clk, "pll-periph0", 10362306a36Sopenharmony_ci "osc24M", 0x028, 10462306a36Sopenharmony_ci 8, 5, /* N */ 10562306a36Sopenharmony_ci 4, 2, /* K */ 10662306a36Sopenharmony_ci BIT(31), /* gate */ 10762306a36Sopenharmony_ci BIT(28), /* lock */ 10862306a36Sopenharmony_ci 2, /* post-div */ 10962306a36Sopenharmony_ci 0); 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_isp_clk, "pll-isp", 11262306a36Sopenharmony_ci "osc24M", 0x002c, 11362306a36Sopenharmony_ci 8, 7, /* N */ 11462306a36Sopenharmony_ci 0, 4, /* M */ 11562306a36Sopenharmony_ci BIT(24), /* frac enable */ 11662306a36Sopenharmony_ci BIT(25), /* frac select */ 11762306a36Sopenharmony_ci 270000000, /* frac rate 0 */ 11862306a36Sopenharmony_ci 297000000, /* frac rate 1 */ 11962306a36Sopenharmony_ci BIT(31), /* gate */ 12062306a36Sopenharmony_ci BIT(28), /* lock */ 12162306a36Sopenharmony_ci 0); 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_cistatic SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1", 12462306a36Sopenharmony_ci "osc24M", 0x044, 12562306a36Sopenharmony_ci 8, 5, /* N */ 12662306a36Sopenharmony_ci 4, 2, /* K */ 12762306a36Sopenharmony_ci BIT(31), /* gate */ 12862306a36Sopenharmony_ci BIT(28), /* lock */ 12962306a36Sopenharmony_ci 2, /* post-div */ 13062306a36Sopenharmony_ci 0); 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", 13362306a36Sopenharmony_ci "osc24M", 0x04c, 13462306a36Sopenharmony_ci 8, 7, /* N */ 13562306a36Sopenharmony_ci 0, 2, /* M */ 13662306a36Sopenharmony_ci BIT(31), /* gate */ 13762306a36Sopenharmony_ci BIT(28), /* lock */ 13862306a36Sopenharmony_ci 0); 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cistatic const char * const cpu_parents[] = { "osc32k", "osc24M", 14162306a36Sopenharmony_ci "pll-cpu", "pll-cpu" }; 14262306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents, 14362306a36Sopenharmony_ci 0x050, 16, 2, CLK_IS_CRITICAL); 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0); 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M", 14862306a36Sopenharmony_ci "axi", "pll-periph0" }; 14962306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = { 15062306a36Sopenharmony_ci { .index = 3, .shift = 6, .width = 2 }, 15162306a36Sopenharmony_ci}; 15262306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = { 15362306a36Sopenharmony_ci .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci .mux = { 15662306a36Sopenharmony_ci .shift = 12, 15762306a36Sopenharmony_ci .width = 2, 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci .var_predivs = ahb1_predivs, 16062306a36Sopenharmony_ci .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 16162306a36Sopenharmony_ci }, 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci .common = { 16462306a36Sopenharmony_ci .reg = 0x054, 16562306a36Sopenharmony_ci .features = CCU_FEATURE_VARIABLE_PREDIV, 16662306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb1", 16762306a36Sopenharmony_ci ahb1_parents, 16862306a36Sopenharmony_ci &ccu_div_ops, 16962306a36Sopenharmony_ci 0), 17062306a36Sopenharmony_ci }, 17162306a36Sopenharmony_ci}; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = { 17462306a36Sopenharmony_ci { .val = 0, .div = 2 }, 17562306a36Sopenharmony_ci { .val = 1, .div = 2 }, 17662306a36Sopenharmony_ci { .val = 2, .div = 4 }, 17762306a36Sopenharmony_ci { .val = 3, .div = 8 }, 17862306a36Sopenharmony_ci { /* Sentinel */ }, 17962306a36Sopenharmony_ci}; 18062306a36Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1", 18162306a36Sopenharmony_ci 0x054, 8, 2, apb1_div_table, 0); 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M", 18462306a36Sopenharmony_ci "pll-periph0", "pll-periph0" }; 18562306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 18662306a36Sopenharmony_ci 0, 5, /* M */ 18762306a36Sopenharmony_ci 16, 2, /* P */ 18862306a36Sopenharmony_ci 24, 2, /* mux */ 18962306a36Sopenharmony_ci 0); 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_cistatic const char * const ahb2_parents[] = { "ahb1", "pll-periph0" }; 19262306a36Sopenharmony_cistatic const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = { 19362306a36Sopenharmony_ci { .index = 1, .div = 2 }, 19462306a36Sopenharmony_ci}; 19562306a36Sopenharmony_cistatic struct ccu_mux ahb2_clk = { 19662306a36Sopenharmony_ci .mux = { 19762306a36Sopenharmony_ci .shift = 0, 19862306a36Sopenharmony_ci .width = 1, 19962306a36Sopenharmony_ci .fixed_predivs = ahb2_fixed_predivs, 20062306a36Sopenharmony_ci .n_predivs = ARRAY_SIZE(ahb2_fixed_predivs), 20162306a36Sopenharmony_ci }, 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci .common = { 20462306a36Sopenharmony_ci .reg = 0x05c, 20562306a36Sopenharmony_ci .features = CCU_FEATURE_FIXED_PREDIV, 20662306a36Sopenharmony_ci .hw.init = CLK_HW_INIT_PARENTS("ahb2", 20762306a36Sopenharmony_ci ahb2_parents, 20862306a36Sopenharmony_ci &ccu_mux_ops, 20962306a36Sopenharmony_ci 0), 21062306a36Sopenharmony_ci }, 21162306a36Sopenharmony_ci}; 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1", 21462306a36Sopenharmony_ci 0x060, BIT(5), 0); 21562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 21662306a36Sopenharmony_ci 0x060, BIT(6), 0); 21762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 21862306a36Sopenharmony_ci 0x060, BIT(8), 0); 21962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 22062306a36Sopenharmony_ci 0x060, BIT(9), 0); 22162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 22262306a36Sopenharmony_ci 0x060, BIT(10), 0); 22362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 22462306a36Sopenharmony_ci 0x060, BIT(14), 0); 22562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2", 22662306a36Sopenharmony_ci 0x060, BIT(17), 0); 22762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 22862306a36Sopenharmony_ci 0x060, BIT(19), 0); 22962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 23062306a36Sopenharmony_ci 0x060, BIT(20), 0); 23162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 23262306a36Sopenharmony_ci 0x060, BIT(24), 0); 23362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1", 23462306a36Sopenharmony_ci 0x060, BIT(26), 0); 23562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1", 23662306a36Sopenharmony_ci 0x060, BIT(29), 0); 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 23962306a36Sopenharmony_ci 0x064, BIT(0), 0); 24062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1", 24162306a36Sopenharmony_ci 0x064, BIT(4), 0); 24262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1", 24362306a36Sopenharmony_ci 0x064, BIT(8), 0); 24462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 24562306a36Sopenharmony_ci 0x064, BIT(12), 0); 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1", 24862306a36Sopenharmony_ci 0x068, BIT(0), 0); 24962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 25062306a36Sopenharmony_ci 0x068, BIT(5), 0); 25162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 25262306a36Sopenharmony_ci 0x068, BIT(12), 0); 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 25562306a36Sopenharmony_ci 0x06c, BIT(0), 0); 25662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 25762306a36Sopenharmony_ci 0x06c, BIT(1), 0); 25862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 25962306a36Sopenharmony_ci 0x06c, BIT(16), 0); 26062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 26162306a36Sopenharmony_ci 0x06c, BIT(17), 0); 26262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 26362306a36Sopenharmony_ci 0x06c, BIT(18), 0); 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ephy_clk, "bus-ephy", "ahb1", 26662306a36Sopenharmony_ci 0x070, BIT(0), 0); 26762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1", 26862306a36Sopenharmony_ci 0x070, BIT(7), 0); 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph0", 27162306a36Sopenharmony_ci "pll-periph1" }; 27262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088, 27362306a36Sopenharmony_ci 0, 4, /* M */ 27462306a36Sopenharmony_ci 16, 2, /* P */ 27562306a36Sopenharmony_ci 24, 2, /* mux */ 27662306a36Sopenharmony_ci BIT(31), /* gate */ 27762306a36Sopenharmony_ci 0); 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0", 28062306a36Sopenharmony_ci 0x088, 20, 3, 0); 28162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0", 28262306a36Sopenharmony_ci 0x088, 8, 3, 0); 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c, 28562306a36Sopenharmony_ci 0, 4, /* M */ 28662306a36Sopenharmony_ci 16, 2, /* P */ 28762306a36Sopenharmony_ci 24, 2, /* mux */ 28862306a36Sopenharmony_ci BIT(31), /* gate */ 28962306a36Sopenharmony_ci 0); 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1", 29262306a36Sopenharmony_ci 0x08c, 20, 3, 0); 29362306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1", 29462306a36Sopenharmony_ci 0x08c, 8, 3, 0); 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090, 29762306a36Sopenharmony_ci 0, 4, /* M */ 29862306a36Sopenharmony_ci 16, 2, /* P */ 29962306a36Sopenharmony_ci 24, 2, /* mux */ 30062306a36Sopenharmony_ci BIT(31), /* gate */ 30162306a36Sopenharmony_ci 0); 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2", 30462306a36Sopenharmony_ci 0x090, 20, 3, 0); 30562306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2", 30662306a36Sopenharmony_ci 0x090, 8, 3, 0); 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_cistatic const char * const ce_parents[] = { "osc24M", "pll-periph0", }; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c, 31162306a36Sopenharmony_ci 0, 4, /* M */ 31262306a36Sopenharmony_ci 16, 2, /* P */ 31362306a36Sopenharmony_ci 24, 2, /* mux */ 31462306a36Sopenharmony_ci BIT(31), /* gate */ 31562306a36Sopenharmony_ci 0); 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, 31862306a36Sopenharmony_ci 0, 4, /* M */ 31962306a36Sopenharmony_ci 16, 2, /* P */ 32062306a36Sopenharmony_ci 24, 2, /* mux */ 32162306a36Sopenharmony_ci BIT(31), /* gate */ 32262306a36Sopenharmony_ci 0); 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", 32562306a36Sopenharmony_ci "pll-audio-2x", "pll-audio" }; 32662306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, 32762306a36Sopenharmony_ci 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 33062306a36Sopenharmony_ci 0x0cc, BIT(8), 0); 33162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc24M", 33262306a36Sopenharmony_ci 0x0cc, BIT(16), 0); 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_cistatic const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1", 33562306a36Sopenharmony_ci "pll-periph0-2x" }; 33662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, 33762306a36Sopenharmony_ci 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL); 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 34062306a36Sopenharmony_ci 0x100, BIT(0), 0); 34162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram", 34262306a36Sopenharmony_ci 0x100, BIT(1), 0); 34362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ehci_clk, "dram-ehci", "dram", 34462306a36Sopenharmony_ci 0x100, BIT(17), 0); 34562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ohci_clk, "dram-ohci", "dram", 34662306a36Sopenharmony_ci 0x100, BIT(18), 0); 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-video", "pll-periph0" }; 34962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, 35062306a36Sopenharmony_ci 0x104, 0, 4, 24, 2, BIT(31), 35162306a36Sopenharmony_ci CLK_SET_RATE_PARENT); 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_cistatic const char * const tcon_parents[] = { "pll-video" }; 35462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents, 35562306a36Sopenharmony_ci 0x118, 0, 4, 24, 3, BIT(31), 0); 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M", 35862306a36Sopenharmony_ci 0x130, BIT(31), 0); 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "osc24M", "pll-video", 36162306a36Sopenharmony_ci "pll-periph0", "pll-periph1" }; 36262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents, 36362306a36Sopenharmony_ci 0x130, 0, 5, 8, 3, BIT(15), 0); 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_cistatic const char * const csi1_sclk_parents[] = { "pll-video", "pll-isp" }; 36662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi1_sclk_clk, "csi-sclk", csi1_sclk_parents, 36762306a36Sopenharmony_ci 0x134, 16, 4, 24, 3, BIT(31), 0); 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi-mclk", csi_mclk_parents, 37062306a36Sopenharmony_ci 0x134, 0, 5, 8, 3, BIT(15), 0); 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 37362306a36Sopenharmony_ci 0x13c, 16, 3, BIT(31), 0); 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio", 37662306a36Sopenharmony_ci 0x140, BIT(31), CLK_SET_RATE_PARENT); 37762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 37862306a36Sopenharmony_ci 0x144, BIT(31), 0); 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", 38162306a36Sopenharmony_ci "pll-ddr" }; 38262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 38362306a36Sopenharmony_ci 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL); 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_cistatic const char * const mipi_csi_parents[] = { "pll-video", "pll-periph0", 38662306a36Sopenharmony_ci "pll-isp" }; 38762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mipi_csi_clk, "mipi-csi", mipi_csi_parents, 38862306a36Sopenharmony_ci 0x16c, 0, 3, 24, 2, BIT(31), 0); 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_cistatic struct ccu_common *sun8i_v3s_ccu_clks[] = { 39162306a36Sopenharmony_ci &pll_cpu_clk.common, 39262306a36Sopenharmony_ci &pll_audio_base_clk.common, 39362306a36Sopenharmony_ci &pll_video_clk.common, 39462306a36Sopenharmony_ci &pll_ve_clk.common, 39562306a36Sopenharmony_ci &pll_ddr0_clk.common, 39662306a36Sopenharmony_ci &pll_periph0_clk.common, 39762306a36Sopenharmony_ci &pll_isp_clk.common, 39862306a36Sopenharmony_ci &pll_periph1_clk.common, 39962306a36Sopenharmony_ci &pll_ddr1_clk.common, 40062306a36Sopenharmony_ci &cpu_clk.common, 40162306a36Sopenharmony_ci &axi_clk.common, 40262306a36Sopenharmony_ci &ahb1_clk.common, 40362306a36Sopenharmony_ci &apb1_clk.common, 40462306a36Sopenharmony_ci &apb2_clk.common, 40562306a36Sopenharmony_ci &ahb2_clk.common, 40662306a36Sopenharmony_ci &bus_ce_clk.common, 40762306a36Sopenharmony_ci &bus_dma_clk.common, 40862306a36Sopenharmony_ci &bus_mmc0_clk.common, 40962306a36Sopenharmony_ci &bus_mmc1_clk.common, 41062306a36Sopenharmony_ci &bus_mmc2_clk.common, 41162306a36Sopenharmony_ci &bus_dram_clk.common, 41262306a36Sopenharmony_ci &bus_emac_clk.common, 41362306a36Sopenharmony_ci &bus_hstimer_clk.common, 41462306a36Sopenharmony_ci &bus_spi0_clk.common, 41562306a36Sopenharmony_ci &bus_otg_clk.common, 41662306a36Sopenharmony_ci &bus_ehci0_clk.common, 41762306a36Sopenharmony_ci &bus_ohci0_clk.common, 41862306a36Sopenharmony_ci &bus_ve_clk.common, 41962306a36Sopenharmony_ci &bus_tcon0_clk.common, 42062306a36Sopenharmony_ci &bus_csi_clk.common, 42162306a36Sopenharmony_ci &bus_de_clk.common, 42262306a36Sopenharmony_ci &bus_codec_clk.common, 42362306a36Sopenharmony_ci &bus_pio_clk.common, 42462306a36Sopenharmony_ci &bus_i2s0_clk.common, 42562306a36Sopenharmony_ci &bus_i2c0_clk.common, 42662306a36Sopenharmony_ci &bus_i2c1_clk.common, 42762306a36Sopenharmony_ci &bus_uart0_clk.common, 42862306a36Sopenharmony_ci &bus_uart1_clk.common, 42962306a36Sopenharmony_ci &bus_uart2_clk.common, 43062306a36Sopenharmony_ci &bus_ephy_clk.common, 43162306a36Sopenharmony_ci &bus_dbg_clk.common, 43262306a36Sopenharmony_ci &mmc0_clk.common, 43362306a36Sopenharmony_ci &mmc0_sample_clk.common, 43462306a36Sopenharmony_ci &mmc0_output_clk.common, 43562306a36Sopenharmony_ci &mmc1_clk.common, 43662306a36Sopenharmony_ci &mmc1_sample_clk.common, 43762306a36Sopenharmony_ci &mmc1_output_clk.common, 43862306a36Sopenharmony_ci &mmc2_clk.common, 43962306a36Sopenharmony_ci &mmc2_sample_clk.common, 44062306a36Sopenharmony_ci &mmc2_output_clk.common, 44162306a36Sopenharmony_ci &ce_clk.common, 44262306a36Sopenharmony_ci &spi0_clk.common, 44362306a36Sopenharmony_ci &i2s0_clk.common, 44462306a36Sopenharmony_ci &usb_phy0_clk.common, 44562306a36Sopenharmony_ci &usb_ohci0_clk.common, 44662306a36Sopenharmony_ci &dram_clk.common, 44762306a36Sopenharmony_ci &dram_ve_clk.common, 44862306a36Sopenharmony_ci &dram_csi_clk.common, 44962306a36Sopenharmony_ci &dram_ohci_clk.common, 45062306a36Sopenharmony_ci &dram_ehci_clk.common, 45162306a36Sopenharmony_ci &de_clk.common, 45262306a36Sopenharmony_ci &tcon_clk.common, 45362306a36Sopenharmony_ci &csi_misc_clk.common, 45462306a36Sopenharmony_ci &csi0_mclk_clk.common, 45562306a36Sopenharmony_ci &csi1_sclk_clk.common, 45662306a36Sopenharmony_ci &csi1_mclk_clk.common, 45762306a36Sopenharmony_ci &ve_clk.common, 45862306a36Sopenharmony_ci &ac_dig_clk.common, 45962306a36Sopenharmony_ci &avs_clk.common, 46062306a36Sopenharmony_ci &mbus_clk.common, 46162306a36Sopenharmony_ci &mipi_csi_clk.common, 46262306a36Sopenharmony_ci}; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = { 46562306a36Sopenharmony_ci &pll_audio_base_clk.common.hw 46662306a36Sopenharmony_ci}; 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci/* We hardcode the divider to 1 for SDM support */ 46962306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", 47062306a36Sopenharmony_ci clk_parent_pll_audio, 47162306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 47262306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", 47362306a36Sopenharmony_ci clk_parent_pll_audio, 47462306a36Sopenharmony_ci 2, 1, CLK_SET_RATE_PARENT); 47562306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x", 47662306a36Sopenharmony_ci clk_parent_pll_audio, 47762306a36Sopenharmony_ci 1, 1, CLK_SET_RATE_PARENT); 47862306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x", 47962306a36Sopenharmony_ci clk_parent_pll_audio, 48062306a36Sopenharmony_ci 1, 2, CLK_SET_RATE_PARENT); 48162306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x", 48262306a36Sopenharmony_ci &pll_periph0_clk.common.hw, 48362306a36Sopenharmony_ci 1, 2, 0); 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_v3s_hw_clks = { 48662306a36Sopenharmony_ci .hws = { 48762306a36Sopenharmony_ci [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, 48862306a36Sopenharmony_ci [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 48962306a36Sopenharmony_ci [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 49062306a36Sopenharmony_ci [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 49162306a36Sopenharmony_ci [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 49262306a36Sopenharmony_ci [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 49362306a36Sopenharmony_ci [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, 49462306a36Sopenharmony_ci [CLK_PLL_VE] = &pll_ve_clk.common.hw, 49562306a36Sopenharmony_ci [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 49662306a36Sopenharmony_ci [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 49762306a36Sopenharmony_ci [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 49862306a36Sopenharmony_ci [CLK_PLL_ISP] = &pll_isp_clk.common.hw, 49962306a36Sopenharmony_ci [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 50062306a36Sopenharmony_ci [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 50162306a36Sopenharmony_ci [CLK_CPU] = &cpu_clk.common.hw, 50262306a36Sopenharmony_ci [CLK_AXI] = &axi_clk.common.hw, 50362306a36Sopenharmony_ci [CLK_AHB1] = &ahb1_clk.common.hw, 50462306a36Sopenharmony_ci [CLK_APB1] = &apb1_clk.common.hw, 50562306a36Sopenharmony_ci [CLK_APB2] = &apb2_clk.common.hw, 50662306a36Sopenharmony_ci [CLK_AHB2] = &ahb2_clk.common.hw, 50762306a36Sopenharmony_ci [CLK_BUS_CE] = &bus_ce_clk.common.hw, 50862306a36Sopenharmony_ci [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 50962306a36Sopenharmony_ci [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 51062306a36Sopenharmony_ci [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 51162306a36Sopenharmony_ci [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 51262306a36Sopenharmony_ci [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 51362306a36Sopenharmony_ci [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 51462306a36Sopenharmony_ci [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 51562306a36Sopenharmony_ci [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 51662306a36Sopenharmony_ci [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 51762306a36Sopenharmony_ci [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 51862306a36Sopenharmony_ci [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 51962306a36Sopenharmony_ci [CLK_BUS_VE] = &bus_ve_clk.common.hw, 52062306a36Sopenharmony_ci [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 52162306a36Sopenharmony_ci [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 52262306a36Sopenharmony_ci [CLK_BUS_DE] = &bus_de_clk.common.hw, 52362306a36Sopenharmony_ci [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 52462306a36Sopenharmony_ci [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 52562306a36Sopenharmony_ci [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 52662306a36Sopenharmony_ci [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 52762306a36Sopenharmony_ci [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 52862306a36Sopenharmony_ci [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 52962306a36Sopenharmony_ci [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 53062306a36Sopenharmony_ci [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw, 53162306a36Sopenharmony_ci [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 53262306a36Sopenharmony_ci [CLK_MMC0] = &mmc0_clk.common.hw, 53362306a36Sopenharmony_ci [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 53462306a36Sopenharmony_ci [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 53562306a36Sopenharmony_ci [CLK_MMC1] = &mmc1_clk.common.hw, 53662306a36Sopenharmony_ci [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 53762306a36Sopenharmony_ci [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 53862306a36Sopenharmony_ci [CLK_MMC2] = &mmc2_clk.common.hw, 53962306a36Sopenharmony_ci [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw, 54062306a36Sopenharmony_ci [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw, 54162306a36Sopenharmony_ci [CLK_CE] = &ce_clk.common.hw, 54262306a36Sopenharmony_ci [CLK_SPI0] = &spi0_clk.common.hw, 54362306a36Sopenharmony_ci [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 54462306a36Sopenharmony_ci [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 54562306a36Sopenharmony_ci [CLK_DRAM] = &dram_clk.common.hw, 54662306a36Sopenharmony_ci [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 54762306a36Sopenharmony_ci [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 54862306a36Sopenharmony_ci [CLK_DRAM_EHCI] = &dram_ehci_clk.common.hw, 54962306a36Sopenharmony_ci [CLK_DRAM_OHCI] = &dram_ohci_clk.common.hw, 55062306a36Sopenharmony_ci [CLK_DE] = &de_clk.common.hw, 55162306a36Sopenharmony_ci [CLK_TCON0] = &tcon_clk.common.hw, 55262306a36Sopenharmony_ci [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 55362306a36Sopenharmony_ci [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw, 55462306a36Sopenharmony_ci [CLK_CSI1_SCLK] = &csi1_sclk_clk.common.hw, 55562306a36Sopenharmony_ci [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw, 55662306a36Sopenharmony_ci [CLK_VE] = &ve_clk.common.hw, 55762306a36Sopenharmony_ci [CLK_AC_DIG] = &ac_dig_clk.common.hw, 55862306a36Sopenharmony_ci [CLK_AVS] = &avs_clk.common.hw, 55962306a36Sopenharmony_ci [CLK_MBUS] = &mbus_clk.common.hw, 56062306a36Sopenharmony_ci [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw, 56162306a36Sopenharmony_ci }, 56262306a36Sopenharmony_ci .num = CLK_PLL_DDR1 + 1, 56362306a36Sopenharmony_ci}; 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_v3_hw_clks = { 56662306a36Sopenharmony_ci .hws = { 56762306a36Sopenharmony_ci [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, 56862306a36Sopenharmony_ci [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 56962306a36Sopenharmony_ci [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 57062306a36Sopenharmony_ci [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 57162306a36Sopenharmony_ci [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 57262306a36Sopenharmony_ci [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 57362306a36Sopenharmony_ci [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, 57462306a36Sopenharmony_ci [CLK_PLL_VE] = &pll_ve_clk.common.hw, 57562306a36Sopenharmony_ci [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 57662306a36Sopenharmony_ci [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 57762306a36Sopenharmony_ci [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 57862306a36Sopenharmony_ci [CLK_PLL_ISP] = &pll_isp_clk.common.hw, 57962306a36Sopenharmony_ci [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 58062306a36Sopenharmony_ci [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 58162306a36Sopenharmony_ci [CLK_CPU] = &cpu_clk.common.hw, 58262306a36Sopenharmony_ci [CLK_AXI] = &axi_clk.common.hw, 58362306a36Sopenharmony_ci [CLK_AHB1] = &ahb1_clk.common.hw, 58462306a36Sopenharmony_ci [CLK_APB1] = &apb1_clk.common.hw, 58562306a36Sopenharmony_ci [CLK_APB2] = &apb2_clk.common.hw, 58662306a36Sopenharmony_ci [CLK_AHB2] = &ahb2_clk.common.hw, 58762306a36Sopenharmony_ci [CLK_BUS_CE] = &bus_ce_clk.common.hw, 58862306a36Sopenharmony_ci [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 58962306a36Sopenharmony_ci [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 59062306a36Sopenharmony_ci [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 59162306a36Sopenharmony_ci [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 59262306a36Sopenharmony_ci [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 59362306a36Sopenharmony_ci [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 59462306a36Sopenharmony_ci [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 59562306a36Sopenharmony_ci [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 59662306a36Sopenharmony_ci [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 59762306a36Sopenharmony_ci [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 59862306a36Sopenharmony_ci [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 59962306a36Sopenharmony_ci [CLK_BUS_VE] = &bus_ve_clk.common.hw, 60062306a36Sopenharmony_ci [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 60162306a36Sopenharmony_ci [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 60262306a36Sopenharmony_ci [CLK_BUS_DE] = &bus_de_clk.common.hw, 60362306a36Sopenharmony_ci [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 60462306a36Sopenharmony_ci [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 60562306a36Sopenharmony_ci [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 60662306a36Sopenharmony_ci [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 60762306a36Sopenharmony_ci [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 60862306a36Sopenharmony_ci [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 60962306a36Sopenharmony_ci [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 61062306a36Sopenharmony_ci [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 61162306a36Sopenharmony_ci [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw, 61262306a36Sopenharmony_ci [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 61362306a36Sopenharmony_ci [CLK_MMC0] = &mmc0_clk.common.hw, 61462306a36Sopenharmony_ci [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 61562306a36Sopenharmony_ci [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 61662306a36Sopenharmony_ci [CLK_MMC1] = &mmc1_clk.common.hw, 61762306a36Sopenharmony_ci [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 61862306a36Sopenharmony_ci [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 61962306a36Sopenharmony_ci [CLK_MMC2] = &mmc2_clk.common.hw, 62062306a36Sopenharmony_ci [CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw, 62162306a36Sopenharmony_ci [CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw, 62262306a36Sopenharmony_ci [CLK_CE] = &ce_clk.common.hw, 62362306a36Sopenharmony_ci [CLK_SPI0] = &spi0_clk.common.hw, 62462306a36Sopenharmony_ci [CLK_I2S0] = &i2s0_clk.common.hw, 62562306a36Sopenharmony_ci [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 62662306a36Sopenharmony_ci [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 62762306a36Sopenharmony_ci [CLK_DRAM] = &dram_clk.common.hw, 62862306a36Sopenharmony_ci [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 62962306a36Sopenharmony_ci [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 63062306a36Sopenharmony_ci [CLK_DRAM_EHCI] = &dram_ehci_clk.common.hw, 63162306a36Sopenharmony_ci [CLK_DRAM_OHCI] = &dram_ohci_clk.common.hw, 63262306a36Sopenharmony_ci [CLK_DE] = &de_clk.common.hw, 63362306a36Sopenharmony_ci [CLK_TCON0] = &tcon_clk.common.hw, 63462306a36Sopenharmony_ci [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 63562306a36Sopenharmony_ci [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw, 63662306a36Sopenharmony_ci [CLK_CSI1_SCLK] = &csi1_sclk_clk.common.hw, 63762306a36Sopenharmony_ci [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw, 63862306a36Sopenharmony_ci [CLK_VE] = &ve_clk.common.hw, 63962306a36Sopenharmony_ci [CLK_AC_DIG] = &ac_dig_clk.common.hw, 64062306a36Sopenharmony_ci [CLK_AVS] = &avs_clk.common.hw, 64162306a36Sopenharmony_ci [CLK_MBUS] = &mbus_clk.common.hw, 64262306a36Sopenharmony_ci [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw, 64362306a36Sopenharmony_ci }, 64462306a36Sopenharmony_ci .num = CLK_I2S0 + 1, 64562306a36Sopenharmony_ci}; 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_v3s_ccu_resets[] = { 64862306a36Sopenharmony_ci [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci [RST_MBUS] = { 0x0fc, BIT(31) }, 65162306a36Sopenharmony_ci 65262306a36Sopenharmony_ci [RST_BUS_CE] = { 0x2c0, BIT(5) }, 65362306a36Sopenharmony_ci [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 65462306a36Sopenharmony_ci [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 65562306a36Sopenharmony_ci [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 65662306a36Sopenharmony_ci [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 65762306a36Sopenharmony_ci [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 65862306a36Sopenharmony_ci [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 65962306a36Sopenharmony_ci [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 66062306a36Sopenharmony_ci [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 66162306a36Sopenharmony_ci [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 66262306a36Sopenharmony_ci [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 66362306a36Sopenharmony_ci [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_ci [RST_BUS_VE] = { 0x2c4, BIT(0) }, 66662306a36Sopenharmony_ci [RST_BUS_TCON0] = { 0x2c4, BIT(4) }, 66762306a36Sopenharmony_ci [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 66862306a36Sopenharmony_ci [RST_BUS_DE] = { 0x2c4, BIT(12) }, 66962306a36Sopenharmony_ci [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_ci [RST_BUS_EPHY] = { 0x2c8, BIT(2) }, 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 67462306a36Sopenharmony_ci 67562306a36Sopenharmony_ci [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 67662306a36Sopenharmony_ci [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 67762306a36Sopenharmony_ci [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 67862306a36Sopenharmony_ci [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 67962306a36Sopenharmony_ci [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 68062306a36Sopenharmony_ci}; 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_v3_ccu_resets[] = { 68362306a36Sopenharmony_ci [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 68462306a36Sopenharmony_ci 68562306a36Sopenharmony_ci [RST_MBUS] = { 0x0fc, BIT(31) }, 68662306a36Sopenharmony_ci 68762306a36Sopenharmony_ci [RST_BUS_CE] = { 0x2c0, BIT(5) }, 68862306a36Sopenharmony_ci [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 68962306a36Sopenharmony_ci [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 69062306a36Sopenharmony_ci [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 69162306a36Sopenharmony_ci [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 69262306a36Sopenharmony_ci [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 69362306a36Sopenharmony_ci [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 69462306a36Sopenharmony_ci [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 69562306a36Sopenharmony_ci [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 69662306a36Sopenharmony_ci [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 69762306a36Sopenharmony_ci [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 69862306a36Sopenharmony_ci [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci [RST_BUS_VE] = { 0x2c4, BIT(0) }, 70162306a36Sopenharmony_ci [RST_BUS_TCON0] = { 0x2c4, BIT(4) }, 70262306a36Sopenharmony_ci [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 70362306a36Sopenharmony_ci [RST_BUS_DE] = { 0x2c4, BIT(12) }, 70462306a36Sopenharmony_ci [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ci [RST_BUS_EPHY] = { 0x2c8, BIT(2) }, 70762306a36Sopenharmony_ci 70862306a36Sopenharmony_ci [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 70962306a36Sopenharmony_ci [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 71062306a36Sopenharmony_ci 71162306a36Sopenharmony_ci [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 71262306a36Sopenharmony_ci [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 71362306a36Sopenharmony_ci [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 71462306a36Sopenharmony_ci [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 71562306a36Sopenharmony_ci [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 71662306a36Sopenharmony_ci}; 71762306a36Sopenharmony_ci 71862306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_v3s_ccu_desc = { 71962306a36Sopenharmony_ci .ccu_clks = sun8i_v3s_ccu_clks, 72062306a36Sopenharmony_ci .num_ccu_clks = ARRAY_SIZE(sun8i_v3s_ccu_clks), 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_ci .hw_clks = &sun8i_v3s_hw_clks, 72362306a36Sopenharmony_ci 72462306a36Sopenharmony_ci .resets = sun8i_v3s_ccu_resets, 72562306a36Sopenharmony_ci .num_resets = ARRAY_SIZE(sun8i_v3s_ccu_resets), 72662306a36Sopenharmony_ci}; 72762306a36Sopenharmony_ci 72862306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_v3_ccu_desc = { 72962306a36Sopenharmony_ci .ccu_clks = sun8i_v3s_ccu_clks, 73062306a36Sopenharmony_ci .num_ccu_clks = ARRAY_SIZE(sun8i_v3s_ccu_clks), 73162306a36Sopenharmony_ci 73262306a36Sopenharmony_ci .hw_clks = &sun8i_v3_hw_clks, 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_ci .resets = sun8i_v3_ccu_resets, 73562306a36Sopenharmony_ci .num_resets = ARRAY_SIZE(sun8i_v3_ccu_resets), 73662306a36Sopenharmony_ci}; 73762306a36Sopenharmony_ci 73862306a36Sopenharmony_cistatic int sun8i_v3s_ccu_probe(struct platform_device *pdev) 73962306a36Sopenharmony_ci{ 74062306a36Sopenharmony_ci const struct sunxi_ccu_desc *desc; 74162306a36Sopenharmony_ci void __iomem *reg; 74262306a36Sopenharmony_ci u32 val; 74362306a36Sopenharmony_ci 74462306a36Sopenharmony_ci desc = of_device_get_match_data(&pdev->dev); 74562306a36Sopenharmony_ci if (!desc) 74662306a36Sopenharmony_ci return -EINVAL; 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci reg = devm_platform_ioremap_resource(pdev, 0); 74962306a36Sopenharmony_ci if (IS_ERR(reg)) 75062306a36Sopenharmony_ci return PTR_ERR(reg); 75162306a36Sopenharmony_ci 75262306a36Sopenharmony_ci /* Force the PLL-Audio-1x divider to 1 */ 75362306a36Sopenharmony_ci val = readl(reg + SUN8I_V3S_PLL_AUDIO_REG); 75462306a36Sopenharmony_ci val &= ~GENMASK(19, 16); 75562306a36Sopenharmony_ci writel(val, reg + SUN8I_V3S_PLL_AUDIO_REG); 75662306a36Sopenharmony_ci 75762306a36Sopenharmony_ci return devm_sunxi_ccu_probe(&pdev->dev, reg, desc); 75862306a36Sopenharmony_ci} 75962306a36Sopenharmony_ci 76062306a36Sopenharmony_cistatic const struct of_device_id sun8i_v3s_ccu_ids[] = { 76162306a36Sopenharmony_ci { 76262306a36Sopenharmony_ci .compatible = "allwinner,sun8i-v3-ccu", 76362306a36Sopenharmony_ci .data = &sun8i_v3_ccu_desc, 76462306a36Sopenharmony_ci }, 76562306a36Sopenharmony_ci { 76662306a36Sopenharmony_ci .compatible = "allwinner,sun8i-v3s-ccu", 76762306a36Sopenharmony_ci .data = &sun8i_v3s_ccu_desc, 76862306a36Sopenharmony_ci }, 76962306a36Sopenharmony_ci { } 77062306a36Sopenharmony_ci}; 77162306a36Sopenharmony_ci 77262306a36Sopenharmony_cistatic struct platform_driver sun8i_v3s_ccu_driver = { 77362306a36Sopenharmony_ci .probe = sun8i_v3s_ccu_probe, 77462306a36Sopenharmony_ci .driver = { 77562306a36Sopenharmony_ci .name = "sun8i-v3s-ccu", 77662306a36Sopenharmony_ci .suppress_bind_attrs = true, 77762306a36Sopenharmony_ci .of_match_table = sun8i_v3s_ccu_ids, 77862306a36Sopenharmony_ci }, 77962306a36Sopenharmony_ci}; 78062306a36Sopenharmony_cimodule_platform_driver(sun8i_v3s_ccu_driver); 78162306a36Sopenharmony_ci 78262306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU); 78362306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 784