19c92ab61SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2d0f11d14SIcenowy Zheng /* 3d0f11d14SIcenowy Zheng * Copyright (c) 2016 Icenowy Zheng <icenowy@aosc.xyz> 4d0f11d14SIcenowy Zheng * 5d0f11d14SIcenowy Zheng * Based on ccu-sun8i-h3.c, which is: 6d0f11d14SIcenowy Zheng * Copyright (c) 2016 Maxime Ripard. All rights reserved. 7d0f11d14SIcenowy Zheng */ 8d0f11d14SIcenowy Zheng 9d0f11d14SIcenowy Zheng #include <linux/clk-provider.h> 1062e59c4eSStephen Boyd #include <linux/io.h> 11d0f11d14SIcenowy Zheng #include <linux/of_address.h> 12d0f11d14SIcenowy Zheng 13d0f11d14SIcenowy Zheng #include "ccu_common.h" 14d0f11d14SIcenowy Zheng #include "ccu_reset.h" 15d0f11d14SIcenowy Zheng 16d0f11d14SIcenowy Zheng #include "ccu_div.h" 17d0f11d14SIcenowy Zheng #include "ccu_gate.h" 18d0f11d14SIcenowy Zheng #include "ccu_mp.h" 19d0f11d14SIcenowy Zheng #include "ccu_mult.h" 20d0f11d14SIcenowy Zheng #include "ccu_nk.h" 21d0f11d14SIcenowy Zheng #include "ccu_nkm.h" 22d0f11d14SIcenowy Zheng #include "ccu_nkmp.h" 23d0f11d14SIcenowy Zheng #include "ccu_nm.h" 24d0f11d14SIcenowy Zheng #include "ccu_phase.h" 25d0f11d14SIcenowy Zheng 26d0f11d14SIcenowy Zheng #include "ccu-sun8i-v3s.h" 27d0f11d14SIcenowy Zheng 28d0f11d14SIcenowy Zheng static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk, "pll-cpu", 29d0f11d14SIcenowy Zheng "osc24M", 0x000, 30d0f11d14SIcenowy Zheng 8, 5, /* N */ 31d0f11d14SIcenowy Zheng 4, 2, /* K */ 32d0f11d14SIcenowy Zheng 0, 2, /* M */ 33d0f11d14SIcenowy Zheng 16, 2, /* P */ 34d0f11d14SIcenowy Zheng BIT(31), /* gate */ 35d0f11d14SIcenowy Zheng BIT(28), /* lock */ 36d0f11d14SIcenowy Zheng 0); 37d0f11d14SIcenowy Zheng 38d0f11d14SIcenowy Zheng /* 39d0f11d14SIcenowy Zheng * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from 40d0f11d14SIcenowy Zheng * the base (2x, 4x and 8x), and one variable divider (the one true 41d0f11d14SIcenowy Zheng * pll audio). 42d0f11d14SIcenowy Zheng * 43d0f11d14SIcenowy Zheng * We don't have any need for the variable divider for now, so we just 44d0f11d14SIcenowy Zheng * hardcode it to match with the clock names 45d0f11d14SIcenowy Zheng */ 46d0f11d14SIcenowy Zheng #define SUN8I_V3S_PLL_AUDIO_REG 0x008 47d0f11d14SIcenowy Zheng 48d0f11d14SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", 49d0f11d14SIcenowy Zheng "osc24M", 0x008, 50d0f11d14SIcenowy Zheng 8, 7, /* N */ 51d0f11d14SIcenowy Zheng 0, 5, /* M */ 52d0f11d14SIcenowy Zheng BIT(31), /* gate */ 53d0f11d14SIcenowy Zheng BIT(28), /* lock */ 54d0f11d14SIcenowy Zheng 0); 55d0f11d14SIcenowy Zheng 56d0f11d14SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video", 57d0f11d14SIcenowy Zheng "osc24M", 0x0010, 58d0f11d14SIcenowy Zheng 8, 7, /* N */ 59d0f11d14SIcenowy Zheng 0, 4, /* M */ 60d0f11d14SIcenowy Zheng BIT(24), /* frac enable */ 61d0f11d14SIcenowy Zheng BIT(25), /* frac select */ 62d0f11d14SIcenowy Zheng 270000000, /* frac rate 0 */ 63d0f11d14SIcenowy Zheng 297000000, /* frac rate 1 */ 64d0f11d14SIcenowy Zheng BIT(31), /* gate */ 65d0f11d14SIcenowy Zheng BIT(28), /* lock */ 66d0f11d14SIcenowy Zheng 0); 67d0f11d14SIcenowy Zheng 68d0f11d14SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", 69d0f11d14SIcenowy Zheng "osc24M", 0x0018, 70d0f11d14SIcenowy Zheng 8, 7, /* N */ 71d0f11d14SIcenowy Zheng 0, 4, /* M */ 72d0f11d14SIcenowy Zheng BIT(24), /* frac enable */ 73d0f11d14SIcenowy Zheng BIT(25), /* frac select */ 74d0f11d14SIcenowy Zheng 270000000, /* frac rate 0 */ 75d0f11d14SIcenowy Zheng 297000000, /* frac rate 1 */ 76d0f11d14SIcenowy Zheng BIT(31), /* gate */ 77d0f11d14SIcenowy Zheng BIT(28), /* lock */ 78d0f11d14SIcenowy Zheng 0); 79d0f11d14SIcenowy Zheng 80c5ed9475SIcenowy Zheng static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", 81d0f11d14SIcenowy Zheng "osc24M", 0x020, 82d0f11d14SIcenowy Zheng 8, 5, /* N */ 83d0f11d14SIcenowy Zheng 4, 2, /* K */ 84d0f11d14SIcenowy Zheng 0, 2, /* M */ 85d0f11d14SIcenowy Zheng BIT(31), /* gate */ 86d0f11d14SIcenowy Zheng BIT(28), /* lock */ 87d0f11d14SIcenowy Zheng 0); 88d0f11d14SIcenowy Zheng 89d0f11d14SIcenowy Zheng static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph0_clk, "pll-periph0", 90d0f11d14SIcenowy Zheng "osc24M", 0x028, 91d0f11d14SIcenowy Zheng 8, 5, /* N */ 92d0f11d14SIcenowy Zheng 4, 2, /* K */ 93d0f11d14SIcenowy Zheng BIT(31), /* gate */ 94d0f11d14SIcenowy Zheng BIT(28), /* lock */ 95d0f11d14SIcenowy Zheng 2, /* post-div */ 96d0f11d14SIcenowy Zheng 0); 97d0f11d14SIcenowy Zheng 98d0f11d14SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_isp_clk, "pll-isp", 99d0f11d14SIcenowy Zheng "osc24M", 0x002c, 100d0f11d14SIcenowy Zheng 8, 7, /* N */ 101d0f11d14SIcenowy Zheng 0, 4, /* M */ 102d0f11d14SIcenowy Zheng BIT(24), /* frac enable */ 103d0f11d14SIcenowy Zheng BIT(25), /* frac select */ 104d0f11d14SIcenowy Zheng 270000000, /* frac rate 0 */ 105d0f11d14SIcenowy Zheng 297000000, /* frac rate 1 */ 106d0f11d14SIcenowy Zheng BIT(31), /* gate */ 107d0f11d14SIcenowy Zheng BIT(28), /* lock */ 108d0f11d14SIcenowy Zheng 0); 109d0f11d14SIcenowy Zheng 110d0f11d14SIcenowy Zheng static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1", 111d0f11d14SIcenowy Zheng "osc24M", 0x044, 112d0f11d14SIcenowy Zheng 8, 5, /* N */ 113d0f11d14SIcenowy Zheng 4, 2, /* K */ 114d0f11d14SIcenowy Zheng BIT(31), /* gate */ 115d0f11d14SIcenowy Zheng BIT(28), /* lock */ 116d0f11d14SIcenowy Zheng 2, /* post-div */ 117d0f11d14SIcenowy Zheng 0); 118d0f11d14SIcenowy Zheng 119c5ed9475SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", 120c5ed9475SIcenowy Zheng "osc24M", 0x04c, 121c5ed9475SIcenowy Zheng 8, 7, /* N */ 122c5ed9475SIcenowy Zheng 0, 2, /* M */ 123c5ed9475SIcenowy Zheng BIT(31), /* gate */ 124c5ed9475SIcenowy Zheng BIT(28), /* lock */ 125c5ed9475SIcenowy Zheng 0); 126c5ed9475SIcenowy Zheng 127d0f11d14SIcenowy Zheng static const char * const cpu_parents[] = { "osc32k", "osc24M", 128d0f11d14SIcenowy Zheng "pll-cpu", "pll-cpu" }; 129d0f11d14SIcenowy Zheng static SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents, 130d0f11d14SIcenowy Zheng 0x050, 16, 2, CLK_IS_CRITICAL); 131d0f11d14SIcenowy Zheng 132d0f11d14SIcenowy Zheng static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0); 133d0f11d14SIcenowy Zheng 134d0f11d14SIcenowy Zheng static const char * const ahb1_parents[] = { "osc32k", "osc24M", 135d0f11d14SIcenowy Zheng "axi", "pll-periph0" }; 13613e0dde8SChen-Yu Tsai static const struct ccu_mux_var_prediv ahb1_predivs[] = { 13713e0dde8SChen-Yu Tsai { .index = 3, .shift = 6, .width = 2 }, 13813e0dde8SChen-Yu Tsai }; 139d0f11d14SIcenowy Zheng static struct ccu_div ahb1_clk = { 140d0f11d14SIcenowy Zheng .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 141d0f11d14SIcenowy Zheng 142d0f11d14SIcenowy Zheng .mux = { 143d0f11d14SIcenowy Zheng .shift = 12, 144d0f11d14SIcenowy Zheng .width = 2, 145d0f11d14SIcenowy Zheng 14613e0dde8SChen-Yu Tsai .var_predivs = ahb1_predivs, 14713e0dde8SChen-Yu Tsai .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 148d0f11d14SIcenowy Zheng }, 149d0f11d14SIcenowy Zheng 150d0f11d14SIcenowy Zheng .common = { 151d0f11d14SIcenowy Zheng .reg = 0x054, 152d0f11d14SIcenowy Zheng .features = CCU_FEATURE_VARIABLE_PREDIV, 153d0f11d14SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("ahb1", 154d0f11d14SIcenowy Zheng ahb1_parents, 155d0f11d14SIcenowy Zheng &ccu_div_ops, 156d0f11d14SIcenowy Zheng 0), 157d0f11d14SIcenowy Zheng }, 158d0f11d14SIcenowy Zheng }; 159d0f11d14SIcenowy Zheng 160d0f11d14SIcenowy Zheng static struct clk_div_table apb1_div_table[] = { 161d0f11d14SIcenowy Zheng { .val = 0, .div = 2 }, 162d0f11d14SIcenowy Zheng { .val = 1, .div = 2 }, 163d0f11d14SIcenowy Zheng { .val = 2, .div = 4 }, 164d0f11d14SIcenowy Zheng { .val = 3, .div = 8 }, 165d0f11d14SIcenowy Zheng { /* Sentinel */ }, 166d0f11d14SIcenowy Zheng }; 167d0f11d14SIcenowy Zheng static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1", 168d0f11d14SIcenowy Zheng 0x054, 8, 2, apb1_div_table, 0); 169d0f11d14SIcenowy Zheng 170d0f11d14SIcenowy Zheng static const char * const apb2_parents[] = { "osc32k", "osc24M", 171d0f11d14SIcenowy Zheng "pll-periph0", "pll-periph0" }; 172d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 173d0f11d14SIcenowy Zheng 0, 5, /* M */ 174d0f11d14SIcenowy Zheng 16, 2, /* P */ 175d0f11d14SIcenowy Zheng 24, 2, /* mux */ 176d0f11d14SIcenowy Zheng 0); 177d0f11d14SIcenowy Zheng 178d0f11d14SIcenowy Zheng static const char * const ahb2_parents[] = { "ahb1", "pll-periph0" }; 179d0f11d14SIcenowy Zheng static const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = { 180d0f11d14SIcenowy Zheng { .index = 1, .div = 2 }, 181d0f11d14SIcenowy Zheng }; 182d0f11d14SIcenowy Zheng static struct ccu_mux ahb2_clk = { 183d0f11d14SIcenowy Zheng .mux = { 184d0f11d14SIcenowy Zheng .shift = 0, 185d0f11d14SIcenowy Zheng .width = 1, 186d0f11d14SIcenowy Zheng .fixed_predivs = ahb2_fixed_predivs, 187d0f11d14SIcenowy Zheng .n_predivs = ARRAY_SIZE(ahb2_fixed_predivs), 188d0f11d14SIcenowy Zheng }, 189d0f11d14SIcenowy Zheng 190d0f11d14SIcenowy Zheng .common = { 191d0f11d14SIcenowy Zheng .reg = 0x05c, 192d0f11d14SIcenowy Zheng .features = CCU_FEATURE_FIXED_PREDIV, 193d0f11d14SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("ahb2", 194d0f11d14SIcenowy Zheng ahb2_parents, 195d0f11d14SIcenowy Zheng &ccu_mux_ops, 196d0f11d14SIcenowy Zheng 0), 197d0f11d14SIcenowy Zheng }, 198d0f11d14SIcenowy Zheng }; 199d0f11d14SIcenowy Zheng 200d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1", 201d0f11d14SIcenowy Zheng 0x060, BIT(5), 0); 202d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 203d0f11d14SIcenowy Zheng 0x060, BIT(6), 0); 204d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 205d0f11d14SIcenowy Zheng 0x060, BIT(8), 0); 206d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 207d0f11d14SIcenowy Zheng 0x060, BIT(9), 0); 208d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 209d0f11d14SIcenowy Zheng 0x060, BIT(10), 0); 210d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 211d0f11d14SIcenowy Zheng 0x060, BIT(14), 0); 212d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb2", 213d0f11d14SIcenowy Zheng 0x060, BIT(17), 0); 214d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 215d0f11d14SIcenowy Zheng 0x060, BIT(19), 0); 216d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 217d0f11d14SIcenowy Zheng 0x060, BIT(20), 0); 218d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 219d0f11d14SIcenowy Zheng 0x060, BIT(24), 0); 220d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1", 221d0f11d14SIcenowy Zheng 0x060, BIT(26), 0); 222d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1", 223d0f11d14SIcenowy Zheng 0x060, BIT(29), 0); 224d0f11d14SIcenowy Zheng 225d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 226d0f11d14SIcenowy Zheng 0x064, BIT(0), 0); 227d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon0_clk, "bus-tcon0", "ahb1", 228d0f11d14SIcenowy Zheng 0x064, BIT(4), 0); 229d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb1", 230d0f11d14SIcenowy Zheng 0x064, BIT(8), 0); 231d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 232d0f11d14SIcenowy Zheng 0x064, BIT(12), 0); 233d0f11d14SIcenowy Zheng 234d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1", 235d0f11d14SIcenowy Zheng 0x068, BIT(0), 0); 236d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 237d0f11d14SIcenowy Zheng 0x068, BIT(5), 0); 238d0f11d14SIcenowy Zheng 239d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 240d0f11d14SIcenowy Zheng 0x06c, BIT(0), 0); 241d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 242d0f11d14SIcenowy Zheng 0x06c, BIT(1), 0); 243d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 244d0f11d14SIcenowy Zheng 0x06c, BIT(16), 0); 245d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 246d0f11d14SIcenowy Zheng 0x06c, BIT(17), 0); 247d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 248d0f11d14SIcenowy Zheng 0x06c, BIT(18), 0); 249d0f11d14SIcenowy Zheng 250d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_ephy_clk, "bus-ephy", "ahb1", 251d0f11d14SIcenowy Zheng 0x070, BIT(0), 0); 252d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1", 253d0f11d14SIcenowy Zheng 0x070, BIT(7), 0); 254d0f11d14SIcenowy Zheng 255d0f11d14SIcenowy Zheng static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0", 256d0f11d14SIcenowy Zheng "pll-periph1" }; 257d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088, 258d0f11d14SIcenowy Zheng 0, 4, /* M */ 259d0f11d14SIcenowy Zheng 16, 2, /* P */ 260d0f11d14SIcenowy Zheng 24, 2, /* mux */ 261d0f11d14SIcenowy Zheng BIT(31), /* gate */ 262d0f11d14SIcenowy Zheng 0); 263d0f11d14SIcenowy Zheng 264d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0", 265d0f11d14SIcenowy Zheng 0x088, 20, 3, 0); 266d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0", 267d0f11d14SIcenowy Zheng 0x088, 8, 3, 0); 268d0f11d14SIcenowy Zheng 269d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c, 270d0f11d14SIcenowy Zheng 0, 4, /* M */ 271d0f11d14SIcenowy Zheng 16, 2, /* P */ 272d0f11d14SIcenowy Zheng 24, 2, /* mux */ 273d0f11d14SIcenowy Zheng BIT(31), /* gate */ 274d0f11d14SIcenowy Zheng 0); 275d0f11d14SIcenowy Zheng 276d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1", 277d0f11d14SIcenowy Zheng 0x08c, 20, 3, 0); 278d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1", 279d0f11d14SIcenowy Zheng 0x08c, 8, 3, 0); 280d0f11d14SIcenowy Zheng 281d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090, 282d0f11d14SIcenowy Zheng 0, 4, /* M */ 283d0f11d14SIcenowy Zheng 16, 2, /* P */ 284d0f11d14SIcenowy Zheng 24, 2, /* mux */ 285d0f11d14SIcenowy Zheng BIT(31), /* gate */ 286d0f11d14SIcenowy Zheng 0); 287d0f11d14SIcenowy Zheng 288d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2", 289d0f11d14SIcenowy Zheng 0x090, 20, 3, 0); 290d0f11d14SIcenowy Zheng static SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2", 291d0f11d14SIcenowy Zheng 0x090, 8, 3, 0); 292d0f11d14SIcenowy Zheng 293d0f11d14SIcenowy Zheng static const char * const ce_parents[] = { "osc24M", "pll-periph0", }; 294d0f11d14SIcenowy Zheng 295d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c, 296d0f11d14SIcenowy Zheng 0, 4, /* M */ 297d0f11d14SIcenowy Zheng 16, 2, /* P */ 298d0f11d14SIcenowy Zheng 24, 2, /* mux */ 299d0f11d14SIcenowy Zheng BIT(31), /* gate */ 300d0f11d14SIcenowy Zheng 0); 301d0f11d14SIcenowy Zheng 302d0f11d14SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, 303d0f11d14SIcenowy Zheng 0, 4, /* M */ 304d0f11d14SIcenowy Zheng 16, 2, /* P */ 305d0f11d14SIcenowy Zheng 24, 2, /* mux */ 306d0f11d14SIcenowy Zheng BIT(31), /* gate */ 307d0f11d14SIcenowy Zheng 0); 308d0f11d14SIcenowy Zheng 309d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 310d0f11d14SIcenowy Zheng 0x0cc, BIT(8), 0); 311d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc24M", 312d0f11d14SIcenowy Zheng 0x0cc, BIT(16), 0); 313d0f11d14SIcenowy Zheng 314c5ed9475SIcenowy Zheng static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1", 315c5ed9475SIcenowy Zheng "pll-periph0-2x" }; 316d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, 317d0f11d14SIcenowy Zheng 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL); 318d0f11d14SIcenowy Zheng 319d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 320d0f11d14SIcenowy Zheng 0x100, BIT(0), 0); 321d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(dram_csi_clk, "dram-csi", "dram", 322d0f11d14SIcenowy Zheng 0x100, BIT(1), 0); 323d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(dram_ehci_clk, "dram-ehci", "dram", 324d0f11d14SIcenowy Zheng 0x100, BIT(17), 0); 325d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(dram_ohci_clk, "dram-ohci", "dram", 326d0f11d14SIcenowy Zheng 0x100, BIT(18), 0); 327d0f11d14SIcenowy Zheng 328d0f11d14SIcenowy Zheng static const char * const de_parents[] = { "pll-video", "pll-periph0" }; 329d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, 330ab65e04dSJernej Skrabec 0x104, 0, 4, 24, 2, BIT(31), 331ab65e04dSJernej Skrabec CLK_SET_RATE_PARENT); 332d0f11d14SIcenowy Zheng 333d0f11d14SIcenowy Zheng static const char * const tcon_parents[] = { "pll-video" }; 334d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents, 335d0f11d14SIcenowy Zheng 0x118, 0, 4, 24, 3, BIT(31), 0); 336d0f11d14SIcenowy Zheng 337d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(csi_misc_clk, "csi-misc", "osc24M", 338d0f11d14SIcenowy Zheng 0x130, BIT(31), 0); 339d0f11d14SIcenowy Zheng 340d0f11d14SIcenowy Zheng static const char * const csi_mclk_parents[] = { "osc24M", "pll-video", 341d0f11d14SIcenowy Zheng "pll-periph0", "pll-periph1" }; 342d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents, 343d0f11d14SIcenowy Zheng 0x130, 0, 5, 8, 3, BIT(15), 0); 344d0f11d14SIcenowy Zheng 345d0f11d14SIcenowy Zheng static const char * const csi1_sclk_parents[] = { "pll-video", "pll-isp" }; 346d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi1_sclk_clk, "csi-sclk", csi1_sclk_parents, 347d0f11d14SIcenowy Zheng 0x134, 16, 4, 24, 3, BIT(31), 0); 348d0f11d14SIcenowy Zheng 349d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi-mclk", csi_mclk_parents, 350d0f11d14SIcenowy Zheng 0x134, 0, 5, 8, 3, BIT(15), 0); 351d0f11d14SIcenowy Zheng 352d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 353d0f11d14SIcenowy Zheng 0x13c, 16, 3, BIT(31), 0); 354d0f11d14SIcenowy Zheng 355d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(ac_dig_clk, "ac-dig", "pll-audio", 356d0f11d14SIcenowy Zheng 0x140, BIT(31), CLK_SET_RATE_PARENT); 357d0f11d14SIcenowy Zheng static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 358d0f11d14SIcenowy Zheng 0x144, BIT(31), 0); 359d0f11d14SIcenowy Zheng 360d0f11d14SIcenowy Zheng static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", 361d0f11d14SIcenowy Zheng "pll-ddr" }; 362d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 363d0f11d14SIcenowy Zheng 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL); 364d0f11d14SIcenowy Zheng 365d0f11d14SIcenowy Zheng static const char * const mipi_csi_parents[] = { "pll-video", "pll-periph0", 366d0f11d14SIcenowy Zheng "pll-isp" }; 367d0f11d14SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(mipi_csi_clk, "mipi-csi", mipi_csi_parents, 368d0f11d14SIcenowy Zheng 0x16c, 0, 3, 24, 2, BIT(31), 0); 369d0f11d14SIcenowy Zheng 370d0f11d14SIcenowy Zheng static struct ccu_common *sun8i_v3s_ccu_clks[] = { 371d0f11d14SIcenowy Zheng &pll_cpu_clk.common, 372d0f11d14SIcenowy Zheng &pll_audio_base_clk.common, 373d0f11d14SIcenowy Zheng &pll_video_clk.common, 374d0f11d14SIcenowy Zheng &pll_ve_clk.common, 375c5ed9475SIcenowy Zheng &pll_ddr0_clk.common, 376d0f11d14SIcenowy Zheng &pll_periph0_clk.common, 377d0f11d14SIcenowy Zheng &pll_isp_clk.common, 378d0f11d14SIcenowy Zheng &pll_periph1_clk.common, 379c5ed9475SIcenowy Zheng &pll_ddr1_clk.common, 380d0f11d14SIcenowy Zheng &cpu_clk.common, 381d0f11d14SIcenowy Zheng &axi_clk.common, 382d0f11d14SIcenowy Zheng &ahb1_clk.common, 383d0f11d14SIcenowy Zheng &apb1_clk.common, 384d0f11d14SIcenowy Zheng &apb2_clk.common, 385d0f11d14SIcenowy Zheng &ahb2_clk.common, 386d0f11d14SIcenowy Zheng &bus_ce_clk.common, 387d0f11d14SIcenowy Zheng &bus_dma_clk.common, 388d0f11d14SIcenowy Zheng &bus_mmc0_clk.common, 389d0f11d14SIcenowy Zheng &bus_mmc1_clk.common, 390d0f11d14SIcenowy Zheng &bus_mmc2_clk.common, 391d0f11d14SIcenowy Zheng &bus_dram_clk.common, 392d0f11d14SIcenowy Zheng &bus_emac_clk.common, 393d0f11d14SIcenowy Zheng &bus_hstimer_clk.common, 394d0f11d14SIcenowy Zheng &bus_spi0_clk.common, 395d0f11d14SIcenowy Zheng &bus_otg_clk.common, 396d0f11d14SIcenowy Zheng &bus_ehci0_clk.common, 397d0f11d14SIcenowy Zheng &bus_ohci0_clk.common, 398d0f11d14SIcenowy Zheng &bus_ve_clk.common, 399d0f11d14SIcenowy Zheng &bus_tcon0_clk.common, 400d0f11d14SIcenowy Zheng &bus_csi_clk.common, 401d0f11d14SIcenowy Zheng &bus_de_clk.common, 402d0f11d14SIcenowy Zheng &bus_codec_clk.common, 403d0f11d14SIcenowy Zheng &bus_pio_clk.common, 404d0f11d14SIcenowy Zheng &bus_i2c0_clk.common, 405d0f11d14SIcenowy Zheng &bus_i2c1_clk.common, 406d0f11d14SIcenowy Zheng &bus_uart0_clk.common, 407d0f11d14SIcenowy Zheng &bus_uart1_clk.common, 408d0f11d14SIcenowy Zheng &bus_uart2_clk.common, 409d0f11d14SIcenowy Zheng &bus_ephy_clk.common, 410d0f11d14SIcenowy Zheng &bus_dbg_clk.common, 411d0f11d14SIcenowy Zheng &mmc0_clk.common, 412d0f11d14SIcenowy Zheng &mmc0_sample_clk.common, 413d0f11d14SIcenowy Zheng &mmc0_output_clk.common, 414d0f11d14SIcenowy Zheng &mmc1_clk.common, 415d0f11d14SIcenowy Zheng &mmc1_sample_clk.common, 416d0f11d14SIcenowy Zheng &mmc1_output_clk.common, 417d0f11d14SIcenowy Zheng &mmc2_clk.common, 418d0f11d14SIcenowy Zheng &mmc2_sample_clk.common, 419d0f11d14SIcenowy Zheng &mmc2_output_clk.common, 420d0f11d14SIcenowy Zheng &ce_clk.common, 421d0f11d14SIcenowy Zheng &spi0_clk.common, 422d0f11d14SIcenowy Zheng &usb_phy0_clk.common, 423d0f11d14SIcenowy Zheng &usb_ohci0_clk.common, 424d0f11d14SIcenowy Zheng &dram_clk.common, 425d0f11d14SIcenowy Zheng &dram_ve_clk.common, 426d0f11d14SIcenowy Zheng &dram_csi_clk.common, 427d0f11d14SIcenowy Zheng &dram_ohci_clk.common, 428d0f11d14SIcenowy Zheng &dram_ehci_clk.common, 429d0f11d14SIcenowy Zheng &de_clk.common, 430d0f11d14SIcenowy Zheng &tcon_clk.common, 431d0f11d14SIcenowy Zheng &csi_misc_clk.common, 432d0f11d14SIcenowy Zheng &csi0_mclk_clk.common, 433d0f11d14SIcenowy Zheng &csi1_sclk_clk.common, 434d0f11d14SIcenowy Zheng &csi1_mclk_clk.common, 435d0f11d14SIcenowy Zheng &ve_clk.common, 436d0f11d14SIcenowy Zheng &ac_dig_clk.common, 437d0f11d14SIcenowy Zheng &avs_clk.common, 438d0f11d14SIcenowy Zheng &mbus_clk.common, 439d0f11d14SIcenowy Zheng &mipi_csi_clk.common, 440d0f11d14SIcenowy Zheng }; 441d0f11d14SIcenowy Zheng 442707f6013SChen-Yu Tsai static const struct clk_hw *clk_parent_pll_audio[] = { 443707f6013SChen-Yu Tsai &pll_audio_base_clk.common.hw 444707f6013SChen-Yu Tsai }; 445707f6013SChen-Yu Tsai 446d0f11d14SIcenowy Zheng /* We hardcode the divider to 4 for now */ 447707f6013SChen-Yu Tsai static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", 448707f6013SChen-Yu Tsai clk_parent_pll_audio, 449707f6013SChen-Yu Tsai 4, 1, CLK_SET_RATE_PARENT); 450707f6013SChen-Yu Tsai static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", 451707f6013SChen-Yu Tsai clk_parent_pll_audio, 452707f6013SChen-Yu Tsai 2, 1, CLK_SET_RATE_PARENT); 453707f6013SChen-Yu Tsai static CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x", 454707f6013SChen-Yu Tsai clk_parent_pll_audio, 455707f6013SChen-Yu Tsai 1, 1, CLK_SET_RATE_PARENT); 456707f6013SChen-Yu Tsai static CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x", 457707f6013SChen-Yu Tsai clk_parent_pll_audio, 458707f6013SChen-Yu Tsai 1, 2, CLK_SET_RATE_PARENT); 459707f6013SChen-Yu Tsai static CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x", 460707f6013SChen-Yu Tsai &pll_periph0_clk.common.hw, 461707f6013SChen-Yu Tsai 1, 2, 0); 462d0f11d14SIcenowy Zheng 463d0f11d14SIcenowy Zheng static struct clk_hw_onecell_data sun8i_v3s_hw_clks = { 464d0f11d14SIcenowy Zheng .hws = { 465d0f11d14SIcenowy Zheng [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, 466d0f11d14SIcenowy Zheng [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 467d0f11d14SIcenowy Zheng [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 468d0f11d14SIcenowy Zheng [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 469d0f11d14SIcenowy Zheng [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 470d0f11d14SIcenowy Zheng [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 471d0f11d14SIcenowy Zheng [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, 472d0f11d14SIcenowy Zheng [CLK_PLL_VE] = &pll_ve_clk.common.hw, 473c5ed9475SIcenowy Zheng [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 474d0f11d14SIcenowy Zheng [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 475d0f11d14SIcenowy Zheng [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 476d0f11d14SIcenowy Zheng [CLK_PLL_ISP] = &pll_isp_clk.common.hw, 477d0f11d14SIcenowy Zheng [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 478c5ed9475SIcenowy Zheng [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 479d0f11d14SIcenowy Zheng [CLK_CPU] = &cpu_clk.common.hw, 480d0f11d14SIcenowy Zheng [CLK_AXI] = &axi_clk.common.hw, 481d0f11d14SIcenowy Zheng [CLK_AHB1] = &ahb1_clk.common.hw, 482d0f11d14SIcenowy Zheng [CLK_APB1] = &apb1_clk.common.hw, 483d0f11d14SIcenowy Zheng [CLK_APB2] = &apb2_clk.common.hw, 484d0f11d14SIcenowy Zheng [CLK_AHB2] = &ahb2_clk.common.hw, 485d0f11d14SIcenowy Zheng [CLK_BUS_CE] = &bus_ce_clk.common.hw, 486d0f11d14SIcenowy Zheng [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 487d0f11d14SIcenowy Zheng [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 488d0f11d14SIcenowy Zheng [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 489d0f11d14SIcenowy Zheng [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 490d0f11d14SIcenowy Zheng [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 491d0f11d14SIcenowy Zheng [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 492d0f11d14SIcenowy Zheng [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 493d0f11d14SIcenowy Zheng [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 494d0f11d14SIcenowy Zheng [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 495d0f11d14SIcenowy Zheng [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 496d0f11d14SIcenowy Zheng [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 497d0f11d14SIcenowy Zheng [CLK_BUS_VE] = &bus_ve_clk.common.hw, 498d0f11d14SIcenowy Zheng [CLK_BUS_TCON0] = &bus_tcon0_clk.common.hw, 499d0f11d14SIcenowy Zheng [CLK_BUS_CSI] = &bus_csi_clk.common.hw, 500d0f11d14SIcenowy Zheng [CLK_BUS_DE] = &bus_de_clk.common.hw, 501d0f11d14SIcenowy Zheng [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 502d0f11d14SIcenowy Zheng [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 503d0f11d14SIcenowy Zheng [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 504d0f11d14SIcenowy Zheng [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 505d0f11d14SIcenowy Zheng [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 506d0f11d14SIcenowy Zheng [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 507d0f11d14SIcenowy Zheng [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 508d0f11d14SIcenowy Zheng [CLK_BUS_EPHY] = &bus_ephy_clk.common.hw, 509d0f11d14SIcenowy Zheng [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 510d0f11d14SIcenowy Zheng [CLK_MMC0] = &mmc0_clk.common.hw, 511d0f11d14SIcenowy Zheng [CLK_MMC0_SAMPLE] = &mmc0_sample_clk.common.hw, 512d0f11d14SIcenowy Zheng [CLK_MMC0_OUTPUT] = &mmc0_output_clk.common.hw, 513d0f11d14SIcenowy Zheng [CLK_MMC1] = &mmc1_clk.common.hw, 514d0f11d14SIcenowy Zheng [CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw, 515d0f11d14SIcenowy Zheng [CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw, 516d0f11d14SIcenowy Zheng [CLK_CE] = &ce_clk.common.hw, 517d0f11d14SIcenowy Zheng [CLK_SPI0] = &spi0_clk.common.hw, 518d0f11d14SIcenowy Zheng [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 519d0f11d14SIcenowy Zheng [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 520d0f11d14SIcenowy Zheng [CLK_DRAM] = &dram_clk.common.hw, 521d0f11d14SIcenowy Zheng [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 522d0f11d14SIcenowy Zheng [CLK_DRAM_CSI] = &dram_csi_clk.common.hw, 523d0f11d14SIcenowy Zheng [CLK_DRAM_EHCI] = &dram_ehci_clk.common.hw, 524d0f11d14SIcenowy Zheng [CLK_DRAM_OHCI] = &dram_ohci_clk.common.hw, 525d0f11d14SIcenowy Zheng [CLK_DE] = &de_clk.common.hw, 526d0f11d14SIcenowy Zheng [CLK_TCON0] = &tcon_clk.common.hw, 527d0f11d14SIcenowy Zheng [CLK_CSI_MISC] = &csi_misc_clk.common.hw, 528d0f11d14SIcenowy Zheng [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw, 529d0f11d14SIcenowy Zheng [CLK_CSI1_SCLK] = &csi1_sclk_clk.common.hw, 530d0f11d14SIcenowy Zheng [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw, 531d0f11d14SIcenowy Zheng [CLK_VE] = &ve_clk.common.hw, 532d0f11d14SIcenowy Zheng [CLK_AC_DIG] = &ac_dig_clk.common.hw, 533d0f11d14SIcenowy Zheng [CLK_AVS] = &avs_clk.common.hw, 534d0f11d14SIcenowy Zheng [CLK_MBUS] = &mbus_clk.common.hw, 535d0f11d14SIcenowy Zheng [CLK_MIPI_CSI] = &mipi_csi_clk.common.hw, 536d0f11d14SIcenowy Zheng }, 537d0f11d14SIcenowy Zheng .num = CLK_NUMBER, 538d0f11d14SIcenowy Zheng }; 539d0f11d14SIcenowy Zheng 540d0f11d14SIcenowy Zheng static struct ccu_reset_map sun8i_v3s_ccu_resets[] = { 541d0f11d14SIcenowy Zheng [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 542d0f11d14SIcenowy Zheng 543d0f11d14SIcenowy Zheng [RST_MBUS] = { 0x0fc, BIT(31) }, 544d0f11d14SIcenowy Zheng 545d0f11d14SIcenowy Zheng [RST_BUS_CE] = { 0x2c0, BIT(5) }, 546d0f11d14SIcenowy Zheng [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 547d0f11d14SIcenowy Zheng [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 548d0f11d14SIcenowy Zheng [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 549d0f11d14SIcenowy Zheng [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 550d0f11d14SIcenowy Zheng [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 551d0f11d14SIcenowy Zheng [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 552d0f11d14SIcenowy Zheng [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 553d0f11d14SIcenowy Zheng [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 5547ffc781eSYong Deng [RST_BUS_OTG] = { 0x2c0, BIT(24) }, 555d0f11d14SIcenowy Zheng [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 556d0f11d14SIcenowy Zheng [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 557d0f11d14SIcenowy Zheng 558d0f11d14SIcenowy Zheng [RST_BUS_VE] = { 0x2c4, BIT(0) }, 5595c59801fSPaul Kocialkowski [RST_BUS_TCON0] = { 0x2c4, BIT(4) }, 560d0f11d14SIcenowy Zheng [RST_BUS_CSI] = { 0x2c4, BIT(8) }, 561d0f11d14SIcenowy Zheng [RST_BUS_DE] = { 0x2c4, BIT(12) }, 562d0f11d14SIcenowy Zheng [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 563d0f11d14SIcenowy Zheng 564d0f11d14SIcenowy Zheng [RST_BUS_EPHY] = { 0x2c8, BIT(2) }, 565d0f11d14SIcenowy Zheng 566d0f11d14SIcenowy Zheng [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 567d0f11d14SIcenowy Zheng 568d0f11d14SIcenowy Zheng [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 569d0f11d14SIcenowy Zheng [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 570d0f11d14SIcenowy Zheng [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 571d0f11d14SIcenowy Zheng [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 572d0f11d14SIcenowy Zheng [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 573d0f11d14SIcenowy Zheng }; 574d0f11d14SIcenowy Zheng 575d0f11d14SIcenowy Zheng static const struct sunxi_ccu_desc sun8i_v3s_ccu_desc = { 576d0f11d14SIcenowy Zheng .ccu_clks = sun8i_v3s_ccu_clks, 577d0f11d14SIcenowy Zheng .num_ccu_clks = ARRAY_SIZE(sun8i_v3s_ccu_clks), 578d0f11d14SIcenowy Zheng 579d0f11d14SIcenowy Zheng .hw_clks = &sun8i_v3s_hw_clks, 580d0f11d14SIcenowy Zheng 581d0f11d14SIcenowy Zheng .resets = sun8i_v3s_ccu_resets, 582d0f11d14SIcenowy Zheng .num_resets = ARRAY_SIZE(sun8i_v3s_ccu_resets), 583d0f11d14SIcenowy Zheng }; 584d0f11d14SIcenowy Zheng 585d0f11d14SIcenowy Zheng static void __init sun8i_v3s_ccu_setup(struct device_node *node) 586d0f11d14SIcenowy Zheng { 587d0f11d14SIcenowy Zheng void __iomem *reg; 588d0f11d14SIcenowy Zheng u32 val; 589d0f11d14SIcenowy Zheng 590d0f11d14SIcenowy Zheng reg = of_io_request_and_map(node, 0, of_node_full_name(node)); 591d0f11d14SIcenowy Zheng if (IS_ERR(reg)) { 59216673931SRob Herring pr_err("%pOF: Could not map the clock registers\n", node); 593d0f11d14SIcenowy Zheng return; 594d0f11d14SIcenowy Zheng } 595d0f11d14SIcenowy Zheng 596d0f11d14SIcenowy Zheng /* Force the PLL-Audio-1x divider to 4 */ 597d0f11d14SIcenowy Zheng val = readl(reg + SUN8I_V3S_PLL_AUDIO_REG); 598d0f11d14SIcenowy Zheng val &= ~GENMASK(19, 16); 599d0f11d14SIcenowy Zheng writel(val | (3 << 16), reg + SUN8I_V3S_PLL_AUDIO_REG); 600d0f11d14SIcenowy Zheng 601d0f11d14SIcenowy Zheng sunxi_ccu_probe(node, reg, &sun8i_v3s_ccu_desc); 602d0f11d14SIcenowy Zheng } 603d0f11d14SIcenowy Zheng CLK_OF_DECLARE(sun8i_v3s_ccu, "allwinner,sun8i-v3s-ccu", 604d0f11d14SIcenowy Zheng sun8i_v3s_ccu_setup); 605