1cd030a78SIcenowy Zheng /* 2cd030a78SIcenowy Zheng * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io> 3cd030a78SIcenowy Zheng * 4cd030a78SIcenowy Zheng * This software is licensed under the terms of the GNU General Public 5cd030a78SIcenowy Zheng * License version 2, as published by the Free Software Foundation, and 6cd030a78SIcenowy Zheng * may be copied, distributed, and modified under those terms. 7cd030a78SIcenowy Zheng * 8cd030a78SIcenowy Zheng * This program is distributed in the hope that it will be useful, 9cd030a78SIcenowy Zheng * but WITHOUT ANY WARRANTY; without even the implied warranty of 10cd030a78SIcenowy Zheng * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11cd030a78SIcenowy Zheng * GNU General Public License for more details. 12cd030a78SIcenowy Zheng */ 13cd030a78SIcenowy Zheng 14cd030a78SIcenowy Zheng #include <linux/clk-provider.h> 15*62e59c4eSStephen Boyd #include <linux/io.h> 16c3bf29f6SIcenowy Zheng #include <linux/platform_device.h> 17c3bf29f6SIcenowy Zheng #include <linux/regmap.h> 18cd030a78SIcenowy Zheng 19cd030a78SIcenowy Zheng #include "ccu_common.h" 20cd030a78SIcenowy Zheng #include "ccu_reset.h" 21cd030a78SIcenowy Zheng 22cd030a78SIcenowy Zheng #include "ccu_div.h" 23cd030a78SIcenowy Zheng #include "ccu_gate.h" 24cd030a78SIcenowy Zheng #include "ccu_mp.h" 25cd030a78SIcenowy Zheng #include "ccu_mult.h" 26cd030a78SIcenowy Zheng #include "ccu_nk.h" 27cd030a78SIcenowy Zheng #include "ccu_nkm.h" 28cd030a78SIcenowy Zheng #include "ccu_nkmp.h" 29cd030a78SIcenowy Zheng #include "ccu_nm.h" 30cd030a78SIcenowy Zheng #include "ccu_phase.h" 31cd030a78SIcenowy Zheng 32cd030a78SIcenowy Zheng #include "ccu-sun8i-r40.h" 33cd030a78SIcenowy Zheng 34cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [10, 88] range. */ 35cd030a78SIcenowy Zheng static struct ccu_nkmp pll_cpu_clk = { 36cd030a78SIcenowy Zheng .enable = BIT(31), 37cd030a78SIcenowy Zheng .lock = BIT(28), 38cd030a78SIcenowy Zheng .n = _SUNXI_CCU_MULT(8, 5), 39cd030a78SIcenowy Zheng .k = _SUNXI_CCU_MULT(4, 2), 40cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(0, 2), 41cd030a78SIcenowy Zheng .p = _SUNXI_CCU_DIV_MAX(16, 2, 4), 42cd030a78SIcenowy Zheng .common = { 43cd030a78SIcenowy Zheng .reg = 0x000, 44cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT("pll-cpu", 45cd030a78SIcenowy Zheng "osc24M", 46cd030a78SIcenowy Zheng &ccu_nkmp_ops, 47cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE), 48cd030a78SIcenowy Zheng }, 49cd030a78SIcenowy Zheng }; 50cd030a78SIcenowy Zheng 51cd030a78SIcenowy Zheng /* 52cd030a78SIcenowy Zheng * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from 53cd030a78SIcenowy Zheng * the base (2x, 4x and 8x), and one variable divider (the one true 54cd030a78SIcenowy Zheng * pll audio). 55cd030a78SIcenowy Zheng * 56cd030a78SIcenowy Zheng * We don't have any need for the variable divider for now, so we just 57cd030a78SIcenowy Zheng * hardcode it to match with the clock names 58cd030a78SIcenowy Zheng */ 59cd030a78SIcenowy Zheng #define SUN8I_R40_PLL_AUDIO_REG 0x008 60cd030a78SIcenowy Zheng 61cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", 62cd030a78SIcenowy Zheng "osc24M", 0x008, 63cd030a78SIcenowy Zheng 8, 7, /* N */ 64cd030a78SIcenowy Zheng 0, 5, /* M */ 65cd030a78SIcenowy Zheng BIT(31), /* gate */ 66cd030a78SIcenowy Zheng BIT(28), /* lock */ 67cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 68cd030a78SIcenowy Zheng 69b16fb669SJernej Skrabec static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0", 70cd030a78SIcenowy Zheng "osc24M", 0x0010, 7124a95f75SJernej Skrabec 192000000, /* Minimum rate */ 72b16fb669SJernej Skrabec 1008000000, /* Maximum rate */ 73cd030a78SIcenowy Zheng 8, 7, /* N */ 74cd030a78SIcenowy Zheng 0, 4, /* M */ 75cd030a78SIcenowy Zheng BIT(24), /* frac enable */ 76cd030a78SIcenowy Zheng BIT(25), /* frac select */ 77cd030a78SIcenowy Zheng 270000000, /* frac rate 0 */ 78cd030a78SIcenowy Zheng 297000000, /* frac rate 1 */ 79cd030a78SIcenowy Zheng BIT(31), /* gate */ 80cd030a78SIcenowy Zheng BIT(28), /* lock */ 81cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 82cd030a78SIcenowy Zheng 83cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */ 84cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", 85cd030a78SIcenowy Zheng "osc24M", 0x0018, 86cd030a78SIcenowy Zheng 8, 7, /* N */ 87cd030a78SIcenowy Zheng 0, 4, /* M */ 88cd030a78SIcenowy Zheng BIT(24), /* frac enable */ 89cd030a78SIcenowy Zheng BIT(25), /* frac select */ 90cd030a78SIcenowy Zheng 270000000, /* frac rate 0 */ 91cd030a78SIcenowy Zheng 297000000, /* frac rate 1 */ 92cd030a78SIcenowy Zheng BIT(31), /* gate */ 93cd030a78SIcenowy Zheng BIT(28), /* lock */ 94cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 95cd030a78SIcenowy Zheng 96cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [10, 77] range. */ 97cd030a78SIcenowy Zheng static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", 98cd030a78SIcenowy Zheng "osc24M", 0x020, 99cd030a78SIcenowy Zheng 8, 5, /* N */ 100cd030a78SIcenowy Zheng 4, 2, /* K */ 101cd030a78SIcenowy Zheng 0, 2, /* M */ 102cd030a78SIcenowy Zheng BIT(31), /* gate */ 103cd030a78SIcenowy Zheng BIT(28), /* lock */ 104cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 105cd030a78SIcenowy Zheng 106cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [21, 58] range. */ 107cd030a78SIcenowy Zheng static struct ccu_nk pll_periph0_clk = { 108cd030a78SIcenowy Zheng .enable = BIT(31), 109cd030a78SIcenowy Zheng .lock = BIT(28), 110cd030a78SIcenowy Zheng .n = _SUNXI_CCU_MULT(8, 5), 111cd030a78SIcenowy Zheng .k = _SUNXI_CCU_MULT(4, 2), 112cd030a78SIcenowy Zheng .fixed_post_div = 2, 113cd030a78SIcenowy Zheng .common = { 114cd030a78SIcenowy Zheng .reg = 0x028, 115cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_POSTDIV, 116cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT("pll-periph0", "osc24M", 117cd030a78SIcenowy Zheng &ccu_nk_ops, 118cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE), 119cd030a78SIcenowy Zheng }, 120cd030a78SIcenowy Zheng }; 121cd030a78SIcenowy Zheng 122cd030a78SIcenowy Zheng static struct ccu_div pll_periph0_sata_clk = { 123cd030a78SIcenowy Zheng .enable = BIT(24), 124cd030a78SIcenowy Zheng .div = _SUNXI_CCU_DIV(0, 2), 125cd030a78SIcenowy Zheng /* 126cd030a78SIcenowy Zheng * The formula of pll-periph0 (1x) is 24MHz*N*K/2, and the formula 127cd030a78SIcenowy Zheng * of pll-periph0-sata is 24MHz*N*K/M/6, so the postdiv here is 128cd030a78SIcenowy Zheng * 6/2 = 3. 129cd030a78SIcenowy Zheng */ 130cd030a78SIcenowy Zheng .fixed_post_div = 3, 131cd030a78SIcenowy Zheng .common = { 132cd030a78SIcenowy Zheng .reg = 0x028, 133cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_POSTDIV, 134cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT("pll-periph0-sata", 135cd030a78SIcenowy Zheng "pll-periph0", 136cd030a78SIcenowy Zheng &ccu_div_ops, 0), 137cd030a78SIcenowy Zheng }, 138cd030a78SIcenowy Zheng }; 139cd030a78SIcenowy Zheng 140cd030a78SIcenowy Zheng /* TODO: The result of N*K is required to be in [21, 58] range. */ 141cd030a78SIcenowy Zheng static struct ccu_nk pll_periph1_clk = { 142cd030a78SIcenowy Zheng .enable = BIT(31), 143cd030a78SIcenowy Zheng .lock = BIT(28), 144cd030a78SIcenowy Zheng .n = _SUNXI_CCU_MULT(8, 5), 145cd030a78SIcenowy Zheng .k = _SUNXI_CCU_MULT(4, 2), 146cd030a78SIcenowy Zheng .fixed_post_div = 2, 147cd030a78SIcenowy Zheng .common = { 148cd030a78SIcenowy Zheng .reg = 0x02c, 149cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_POSTDIV, 150cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT("pll-periph1", "osc24M", 151cd030a78SIcenowy Zheng &ccu_nk_ops, 152cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE), 153cd030a78SIcenowy Zheng }, 154cd030a78SIcenowy Zheng }; 155cd030a78SIcenowy Zheng 156b16fb669SJernej Skrabec static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1", 157cd030a78SIcenowy Zheng "osc24M", 0x030, 15824a95f75SJernej Skrabec 192000000, /* Minimum rate */ 159b16fb669SJernej Skrabec 1008000000, /* Maximum rate */ 160cd030a78SIcenowy Zheng 8, 7, /* N */ 161cd030a78SIcenowy Zheng 0, 4, /* M */ 162cd030a78SIcenowy Zheng BIT(24), /* frac enable */ 163cd030a78SIcenowy Zheng BIT(25), /* frac select */ 164cd030a78SIcenowy Zheng 270000000, /* frac rate 0 */ 165cd030a78SIcenowy Zheng 297000000, /* frac rate 1 */ 166cd030a78SIcenowy Zheng BIT(31), /* gate */ 167cd030a78SIcenowy Zheng BIT(28), /* lock */ 168cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 169cd030a78SIcenowy Zheng 170cd030a78SIcenowy Zheng static struct ccu_nkm pll_sata_clk = { 171cd030a78SIcenowy Zheng .enable = BIT(31), 172cd030a78SIcenowy Zheng .lock = BIT(28), 173cd030a78SIcenowy Zheng .n = _SUNXI_CCU_MULT(8, 5), 174cd030a78SIcenowy Zheng .k = _SUNXI_CCU_MULT(4, 2), 175cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(0, 2), 176cd030a78SIcenowy Zheng .fixed_post_div = 6, 177cd030a78SIcenowy Zheng .common = { 178cd030a78SIcenowy Zheng .reg = 0x034, 179cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_POSTDIV, 180cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT("pll-sata", "osc24M", 181cd030a78SIcenowy Zheng &ccu_nkm_ops, 182cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE), 183cd030a78SIcenowy Zheng }, 184cd030a78SIcenowy Zheng }; 185cd030a78SIcenowy Zheng 186cd030a78SIcenowy Zheng static const char * const pll_sata_out_parents[] = { "pll-sata", 187cd030a78SIcenowy Zheng "pll-periph0-sata" }; 188cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(pll_sata_out_clk, "pll-sata-out", 189cd030a78SIcenowy Zheng pll_sata_out_parents, 0x034, 190cd030a78SIcenowy Zheng 30, 1, /* mux */ 191cd030a78SIcenowy Zheng BIT(14), /* gate */ 192cd030a78SIcenowy Zheng CLK_SET_RATE_PARENT); 193cd030a78SIcenowy Zheng 194cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */ 195cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu", 196cd030a78SIcenowy Zheng "osc24M", 0x038, 197cd030a78SIcenowy Zheng 8, 7, /* N */ 198cd030a78SIcenowy Zheng 0, 4, /* M */ 199cd030a78SIcenowy Zheng BIT(24), /* frac enable */ 200cd030a78SIcenowy Zheng BIT(25), /* frac select */ 201cd030a78SIcenowy Zheng 270000000, /* frac rate 0 */ 202cd030a78SIcenowy Zheng 297000000, /* frac rate 1 */ 203cd030a78SIcenowy Zheng BIT(31), /* gate */ 204cd030a78SIcenowy Zheng BIT(28), /* lock */ 205cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 206cd030a78SIcenowy Zheng 207cd030a78SIcenowy Zheng /* 208cd030a78SIcenowy Zheng * The MIPI PLL has 2 modes: "MIPI" and "HDMI". 209cd030a78SIcenowy Zheng * 210cd030a78SIcenowy Zheng * The MIPI mode is a standard NKM-style clock. The HDMI mode is an 211cd030a78SIcenowy Zheng * integer / fractional clock with switchable multipliers and dividers. 212cd030a78SIcenowy Zheng * This is not supported here. We hardcode the PLL to MIPI mode. 213cd030a78SIcenowy Zheng * 214cd030a78SIcenowy Zheng * TODO: In the MIPI mode, M/N is required to be equal or lesser than 3, 215cd030a78SIcenowy Zheng * which cannot be implemented now. 216cd030a78SIcenowy Zheng */ 217cd030a78SIcenowy Zheng #define SUN8I_R40_PLL_MIPI_REG 0x040 218cd030a78SIcenowy Zheng 219cd030a78SIcenowy Zheng static const char * const pll_mipi_parents[] = { "pll-video0" }; 220cd030a78SIcenowy Zheng static struct ccu_nkm pll_mipi_clk = { 221cd030a78SIcenowy Zheng .enable = BIT(31) | BIT(23) | BIT(22), 222cd030a78SIcenowy Zheng .lock = BIT(28), 223cd030a78SIcenowy Zheng .n = _SUNXI_CCU_MULT(8, 4), 224cd030a78SIcenowy Zheng .k = _SUNXI_CCU_MULT_MIN(4, 2, 2), 225cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(0, 4), 226cd030a78SIcenowy Zheng .mux = _SUNXI_CCU_MUX(21, 1), 227cd030a78SIcenowy Zheng .common = { 228cd030a78SIcenowy Zheng .reg = 0x040, 229cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("pll-mipi", 230cd030a78SIcenowy Zheng pll_mipi_parents, 231cd030a78SIcenowy Zheng &ccu_nkm_ops, 232cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE) 233cd030a78SIcenowy Zheng }, 234cd030a78SIcenowy Zheng }; 235cd030a78SIcenowy Zheng 236cd030a78SIcenowy Zheng /* TODO: The result of N/M is required to be in [8, 25] range. */ 237cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de", 238cd030a78SIcenowy Zheng "osc24M", 0x048, 239cd030a78SIcenowy Zheng 8, 7, /* N */ 240cd030a78SIcenowy Zheng 0, 4, /* M */ 241cd030a78SIcenowy Zheng BIT(24), /* frac enable */ 242cd030a78SIcenowy Zheng BIT(25), /* frac select */ 243cd030a78SIcenowy Zheng 270000000, /* frac rate 0 */ 244cd030a78SIcenowy Zheng 297000000, /* frac rate 1 */ 245cd030a78SIcenowy Zheng BIT(31), /* gate */ 246cd030a78SIcenowy Zheng BIT(28), /* lock */ 247cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 248cd030a78SIcenowy Zheng 249cd030a78SIcenowy Zheng /* TODO: The N factor is required to be in [16, 75] range. */ 250cd030a78SIcenowy Zheng static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", 251cd030a78SIcenowy Zheng "osc24M", 0x04c, 252cd030a78SIcenowy Zheng 8, 7, /* N */ 253cd030a78SIcenowy Zheng 0, 2, /* M */ 254cd030a78SIcenowy Zheng BIT(31), /* gate */ 255cd030a78SIcenowy Zheng BIT(28), /* lock */ 256cd030a78SIcenowy Zheng CLK_SET_RATE_UNGATE); 257cd030a78SIcenowy Zheng 258cd030a78SIcenowy Zheng static const char * const cpu_parents[] = { "osc32k", "osc24M", 259cd030a78SIcenowy Zheng "pll-cpu", "pll-cpu" }; 260cd030a78SIcenowy Zheng static SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents, 261cd030a78SIcenowy Zheng 0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT); 262cd030a78SIcenowy Zheng 263cd030a78SIcenowy Zheng static SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0); 264cd030a78SIcenowy Zheng 265cd030a78SIcenowy Zheng static const char * const ahb1_parents[] = { "osc32k", "osc24M", 266cd030a78SIcenowy Zheng "axi", "pll-periph0" }; 267cd030a78SIcenowy Zheng static const struct ccu_mux_var_prediv ahb1_predivs[] = { 268cd030a78SIcenowy Zheng { .index = 3, .shift = 6, .width = 2 }, 269cd030a78SIcenowy Zheng }; 270cd030a78SIcenowy Zheng static struct ccu_div ahb1_clk = { 271cd030a78SIcenowy Zheng .div = _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO), 272cd030a78SIcenowy Zheng 273cd030a78SIcenowy Zheng .mux = { 274cd030a78SIcenowy Zheng .shift = 12, 275cd030a78SIcenowy Zheng .width = 2, 276cd030a78SIcenowy Zheng 277cd030a78SIcenowy Zheng .var_predivs = ahb1_predivs, 278cd030a78SIcenowy Zheng .n_var_predivs = ARRAY_SIZE(ahb1_predivs), 279cd030a78SIcenowy Zheng }, 280cd030a78SIcenowy Zheng 281cd030a78SIcenowy Zheng .common = { 282cd030a78SIcenowy Zheng .reg = 0x054, 283cd030a78SIcenowy Zheng .features = CCU_FEATURE_VARIABLE_PREDIV, 284cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("ahb1", 285cd030a78SIcenowy Zheng ahb1_parents, 286cd030a78SIcenowy Zheng &ccu_div_ops, 287cd030a78SIcenowy Zheng 0), 288cd030a78SIcenowy Zheng }, 289cd030a78SIcenowy Zheng }; 290cd030a78SIcenowy Zheng 291cd030a78SIcenowy Zheng static struct clk_div_table apb1_div_table[] = { 292cd030a78SIcenowy Zheng { .val = 0, .div = 2 }, 293cd030a78SIcenowy Zheng { .val = 1, .div = 2 }, 294cd030a78SIcenowy Zheng { .val = 2, .div = 4 }, 295cd030a78SIcenowy Zheng { .val = 3, .div = 8 }, 296cd030a78SIcenowy Zheng { /* Sentinel */ }, 297cd030a78SIcenowy Zheng }; 298cd030a78SIcenowy Zheng static SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1", 299cd030a78SIcenowy Zheng 0x054, 8, 2, apb1_div_table, 0); 300cd030a78SIcenowy Zheng 301cd030a78SIcenowy Zheng static const char * const apb2_parents[] = { "osc32k", "osc24M", 302cd030a78SIcenowy Zheng "pll-periph0-2x", 303cd030a78SIcenowy Zheng "pll-periph0-2x" }; 304cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058, 305cd030a78SIcenowy Zheng 0, 5, /* M */ 306cd030a78SIcenowy Zheng 16, 2, /* P */ 307cd030a78SIcenowy Zheng 24, 2, /* mux */ 308cd030a78SIcenowy Zheng 0); 309cd030a78SIcenowy Zheng 310cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb1", 311cd030a78SIcenowy Zheng 0x060, BIT(1), 0); 312cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "ahb1", 313cd030a78SIcenowy Zheng 0x060, BIT(5), 0); 314cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "ahb1", 315cd030a78SIcenowy Zheng 0x060, BIT(6), 0); 316cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb1", 317cd030a78SIcenowy Zheng 0x060, BIT(8), 0); 318cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb1", 319cd030a78SIcenowy Zheng 0x060, BIT(9), 0); 320cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb1", 321cd030a78SIcenowy Zheng 0x060, BIT(10), 0); 322cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mmc3_clk, "bus-mmc3", "ahb1", 323cd030a78SIcenowy Zheng 0x060, BIT(11), 0); 324cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb1", 325cd030a78SIcenowy Zheng 0x060, BIT(13), 0); 326cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "ahb1", 327cd030a78SIcenowy Zheng 0x060, BIT(14), 0); 328cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb1", 329cd030a78SIcenowy Zheng 0x060, BIT(17), 0); 330cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ts_clk, "bus-ts", "ahb1", 331cd030a78SIcenowy Zheng 0x060, BIT(18), 0); 332cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1", 333cd030a78SIcenowy Zheng 0x060, BIT(19), 0); 334cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb1", 335cd030a78SIcenowy Zheng 0x060, BIT(20), 0); 336cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb1", 337cd030a78SIcenowy Zheng 0x060, BIT(21), 0); 338cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi2_clk, "bus-spi2", "ahb1", 339cd030a78SIcenowy Zheng 0x060, BIT(22), 0); 340cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spi3_clk, "bus-spi3", "ahb1", 341cd030a78SIcenowy Zheng 0x060, BIT(23), 0); 342cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_sata_clk, "bus-sata", "ahb1", 343cd030a78SIcenowy Zheng 0x060, BIT(24), 0); 344cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb1", 345cd030a78SIcenowy Zheng 0x060, BIT(25), 0); 346cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb1", 347cd030a78SIcenowy Zheng 0x060, BIT(26), 0); 348cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb1", 349cd030a78SIcenowy Zheng 0x060, BIT(27), 0); 350cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ehci2_clk, "bus-ehci2", "ahb1", 351cd030a78SIcenowy Zheng 0x060, BIT(28), 0); 352cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb1", 353cd030a78SIcenowy Zheng 0x060, BIT(29), 0); 354cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci1_clk, "bus-ohci1", "ahb1", 355cd030a78SIcenowy Zheng 0x060, BIT(30), 0); 356cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ohci2_clk, "bus-ohci2", "ahb1", 357cd030a78SIcenowy Zheng 0x060, BIT(31), 0); 358cd030a78SIcenowy Zheng 359cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "ahb1", 360cd030a78SIcenowy Zheng 0x064, BIT(0), 0); 361cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_mp_clk, "bus-mp", "ahb1", 362cd030a78SIcenowy Zheng 0x064, BIT(2), 0); 363cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_deinterlace_clk, "bus-deinterlace", "ahb1", 364cd030a78SIcenowy Zheng 0x064, BIT(5), 0); 365cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_csi0_clk, "bus-csi0", "ahb1", 366cd030a78SIcenowy Zheng 0x064, BIT(8), 0); 367cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_csi1_clk, "bus-csi1", "ahb1", 368cd030a78SIcenowy Zheng 0x064, BIT(9), 0); 369cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hdmi0_clk, "bus-hdmi0", "ahb1", 370cd030a78SIcenowy Zheng 0x064, BIT(10), 0); 371cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_hdmi1_clk, "bus-hdmi1", "ahb1", 372cd030a78SIcenowy Zheng 0x064, BIT(11), 0); 373cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 374cd030a78SIcenowy Zheng 0x064, BIT(12), 0); 375cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve0_clk, "bus-tve0", "ahb1", 376cd030a78SIcenowy Zheng 0x064, BIT(13), 0); 377cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve1_clk, "bus-tve1", "ahb1", 378cd030a78SIcenowy Zheng 0x064, BIT(14), 0); 379cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tve_top_clk, "bus-tve-top", "ahb1", 380cd030a78SIcenowy Zheng 0x064, BIT(15), 0); 381cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_gmac_clk, "bus-gmac", "ahb1", 382cd030a78SIcenowy Zheng 0x064, BIT(17), 0); 383cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 384cd030a78SIcenowy Zheng 0x064, BIT(20), 0); 385cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd0_clk, "bus-tvd0", "ahb1", 386cd030a78SIcenowy Zheng 0x064, BIT(21), 0); 387cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd1_clk, "bus-tvd1", "ahb1", 388cd030a78SIcenowy Zheng 0x064, BIT(22), 0); 389cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd2_clk, "bus-tvd2", "ahb1", 390cd030a78SIcenowy Zheng 0x064, BIT(23), 0); 391cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd3_clk, "bus-tvd3", "ahb1", 392cd030a78SIcenowy Zheng 0x064, BIT(24), 0); 393cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tvd_top_clk, "bus-tvd-top", "ahb1", 394cd030a78SIcenowy Zheng 0x064, BIT(25), 0); 395cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_lcd0_clk, "bus-tcon-lcd0", "ahb1", 396cd030a78SIcenowy Zheng 0x064, BIT(26), 0); 397cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_lcd1_clk, "bus-tcon-lcd1", "ahb1", 398cd030a78SIcenowy Zheng 0x064, BIT(27), 0); 399cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_tv0_clk, "bus-tcon-tv0", "ahb1", 400cd030a78SIcenowy Zheng 0x064, BIT(28), 0); 401cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_tv1_clk, "bus-tcon-tv1", "ahb1", 402cd030a78SIcenowy Zheng 0x064, BIT(29), 0); 403cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_tcon_top_clk, "bus-tcon-top", "ahb1", 404cd030a78SIcenowy Zheng 0x064, BIT(30), 0); 405cd030a78SIcenowy Zheng 406cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_codec_clk, "bus-codec", "apb1", 407cd030a78SIcenowy Zheng 0x068, BIT(0), 0); 408cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1", 409cd030a78SIcenowy Zheng 0x068, BIT(1), 0); 410cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ac97_clk, "bus-ac97", "apb1", 411cd030a78SIcenowy Zheng 0x068, BIT(2), 0); 412cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_pio_clk, "bus-pio", "apb1", 413cd030a78SIcenowy Zheng 0x068, BIT(5), 0); 414cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ir0_clk, "bus-ir0", "apb1", 415cd030a78SIcenowy Zheng 0x068, BIT(6), 0); 416cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ir1_clk, "bus-ir1", "apb1", 417cd030a78SIcenowy Zheng 0x068, BIT(7), 0); 418cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1", 419cd030a78SIcenowy Zheng 0x068, BIT(8), 0); 420cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_keypad_clk, "bus-keypad", "apb1", 421cd030a78SIcenowy Zheng 0x068, BIT(10), 0); 422cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 423cd030a78SIcenowy Zheng 0x068, BIT(12), 0); 424cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 425cd030a78SIcenowy Zheng 0x068, BIT(13), 0); 426cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1", 427cd030a78SIcenowy Zheng 0x068, BIT(14), 0); 428cd030a78SIcenowy Zheng 429cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 430cd030a78SIcenowy Zheng 0x06c, BIT(0), 0); 431cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 432cd030a78SIcenowy Zheng 0x06c, BIT(1), 0); 433cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 434cd030a78SIcenowy Zheng 0x06c, BIT(2), 0); 435cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c3_clk, "bus-i2c3", "apb2", 436cd030a78SIcenowy Zheng 0x06c, BIT(3), 0); 437cd030a78SIcenowy Zheng /* 438cd030a78SIcenowy Zheng * In datasheet here's "Reserved", however the gate exists in BSP soucre 439cd030a78SIcenowy Zheng * code. 440cd030a78SIcenowy Zheng */ 441cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_can_clk, "bus-can", "apb2", 442cd030a78SIcenowy Zheng 0x06c, BIT(4), 0); 443cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_scr_clk, "bus-scr", "apb2", 444cd030a78SIcenowy Zheng 0x06c, BIT(5), 0); 445cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ps20_clk, "bus-ps20", "apb2", 446cd030a78SIcenowy Zheng 0x06c, BIT(6), 0); 447cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_ps21_clk, "bus-ps21", "apb2", 448cd030a78SIcenowy Zheng 0x06c, BIT(7), 0); 449cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_i2c4_clk, "bus-i2c4", "apb2", 450cd030a78SIcenowy Zheng 0x06c, BIT(15), 0); 451cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 452cd030a78SIcenowy Zheng 0x06c, BIT(16), 0); 453cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 454cd030a78SIcenowy Zheng 0x06c, BIT(17), 0); 455cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 456cd030a78SIcenowy Zheng 0x06c, BIT(18), 0); 457cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 458cd030a78SIcenowy Zheng 0x06c, BIT(19), 0); 459cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2", 460cd030a78SIcenowy Zheng 0x06c, BIT(20), 0); 461cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart5_clk, "bus-uart5", "apb2", 462cd030a78SIcenowy Zheng 0x06c, BIT(21), 0); 463cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart6_clk, "bus-uart6", "apb2", 464cd030a78SIcenowy Zheng 0x06c, BIT(22), 0); 465cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_uart7_clk, "bus-uart7", "apb2", 466cd030a78SIcenowy Zheng 0x06c, BIT(23), 0); 467cd030a78SIcenowy Zheng 468cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "ahb1", 469cd030a78SIcenowy Zheng 0x070, BIT(7), 0); 470cd030a78SIcenowy Zheng 471cd030a78SIcenowy Zheng static const char * const ths_parents[] = { "osc24M" }; 472cd030a78SIcenowy Zheng static struct ccu_div ths_clk = { 473cd030a78SIcenowy Zheng .enable = BIT(31), 474cd030a78SIcenowy Zheng .div = _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO), 475cd030a78SIcenowy Zheng .mux = _SUNXI_CCU_MUX(24, 2), 476cd030a78SIcenowy Zheng .common = { 477cd030a78SIcenowy Zheng .reg = 0x074, 478cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("ths", 479cd030a78SIcenowy Zheng ths_parents, 480cd030a78SIcenowy Zheng &ccu_div_ops, 481cd030a78SIcenowy Zheng 0), 482cd030a78SIcenowy Zheng }, 483cd030a78SIcenowy Zheng }; 484cd030a78SIcenowy Zheng 485cd030a78SIcenowy Zheng static const char * const mod0_default_parents[] = { "osc24M", "pll-periph0", 486cd030a78SIcenowy Zheng "pll-periph1" }; 487cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080, 488cd030a78SIcenowy Zheng 0, 4, /* M */ 489cd030a78SIcenowy Zheng 16, 2, /* P */ 490cd030a78SIcenowy Zheng 24, 2, /* mux */ 491cd030a78SIcenowy Zheng BIT(31), /* gate */ 492cd030a78SIcenowy Zheng 0); 493cd030a78SIcenowy Zheng 494cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088, 495cd030a78SIcenowy Zheng 0, 4, /* M */ 496cd030a78SIcenowy Zheng 16, 2, /* P */ 497cd030a78SIcenowy Zheng 24, 2, /* mux */ 498cd030a78SIcenowy Zheng BIT(31), /* gate */ 499cd030a78SIcenowy Zheng 0); 500cd030a78SIcenowy Zheng 501cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c, 502cd030a78SIcenowy Zheng 0, 4, /* M */ 503cd030a78SIcenowy Zheng 16, 2, /* P */ 504cd030a78SIcenowy Zheng 24, 2, /* mux */ 505cd030a78SIcenowy Zheng BIT(31), /* gate */ 506cd030a78SIcenowy Zheng 0); 507cd030a78SIcenowy Zheng 508cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090, 509cd030a78SIcenowy Zheng 0, 4, /* M */ 510cd030a78SIcenowy Zheng 16, 2, /* P */ 511cd030a78SIcenowy Zheng 24, 2, /* mux */ 512cd030a78SIcenowy Zheng BIT(31), /* gate */ 513cd030a78SIcenowy Zheng 0); 514cd030a78SIcenowy Zheng 515cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents, 0x094, 516cd030a78SIcenowy Zheng 0, 4, /* M */ 517cd030a78SIcenowy Zheng 16, 2, /* P */ 518cd030a78SIcenowy Zheng 24, 2, /* mux */ 519cd030a78SIcenowy Zheng BIT(31), /* gate */ 520cd030a78SIcenowy Zheng 0); 521cd030a78SIcenowy Zheng 522cd030a78SIcenowy Zheng static const char * const ts_parents[] = { "osc24M", "pll-periph0", }; 523cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098, 524cd030a78SIcenowy Zheng 0, 4, /* M */ 525cd030a78SIcenowy Zheng 16, 2, /* P */ 526cd030a78SIcenowy Zheng 24, 4, /* mux */ 527cd030a78SIcenowy Zheng BIT(31), /* gate */ 528cd030a78SIcenowy Zheng 0); 529cd030a78SIcenowy Zheng 530cd030a78SIcenowy Zheng static const char * const ce_parents[] = { "osc24M", "pll-periph0-2x", 531cd030a78SIcenowy Zheng "pll-periph1-2x" }; 532cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c, 533cd030a78SIcenowy Zheng 0, 4, /* M */ 534cd030a78SIcenowy Zheng 16, 2, /* P */ 535cd030a78SIcenowy Zheng 24, 2, /* mux */ 536cd030a78SIcenowy Zheng BIT(31), /* gate */ 537cd030a78SIcenowy Zheng 0); 538cd030a78SIcenowy Zheng 539cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0, 540cd030a78SIcenowy Zheng 0, 4, /* M */ 541cd030a78SIcenowy Zheng 16, 2, /* P */ 542cd030a78SIcenowy Zheng 24, 2, /* mux */ 543cd030a78SIcenowy Zheng BIT(31), /* gate */ 544cd030a78SIcenowy Zheng 0); 545cd030a78SIcenowy Zheng 546cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4, 547cd030a78SIcenowy Zheng 0, 4, /* M */ 548cd030a78SIcenowy Zheng 16, 2, /* P */ 549cd030a78SIcenowy Zheng 24, 2, /* mux */ 550cd030a78SIcenowy Zheng BIT(31), /* gate */ 551cd030a78SIcenowy Zheng 0); 552cd030a78SIcenowy Zheng 553cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8, 554cd030a78SIcenowy Zheng 0, 4, /* M */ 555cd030a78SIcenowy Zheng 16, 2, /* P */ 556cd030a78SIcenowy Zheng 24, 2, /* mux */ 557cd030a78SIcenowy Zheng BIT(31), /* gate */ 558cd030a78SIcenowy Zheng 0); 559cd030a78SIcenowy Zheng 560cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents, 0x0ac, 561cd030a78SIcenowy Zheng 0, 4, /* M */ 562cd030a78SIcenowy Zheng 16, 2, /* P */ 563cd030a78SIcenowy Zheng 24, 2, /* mux */ 564cd030a78SIcenowy Zheng BIT(31), /* gate */ 565cd030a78SIcenowy Zheng 0); 566cd030a78SIcenowy Zheng 567cd030a78SIcenowy Zheng static const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x", 568cd030a78SIcenowy Zheng "pll-audio-2x", "pll-audio" }; 569cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents, 570cd030a78SIcenowy Zheng 0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 571cd030a78SIcenowy Zheng 572cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents, 573cd030a78SIcenowy Zheng 0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 574cd030a78SIcenowy Zheng 575cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents, 576cd030a78SIcenowy Zheng 0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 577cd030a78SIcenowy Zheng 578cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(ac97_clk, "ac97", i2s_parents, 579cd030a78SIcenowy Zheng 0x0bc, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 580cd030a78SIcenowy Zheng 581cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", i2s_parents, 582cd030a78SIcenowy Zheng 0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT); 583cd030a78SIcenowy Zheng 584cd030a78SIcenowy Zheng static const char * const keypad_parents[] = { "osc24M", "osc32k" }; 585cd030a78SIcenowy Zheng static const u8 keypad_table[] = { 0, 2 }; 586cd030a78SIcenowy Zheng static struct ccu_mp keypad_clk = { 587cd030a78SIcenowy Zheng .enable = BIT(31), 588cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(0, 5), 589cd030a78SIcenowy Zheng .p = _SUNXI_CCU_DIV(16, 2), 590cd030a78SIcenowy Zheng .mux = _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table), 591cd030a78SIcenowy Zheng .common = { 592cd030a78SIcenowy Zheng .reg = 0x0c4, 593cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("keypad", 594cd030a78SIcenowy Zheng keypad_parents, 595cd030a78SIcenowy Zheng &ccu_mp_ops, 596cd030a78SIcenowy Zheng 0), 597cd030a78SIcenowy Zheng } 598cd030a78SIcenowy Zheng }; 599cd030a78SIcenowy Zheng 600cd030a78SIcenowy Zheng static const char * const sata_parents[] = { "pll-sata-out", "sata-ext" }; 601cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(sata_clk, "sata", sata_parents, 602cd030a78SIcenowy Zheng 0x0c8, 24, 1, BIT(31), CLK_SET_RATE_PARENT); 603cd030a78SIcenowy Zheng 604cd030a78SIcenowy Zheng /* 605cd030a78SIcenowy Zheng * There are 3 OHCI 12M clock source selection bits in this register. 606cd030a78SIcenowy Zheng * We will force them to 0 (12M divided from 48M). 607cd030a78SIcenowy Zheng */ 608cd030a78SIcenowy Zheng #define SUN8I_R40_USB_CLK_REG 0x0cc 609cd030a78SIcenowy Zheng 610cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", 611cd030a78SIcenowy Zheng 0x0cc, BIT(8), 0); 612cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "osc24M", 613cd030a78SIcenowy Zheng 0x0cc, BIT(9), 0); 614cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_phy2_clk, "usb-phy2", "osc24M", 615cd030a78SIcenowy Zheng 0x0cc, BIT(10), 0); 616cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc12M", 617cd030a78SIcenowy Zheng 0x0cc, BIT(16), 0); 618cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "osc12M", 619cd030a78SIcenowy Zheng 0x0cc, BIT(17), 0); 620cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(usb_ohci2_clk, "usb-ohci2", "osc12M", 621cd030a78SIcenowy Zheng 0x0cc, BIT(18), 0); 622cd030a78SIcenowy Zheng 623cd030a78SIcenowy Zheng static const char * const ir_parents[] = { "osc24M", "pll-periph0", 624cd030a78SIcenowy Zheng "pll-periph1", "osc32k" }; 625cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ir0_clk, "ir0", ir_parents, 0x0d0, 626cd030a78SIcenowy Zheng 0, 4, /* M */ 627cd030a78SIcenowy Zheng 16, 2, /* P */ 628cd030a78SIcenowy Zheng 24, 2, /* mux */ 629cd030a78SIcenowy Zheng BIT(31), /* gate */ 630cd030a78SIcenowy Zheng 0); 631cd030a78SIcenowy Zheng 632cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(ir1_clk, "ir1", ir_parents, 0x0d4, 633cd030a78SIcenowy Zheng 0, 4, /* M */ 634cd030a78SIcenowy Zheng 16, 2, /* P */ 635cd030a78SIcenowy Zheng 24, 2, /* mux */ 636cd030a78SIcenowy Zheng BIT(31), /* gate */ 637cd030a78SIcenowy Zheng 0); 638cd030a78SIcenowy Zheng 639cd030a78SIcenowy Zheng static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" }; 640cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, 641cd030a78SIcenowy Zheng 0x0f4, 0, 2, 20, 2, CLK_IS_CRITICAL); 642cd030a78SIcenowy Zheng 643cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "dram", 644cd030a78SIcenowy Zheng 0x100, BIT(0), 0); 645cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_csi0_clk, "dram-csi0", "dram", 646cd030a78SIcenowy Zheng 0x100, BIT(1), 0); 647cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_csi1_clk, "dram-csi1", "dram", 648cd030a78SIcenowy Zheng 0x100, BIT(2), 0); 649cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_ts_clk, "dram-ts", "dram", 650cd030a78SIcenowy Zheng 0x100, BIT(3), 0); 651cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_tvd_clk, "dram-tvd", "dram", 652cd030a78SIcenowy Zheng 0x100, BIT(4), 0); 653cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_mp_clk, "dram-mp", "dram", 654cd030a78SIcenowy Zheng 0x100, BIT(5), 0); 655cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(dram_deinterlace_clk, "dram-deinterlace", "dram", 656cd030a78SIcenowy Zheng 0x100, BIT(6), 0); 657cd030a78SIcenowy Zheng 658cd030a78SIcenowy Zheng static const char * const de_parents[] = { "pll-periph0-2x", "pll-de" }; 659cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, 660fb4aa0f6SJernej Skrabec 0x104, 0, 4, 24, 3, BIT(31), 661fb4aa0f6SJernej Skrabec CLK_SET_RATE_PARENT); 662cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(mp_clk, "mp", de_parents, 663cd030a78SIcenowy Zheng 0x108, 0, 4, 24, 3, BIT(31), 0); 664cd030a78SIcenowy Zheng 665cd030a78SIcenowy Zheng static const char * const tcon_parents[] = { "pll-video0", "pll-video1", 666cd030a78SIcenowy Zheng "pll-video0-2x", "pll-video1-2x", 667cd030a78SIcenowy Zheng "pll-mipi" }; 668cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk, "tcon-lcd0", tcon_parents, 669cd030a78SIcenowy Zheng 0x110, 24, 3, BIT(31), CLK_SET_RATE_PARENT); 670cd030a78SIcenowy Zheng static SUNXI_CCU_MUX_WITH_GATE(tcon_lcd1_clk, "tcon-lcd1", tcon_parents, 671cd030a78SIcenowy Zheng 0x114, 24, 3, BIT(31), CLK_SET_RATE_PARENT); 672cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv0_clk, "tcon-tv0", tcon_parents, 673fb4aa0f6SJernej Skrabec 0x118, 0, 4, 24, 3, BIT(31), 674fb4aa0f6SJernej Skrabec CLK_SET_RATE_PARENT); 675cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv1_clk, "tcon-tv1", tcon_parents, 676fb4aa0f6SJernej Skrabec 0x11c, 0, 4, 24, 3, BIT(31), 677fb4aa0f6SJernej Skrabec CLK_SET_RATE_PARENT); 678cd030a78SIcenowy Zheng 679cd030a78SIcenowy Zheng static const char * const deinterlace_parents[] = { "pll-periph0", 680cd030a78SIcenowy Zheng "pll-periph1" }; 681cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", 682cd030a78SIcenowy Zheng deinterlace_parents, 0x124, 0, 4, 24, 3, 683cd030a78SIcenowy Zheng BIT(31), 0); 684cd030a78SIcenowy Zheng 685cd030a78SIcenowy Zheng static const char * const csi_mclk_parents[] = { "osc24M", "pll-video1", 686cd030a78SIcenowy Zheng "pll-periph1" }; 687cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi1-mclk", csi_mclk_parents, 688cd030a78SIcenowy Zheng 0x130, 0, 5, 8, 3, BIT(15), 0); 689cd030a78SIcenowy Zheng 690cd030a78SIcenowy Zheng static const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" }; 691cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents, 692cd030a78SIcenowy Zheng 0x134, 16, 4, 24, 3, BIT(31), 0); 693cd030a78SIcenowy Zheng 694cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents, 695cd030a78SIcenowy Zheng 0x134, 0, 5, 8, 3, BIT(15), 0); 696cd030a78SIcenowy Zheng 697cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve", 698cd030a78SIcenowy Zheng 0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT); 699cd030a78SIcenowy Zheng 700cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(codec_clk, "codec", "pll-audio", 701cd030a78SIcenowy Zheng 0x140, BIT(31), CLK_SET_RATE_PARENT); 702cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 703cd030a78SIcenowy Zheng 0x144, BIT(31), 0); 704cd030a78SIcenowy Zheng 705cd030a78SIcenowy Zheng static const char * const hdmi_parents[] = { "pll-video0", "pll-video1" }; 706cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents, 707fb4aa0f6SJernej Skrabec 0x150, 0, 4, 24, 2, BIT(31), 708fb4aa0f6SJernej Skrabec CLK_SET_RATE_PARENT); 709cd030a78SIcenowy Zheng 710cd030a78SIcenowy Zheng static SUNXI_CCU_GATE(hdmi_slow_clk, "hdmi-slow", "osc24M", 711cd030a78SIcenowy Zheng 0x154, BIT(31), 0); 712cd030a78SIcenowy Zheng 713cd030a78SIcenowy Zheng /* 714cd030a78SIcenowy Zheng * In the SoC's user manual, the P factor is mentioned, but not used in 715cd030a78SIcenowy Zheng * the frequency formula. 716cd030a78SIcenowy Zheng * 717cd030a78SIcenowy Zheng * Here the factor is included, according to the BSP kernel source, 718cd030a78SIcenowy Zheng * which contains the P factor of this clock. 719cd030a78SIcenowy Zheng */ 720cd030a78SIcenowy Zheng static const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x", 721cd030a78SIcenowy Zheng "pll-ddr0" }; 722cd030a78SIcenowy Zheng static SUNXI_CCU_MP_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c, 723cd030a78SIcenowy Zheng 0, 4, /* M */ 724cd030a78SIcenowy Zheng 16, 2, /* P */ 725cd030a78SIcenowy Zheng 24, 2, /* mux */ 726cd030a78SIcenowy Zheng BIT(31), /* gate */ 727cd030a78SIcenowy Zheng CLK_IS_CRITICAL); 728cd030a78SIcenowy Zheng 729cd030a78SIcenowy Zheng static const char * const dsi_dphy_parents[] = { "pll-video0", "pll-video1", 730cd030a78SIcenowy Zheng "pll-periph0" }; 731cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(dsi_dphy_clk, "dsi-dphy", dsi_dphy_parents, 732cd030a78SIcenowy Zheng 0x168, 0, 4, 8, 2, BIT(15), 0); 733cd030a78SIcenowy Zheng 734cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tve0_clk, "tve0", tcon_parents, 735cd030a78SIcenowy Zheng 0x180, 0, 4, 24, 3, BIT(31), 0); 736cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tve1_clk, "tve1", tcon_parents, 737cd030a78SIcenowy Zheng 0x184, 0, 4, 24, 3, BIT(31), 0); 738cd030a78SIcenowy Zheng 739cd030a78SIcenowy Zheng static const char * const tvd_parents[] = { "pll-video0", "pll-video1", 740cd030a78SIcenowy Zheng "pll-video0-2x", "pll-video1-2x" }; 741cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd0_clk, "tvd0", tvd_parents, 742cd030a78SIcenowy Zheng 0x188, 0, 4, 24, 3, BIT(31), 0); 743cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd1_clk, "tvd1", tvd_parents, 744cd030a78SIcenowy Zheng 0x18c, 0, 4, 24, 3, BIT(31), 0); 745cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd2_clk, "tvd2", tvd_parents, 746cd030a78SIcenowy Zheng 0x190, 0, 4, 24, 3, BIT(31), 0); 747cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_MUX_GATE(tvd3_clk, "tvd3", tvd_parents, 748cd030a78SIcenowy Zheng 0x194, 0, 4, 24, 3, BIT(31), 0); 749cd030a78SIcenowy Zheng 750cd030a78SIcenowy Zheng static SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu", 751cd030a78SIcenowy Zheng 0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT); 752cd030a78SIcenowy Zheng 753cd030a78SIcenowy Zheng static const char * const out_parents[] = { "osc24M", "osc32k", "osc24M" }; 754cd030a78SIcenowy Zheng static const struct ccu_mux_fixed_prediv out_predivs[] = { 755cd030a78SIcenowy Zheng { .index = 0, .div = 750, }, 756cd030a78SIcenowy Zheng }; 757cd030a78SIcenowy Zheng 758cd030a78SIcenowy Zheng static struct ccu_mp outa_clk = { 759cd030a78SIcenowy Zheng .enable = BIT(31), 760cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(8, 5), 761cd030a78SIcenowy Zheng .p = _SUNXI_CCU_DIV(20, 2), 762cd030a78SIcenowy Zheng .mux = { 763cd030a78SIcenowy Zheng .shift = 24, 764cd030a78SIcenowy Zheng .width = 2, 765cd030a78SIcenowy Zheng .fixed_predivs = out_predivs, 766cd030a78SIcenowy Zheng .n_predivs = ARRAY_SIZE(out_predivs), 767cd030a78SIcenowy Zheng }, 768cd030a78SIcenowy Zheng .common = { 769cd030a78SIcenowy Zheng .reg = 0x1f0, 770cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_PREDIV, 771cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("outa", out_parents, 772cd030a78SIcenowy Zheng &ccu_mp_ops, 0), 773cd030a78SIcenowy Zheng } 774cd030a78SIcenowy Zheng }; 775cd030a78SIcenowy Zheng 776cd030a78SIcenowy Zheng static struct ccu_mp outb_clk = { 777cd030a78SIcenowy Zheng .enable = BIT(31), 778cd030a78SIcenowy Zheng .m = _SUNXI_CCU_DIV(8, 5), 779cd030a78SIcenowy Zheng .p = _SUNXI_CCU_DIV(20, 2), 780cd030a78SIcenowy Zheng .mux = { 781cd030a78SIcenowy Zheng .shift = 24, 782cd030a78SIcenowy Zheng .width = 2, 783cd030a78SIcenowy Zheng .fixed_predivs = out_predivs, 784cd030a78SIcenowy Zheng .n_predivs = ARRAY_SIZE(out_predivs), 785cd030a78SIcenowy Zheng }, 786cd030a78SIcenowy Zheng .common = { 787cd030a78SIcenowy Zheng .reg = 0x1f4, 788cd030a78SIcenowy Zheng .features = CCU_FEATURE_FIXED_PREDIV, 789cd030a78SIcenowy Zheng .hw.init = CLK_HW_INIT_PARENTS("outb", out_parents, 790cd030a78SIcenowy Zheng &ccu_mp_ops, 0), 791cd030a78SIcenowy Zheng } 792cd030a78SIcenowy Zheng }; 793cd030a78SIcenowy Zheng 794cd030a78SIcenowy Zheng static struct ccu_common *sun8i_r40_ccu_clks[] = { 795cd030a78SIcenowy Zheng &pll_cpu_clk.common, 796cd030a78SIcenowy Zheng &pll_audio_base_clk.common, 797cd030a78SIcenowy Zheng &pll_video0_clk.common, 798cd030a78SIcenowy Zheng &pll_ve_clk.common, 799cd030a78SIcenowy Zheng &pll_ddr0_clk.common, 800cd030a78SIcenowy Zheng &pll_periph0_clk.common, 801cd030a78SIcenowy Zheng &pll_periph0_sata_clk.common, 802cd030a78SIcenowy Zheng &pll_periph1_clk.common, 803cd030a78SIcenowy Zheng &pll_video1_clk.common, 804cd030a78SIcenowy Zheng &pll_sata_clk.common, 805cd030a78SIcenowy Zheng &pll_sata_out_clk.common, 806cd030a78SIcenowy Zheng &pll_gpu_clk.common, 807cd030a78SIcenowy Zheng &pll_mipi_clk.common, 808cd030a78SIcenowy Zheng &pll_de_clk.common, 809cd030a78SIcenowy Zheng &pll_ddr1_clk.common, 810cd030a78SIcenowy Zheng &cpu_clk.common, 811cd030a78SIcenowy Zheng &axi_clk.common, 812cd030a78SIcenowy Zheng &ahb1_clk.common, 813cd030a78SIcenowy Zheng &apb1_clk.common, 814cd030a78SIcenowy Zheng &apb2_clk.common, 815cd030a78SIcenowy Zheng &bus_mipi_dsi_clk.common, 816cd030a78SIcenowy Zheng &bus_ce_clk.common, 817cd030a78SIcenowy Zheng &bus_dma_clk.common, 818cd030a78SIcenowy Zheng &bus_mmc0_clk.common, 819cd030a78SIcenowy Zheng &bus_mmc1_clk.common, 820cd030a78SIcenowy Zheng &bus_mmc2_clk.common, 821cd030a78SIcenowy Zheng &bus_mmc3_clk.common, 822cd030a78SIcenowy Zheng &bus_nand_clk.common, 823cd030a78SIcenowy Zheng &bus_dram_clk.common, 824cd030a78SIcenowy Zheng &bus_emac_clk.common, 825cd030a78SIcenowy Zheng &bus_ts_clk.common, 826cd030a78SIcenowy Zheng &bus_hstimer_clk.common, 827cd030a78SIcenowy Zheng &bus_spi0_clk.common, 828cd030a78SIcenowy Zheng &bus_spi1_clk.common, 829cd030a78SIcenowy Zheng &bus_spi2_clk.common, 830cd030a78SIcenowy Zheng &bus_spi3_clk.common, 831cd030a78SIcenowy Zheng &bus_sata_clk.common, 832cd030a78SIcenowy Zheng &bus_otg_clk.common, 833cd030a78SIcenowy Zheng &bus_ehci0_clk.common, 834cd030a78SIcenowy Zheng &bus_ehci1_clk.common, 835cd030a78SIcenowy Zheng &bus_ehci2_clk.common, 836cd030a78SIcenowy Zheng &bus_ohci0_clk.common, 837cd030a78SIcenowy Zheng &bus_ohci1_clk.common, 838cd030a78SIcenowy Zheng &bus_ohci2_clk.common, 839cd030a78SIcenowy Zheng &bus_ve_clk.common, 840cd030a78SIcenowy Zheng &bus_mp_clk.common, 841cd030a78SIcenowy Zheng &bus_deinterlace_clk.common, 842cd030a78SIcenowy Zheng &bus_csi0_clk.common, 843cd030a78SIcenowy Zheng &bus_csi1_clk.common, 844cd030a78SIcenowy Zheng &bus_hdmi0_clk.common, 845cd030a78SIcenowy Zheng &bus_hdmi1_clk.common, 846cd030a78SIcenowy Zheng &bus_de_clk.common, 847cd030a78SIcenowy Zheng &bus_tve0_clk.common, 848cd030a78SIcenowy Zheng &bus_tve1_clk.common, 849cd030a78SIcenowy Zheng &bus_tve_top_clk.common, 850cd030a78SIcenowy Zheng &bus_gmac_clk.common, 851cd030a78SIcenowy Zheng &bus_gpu_clk.common, 852cd030a78SIcenowy Zheng &bus_tvd0_clk.common, 853cd030a78SIcenowy Zheng &bus_tvd1_clk.common, 854cd030a78SIcenowy Zheng &bus_tvd2_clk.common, 855cd030a78SIcenowy Zheng &bus_tvd3_clk.common, 856cd030a78SIcenowy Zheng &bus_tvd_top_clk.common, 857cd030a78SIcenowy Zheng &bus_tcon_lcd0_clk.common, 858cd030a78SIcenowy Zheng &bus_tcon_lcd1_clk.common, 859cd030a78SIcenowy Zheng &bus_tcon_tv0_clk.common, 860cd030a78SIcenowy Zheng &bus_tcon_tv1_clk.common, 861cd030a78SIcenowy Zheng &bus_tcon_top_clk.common, 862cd030a78SIcenowy Zheng &bus_codec_clk.common, 863cd030a78SIcenowy Zheng &bus_spdif_clk.common, 864cd030a78SIcenowy Zheng &bus_ac97_clk.common, 865cd030a78SIcenowy Zheng &bus_pio_clk.common, 866cd030a78SIcenowy Zheng &bus_ir0_clk.common, 867cd030a78SIcenowy Zheng &bus_ir1_clk.common, 868cd030a78SIcenowy Zheng &bus_ths_clk.common, 869cd030a78SIcenowy Zheng &bus_keypad_clk.common, 870cd030a78SIcenowy Zheng &bus_i2s0_clk.common, 871cd030a78SIcenowy Zheng &bus_i2s1_clk.common, 872cd030a78SIcenowy Zheng &bus_i2s2_clk.common, 873cd030a78SIcenowy Zheng &bus_i2c0_clk.common, 874cd030a78SIcenowy Zheng &bus_i2c1_clk.common, 875cd030a78SIcenowy Zheng &bus_i2c2_clk.common, 876cd030a78SIcenowy Zheng &bus_i2c3_clk.common, 877cd030a78SIcenowy Zheng &bus_can_clk.common, 878cd030a78SIcenowy Zheng &bus_scr_clk.common, 879cd030a78SIcenowy Zheng &bus_ps20_clk.common, 880cd030a78SIcenowy Zheng &bus_ps21_clk.common, 881cd030a78SIcenowy Zheng &bus_i2c4_clk.common, 882cd030a78SIcenowy Zheng &bus_uart0_clk.common, 883cd030a78SIcenowy Zheng &bus_uart1_clk.common, 884cd030a78SIcenowy Zheng &bus_uart2_clk.common, 885cd030a78SIcenowy Zheng &bus_uart3_clk.common, 886cd030a78SIcenowy Zheng &bus_uart4_clk.common, 887cd030a78SIcenowy Zheng &bus_uart5_clk.common, 888cd030a78SIcenowy Zheng &bus_uart6_clk.common, 889cd030a78SIcenowy Zheng &bus_uart7_clk.common, 890cd030a78SIcenowy Zheng &bus_dbg_clk.common, 891cd030a78SIcenowy Zheng &ths_clk.common, 892cd030a78SIcenowy Zheng &nand_clk.common, 893cd030a78SIcenowy Zheng &mmc0_clk.common, 894cd030a78SIcenowy Zheng &mmc1_clk.common, 895cd030a78SIcenowy Zheng &mmc2_clk.common, 896cd030a78SIcenowy Zheng &mmc3_clk.common, 897cd030a78SIcenowy Zheng &ts_clk.common, 898cd030a78SIcenowy Zheng &ce_clk.common, 899cd030a78SIcenowy Zheng &spi0_clk.common, 900cd030a78SIcenowy Zheng &spi1_clk.common, 901cd030a78SIcenowy Zheng &spi2_clk.common, 902cd030a78SIcenowy Zheng &spi3_clk.common, 903cd030a78SIcenowy Zheng &i2s0_clk.common, 904cd030a78SIcenowy Zheng &i2s1_clk.common, 905cd030a78SIcenowy Zheng &i2s2_clk.common, 906cd030a78SIcenowy Zheng &ac97_clk.common, 907cd030a78SIcenowy Zheng &spdif_clk.common, 908cd030a78SIcenowy Zheng &keypad_clk.common, 909cd030a78SIcenowy Zheng &sata_clk.common, 910cd030a78SIcenowy Zheng &usb_phy0_clk.common, 911cd030a78SIcenowy Zheng &usb_phy1_clk.common, 912cd030a78SIcenowy Zheng &usb_phy2_clk.common, 913cd030a78SIcenowy Zheng &usb_ohci0_clk.common, 914cd030a78SIcenowy Zheng &usb_ohci1_clk.common, 915cd030a78SIcenowy Zheng &usb_ohci2_clk.common, 916cd030a78SIcenowy Zheng &ir0_clk.common, 917cd030a78SIcenowy Zheng &ir1_clk.common, 918cd030a78SIcenowy Zheng &dram_clk.common, 919cd030a78SIcenowy Zheng &dram_ve_clk.common, 920cd030a78SIcenowy Zheng &dram_csi0_clk.common, 921cd030a78SIcenowy Zheng &dram_csi1_clk.common, 922cd030a78SIcenowy Zheng &dram_ts_clk.common, 923cd030a78SIcenowy Zheng &dram_tvd_clk.common, 924cd030a78SIcenowy Zheng &dram_mp_clk.common, 925cd030a78SIcenowy Zheng &dram_deinterlace_clk.common, 926cd030a78SIcenowy Zheng &de_clk.common, 927cd030a78SIcenowy Zheng &mp_clk.common, 928cd030a78SIcenowy Zheng &tcon_lcd0_clk.common, 929cd030a78SIcenowy Zheng &tcon_lcd1_clk.common, 930cd030a78SIcenowy Zheng &tcon_tv0_clk.common, 931cd030a78SIcenowy Zheng &tcon_tv1_clk.common, 932cd030a78SIcenowy Zheng &deinterlace_clk.common, 933cd030a78SIcenowy Zheng &csi1_mclk_clk.common, 934cd030a78SIcenowy Zheng &csi_sclk_clk.common, 935cd030a78SIcenowy Zheng &csi0_mclk_clk.common, 936cd030a78SIcenowy Zheng &ve_clk.common, 937cd030a78SIcenowy Zheng &codec_clk.common, 938cd030a78SIcenowy Zheng &avs_clk.common, 939cd030a78SIcenowy Zheng &hdmi_clk.common, 940cd030a78SIcenowy Zheng &hdmi_slow_clk.common, 941cd030a78SIcenowy Zheng &mbus_clk.common, 942cd030a78SIcenowy Zheng &dsi_dphy_clk.common, 943cd030a78SIcenowy Zheng &tve0_clk.common, 944cd030a78SIcenowy Zheng &tve1_clk.common, 945cd030a78SIcenowy Zheng &tvd0_clk.common, 946cd030a78SIcenowy Zheng &tvd1_clk.common, 947cd030a78SIcenowy Zheng &tvd2_clk.common, 948cd030a78SIcenowy Zheng &tvd3_clk.common, 949cd030a78SIcenowy Zheng &gpu_clk.common, 950cd030a78SIcenowy Zheng &outa_clk.common, 951cd030a78SIcenowy Zheng &outb_clk.common, 952cd030a78SIcenowy Zheng }; 953cd030a78SIcenowy Zheng 954cd030a78SIcenowy Zheng /* Fixed Factor clocks */ 955cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(osc12M_clk, "osc12M", "osc24M", 2, 1, 0); 956cd030a78SIcenowy Zheng 957cd030a78SIcenowy Zheng /* We hardcode the divider to 4 for now */ 958cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_clk, "pll-audio", 959cd030a78SIcenowy Zheng "pll-audio-base", 4, 1, CLK_SET_RATE_PARENT); 960cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_2x_clk, "pll-audio-2x", 961cd030a78SIcenowy Zheng "pll-audio-base", 2, 1, CLK_SET_RATE_PARENT); 962cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_4x_clk, "pll-audio-4x", 963cd030a78SIcenowy Zheng "pll-audio-base", 1, 1, CLK_SET_RATE_PARENT); 964cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_audio_8x_clk, "pll-audio-8x", 965cd030a78SIcenowy Zheng "pll-audio-base", 1, 2, CLK_SET_RATE_PARENT); 966cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph0_2x_clk, "pll-periph0-2x", 967cd030a78SIcenowy Zheng "pll-periph0", 1, 2, 0); 968cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_periph1_2x_clk, "pll-periph1-2x", 969cd030a78SIcenowy Zheng "pll-periph1", 1, 2, 0); 970cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_video0_2x_clk, "pll-video0-2x", 971cd030a78SIcenowy Zheng "pll-video0", 1, 2, 0); 972cd030a78SIcenowy Zheng static CLK_FIXED_FACTOR(pll_video1_2x_clk, "pll-video1-2x", 973cd030a78SIcenowy Zheng "pll-video1", 1, 2, 0); 974cd030a78SIcenowy Zheng 975cd030a78SIcenowy Zheng static struct clk_hw_onecell_data sun8i_r40_hw_clks = { 976cd030a78SIcenowy Zheng .hws = { 977cd030a78SIcenowy Zheng [CLK_OSC_12M] = &osc12M_clk.hw, 978cd030a78SIcenowy Zheng [CLK_PLL_CPU] = &pll_cpu_clk.common.hw, 979cd030a78SIcenowy Zheng [CLK_PLL_AUDIO_BASE] = &pll_audio_base_clk.common.hw, 980cd030a78SIcenowy Zheng [CLK_PLL_AUDIO] = &pll_audio_clk.hw, 981cd030a78SIcenowy Zheng [CLK_PLL_AUDIO_2X] = &pll_audio_2x_clk.hw, 982cd030a78SIcenowy Zheng [CLK_PLL_AUDIO_4X] = &pll_audio_4x_clk.hw, 983cd030a78SIcenowy Zheng [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, 984cd030a78SIcenowy Zheng [CLK_PLL_VIDEO0] = &pll_video0_clk.common.hw, 985cd030a78SIcenowy Zheng [CLK_PLL_VIDEO0_2X] = &pll_video0_2x_clk.hw, 986cd030a78SIcenowy Zheng [CLK_PLL_VE] = &pll_ve_clk.common.hw, 987cd030a78SIcenowy Zheng [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, 988cd030a78SIcenowy Zheng [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, 989cd030a78SIcenowy Zheng [CLK_PLL_PERIPH0_SATA] = &pll_periph0_sata_clk.common.hw, 990cd030a78SIcenowy Zheng [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, 991cd030a78SIcenowy Zheng [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, 992cd030a78SIcenowy Zheng [CLK_PLL_PERIPH1_2X] = &pll_periph1_2x_clk.hw, 993cd030a78SIcenowy Zheng [CLK_PLL_VIDEO1] = &pll_video1_clk.common.hw, 994cd030a78SIcenowy Zheng [CLK_PLL_VIDEO1_2X] = &pll_video1_2x_clk.hw, 995cd030a78SIcenowy Zheng [CLK_PLL_SATA] = &pll_sata_clk.common.hw, 996cd030a78SIcenowy Zheng [CLK_PLL_SATA_OUT] = &pll_sata_out_clk.common.hw, 997cd030a78SIcenowy Zheng [CLK_PLL_GPU] = &pll_gpu_clk.common.hw, 998cd030a78SIcenowy Zheng [CLK_PLL_MIPI] = &pll_mipi_clk.common.hw, 999cd030a78SIcenowy Zheng [CLK_PLL_DE] = &pll_de_clk.common.hw, 1000cd030a78SIcenowy Zheng [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, 1001cd030a78SIcenowy Zheng [CLK_CPU] = &cpu_clk.common.hw, 1002cd030a78SIcenowy Zheng [CLK_AXI] = &axi_clk.common.hw, 1003cd030a78SIcenowy Zheng [CLK_AHB1] = &ahb1_clk.common.hw, 1004cd030a78SIcenowy Zheng [CLK_APB1] = &apb1_clk.common.hw, 1005cd030a78SIcenowy Zheng [CLK_APB2] = &apb2_clk.common.hw, 1006cd030a78SIcenowy Zheng [CLK_BUS_MIPI_DSI] = &bus_mipi_dsi_clk.common.hw, 1007cd030a78SIcenowy Zheng [CLK_BUS_CE] = &bus_ce_clk.common.hw, 1008cd030a78SIcenowy Zheng [CLK_BUS_DMA] = &bus_dma_clk.common.hw, 1009cd030a78SIcenowy Zheng [CLK_BUS_MMC0] = &bus_mmc0_clk.common.hw, 1010cd030a78SIcenowy Zheng [CLK_BUS_MMC1] = &bus_mmc1_clk.common.hw, 1011cd030a78SIcenowy Zheng [CLK_BUS_MMC2] = &bus_mmc2_clk.common.hw, 1012cd030a78SIcenowy Zheng [CLK_BUS_MMC3] = &bus_mmc3_clk.common.hw, 1013cd030a78SIcenowy Zheng [CLK_BUS_NAND] = &bus_nand_clk.common.hw, 1014cd030a78SIcenowy Zheng [CLK_BUS_DRAM] = &bus_dram_clk.common.hw, 1015cd030a78SIcenowy Zheng [CLK_BUS_EMAC] = &bus_emac_clk.common.hw, 1016cd030a78SIcenowy Zheng [CLK_BUS_TS] = &bus_ts_clk.common.hw, 1017cd030a78SIcenowy Zheng [CLK_BUS_HSTIMER] = &bus_hstimer_clk.common.hw, 1018cd030a78SIcenowy Zheng [CLK_BUS_SPI0] = &bus_spi0_clk.common.hw, 1019cd030a78SIcenowy Zheng [CLK_BUS_SPI1] = &bus_spi1_clk.common.hw, 1020cd030a78SIcenowy Zheng [CLK_BUS_SPI2] = &bus_spi2_clk.common.hw, 1021cd030a78SIcenowy Zheng [CLK_BUS_SPI3] = &bus_spi3_clk.common.hw, 1022cd030a78SIcenowy Zheng [CLK_BUS_SATA] = &bus_sata_clk.common.hw, 1023cd030a78SIcenowy Zheng [CLK_BUS_OTG] = &bus_otg_clk.common.hw, 1024cd030a78SIcenowy Zheng [CLK_BUS_EHCI0] = &bus_ehci0_clk.common.hw, 1025cd030a78SIcenowy Zheng [CLK_BUS_EHCI1] = &bus_ehci1_clk.common.hw, 1026cd030a78SIcenowy Zheng [CLK_BUS_EHCI2] = &bus_ehci2_clk.common.hw, 1027cd030a78SIcenowy Zheng [CLK_BUS_OHCI0] = &bus_ohci0_clk.common.hw, 1028cd030a78SIcenowy Zheng [CLK_BUS_OHCI1] = &bus_ohci1_clk.common.hw, 1029cd030a78SIcenowy Zheng [CLK_BUS_OHCI2] = &bus_ohci2_clk.common.hw, 1030cd030a78SIcenowy Zheng [CLK_BUS_VE] = &bus_ve_clk.common.hw, 1031cd030a78SIcenowy Zheng [CLK_BUS_MP] = &bus_mp_clk.common.hw, 1032cd030a78SIcenowy Zheng [CLK_BUS_DEINTERLACE] = &bus_deinterlace_clk.common.hw, 1033cd030a78SIcenowy Zheng [CLK_BUS_CSI0] = &bus_csi0_clk.common.hw, 1034cd030a78SIcenowy Zheng [CLK_BUS_CSI1] = &bus_csi1_clk.common.hw, 1035cd030a78SIcenowy Zheng [CLK_BUS_HDMI0] = &bus_hdmi0_clk.common.hw, 1036cd030a78SIcenowy Zheng [CLK_BUS_HDMI1] = &bus_hdmi1_clk.common.hw, 1037cd030a78SIcenowy Zheng [CLK_BUS_DE] = &bus_de_clk.common.hw, 1038cd030a78SIcenowy Zheng [CLK_BUS_TVE0] = &bus_tve0_clk.common.hw, 1039cd030a78SIcenowy Zheng [CLK_BUS_TVE1] = &bus_tve1_clk.common.hw, 1040cd030a78SIcenowy Zheng [CLK_BUS_TVE_TOP] = &bus_tve_top_clk.common.hw, 1041cd030a78SIcenowy Zheng [CLK_BUS_GMAC] = &bus_gmac_clk.common.hw, 1042cd030a78SIcenowy Zheng [CLK_BUS_GPU] = &bus_gpu_clk.common.hw, 1043cd030a78SIcenowy Zheng [CLK_BUS_TVD0] = &bus_tvd0_clk.common.hw, 1044cd030a78SIcenowy Zheng [CLK_BUS_TVD1] = &bus_tvd1_clk.common.hw, 1045cd030a78SIcenowy Zheng [CLK_BUS_TVD2] = &bus_tvd2_clk.common.hw, 1046cd030a78SIcenowy Zheng [CLK_BUS_TVD3] = &bus_tvd3_clk.common.hw, 1047cd030a78SIcenowy Zheng [CLK_BUS_TVD_TOP] = &bus_tvd_top_clk.common.hw, 1048cd030a78SIcenowy Zheng [CLK_BUS_TCON_LCD0] = &bus_tcon_lcd0_clk.common.hw, 1049cd030a78SIcenowy Zheng [CLK_BUS_TCON_LCD1] = &bus_tcon_lcd1_clk.common.hw, 1050cd030a78SIcenowy Zheng [CLK_BUS_TCON_TV0] = &bus_tcon_tv0_clk.common.hw, 1051cd030a78SIcenowy Zheng [CLK_BUS_TCON_TV1] = &bus_tcon_tv1_clk.common.hw, 1052cd030a78SIcenowy Zheng [CLK_BUS_TCON_TOP] = &bus_tcon_top_clk.common.hw, 1053cd030a78SIcenowy Zheng [CLK_BUS_CODEC] = &bus_codec_clk.common.hw, 1054cd030a78SIcenowy Zheng [CLK_BUS_SPDIF] = &bus_spdif_clk.common.hw, 1055cd030a78SIcenowy Zheng [CLK_BUS_AC97] = &bus_ac97_clk.common.hw, 1056cd030a78SIcenowy Zheng [CLK_BUS_PIO] = &bus_pio_clk.common.hw, 1057cd030a78SIcenowy Zheng [CLK_BUS_IR0] = &bus_ir0_clk.common.hw, 1058cd030a78SIcenowy Zheng [CLK_BUS_IR1] = &bus_ir1_clk.common.hw, 1059cd030a78SIcenowy Zheng [CLK_BUS_THS] = &bus_ths_clk.common.hw, 1060cd030a78SIcenowy Zheng [CLK_BUS_KEYPAD] = &bus_keypad_clk.common.hw, 1061cd030a78SIcenowy Zheng [CLK_BUS_I2S0] = &bus_i2s0_clk.common.hw, 1062cd030a78SIcenowy Zheng [CLK_BUS_I2S1] = &bus_i2s1_clk.common.hw, 1063cd030a78SIcenowy Zheng [CLK_BUS_I2S2] = &bus_i2s2_clk.common.hw, 1064cd030a78SIcenowy Zheng [CLK_BUS_I2C0] = &bus_i2c0_clk.common.hw, 1065cd030a78SIcenowy Zheng [CLK_BUS_I2C1] = &bus_i2c1_clk.common.hw, 1066cd030a78SIcenowy Zheng [CLK_BUS_I2C2] = &bus_i2c2_clk.common.hw, 1067cd030a78SIcenowy Zheng [CLK_BUS_I2C3] = &bus_i2c3_clk.common.hw, 1068cd030a78SIcenowy Zheng [CLK_BUS_CAN] = &bus_can_clk.common.hw, 1069cd030a78SIcenowy Zheng [CLK_BUS_SCR] = &bus_scr_clk.common.hw, 1070cd030a78SIcenowy Zheng [CLK_BUS_PS20] = &bus_ps20_clk.common.hw, 1071cd030a78SIcenowy Zheng [CLK_BUS_PS21] = &bus_ps21_clk.common.hw, 1072cd030a78SIcenowy Zheng [CLK_BUS_I2C4] = &bus_i2c4_clk.common.hw, 1073cd030a78SIcenowy Zheng [CLK_BUS_UART0] = &bus_uart0_clk.common.hw, 1074cd030a78SIcenowy Zheng [CLK_BUS_UART1] = &bus_uart1_clk.common.hw, 1075cd030a78SIcenowy Zheng [CLK_BUS_UART2] = &bus_uart2_clk.common.hw, 1076cd030a78SIcenowy Zheng [CLK_BUS_UART3] = &bus_uart3_clk.common.hw, 1077cd030a78SIcenowy Zheng [CLK_BUS_UART4] = &bus_uart4_clk.common.hw, 1078cd030a78SIcenowy Zheng [CLK_BUS_UART5] = &bus_uart5_clk.common.hw, 1079cd030a78SIcenowy Zheng [CLK_BUS_UART6] = &bus_uart6_clk.common.hw, 1080cd030a78SIcenowy Zheng [CLK_BUS_UART7] = &bus_uart7_clk.common.hw, 1081cd030a78SIcenowy Zheng [CLK_BUS_DBG] = &bus_dbg_clk.common.hw, 1082cd030a78SIcenowy Zheng [CLK_THS] = &ths_clk.common.hw, 1083cd030a78SIcenowy Zheng [CLK_NAND] = &nand_clk.common.hw, 1084cd030a78SIcenowy Zheng [CLK_MMC0] = &mmc0_clk.common.hw, 1085cd030a78SIcenowy Zheng [CLK_MMC1] = &mmc1_clk.common.hw, 1086cd030a78SIcenowy Zheng [CLK_MMC2] = &mmc2_clk.common.hw, 1087cd030a78SIcenowy Zheng [CLK_MMC3] = &mmc3_clk.common.hw, 1088cd030a78SIcenowy Zheng [CLK_TS] = &ts_clk.common.hw, 1089cd030a78SIcenowy Zheng [CLK_CE] = &ce_clk.common.hw, 1090cd030a78SIcenowy Zheng [CLK_SPI0] = &spi0_clk.common.hw, 1091cd030a78SIcenowy Zheng [CLK_SPI1] = &spi1_clk.common.hw, 1092cd030a78SIcenowy Zheng [CLK_SPI2] = &spi2_clk.common.hw, 1093cd030a78SIcenowy Zheng [CLK_SPI3] = &spi3_clk.common.hw, 1094cd030a78SIcenowy Zheng [CLK_I2S0] = &i2s0_clk.common.hw, 1095cd030a78SIcenowy Zheng [CLK_I2S1] = &i2s1_clk.common.hw, 1096cd030a78SIcenowy Zheng [CLK_I2S2] = &i2s2_clk.common.hw, 1097cd030a78SIcenowy Zheng [CLK_AC97] = &ac97_clk.common.hw, 1098cd030a78SIcenowy Zheng [CLK_SPDIF] = &spdif_clk.common.hw, 1099cd030a78SIcenowy Zheng [CLK_KEYPAD] = &keypad_clk.common.hw, 1100cd030a78SIcenowy Zheng [CLK_SATA] = &sata_clk.common.hw, 1101cd030a78SIcenowy Zheng [CLK_USB_PHY0] = &usb_phy0_clk.common.hw, 1102cd030a78SIcenowy Zheng [CLK_USB_PHY1] = &usb_phy1_clk.common.hw, 1103cd030a78SIcenowy Zheng [CLK_USB_PHY2] = &usb_phy2_clk.common.hw, 1104cd030a78SIcenowy Zheng [CLK_USB_OHCI0] = &usb_ohci0_clk.common.hw, 1105cd030a78SIcenowy Zheng [CLK_USB_OHCI1] = &usb_ohci1_clk.common.hw, 1106cd030a78SIcenowy Zheng [CLK_USB_OHCI2] = &usb_ohci2_clk.common.hw, 1107cd030a78SIcenowy Zheng [CLK_IR0] = &ir0_clk.common.hw, 1108cd030a78SIcenowy Zheng [CLK_IR1] = &ir1_clk.common.hw, 1109cd030a78SIcenowy Zheng [CLK_DRAM] = &dram_clk.common.hw, 1110cd030a78SIcenowy Zheng [CLK_DRAM_VE] = &dram_ve_clk.common.hw, 1111cd030a78SIcenowy Zheng [CLK_DRAM_CSI0] = &dram_csi0_clk.common.hw, 1112cd030a78SIcenowy Zheng [CLK_DRAM_CSI1] = &dram_csi1_clk.common.hw, 1113cd030a78SIcenowy Zheng [CLK_DRAM_TS] = &dram_ts_clk.common.hw, 1114cd030a78SIcenowy Zheng [CLK_DRAM_TVD] = &dram_tvd_clk.common.hw, 1115cd030a78SIcenowy Zheng [CLK_DRAM_MP] = &dram_mp_clk.common.hw, 1116cd030a78SIcenowy Zheng [CLK_DRAM_DEINTERLACE] = &dram_deinterlace_clk.common.hw, 1117cd030a78SIcenowy Zheng [CLK_DE] = &de_clk.common.hw, 1118cd030a78SIcenowy Zheng [CLK_MP] = &mp_clk.common.hw, 1119cd030a78SIcenowy Zheng [CLK_TCON_LCD0] = &tcon_lcd0_clk.common.hw, 1120cd030a78SIcenowy Zheng [CLK_TCON_LCD1] = &tcon_lcd1_clk.common.hw, 1121cd030a78SIcenowy Zheng [CLK_TCON_TV0] = &tcon_tv0_clk.common.hw, 1122cd030a78SIcenowy Zheng [CLK_TCON_TV1] = &tcon_tv1_clk.common.hw, 1123cd030a78SIcenowy Zheng [CLK_DEINTERLACE] = &deinterlace_clk.common.hw, 1124cd030a78SIcenowy Zheng [CLK_CSI1_MCLK] = &csi1_mclk_clk.common.hw, 1125cd030a78SIcenowy Zheng [CLK_CSI_SCLK] = &csi_sclk_clk.common.hw, 1126cd030a78SIcenowy Zheng [CLK_CSI0_MCLK] = &csi0_mclk_clk.common.hw, 1127cd030a78SIcenowy Zheng [CLK_VE] = &ve_clk.common.hw, 1128cd030a78SIcenowy Zheng [CLK_CODEC] = &codec_clk.common.hw, 1129cd030a78SIcenowy Zheng [CLK_AVS] = &avs_clk.common.hw, 1130cd030a78SIcenowy Zheng [CLK_HDMI] = &hdmi_clk.common.hw, 1131cd030a78SIcenowy Zheng [CLK_HDMI_SLOW] = &hdmi_slow_clk.common.hw, 1132cd030a78SIcenowy Zheng [CLK_MBUS] = &mbus_clk.common.hw, 1133cd030a78SIcenowy Zheng [CLK_DSI_DPHY] = &dsi_dphy_clk.common.hw, 1134cd030a78SIcenowy Zheng [CLK_TVE0] = &tve0_clk.common.hw, 1135cd030a78SIcenowy Zheng [CLK_TVE1] = &tve1_clk.common.hw, 1136cd030a78SIcenowy Zheng [CLK_TVD0] = &tvd0_clk.common.hw, 1137cd030a78SIcenowy Zheng [CLK_TVD1] = &tvd1_clk.common.hw, 1138cd030a78SIcenowy Zheng [CLK_TVD2] = &tvd2_clk.common.hw, 1139cd030a78SIcenowy Zheng [CLK_TVD3] = &tvd3_clk.common.hw, 1140cd030a78SIcenowy Zheng [CLK_GPU] = &gpu_clk.common.hw, 1141cd030a78SIcenowy Zheng [CLK_OUTA] = &outa_clk.common.hw, 1142cd030a78SIcenowy Zheng [CLK_OUTB] = &outb_clk.common.hw, 1143cd030a78SIcenowy Zheng }, 1144cd030a78SIcenowy Zheng .num = CLK_NUMBER, 1145cd030a78SIcenowy Zheng }; 1146cd030a78SIcenowy Zheng 1147cd030a78SIcenowy Zheng static struct ccu_reset_map sun8i_r40_ccu_resets[] = { 1148cd030a78SIcenowy Zheng [RST_USB_PHY0] = { 0x0cc, BIT(0) }, 1149cd030a78SIcenowy Zheng [RST_USB_PHY1] = { 0x0cc, BIT(1) }, 1150cd030a78SIcenowy Zheng [RST_USB_PHY2] = { 0x0cc, BIT(2) }, 1151cd030a78SIcenowy Zheng 1152cd030a78SIcenowy Zheng [RST_DRAM] = { 0x0f4, BIT(31) }, 1153cd030a78SIcenowy Zheng [RST_MBUS] = { 0x0fc, BIT(31) }, 1154cd030a78SIcenowy Zheng 1155cd030a78SIcenowy Zheng [RST_BUS_MIPI_DSI] = { 0x2c0, BIT(1) }, 1156cd030a78SIcenowy Zheng [RST_BUS_CE] = { 0x2c0, BIT(5) }, 1157cd030a78SIcenowy Zheng [RST_BUS_DMA] = { 0x2c0, BIT(6) }, 1158cd030a78SIcenowy Zheng [RST_BUS_MMC0] = { 0x2c0, BIT(8) }, 1159cd030a78SIcenowy Zheng [RST_BUS_MMC1] = { 0x2c0, BIT(9) }, 1160cd030a78SIcenowy Zheng [RST_BUS_MMC2] = { 0x2c0, BIT(10) }, 1161cd030a78SIcenowy Zheng [RST_BUS_MMC3] = { 0x2c0, BIT(11) }, 1162cd030a78SIcenowy Zheng [RST_BUS_NAND] = { 0x2c0, BIT(13) }, 1163cd030a78SIcenowy Zheng [RST_BUS_DRAM] = { 0x2c0, BIT(14) }, 1164cd030a78SIcenowy Zheng [RST_BUS_EMAC] = { 0x2c0, BIT(17) }, 1165cd030a78SIcenowy Zheng [RST_BUS_TS] = { 0x2c0, BIT(18) }, 1166cd030a78SIcenowy Zheng [RST_BUS_HSTIMER] = { 0x2c0, BIT(19) }, 1167cd030a78SIcenowy Zheng [RST_BUS_SPI0] = { 0x2c0, BIT(20) }, 1168cd030a78SIcenowy Zheng [RST_BUS_SPI1] = { 0x2c0, BIT(21) }, 1169cd030a78SIcenowy Zheng [RST_BUS_SPI2] = { 0x2c0, BIT(22) }, 1170cd030a78SIcenowy Zheng [RST_BUS_SPI3] = { 0x2c0, BIT(23) }, 1171cd030a78SIcenowy Zheng [RST_BUS_SATA] = { 0x2c0, BIT(24) }, 1172cd030a78SIcenowy Zheng [RST_BUS_OTG] = { 0x2c0, BIT(25) }, 1173cd030a78SIcenowy Zheng [RST_BUS_EHCI0] = { 0x2c0, BIT(26) }, 1174cd030a78SIcenowy Zheng [RST_BUS_EHCI1] = { 0x2c0, BIT(27) }, 1175cd030a78SIcenowy Zheng [RST_BUS_EHCI2] = { 0x2c0, BIT(28) }, 1176cd030a78SIcenowy Zheng [RST_BUS_OHCI0] = { 0x2c0, BIT(29) }, 1177cd030a78SIcenowy Zheng [RST_BUS_OHCI1] = { 0x2c0, BIT(30) }, 1178cd030a78SIcenowy Zheng [RST_BUS_OHCI2] = { 0x2c0, BIT(31) }, 1179cd030a78SIcenowy Zheng 1180cd030a78SIcenowy Zheng [RST_BUS_VE] = { 0x2c4, BIT(0) }, 1181cd030a78SIcenowy Zheng [RST_BUS_MP] = { 0x2c4, BIT(2) }, 1182cd030a78SIcenowy Zheng [RST_BUS_DEINTERLACE] = { 0x2c4, BIT(5) }, 1183cd030a78SIcenowy Zheng [RST_BUS_CSI0] = { 0x2c4, BIT(8) }, 1184cd030a78SIcenowy Zheng [RST_BUS_CSI1] = { 0x2c4, BIT(9) }, 1185cd030a78SIcenowy Zheng [RST_BUS_HDMI0] = { 0x2c4, BIT(10) }, 1186cd030a78SIcenowy Zheng [RST_BUS_HDMI1] = { 0x2c4, BIT(11) }, 1187cd030a78SIcenowy Zheng [RST_BUS_DE] = { 0x2c4, BIT(12) }, 1188cd030a78SIcenowy Zheng [RST_BUS_TVE0] = { 0x2c4, BIT(13) }, 1189cd030a78SIcenowy Zheng [RST_BUS_TVE1] = { 0x2c4, BIT(14) }, 1190cd030a78SIcenowy Zheng [RST_BUS_TVE_TOP] = { 0x2c4, BIT(15) }, 1191cd030a78SIcenowy Zheng [RST_BUS_GMAC] = { 0x2c4, BIT(17) }, 1192cd030a78SIcenowy Zheng [RST_BUS_GPU] = { 0x2c4, BIT(20) }, 1193cd030a78SIcenowy Zheng [RST_BUS_TVD0] = { 0x2c4, BIT(21) }, 1194cd030a78SIcenowy Zheng [RST_BUS_TVD1] = { 0x2c4, BIT(22) }, 1195cd030a78SIcenowy Zheng [RST_BUS_TVD2] = { 0x2c4, BIT(23) }, 1196cd030a78SIcenowy Zheng [RST_BUS_TVD3] = { 0x2c4, BIT(24) }, 1197cd030a78SIcenowy Zheng [RST_BUS_TVD_TOP] = { 0x2c4, BIT(25) }, 1198cd030a78SIcenowy Zheng [RST_BUS_TCON_LCD0] = { 0x2c4, BIT(26) }, 1199cd030a78SIcenowy Zheng [RST_BUS_TCON_LCD1] = { 0x2c4, BIT(27) }, 1200cd030a78SIcenowy Zheng [RST_BUS_TCON_TV0] = { 0x2c4, BIT(28) }, 1201cd030a78SIcenowy Zheng [RST_BUS_TCON_TV1] = { 0x2c4, BIT(29) }, 1202cd030a78SIcenowy Zheng [RST_BUS_TCON_TOP] = { 0x2c4, BIT(30) }, 1203cd030a78SIcenowy Zheng [RST_BUS_DBG] = { 0x2c4, BIT(31) }, 1204cd030a78SIcenowy Zheng 1205cd030a78SIcenowy Zheng [RST_BUS_LVDS] = { 0x2c8, BIT(0) }, 1206cd030a78SIcenowy Zheng 1207cd030a78SIcenowy Zheng [RST_BUS_CODEC] = { 0x2d0, BIT(0) }, 1208cd030a78SIcenowy Zheng [RST_BUS_SPDIF] = { 0x2d0, BIT(1) }, 1209cd030a78SIcenowy Zheng [RST_BUS_AC97] = { 0x2d0, BIT(2) }, 1210cd030a78SIcenowy Zheng [RST_BUS_IR0] = { 0x2d0, BIT(6) }, 1211cd030a78SIcenowy Zheng [RST_BUS_IR1] = { 0x2d0, BIT(7) }, 1212cd030a78SIcenowy Zheng [RST_BUS_THS] = { 0x2d0, BIT(8) }, 1213cd030a78SIcenowy Zheng [RST_BUS_KEYPAD] = { 0x2d0, BIT(10) }, 1214cd030a78SIcenowy Zheng [RST_BUS_I2S0] = { 0x2d0, BIT(12) }, 1215cd030a78SIcenowy Zheng [RST_BUS_I2S1] = { 0x2d0, BIT(13) }, 1216cd030a78SIcenowy Zheng [RST_BUS_I2S2] = { 0x2d0, BIT(14) }, 1217cd030a78SIcenowy Zheng 1218cd030a78SIcenowy Zheng [RST_BUS_I2C0] = { 0x2d8, BIT(0) }, 1219cd030a78SIcenowy Zheng [RST_BUS_I2C1] = { 0x2d8, BIT(1) }, 1220cd030a78SIcenowy Zheng [RST_BUS_I2C2] = { 0x2d8, BIT(2) }, 1221cd030a78SIcenowy Zheng [RST_BUS_I2C3] = { 0x2d8, BIT(3) }, 1222cd030a78SIcenowy Zheng [RST_BUS_CAN] = { 0x2d8, BIT(4) }, 1223cd030a78SIcenowy Zheng [RST_BUS_SCR] = { 0x2d8, BIT(5) }, 1224cd030a78SIcenowy Zheng [RST_BUS_PS20] = { 0x2d8, BIT(6) }, 1225cd030a78SIcenowy Zheng [RST_BUS_PS21] = { 0x2d8, BIT(7) }, 1226cd030a78SIcenowy Zheng [RST_BUS_I2C4] = { 0x2d8, BIT(15) }, 1227cd030a78SIcenowy Zheng [RST_BUS_UART0] = { 0x2d8, BIT(16) }, 1228cd030a78SIcenowy Zheng [RST_BUS_UART1] = { 0x2d8, BIT(17) }, 1229cd030a78SIcenowy Zheng [RST_BUS_UART2] = { 0x2d8, BIT(18) }, 1230cd030a78SIcenowy Zheng [RST_BUS_UART3] = { 0x2d8, BIT(19) }, 1231cd030a78SIcenowy Zheng [RST_BUS_UART4] = { 0x2d8, BIT(20) }, 1232cd030a78SIcenowy Zheng [RST_BUS_UART5] = { 0x2d8, BIT(21) }, 1233cd030a78SIcenowy Zheng [RST_BUS_UART6] = { 0x2d8, BIT(22) }, 1234cd030a78SIcenowy Zheng [RST_BUS_UART7] = { 0x2d8, BIT(23) }, 1235cd030a78SIcenowy Zheng }; 1236cd030a78SIcenowy Zheng 1237cd030a78SIcenowy Zheng static const struct sunxi_ccu_desc sun8i_r40_ccu_desc = { 1238cd030a78SIcenowy Zheng .ccu_clks = sun8i_r40_ccu_clks, 1239cd030a78SIcenowy Zheng .num_ccu_clks = ARRAY_SIZE(sun8i_r40_ccu_clks), 1240cd030a78SIcenowy Zheng 1241cd030a78SIcenowy Zheng .hw_clks = &sun8i_r40_hw_clks, 1242cd030a78SIcenowy Zheng 1243cd030a78SIcenowy Zheng .resets = sun8i_r40_ccu_resets, 1244cd030a78SIcenowy Zheng .num_resets = ARRAY_SIZE(sun8i_r40_ccu_resets), 1245cd030a78SIcenowy Zheng }; 1246cd030a78SIcenowy Zheng 1247cd030a78SIcenowy Zheng static struct ccu_pll_nb sun8i_r40_pll_cpu_nb = { 1248cd030a78SIcenowy Zheng .common = &pll_cpu_clk.common, 1249cd030a78SIcenowy Zheng /* copy from pll_cpu_clk */ 1250cd030a78SIcenowy Zheng .enable = BIT(31), 1251cd030a78SIcenowy Zheng .lock = BIT(28), 1252cd030a78SIcenowy Zheng }; 1253cd030a78SIcenowy Zheng 1254cd030a78SIcenowy Zheng static struct ccu_mux_nb sun8i_r40_cpu_nb = { 1255cd030a78SIcenowy Zheng .common = &cpu_clk.common, 1256cd030a78SIcenowy Zheng .cm = &cpu_clk.mux, 1257cd030a78SIcenowy Zheng .delay_us = 1, /* > 8 clock cycles at 24 MHz */ 1258cd030a78SIcenowy Zheng .bypass_index = 1, /* index of 24 MHz oscillator */ 1259cd030a78SIcenowy Zheng }; 1260cd030a78SIcenowy Zheng 126117de4c85SIcenowy Zheng /* 126217de4c85SIcenowy Zheng * Add a regmap for the GMAC driver (dwmac-sun8i) to access the 126317de4c85SIcenowy Zheng * GMAC configuration register. 126417de4c85SIcenowy Zheng * Only this register is allowed to be written, in order to 126517de4c85SIcenowy Zheng * prevent overriding critical clock configuration. 126617de4c85SIcenowy Zheng */ 126717de4c85SIcenowy Zheng 126817de4c85SIcenowy Zheng #define SUN8I_R40_GMAC_CFG_REG 0x164 126917de4c85SIcenowy Zheng static bool sun8i_r40_ccu_regmap_accessible_reg(struct device *dev, 127017de4c85SIcenowy Zheng unsigned int reg) 127117de4c85SIcenowy Zheng { 127217de4c85SIcenowy Zheng if (reg == SUN8I_R40_GMAC_CFG_REG) 127317de4c85SIcenowy Zheng return true; 127417de4c85SIcenowy Zheng return false; 127517de4c85SIcenowy Zheng } 127617de4c85SIcenowy Zheng 127717de4c85SIcenowy Zheng static struct regmap_config sun8i_r40_ccu_regmap_config = { 127817de4c85SIcenowy Zheng .reg_bits = 32, 127917de4c85SIcenowy Zheng .val_bits = 32, 128017de4c85SIcenowy Zheng .reg_stride = 4, 128117de4c85SIcenowy Zheng .max_register = 0x320, /* PLL_LOCK_CTRL_REG */ 128217de4c85SIcenowy Zheng 128317de4c85SIcenowy Zheng /* other devices have no business accessing other registers */ 128417de4c85SIcenowy Zheng .readable_reg = sun8i_r40_ccu_regmap_accessible_reg, 128517de4c85SIcenowy Zheng .writeable_reg = sun8i_r40_ccu_regmap_accessible_reg, 128617de4c85SIcenowy Zheng }; 128717de4c85SIcenowy Zheng 128801a7ea76SChen-Yu Tsai #define SUN8I_R40_SYS_32K_CLK_REG 0x310 128901a7ea76SChen-Yu Tsai #define SUN8I_R40_SYS_32K_CLK_KEY (0x16AA << 16) 129001a7ea76SChen-Yu Tsai 1291c3bf29f6SIcenowy Zheng static int sun8i_r40_ccu_probe(struct platform_device *pdev) 1292cd030a78SIcenowy Zheng { 1293c3bf29f6SIcenowy Zheng struct resource *res; 129417de4c85SIcenowy Zheng struct regmap *regmap; 1295cd030a78SIcenowy Zheng void __iomem *reg; 1296cd030a78SIcenowy Zheng u32 val; 1297c3bf29f6SIcenowy Zheng int ret; 1298cd030a78SIcenowy Zheng 1299c3bf29f6SIcenowy Zheng res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1300c3bf29f6SIcenowy Zheng reg = devm_ioremap_resource(&pdev->dev, res); 1301c3bf29f6SIcenowy Zheng if (IS_ERR(reg)) 1302c3bf29f6SIcenowy Zheng return PTR_ERR(reg); 1303cd030a78SIcenowy Zheng 1304cd030a78SIcenowy Zheng /* Force the PLL-Audio-1x divider to 4 */ 1305cd030a78SIcenowy Zheng val = readl(reg + SUN8I_R40_PLL_AUDIO_REG); 1306cd030a78SIcenowy Zheng val &= ~GENMASK(19, 16); 1307cd030a78SIcenowy Zheng writel(val | (3 << 16), reg + SUN8I_R40_PLL_AUDIO_REG); 1308cd030a78SIcenowy Zheng 1309cd030a78SIcenowy Zheng /* Force PLL-MIPI to MIPI mode */ 1310cd030a78SIcenowy Zheng val = readl(reg + SUN8I_R40_PLL_MIPI_REG); 1311cd030a78SIcenowy Zheng val &= ~BIT(16); 1312cd030a78SIcenowy Zheng writel(val, reg + SUN8I_R40_PLL_MIPI_REG); 1313cd030a78SIcenowy Zheng 1314cd030a78SIcenowy Zheng /* Force OHCI 12M parent to 12M divided from 48M */ 1315cd030a78SIcenowy Zheng val = readl(reg + SUN8I_R40_USB_CLK_REG); 1316cd030a78SIcenowy Zheng val &= ~GENMASK(25, 20); 1317cd030a78SIcenowy Zheng writel(val, reg + SUN8I_R40_USB_CLK_REG); 1318cd030a78SIcenowy Zheng 131901a7ea76SChen-Yu Tsai /* 132001a7ea76SChen-Yu Tsai * Force SYS 32k (otherwise known as LOSC throughout the CCU) 132101a7ea76SChen-Yu Tsai * clock parent to LOSC output from RTC module instead of the 132201a7ea76SChen-Yu Tsai * CCU's internal RC oscillator divided output. 132301a7ea76SChen-Yu Tsai */ 132401a7ea76SChen-Yu Tsai writel(SUN8I_R40_SYS_32K_CLK_KEY | BIT(8), 132501a7ea76SChen-Yu Tsai reg + SUN8I_R40_SYS_32K_CLK_REG); 132601a7ea76SChen-Yu Tsai 132717de4c85SIcenowy Zheng regmap = devm_regmap_init_mmio(&pdev->dev, reg, 132817de4c85SIcenowy Zheng &sun8i_r40_ccu_regmap_config); 132917de4c85SIcenowy Zheng if (IS_ERR(regmap)) 133017de4c85SIcenowy Zheng return PTR_ERR(regmap); 133117de4c85SIcenowy Zheng 1332c3bf29f6SIcenowy Zheng ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_r40_ccu_desc); 1333c3bf29f6SIcenowy Zheng if (ret) 1334c3bf29f6SIcenowy Zheng return ret; 1335cd030a78SIcenowy Zheng 1336cd030a78SIcenowy Zheng /* Gate then ungate PLL CPU after any rate changes */ 1337cd030a78SIcenowy Zheng ccu_pll_notifier_register(&sun8i_r40_pll_cpu_nb); 1338cd030a78SIcenowy Zheng 1339cd030a78SIcenowy Zheng /* Reparent CPU during PLL CPU rate changes */ 1340cd030a78SIcenowy Zheng ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk, 1341cd030a78SIcenowy Zheng &sun8i_r40_cpu_nb); 1342c3bf29f6SIcenowy Zheng 1343c3bf29f6SIcenowy Zheng return 0; 1344cd030a78SIcenowy Zheng } 1345c3bf29f6SIcenowy Zheng 1346c3bf29f6SIcenowy Zheng static const struct of_device_id sun8i_r40_ccu_ids[] = { 1347c3bf29f6SIcenowy Zheng { .compatible = "allwinner,sun8i-r40-ccu" }, 1348c3bf29f6SIcenowy Zheng { } 1349c3bf29f6SIcenowy Zheng }; 1350c3bf29f6SIcenowy Zheng 1351c3bf29f6SIcenowy Zheng static struct platform_driver sun8i_r40_ccu_driver = { 1352c3bf29f6SIcenowy Zheng .probe = sun8i_r40_ccu_probe, 1353c3bf29f6SIcenowy Zheng .driver = { 1354c3bf29f6SIcenowy Zheng .name = "sun8i-r40-ccu", 1355c3bf29f6SIcenowy Zheng .of_match_table = sun8i_r40_ccu_ids, 1356c3bf29f6SIcenowy Zheng }, 1357c3bf29f6SIcenowy Zheng }; 1358c3bf29f6SIcenowy Zheng builtin_platform_driver(sun8i_r40_ccu_driver); 1359