18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
78c2ecf20Sopenharmony_ci#include <linux/io.h>
88c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
98c2ecf20Sopenharmony_ci#include <linux/regmap.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "ccu_common.h"
128c2ecf20Sopenharmony_ci#include "ccu_reset.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "ccu_div.h"
158c2ecf20Sopenharmony_ci#include "ccu_gate.h"
168c2ecf20Sopenharmony_ci#include "ccu_mp.h"
178c2ecf20Sopenharmony_ci#include "ccu_mult.h"
188c2ecf20Sopenharmony_ci#include "ccu_nk.h"
198c2ecf20Sopenharmony_ci#include "ccu_nkm.h"
208c2ecf20Sopenharmony_ci#include "ccu_nkmp.h"
218c2ecf20Sopenharmony_ci#include "ccu_nm.h"
228c2ecf20Sopenharmony_ci#include "ccu_phase.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "ccu-sun8i-r40.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* TODO: The result of N*K is required to be in [10, 88] range. */
278c2ecf20Sopenharmony_cistatic struct ccu_nkmp pll_cpu_clk = {
288c2ecf20Sopenharmony_ci	.enable		= BIT(31),
298c2ecf20Sopenharmony_ci	.lock		= BIT(28),
308c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
318c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
328c2ecf20Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 2),
338c2ecf20Sopenharmony_ci	.p		= _SUNXI_CCU_DIV_MAX(16, 2, 4),
348c2ecf20Sopenharmony_ci	.common		= {
358c2ecf20Sopenharmony_ci		.reg		= 0x000,
368c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpu",
378c2ecf20Sopenharmony_ci					      "osc24M",
388c2ecf20Sopenharmony_ci					      &ccu_nkmp_ops,
398c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
408c2ecf20Sopenharmony_ci	},
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
458c2ecf20Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true
468c2ecf20Sopenharmony_ci * pll audio).
478c2ecf20Sopenharmony_ci *
488c2ecf20Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL,
498c2ecf20Sopenharmony_ci * we have to use specific dividers. This means the variable divider
508c2ecf20Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock
518c2ecf20Sopenharmony_ci * rates we support through this mechanism. So we now hard code the
528c2ecf20Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer
538c2ecf20Sopenharmony_ci * match the clock names.
548c2ecf20Sopenharmony_ci */
558c2ecf20Sopenharmony_ci#define SUN8I_R40_PLL_AUDIO_REG	0x008
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = {
588c2ecf20Sopenharmony_ci	{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
598c2ecf20Sopenharmony_ci	{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
608c2ecf20Sopenharmony_ci};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
638c2ecf20Sopenharmony_ci				       "osc24M", 0x008,
648c2ecf20Sopenharmony_ci				       8, 7,	/* N */
658c2ecf20Sopenharmony_ci				       0, 5,	/* M */
668c2ecf20Sopenharmony_ci				       pll_audio_sdm_table, BIT(24),
678c2ecf20Sopenharmony_ci				       0x284, BIT(31),
688c2ecf20Sopenharmony_ci				       BIT(31),	/* gate */
698c2ecf20Sopenharmony_ci				       BIT(28),	/* lock */
708c2ecf20Sopenharmony_ci				       CLK_SET_RATE_UNGATE);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
738c2ecf20Sopenharmony_ci						"osc24M", 0x0010,
748c2ecf20Sopenharmony_ci						192000000,  /* Minimum rate */
758c2ecf20Sopenharmony_ci						1008000000, /* Maximum rate */
768c2ecf20Sopenharmony_ci						8, 7,       /* N */
778c2ecf20Sopenharmony_ci						0, 4,       /* M */
788c2ecf20Sopenharmony_ci						BIT(24),    /* frac enable */
798c2ecf20Sopenharmony_ci						BIT(25),    /* frac select */
808c2ecf20Sopenharmony_ci						270000000,  /* frac rate 0 */
818c2ecf20Sopenharmony_ci						297000000,  /* frac rate 1 */
828c2ecf20Sopenharmony_ci						BIT(31),    /* gate */
838c2ecf20Sopenharmony_ci						BIT(28),    /* lock */
848c2ecf20Sopenharmony_ci						CLK_SET_RATE_UNGATE);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
878c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
888c2ecf20Sopenharmony_ci					"osc24M", 0x0018,
898c2ecf20Sopenharmony_ci					8, 7,		/* N */
908c2ecf20Sopenharmony_ci					0, 4,		/* M */
918c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
928c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
938c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
948c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
958c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
968c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
978c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/* TODO: The result of N*K is required to be in [10, 77] range. */
1008c2ecf20Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
1018c2ecf20Sopenharmony_ci				    "osc24M", 0x020,
1028c2ecf20Sopenharmony_ci				    8, 5,	/* N */
1038c2ecf20Sopenharmony_ci				    4, 2,	/* K */
1048c2ecf20Sopenharmony_ci				    0, 2,	/* M */
1058c2ecf20Sopenharmony_ci				    BIT(31),	/* gate */
1068c2ecf20Sopenharmony_ci				    BIT(28),	/* lock */
1078c2ecf20Sopenharmony_ci				    CLK_SET_RATE_UNGATE);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/* TODO: The result of N*K is required to be in [21, 58] range. */
1108c2ecf20Sopenharmony_cistatic struct ccu_nk pll_periph0_clk = {
1118c2ecf20Sopenharmony_ci	.enable		= BIT(31),
1128c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1138c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1148c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
1158c2ecf20Sopenharmony_ci	.fixed_post_div	= 2,
1168c2ecf20Sopenharmony_ci	.common		= {
1178c2ecf20Sopenharmony_ci		.reg		= 0x028,
1188c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1198c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0", "osc24M",
1208c2ecf20Sopenharmony_ci					      &ccu_nk_ops,
1218c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
1228c2ecf20Sopenharmony_ci	},
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_cistatic struct ccu_div pll_periph0_sata_clk = {
1268c2ecf20Sopenharmony_ci	.enable		= BIT(24),
1278c2ecf20Sopenharmony_ci	.div		= _SUNXI_CCU_DIV(0, 2),
1288c2ecf20Sopenharmony_ci	/*
1298c2ecf20Sopenharmony_ci	 * The formula of pll-periph0 (1x) is 24MHz*N*K/2, and the formula
1308c2ecf20Sopenharmony_ci	 * of pll-periph0-sata is 24MHz*N*K/M/6, so the postdiv here is
1318c2ecf20Sopenharmony_ci	 * 6/2 = 3.
1328c2ecf20Sopenharmony_ci	 */
1338c2ecf20Sopenharmony_ci	.fixed_post_div	= 3,
1348c2ecf20Sopenharmony_ci	.common		= {
1358c2ecf20Sopenharmony_ci		.reg		= 0x028,
1368c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1378c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0-sata",
1388c2ecf20Sopenharmony_ci					      "pll-periph0",
1398c2ecf20Sopenharmony_ci					      &ccu_div_ops, 0),
1408c2ecf20Sopenharmony_ci	},
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/* TODO: The result of N*K is required to be in [21, 58] range. */
1448c2ecf20Sopenharmony_cistatic struct ccu_nk pll_periph1_clk = {
1458c2ecf20Sopenharmony_ci	.enable		= BIT(31),
1468c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1478c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1488c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
1498c2ecf20Sopenharmony_ci	.fixed_post_div	= 2,
1508c2ecf20Sopenharmony_ci	.common		= {
1518c2ecf20Sopenharmony_ci		.reg		= 0x02c,
1528c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1538c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph1", "osc24M",
1548c2ecf20Sopenharmony_ci					      &ccu_nk_ops,
1558c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
1568c2ecf20Sopenharmony_ci	},
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1",
1608c2ecf20Sopenharmony_ci						"osc24M", 0x030,
1618c2ecf20Sopenharmony_ci						192000000,  /* Minimum rate */
1628c2ecf20Sopenharmony_ci						1008000000, /* Maximum rate */
1638c2ecf20Sopenharmony_ci						8, 7,       /* N */
1648c2ecf20Sopenharmony_ci						0, 4,       /* M */
1658c2ecf20Sopenharmony_ci						BIT(24),    /* frac enable */
1668c2ecf20Sopenharmony_ci						BIT(25),    /* frac select */
1678c2ecf20Sopenharmony_ci						270000000,  /* frac rate 0 */
1688c2ecf20Sopenharmony_ci						297000000,  /* frac rate 1 */
1698c2ecf20Sopenharmony_ci						BIT(31),    /* gate */
1708c2ecf20Sopenharmony_ci						BIT(28),    /* lock */
1718c2ecf20Sopenharmony_ci						CLK_SET_RATE_UNGATE);
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_cistatic struct ccu_nkm pll_sata_clk = {
1748c2ecf20Sopenharmony_ci	.enable		= BIT(31),
1758c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1768c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1778c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
1788c2ecf20Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 2),
1798c2ecf20Sopenharmony_ci	.fixed_post_div	= 6,
1808c2ecf20Sopenharmony_ci	.common		= {
1818c2ecf20Sopenharmony_ci		.reg		= 0x034,
1828c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1838c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-sata", "osc24M",
1848c2ecf20Sopenharmony_ci					      &ccu_nkm_ops,
1858c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
1868c2ecf20Sopenharmony_ci	},
1878c2ecf20Sopenharmony_ci};
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic const char * const pll_sata_out_parents[] = { "pll-sata",
1908c2ecf20Sopenharmony_ci						     "pll-periph0-sata" };
1918c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(pll_sata_out_clk, "pll-sata-out",
1928c2ecf20Sopenharmony_ci			       pll_sata_out_parents, 0x034,
1938c2ecf20Sopenharmony_ci			       30, 1,	/* mux */
1948c2ecf20Sopenharmony_ci			       BIT(14),	/* gate */
1958c2ecf20Sopenharmony_ci			       CLK_SET_RATE_PARENT);
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
1988c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
1998c2ecf20Sopenharmony_ci					"osc24M", 0x038,
2008c2ecf20Sopenharmony_ci					8, 7,		/* N */
2018c2ecf20Sopenharmony_ci					0, 4,		/* M */
2028c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
2038c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
2048c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
2058c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
2068c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
2078c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
2088c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci/*
2118c2ecf20Sopenharmony_ci * The MIPI PLL has 2 modes: "MIPI" and "HDMI".
2128c2ecf20Sopenharmony_ci *
2138c2ecf20Sopenharmony_ci * The MIPI mode is a standard NKM-style clock. The HDMI mode is an
2148c2ecf20Sopenharmony_ci * integer / fractional clock with switchable multipliers and dividers.
2158c2ecf20Sopenharmony_ci * This is not supported here. We hardcode the PLL to MIPI mode.
2168c2ecf20Sopenharmony_ci *
2178c2ecf20Sopenharmony_ci * TODO: In the MIPI mode, M/N is required to be equal or lesser than 3,
2188c2ecf20Sopenharmony_ci * which cannot be implemented now.
2198c2ecf20Sopenharmony_ci */
2208c2ecf20Sopenharmony_ci#define SUN8I_R40_PLL_MIPI_REG	0x040
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic const char * const pll_mipi_parents[] = { "pll-video0" };
2238c2ecf20Sopenharmony_cistatic struct ccu_nkm pll_mipi_clk = {
2248c2ecf20Sopenharmony_ci	.enable	= BIT(31) | BIT(23) | BIT(22),
2258c2ecf20Sopenharmony_ci	.lock	= BIT(28),
2268c2ecf20Sopenharmony_ci	.n	= _SUNXI_CCU_MULT(8, 4),
2278c2ecf20Sopenharmony_ci	.k	= _SUNXI_CCU_MULT_MIN(4, 2, 2),
2288c2ecf20Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 4),
2298c2ecf20Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX(21, 1),
2308c2ecf20Sopenharmony_ci	.common	= {
2318c2ecf20Sopenharmony_ci		.reg		= 0x040,
2328c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("pll-mipi",
2338c2ecf20Sopenharmony_ci						      pll_mipi_parents,
2348c2ecf20Sopenharmony_ci						      &ccu_nkm_ops,
2358c2ecf20Sopenharmony_ci						      CLK_SET_RATE_UNGATE)
2368c2ecf20Sopenharmony_ci	},
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
2408c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
2418c2ecf20Sopenharmony_ci					"osc24M", 0x048,
2428c2ecf20Sopenharmony_ci					8, 7,		/* N */
2438c2ecf20Sopenharmony_ci					0, 4,		/* M */
2448c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
2458c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
2468c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
2478c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
2488c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
2498c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
2508c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci/* TODO: The N factor is required to be in [16, 75] range. */
2538c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
2548c2ecf20Sopenharmony_ci				   "osc24M", 0x04c,
2558c2ecf20Sopenharmony_ci				   8, 7,	/* N */
2568c2ecf20Sopenharmony_ci				   0, 2,	/* M */
2578c2ecf20Sopenharmony_ci				   BIT(31),	/* gate */
2588c2ecf20Sopenharmony_ci				   BIT(28),	/* lock */
2598c2ecf20Sopenharmony_ci				   CLK_SET_RATE_UNGATE);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_cistatic const char * const cpu_parents[] = { "osc32k", "osc24M",
2628c2ecf20Sopenharmony_ci					     "pll-cpu", "pll-cpu" };
2638c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents,
2648c2ecf20Sopenharmony_ci		     0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0);
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M",
2698c2ecf20Sopenharmony_ci					     "axi", "pll-periph0" };
2708c2ecf20Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = {
2718c2ecf20Sopenharmony_ci	{ .index = 3, .shift = 6, .width = 2 },
2728c2ecf20Sopenharmony_ci};
2738c2ecf20Sopenharmony_cistatic struct ccu_div ahb1_clk = {
2748c2ecf20Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	.mux		= {
2778c2ecf20Sopenharmony_ci		.shift	= 12,
2788c2ecf20Sopenharmony_ci		.width	= 2,
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci		.var_predivs	= ahb1_predivs,
2818c2ecf20Sopenharmony_ci		.n_var_predivs	= ARRAY_SIZE(ahb1_predivs),
2828c2ecf20Sopenharmony_ci	},
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	.common		= {
2858c2ecf20Sopenharmony_ci		.reg		= 0x054,
2868c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_VARIABLE_PREDIV,
2878c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb1",
2888c2ecf20Sopenharmony_ci						      ahb1_parents,
2898c2ecf20Sopenharmony_ci						      &ccu_div_ops,
2908c2ecf20Sopenharmony_ci						      0),
2918c2ecf20Sopenharmony_ci	},
2928c2ecf20Sopenharmony_ci};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = {
2958c2ecf20Sopenharmony_ci	{ .val = 0, .div = 2 },
2968c2ecf20Sopenharmony_ci	{ .val = 1, .div = 2 },
2978c2ecf20Sopenharmony_ci	{ .val = 2, .div = 4 },
2988c2ecf20Sopenharmony_ci	{ .val = 3, .div = 8 },
2998c2ecf20Sopenharmony_ci	{ /* Sentinel */ },
3008c2ecf20Sopenharmony_ci};
3018c2ecf20Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
3028c2ecf20Sopenharmony_ci			   0x054, 8, 2, apb1_div_table, 0);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M",
3058c2ecf20Sopenharmony_ci					     "pll-periph0-2x",
3068c2ecf20Sopenharmony_ci					     "pll-periph0-2x" };
3078c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
3088c2ecf20Sopenharmony_ci			     0, 5,	/* M */
3098c2ecf20Sopenharmony_ci			     16, 2,	/* P */
3108c2ecf20Sopenharmony_ci			     24, 2,	/* mux */
3118c2ecf20Sopenharmony_ci			     0);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk,	"bus-mipi-dsi",	"ahb1",
3148c2ecf20Sopenharmony_ci		      0x060, BIT(1), 0);
3158c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk,	"bus-ce",	"ahb1",
3168c2ecf20Sopenharmony_ci		      0x060, BIT(5), 0);
3178c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb1",
3188c2ecf20Sopenharmony_ci		      0x060, BIT(6), 0);
3198c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb1",
3208c2ecf20Sopenharmony_ci		      0x060, BIT(8), 0);
3218c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb1",
3228c2ecf20Sopenharmony_ci		      0x060, BIT(9), 0);
3238c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk,	"bus-mmc2",	"ahb1",
3248c2ecf20Sopenharmony_ci		      0x060, BIT(10), 0);
3258c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc3_clk,	"bus-mmc3",	"ahb1",
3268c2ecf20Sopenharmony_ci		      0x060, BIT(11), 0);
3278c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk,	"bus-nand",	"ahb1",
3288c2ecf20Sopenharmony_ci		      0x060, BIT(13), 0);
3298c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb1",
3308c2ecf20Sopenharmony_ci		      0x060, BIT(14), 0);
3318c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk,	"bus-emac",	"ahb1",
3328c2ecf20Sopenharmony_ci		      0x060, BIT(17), 0);
3338c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ts_clk,	"bus-ts",	"ahb1",
3348c2ecf20Sopenharmony_ci		      0x060, BIT(18), 0);
3358c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
3368c2ecf20Sopenharmony_ci		      0x060, BIT(19), 0);
3378c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb1",
3388c2ecf20Sopenharmony_ci		      0x060, BIT(20), 0);
3398c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb1",
3408c2ecf20Sopenharmony_ci		      0x060, BIT(21), 0);
3418c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi2_clk,	"bus-spi2",	"ahb1",
3428c2ecf20Sopenharmony_ci		      0x060, BIT(22), 0);
3438c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi3_clk,	"bus-spi3",	"ahb1",
3448c2ecf20Sopenharmony_ci		      0x060, BIT(23), 0);
3458c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_sata_clk,	"bus-sata",	"ahb1",
3468c2ecf20Sopenharmony_ci		      0x060, BIT(24), 0);
3478c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb1",
3488c2ecf20Sopenharmony_ci		      0x060, BIT(25), 0);
3498c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk,	"bus-ehci0",	"ahb1",
3508c2ecf20Sopenharmony_ci		      0x060, BIT(26), 0);
3518c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk,	"bus-ehci1",	"ahb1",
3528c2ecf20Sopenharmony_ci		      0x060, BIT(27), 0);
3538c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci2_clk,	"bus-ehci2",	"ahb1",
3548c2ecf20Sopenharmony_ci		      0x060, BIT(28), 0);
3558c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk,	"bus-ohci0",	"ahb1",
3568c2ecf20Sopenharmony_ci		      0x060, BIT(29), 0);
3578c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci1_clk,	"bus-ohci1",	"ahb1",
3588c2ecf20Sopenharmony_ci		      0x060, BIT(30), 0);
3598c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci2_clk,	"bus-ohci2",	"ahb1",
3608c2ecf20Sopenharmony_ci		      0x060, BIT(31), 0);
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
3638c2ecf20Sopenharmony_ci		      0x064, BIT(0), 0);
3648c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mp_clk,	"bus-mp",	"ahb1",
3658c2ecf20Sopenharmony_ci		      0x064, BIT(2), 0);
3668c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb1",
3678c2ecf20Sopenharmony_ci		      0x064, BIT(5), 0);
3688c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi0_clk,	"bus-csi0",	"ahb1",
3698c2ecf20Sopenharmony_ci		      0x064, BIT(8), 0);
3708c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi1_clk,	"bus-csi1",	"ahb1",
3718c2ecf20Sopenharmony_ci		      0x064, BIT(9), 0);
3728c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi0_clk,	"bus-hdmi0",	"ahb1",
3738c2ecf20Sopenharmony_ci		      0x064, BIT(10), 0);
3748c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi1_clk,	"bus-hdmi1",	"ahb1",
3758c2ecf20Sopenharmony_ci		      0x064, BIT(11), 0);
3768c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
3778c2ecf20Sopenharmony_ci		      0x064, BIT(12), 0);
3788c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve0_clk,	"bus-tve0",	"ahb1",
3798c2ecf20Sopenharmony_ci		      0x064, BIT(13), 0);
3808c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve1_clk,	"bus-tve1",	"ahb1",
3818c2ecf20Sopenharmony_ci		      0x064, BIT(14), 0);
3828c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve_top_clk,	"bus-tve-top",	"ahb1",
3838c2ecf20Sopenharmony_ci		      0x064, BIT(15), 0);
3848c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gmac_clk,	"bus-gmac",	"ahb1",
3858c2ecf20Sopenharmony_ci		      0x064, BIT(17), 0);
3868c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
3878c2ecf20Sopenharmony_ci		      0x064, BIT(20), 0);
3888c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd0_clk,	"bus-tvd0",	"ahb1",
3898c2ecf20Sopenharmony_ci		      0x064, BIT(21), 0);
3908c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd1_clk,	"bus-tvd1",	"ahb1",
3918c2ecf20Sopenharmony_ci		      0x064, BIT(22), 0);
3928c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd2_clk,	"bus-tvd2",	"ahb1",
3938c2ecf20Sopenharmony_ci		      0x064, BIT(23), 0);
3948c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd3_clk,	"bus-tvd3",	"ahb1",
3958c2ecf20Sopenharmony_ci		      0x064, BIT(24), 0);
3968c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd_top_clk,	"bus-tvd-top",	"ahb1",
3978c2ecf20Sopenharmony_ci		      0x064, BIT(25), 0);
3988c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_lcd0_clk,	"bus-tcon-lcd0",	"ahb1",
3998c2ecf20Sopenharmony_ci		      0x064, BIT(26), 0);
4008c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_lcd1_clk,	"bus-tcon-lcd1",	"ahb1",
4018c2ecf20Sopenharmony_ci		      0x064, BIT(27), 0);
4028c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_tv0_clk,	"bus-tcon-tv0",	"ahb1",
4038c2ecf20Sopenharmony_ci		      0x064, BIT(28), 0);
4048c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_tv1_clk,	"bus-tcon-tv1",	"ahb1",
4058c2ecf20Sopenharmony_ci		      0x064, BIT(29), 0);
4068c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_top_clk,	"bus-tcon-top",	"ahb1",
4078c2ecf20Sopenharmony_ci		      0x064, BIT(30), 0);
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb1",
4108c2ecf20Sopenharmony_ci		      0x068, BIT(0), 0);
4118c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk,	"bus-spdif",	"apb1",
4128c2ecf20Sopenharmony_ci		      0x068, BIT(1), 0);
4138c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ac97_clk,	"bus-ac97",	"apb1",
4148c2ecf20Sopenharmony_ci		      0x068, BIT(2), 0);
4158c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb1",
4168c2ecf20Sopenharmony_ci		      0x068, BIT(5), 0);
4178c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir0_clk,	"bus-ir0",	"apb1",
4188c2ecf20Sopenharmony_ci		      0x068, BIT(6), 0);
4198c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir1_clk,	"bus-ir1",	"apb1",
4208c2ecf20Sopenharmony_ci		      0x068, BIT(7), 0);
4218c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ths_clk,	"bus-ths",	"apb1",
4228c2ecf20Sopenharmony_ci		      0x068, BIT(8), 0);
4238c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_keypad_clk,	"bus-keypad",	"apb1",
4248c2ecf20Sopenharmony_ci		      0x068, BIT(10), 0);
4258c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb1",
4268c2ecf20Sopenharmony_ci		      0x068, BIT(12), 0);
4278c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk,	"bus-i2s1",	"apb1",
4288c2ecf20Sopenharmony_ci		      0x068, BIT(13), 0);
4298c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk,	"bus-i2s2",	"apb1",
4308c2ecf20Sopenharmony_ci		      0x068, BIT(14), 0);
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb2",
4338c2ecf20Sopenharmony_ci		      0x06c, BIT(0), 0);
4348c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb2",
4358c2ecf20Sopenharmony_ci		      0x06c, BIT(1), 0);
4368c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb2",
4378c2ecf20Sopenharmony_ci		      0x06c, BIT(2), 0);
4388c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c3_clk,	"bus-i2c3",	"apb2",
4398c2ecf20Sopenharmony_ci		      0x06c, BIT(3), 0);
4408c2ecf20Sopenharmony_ci/*
4418c2ecf20Sopenharmony_ci * In datasheet here's "Reserved", however the gate exists in BSP soucre
4428c2ecf20Sopenharmony_ci * code.
4438c2ecf20Sopenharmony_ci */
4448c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_can_clk,	"bus-can",	"apb2",
4458c2ecf20Sopenharmony_ci		      0x06c, BIT(4), 0);
4468c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_scr_clk,	"bus-scr",	"apb2",
4478c2ecf20Sopenharmony_ci		      0x06c, BIT(5), 0);
4488c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ps20_clk,	"bus-ps20",	"apb2",
4498c2ecf20Sopenharmony_ci		      0x06c, BIT(6), 0);
4508c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ps21_clk,	"bus-ps21",	"apb2",
4518c2ecf20Sopenharmony_ci		      0x06c, BIT(7), 0);
4528c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c4_clk,	"bus-i2c4",	"apb2",
4538c2ecf20Sopenharmony_ci		      0x06c, BIT(15), 0);
4548c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb2",
4558c2ecf20Sopenharmony_ci		      0x06c, BIT(16), 0);
4568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb2",
4578c2ecf20Sopenharmony_ci		      0x06c, BIT(17), 0);
4588c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
4598c2ecf20Sopenharmony_ci		      0x06c, BIT(18), 0);
4608c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
4618c2ecf20Sopenharmony_ci		      0x06c, BIT(19), 0);
4628c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk,	"bus-uart4",	"apb2",
4638c2ecf20Sopenharmony_ci		      0x06c, BIT(20), 0);
4648c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart5_clk,	"bus-uart5",	"apb2",
4658c2ecf20Sopenharmony_ci		      0x06c, BIT(21), 0);
4668c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart6_clk,	"bus-uart6",	"apb2",
4678c2ecf20Sopenharmony_ci		      0x06c, BIT(22), 0);
4688c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart7_clk,	"bus-uart7",	"apb2",
4698c2ecf20Sopenharmony_ci		      0x06c, BIT(23), 0);
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk,	"bus-dbg",	"ahb1",
4728c2ecf20Sopenharmony_ci		      0x070, BIT(7), 0);
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_cistatic const char * const ths_parents[] = { "osc24M" };
4758c2ecf20Sopenharmony_cistatic struct ccu_div ths_clk = {
4768c2ecf20Sopenharmony_ci	.enable	= BIT(31),
4778c2ecf20Sopenharmony_ci	.div	= _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
4788c2ecf20Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX(24, 2),
4798c2ecf20Sopenharmony_ci	.common	= {
4808c2ecf20Sopenharmony_ci		.reg		= 0x074,
4818c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ths",
4828c2ecf20Sopenharmony_ci						      ths_parents,
4838c2ecf20Sopenharmony_ci						      &ccu_div_ops,
4848c2ecf20Sopenharmony_ci						      0),
4858c2ecf20Sopenharmony_ci	},
4868c2ecf20Sopenharmony_ci};
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
4898c2ecf20Sopenharmony_ci						     "pll-periph1" };
4908c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
4918c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4928c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4938c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
4948c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4958c2ecf20Sopenharmony_ci				  0);
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
4988c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4998c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5008c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5018c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5028c2ecf20Sopenharmony_ci				  0);
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
5058c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5068c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5078c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5088c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5098c2ecf20Sopenharmony_ci				  0);
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
5128c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5138c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5148c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5158c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5168c2ecf20Sopenharmony_ci				  0);
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents, 0x094,
5198c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5208c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5218c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5228c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5238c2ecf20Sopenharmony_ci				  0);
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cistatic const char * const ts_parents[] = { "osc24M", "pll-periph0", };
5268c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
5278c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5288c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5298c2ecf20Sopenharmony_ci				  24, 4,	/* mux */
5308c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5318c2ecf20Sopenharmony_ci				  0);
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_cistatic const char * const ce_parents[] = { "osc24M", "pll-periph0-2x",
5348c2ecf20Sopenharmony_ci					   "pll-periph1-2x" };
5358c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c,
5368c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5378c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5388c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5398c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5408c2ecf20Sopenharmony_ci				  0);
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
5438c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5448c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5458c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5468c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5478c2ecf20Sopenharmony_ci				  0);
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
5508c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5518c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5528c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5538c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5548c2ecf20Sopenharmony_ci				  0);
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8,
5578c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5588c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5598c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5608c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5618c2ecf20Sopenharmony_ci				  0);
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents, 0x0ac,
5648c2ecf20Sopenharmony_ci				  0, 4,		/* M */
5658c2ecf20Sopenharmony_ci				  16, 2,	/* P */
5668c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
5678c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
5688c2ecf20Sopenharmony_ci				  0);
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
5718c2ecf20Sopenharmony_ci					    "pll-audio-2x", "pll-audio" };
5728c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
5738c2ecf20Sopenharmony_ci			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
5768c2ecf20Sopenharmony_ci			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
5798c2ecf20Sopenharmony_ci			       0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(ac97_clk, "ac97", i2s_parents,
5828c2ecf20Sopenharmony_ci			       0x0bc, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", i2s_parents,
5858c2ecf20Sopenharmony_ci			       0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_cistatic const char * const keypad_parents[] = { "osc24M", "osc32k" };
5888c2ecf20Sopenharmony_cistatic const u8 keypad_table[] = { 0, 2 };
5898c2ecf20Sopenharmony_cistatic struct ccu_mp keypad_clk = {
5908c2ecf20Sopenharmony_ci	.enable	= BIT(31),
5918c2ecf20Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 5),
5928c2ecf20Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(16, 2),
5938c2ecf20Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table),
5948c2ecf20Sopenharmony_ci	.common	= {
5958c2ecf20Sopenharmony_ci		.reg		= 0x0c4,
5968c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("keypad",
5978c2ecf20Sopenharmony_ci						      keypad_parents,
5988c2ecf20Sopenharmony_ci						      &ccu_mp_ops,
5998c2ecf20Sopenharmony_ci						      0),
6008c2ecf20Sopenharmony_ci	}
6018c2ecf20Sopenharmony_ci};
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_cistatic const char * const sata_parents[] = { "pll-sata-out", "sata-ext" };
6048c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(sata_clk, "sata", sata_parents,
6058c2ecf20Sopenharmony_ci			       0x0c8, 24, 1, BIT(31), CLK_SET_RATE_PARENT);
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci/*
6088c2ecf20Sopenharmony_ci * There are 3 OHCI 12M clock source selection bits in this register.
6098c2ecf20Sopenharmony_ci * We will force them to 0 (12M divided from 48M).
6108c2ecf20Sopenharmony_ci */
6118c2ecf20Sopenharmony_ci#define SUN8I_R40_USB_CLK_REG	0x0cc
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
6148c2ecf20Sopenharmony_ci		      0x0cc, BIT(8), 0);
6158c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
6168c2ecf20Sopenharmony_ci		      0x0cc, BIT(9), 0);
6178c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy2_clk,	"usb-phy2",	"osc24M",
6188c2ecf20Sopenharmony_ci		      0x0cc, BIT(10), 0);
6198c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk,	"usb-ohci0",	"osc12M",
6208c2ecf20Sopenharmony_ci		      0x0cc, BIT(16), 0);
6218c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci1_clk,	"usb-ohci1",	"osc12M",
6228c2ecf20Sopenharmony_ci		      0x0cc, BIT(17), 0);
6238c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci2_clk,	"usb-ohci2",	"osc12M",
6248c2ecf20Sopenharmony_ci		      0x0cc, BIT(18), 0);
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_cistatic const char * const ir_parents[] = { "osc24M", "pll-periph0",
6278c2ecf20Sopenharmony_ci					   "pll-periph1", "osc32k" };
6288c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir0_clk, "ir0", ir_parents, 0x0d0,
6298c2ecf20Sopenharmony_ci				  0, 4,		/* M */
6308c2ecf20Sopenharmony_ci				  16, 2,	/* P */
6318c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
6328c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
6338c2ecf20Sopenharmony_ci				  0);
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir1_clk, "ir1", ir_parents, 0x0d4,
6368c2ecf20Sopenharmony_ci				  0, 4,		/* M */
6378c2ecf20Sopenharmony_ci				  16, 2,	/* P */
6388c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
6398c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
6408c2ecf20Sopenharmony_ci				  0);
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_cistatic const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" };
6438c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
6448c2ecf20Sopenharmony_ci			    0x0f4, 0, 2, 20, 2, CLK_IS_CRITICAL);
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"dram",
6478c2ecf20Sopenharmony_ci		      0x100, BIT(0), 0);
6488c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi0_clk,	"dram-csi0",	"dram",
6498c2ecf20Sopenharmony_ci		      0x100, BIT(1), 0);
6508c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi1_clk,	"dram-csi1",	"dram",
6518c2ecf20Sopenharmony_ci		      0x100, BIT(2), 0);
6528c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ts_clk,	"dram-ts",	"dram",
6538c2ecf20Sopenharmony_ci		      0x100, BIT(3), 0);
6548c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_tvd_clk,	"dram-tvd",	"dram",
6558c2ecf20Sopenharmony_ci		      0x100, BIT(4), 0);
6568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_mp_clk,	"dram-mp",	"dram",
6578c2ecf20Sopenharmony_ci		      0x100, BIT(5), 0);
6588c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_deinterlace_clk,	"dram-deinterlace",	"dram",
6598c2ecf20Sopenharmony_ci		      0x100, BIT(6), 0);
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_cistatic const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
6628c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
6638c2ecf20Sopenharmony_ci				 0x104, 0, 4, 24, 3, BIT(31),
6648c2ecf20Sopenharmony_ci				 CLK_SET_RATE_PARENT);
6658c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mp_clk, "mp", de_parents,
6668c2ecf20Sopenharmony_ci				 0x108, 0, 4, 24, 3, BIT(31), 0);
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_cistatic const char * const tcon_parents[] = { "pll-video0", "pll-video1",
6698c2ecf20Sopenharmony_ci					     "pll-video0-2x", "pll-video1-2x",
6708c2ecf20Sopenharmony_ci					     "pll-mipi" };
6718c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk, "tcon-lcd0", tcon_parents,
6728c2ecf20Sopenharmony_ci			       0x110, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
6738c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(tcon_lcd1_clk, "tcon-lcd1", tcon_parents,
6748c2ecf20Sopenharmony_ci			       0x114, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
6758c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv0_clk, "tcon-tv0", tcon_parents,
6768c2ecf20Sopenharmony_ci				 0x118, 0, 4, 24, 3, BIT(31),
6778c2ecf20Sopenharmony_ci				 CLK_SET_RATE_PARENT);
6788c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv1_clk, "tcon-tv1", tcon_parents,
6798c2ecf20Sopenharmony_ci				 0x11c, 0, 4, 24, 3, BIT(31),
6808c2ecf20Sopenharmony_ci				 CLK_SET_RATE_PARENT);
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_cistatic const char * const deinterlace_parents[] = { "pll-periph0",
6838c2ecf20Sopenharmony_ci						    "pll-periph1" };
6848c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace",
6858c2ecf20Sopenharmony_ci				 deinterlace_parents, 0x124, 0, 4, 24, 3,
6868c2ecf20Sopenharmony_ci				 BIT(31), 0);
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "osc24M", "pll-video1",
6898c2ecf20Sopenharmony_ci						 "pll-periph1" };
6908c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi1-mclk", csi_mclk_parents,
6918c2ecf20Sopenharmony_ci				 0x130, 0, 5, 8, 3, BIT(15), 0);
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
6948c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
6958c2ecf20Sopenharmony_ci				 0x134, 16, 4, 24, 3, BIT(31), 0);
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents,
6988c2ecf20Sopenharmony_ci				 0x134, 0, 5, 8, 3, BIT(15), 0);
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
7018c2ecf20Sopenharmony_ci			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(codec_clk,	"codec",	"pll-audio",
7048c2ecf20Sopenharmony_ci		      0x140, BIT(31), CLK_SET_RATE_PARENT);
7058c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
7068c2ecf20Sopenharmony_ci		      0x144, BIT(31), 0);
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_cistatic const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
7098c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
7108c2ecf20Sopenharmony_ci				 0x150, 0, 4, 24, 2, BIT(31),
7118c2ecf20Sopenharmony_ci				 CLK_SET_RATE_PARENT);
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(hdmi_slow_clk,	"hdmi-slow",	"osc24M",
7148c2ecf20Sopenharmony_ci		      0x154, BIT(31), 0);
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci/*
7178c2ecf20Sopenharmony_ci * In the SoC's user manual, the P factor is mentioned, but not used in
7188c2ecf20Sopenharmony_ci * the frequency formula.
7198c2ecf20Sopenharmony_ci *
7208c2ecf20Sopenharmony_ci * Here the factor is included, according to the BSP kernel source,
7218c2ecf20Sopenharmony_ci * which contains the P factor of this clock.
7228c2ecf20Sopenharmony_ci */
7238c2ecf20Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
7248c2ecf20Sopenharmony_ci					     "pll-ddr0" };
7258c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c,
7268c2ecf20Sopenharmony_ci				  0, 4,		/* M */
7278c2ecf20Sopenharmony_ci				  16, 2,	/* P */
7288c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
7298c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
7308c2ecf20Sopenharmony_ci				  CLK_IS_CRITICAL);
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video0", "pll-video1",
7338c2ecf20Sopenharmony_ci						 "pll-periph0" };
7348c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(dsi_dphy_clk, "dsi-dphy", dsi_dphy_parents,
7358c2ecf20Sopenharmony_ci				 0x168, 0, 4, 8, 2, BIT(15), 0);
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tve0_clk, "tve0", tcon_parents,
7388c2ecf20Sopenharmony_ci				 0x180, 0, 4, 24, 3, BIT(31), 0);
7398c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tve1_clk, "tve1", tcon_parents,
7408c2ecf20Sopenharmony_ci				 0x184, 0, 4, 24, 3, BIT(31), 0);
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_cistatic const char * const tvd_parents[] = { "pll-video0", "pll-video1",
7438c2ecf20Sopenharmony_ci					    "pll-video0-2x", "pll-video1-2x" };
7448c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd0_clk, "tvd0", tvd_parents,
7458c2ecf20Sopenharmony_ci				 0x188, 0, 4, 24, 3, BIT(31), 0);
7468c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd1_clk, "tvd1", tvd_parents,
7478c2ecf20Sopenharmony_ci				 0x18c, 0, 4, 24, 3, BIT(31), 0);
7488c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd2_clk, "tvd2", tvd_parents,
7498c2ecf20Sopenharmony_ci				 0x190, 0, 4, 24, 3, BIT(31), 0);
7508c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd3_clk, "tvd3", tvd_parents,
7518c2ecf20Sopenharmony_ci				 0x194, 0, 4, 24, 3, BIT(31), 0);
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
7548c2ecf20Sopenharmony_ci			     0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_cistatic const char * const out_parents[] = { "osc24M", "osc32k", "osc24M" };
7578c2ecf20Sopenharmony_cistatic const struct ccu_mux_fixed_prediv out_predivs[] = {
7588c2ecf20Sopenharmony_ci	{ .index = 0, .div = 750, },
7598c2ecf20Sopenharmony_ci};
7608c2ecf20Sopenharmony_ci
7618c2ecf20Sopenharmony_cistatic struct ccu_mp outa_clk = {
7628c2ecf20Sopenharmony_ci	.enable	= BIT(31),
7638c2ecf20Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(8, 5),
7648c2ecf20Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(20, 2),
7658c2ecf20Sopenharmony_ci	.mux	= {
7668c2ecf20Sopenharmony_ci		.shift		= 24,
7678c2ecf20Sopenharmony_ci		.width		= 2,
7688c2ecf20Sopenharmony_ci		.fixed_predivs	= out_predivs,
7698c2ecf20Sopenharmony_ci		.n_predivs	= ARRAY_SIZE(out_predivs),
7708c2ecf20Sopenharmony_ci	},
7718c2ecf20Sopenharmony_ci	.common	= {
7728c2ecf20Sopenharmony_ci		.reg		= 0x1f0,
7738c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_PREDIV,
7748c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("outa", out_parents,
7758c2ecf20Sopenharmony_ci						      &ccu_mp_ops,
7768c2ecf20Sopenharmony_ci						      CLK_SET_RATE_PARENT),
7778c2ecf20Sopenharmony_ci	}
7788c2ecf20Sopenharmony_ci};
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_cistatic struct ccu_mp outb_clk = {
7818c2ecf20Sopenharmony_ci	.enable	= BIT(31),
7828c2ecf20Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(8, 5),
7838c2ecf20Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(20, 2),
7848c2ecf20Sopenharmony_ci	.mux	= {
7858c2ecf20Sopenharmony_ci		.shift		= 24,
7868c2ecf20Sopenharmony_ci		.width		= 2,
7878c2ecf20Sopenharmony_ci		.fixed_predivs	= out_predivs,
7888c2ecf20Sopenharmony_ci		.n_predivs	= ARRAY_SIZE(out_predivs),
7898c2ecf20Sopenharmony_ci	},
7908c2ecf20Sopenharmony_ci	.common	= {
7918c2ecf20Sopenharmony_ci		.reg		= 0x1f4,
7928c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_PREDIV,
7938c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("outb", out_parents,
7948c2ecf20Sopenharmony_ci						      &ccu_mp_ops,
7958c2ecf20Sopenharmony_ci						      CLK_SET_RATE_PARENT),
7968c2ecf20Sopenharmony_ci	}
7978c2ecf20Sopenharmony_ci};
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_cistatic struct ccu_common *sun8i_r40_ccu_clks[] = {
8008c2ecf20Sopenharmony_ci	&pll_cpu_clk.common,
8018c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common,
8028c2ecf20Sopenharmony_ci	&pll_video0_clk.common,
8038c2ecf20Sopenharmony_ci	&pll_ve_clk.common,
8048c2ecf20Sopenharmony_ci	&pll_ddr0_clk.common,
8058c2ecf20Sopenharmony_ci	&pll_periph0_clk.common,
8068c2ecf20Sopenharmony_ci	&pll_periph0_sata_clk.common,
8078c2ecf20Sopenharmony_ci	&pll_periph1_clk.common,
8088c2ecf20Sopenharmony_ci	&pll_video1_clk.common,
8098c2ecf20Sopenharmony_ci	&pll_sata_clk.common,
8108c2ecf20Sopenharmony_ci	&pll_sata_out_clk.common,
8118c2ecf20Sopenharmony_ci	&pll_gpu_clk.common,
8128c2ecf20Sopenharmony_ci	&pll_mipi_clk.common,
8138c2ecf20Sopenharmony_ci	&pll_de_clk.common,
8148c2ecf20Sopenharmony_ci	&pll_ddr1_clk.common,
8158c2ecf20Sopenharmony_ci	&cpu_clk.common,
8168c2ecf20Sopenharmony_ci	&axi_clk.common,
8178c2ecf20Sopenharmony_ci	&ahb1_clk.common,
8188c2ecf20Sopenharmony_ci	&apb1_clk.common,
8198c2ecf20Sopenharmony_ci	&apb2_clk.common,
8208c2ecf20Sopenharmony_ci	&bus_mipi_dsi_clk.common,
8218c2ecf20Sopenharmony_ci	&bus_ce_clk.common,
8228c2ecf20Sopenharmony_ci	&bus_dma_clk.common,
8238c2ecf20Sopenharmony_ci	&bus_mmc0_clk.common,
8248c2ecf20Sopenharmony_ci	&bus_mmc1_clk.common,
8258c2ecf20Sopenharmony_ci	&bus_mmc2_clk.common,
8268c2ecf20Sopenharmony_ci	&bus_mmc3_clk.common,
8278c2ecf20Sopenharmony_ci	&bus_nand_clk.common,
8288c2ecf20Sopenharmony_ci	&bus_dram_clk.common,
8298c2ecf20Sopenharmony_ci	&bus_emac_clk.common,
8308c2ecf20Sopenharmony_ci	&bus_ts_clk.common,
8318c2ecf20Sopenharmony_ci	&bus_hstimer_clk.common,
8328c2ecf20Sopenharmony_ci	&bus_spi0_clk.common,
8338c2ecf20Sopenharmony_ci	&bus_spi1_clk.common,
8348c2ecf20Sopenharmony_ci	&bus_spi2_clk.common,
8358c2ecf20Sopenharmony_ci	&bus_spi3_clk.common,
8368c2ecf20Sopenharmony_ci	&bus_sata_clk.common,
8378c2ecf20Sopenharmony_ci	&bus_otg_clk.common,
8388c2ecf20Sopenharmony_ci	&bus_ehci0_clk.common,
8398c2ecf20Sopenharmony_ci	&bus_ehci1_clk.common,
8408c2ecf20Sopenharmony_ci	&bus_ehci2_clk.common,
8418c2ecf20Sopenharmony_ci	&bus_ohci0_clk.common,
8428c2ecf20Sopenharmony_ci	&bus_ohci1_clk.common,
8438c2ecf20Sopenharmony_ci	&bus_ohci2_clk.common,
8448c2ecf20Sopenharmony_ci	&bus_ve_clk.common,
8458c2ecf20Sopenharmony_ci	&bus_mp_clk.common,
8468c2ecf20Sopenharmony_ci	&bus_deinterlace_clk.common,
8478c2ecf20Sopenharmony_ci	&bus_csi0_clk.common,
8488c2ecf20Sopenharmony_ci	&bus_csi1_clk.common,
8498c2ecf20Sopenharmony_ci	&bus_hdmi0_clk.common,
8508c2ecf20Sopenharmony_ci	&bus_hdmi1_clk.common,
8518c2ecf20Sopenharmony_ci	&bus_de_clk.common,
8528c2ecf20Sopenharmony_ci	&bus_tve0_clk.common,
8538c2ecf20Sopenharmony_ci	&bus_tve1_clk.common,
8548c2ecf20Sopenharmony_ci	&bus_tve_top_clk.common,
8558c2ecf20Sopenharmony_ci	&bus_gmac_clk.common,
8568c2ecf20Sopenharmony_ci	&bus_gpu_clk.common,
8578c2ecf20Sopenharmony_ci	&bus_tvd0_clk.common,
8588c2ecf20Sopenharmony_ci	&bus_tvd1_clk.common,
8598c2ecf20Sopenharmony_ci	&bus_tvd2_clk.common,
8608c2ecf20Sopenharmony_ci	&bus_tvd3_clk.common,
8618c2ecf20Sopenharmony_ci	&bus_tvd_top_clk.common,
8628c2ecf20Sopenharmony_ci	&bus_tcon_lcd0_clk.common,
8638c2ecf20Sopenharmony_ci	&bus_tcon_lcd1_clk.common,
8648c2ecf20Sopenharmony_ci	&bus_tcon_tv0_clk.common,
8658c2ecf20Sopenharmony_ci	&bus_tcon_tv1_clk.common,
8668c2ecf20Sopenharmony_ci	&bus_tcon_top_clk.common,
8678c2ecf20Sopenharmony_ci	&bus_codec_clk.common,
8688c2ecf20Sopenharmony_ci	&bus_spdif_clk.common,
8698c2ecf20Sopenharmony_ci	&bus_ac97_clk.common,
8708c2ecf20Sopenharmony_ci	&bus_pio_clk.common,
8718c2ecf20Sopenharmony_ci	&bus_ir0_clk.common,
8728c2ecf20Sopenharmony_ci	&bus_ir1_clk.common,
8738c2ecf20Sopenharmony_ci	&bus_ths_clk.common,
8748c2ecf20Sopenharmony_ci	&bus_keypad_clk.common,
8758c2ecf20Sopenharmony_ci	&bus_i2s0_clk.common,
8768c2ecf20Sopenharmony_ci	&bus_i2s1_clk.common,
8778c2ecf20Sopenharmony_ci	&bus_i2s2_clk.common,
8788c2ecf20Sopenharmony_ci	&bus_i2c0_clk.common,
8798c2ecf20Sopenharmony_ci	&bus_i2c1_clk.common,
8808c2ecf20Sopenharmony_ci	&bus_i2c2_clk.common,
8818c2ecf20Sopenharmony_ci	&bus_i2c3_clk.common,
8828c2ecf20Sopenharmony_ci	&bus_can_clk.common,
8838c2ecf20Sopenharmony_ci	&bus_scr_clk.common,
8848c2ecf20Sopenharmony_ci	&bus_ps20_clk.common,
8858c2ecf20Sopenharmony_ci	&bus_ps21_clk.common,
8868c2ecf20Sopenharmony_ci	&bus_i2c4_clk.common,
8878c2ecf20Sopenharmony_ci	&bus_uart0_clk.common,
8888c2ecf20Sopenharmony_ci	&bus_uart1_clk.common,
8898c2ecf20Sopenharmony_ci	&bus_uart2_clk.common,
8908c2ecf20Sopenharmony_ci	&bus_uart3_clk.common,
8918c2ecf20Sopenharmony_ci	&bus_uart4_clk.common,
8928c2ecf20Sopenharmony_ci	&bus_uart5_clk.common,
8938c2ecf20Sopenharmony_ci	&bus_uart6_clk.common,
8948c2ecf20Sopenharmony_ci	&bus_uart7_clk.common,
8958c2ecf20Sopenharmony_ci	&bus_dbg_clk.common,
8968c2ecf20Sopenharmony_ci	&ths_clk.common,
8978c2ecf20Sopenharmony_ci	&nand_clk.common,
8988c2ecf20Sopenharmony_ci	&mmc0_clk.common,
8998c2ecf20Sopenharmony_ci	&mmc1_clk.common,
9008c2ecf20Sopenharmony_ci	&mmc2_clk.common,
9018c2ecf20Sopenharmony_ci	&mmc3_clk.common,
9028c2ecf20Sopenharmony_ci	&ts_clk.common,
9038c2ecf20Sopenharmony_ci	&ce_clk.common,
9048c2ecf20Sopenharmony_ci	&spi0_clk.common,
9058c2ecf20Sopenharmony_ci	&spi1_clk.common,
9068c2ecf20Sopenharmony_ci	&spi2_clk.common,
9078c2ecf20Sopenharmony_ci	&spi3_clk.common,
9088c2ecf20Sopenharmony_ci	&i2s0_clk.common,
9098c2ecf20Sopenharmony_ci	&i2s1_clk.common,
9108c2ecf20Sopenharmony_ci	&i2s2_clk.common,
9118c2ecf20Sopenharmony_ci	&ac97_clk.common,
9128c2ecf20Sopenharmony_ci	&spdif_clk.common,
9138c2ecf20Sopenharmony_ci	&keypad_clk.common,
9148c2ecf20Sopenharmony_ci	&sata_clk.common,
9158c2ecf20Sopenharmony_ci	&usb_phy0_clk.common,
9168c2ecf20Sopenharmony_ci	&usb_phy1_clk.common,
9178c2ecf20Sopenharmony_ci	&usb_phy2_clk.common,
9188c2ecf20Sopenharmony_ci	&usb_ohci0_clk.common,
9198c2ecf20Sopenharmony_ci	&usb_ohci1_clk.common,
9208c2ecf20Sopenharmony_ci	&usb_ohci2_clk.common,
9218c2ecf20Sopenharmony_ci	&ir0_clk.common,
9228c2ecf20Sopenharmony_ci	&ir1_clk.common,
9238c2ecf20Sopenharmony_ci	&dram_clk.common,
9248c2ecf20Sopenharmony_ci	&dram_ve_clk.common,
9258c2ecf20Sopenharmony_ci	&dram_csi0_clk.common,
9268c2ecf20Sopenharmony_ci	&dram_csi1_clk.common,
9278c2ecf20Sopenharmony_ci	&dram_ts_clk.common,
9288c2ecf20Sopenharmony_ci	&dram_tvd_clk.common,
9298c2ecf20Sopenharmony_ci	&dram_mp_clk.common,
9308c2ecf20Sopenharmony_ci	&dram_deinterlace_clk.common,
9318c2ecf20Sopenharmony_ci	&de_clk.common,
9328c2ecf20Sopenharmony_ci	&mp_clk.common,
9338c2ecf20Sopenharmony_ci	&tcon_lcd0_clk.common,
9348c2ecf20Sopenharmony_ci	&tcon_lcd1_clk.common,
9358c2ecf20Sopenharmony_ci	&tcon_tv0_clk.common,
9368c2ecf20Sopenharmony_ci	&tcon_tv1_clk.common,
9378c2ecf20Sopenharmony_ci	&deinterlace_clk.common,
9388c2ecf20Sopenharmony_ci	&csi1_mclk_clk.common,
9398c2ecf20Sopenharmony_ci	&csi_sclk_clk.common,
9408c2ecf20Sopenharmony_ci	&csi0_mclk_clk.common,
9418c2ecf20Sopenharmony_ci	&ve_clk.common,
9428c2ecf20Sopenharmony_ci	&codec_clk.common,
9438c2ecf20Sopenharmony_ci	&avs_clk.common,
9448c2ecf20Sopenharmony_ci	&hdmi_clk.common,
9458c2ecf20Sopenharmony_ci	&hdmi_slow_clk.common,
9468c2ecf20Sopenharmony_ci	&mbus_clk.common,
9478c2ecf20Sopenharmony_ci	&dsi_dphy_clk.common,
9488c2ecf20Sopenharmony_ci	&tve0_clk.common,
9498c2ecf20Sopenharmony_ci	&tve1_clk.common,
9508c2ecf20Sopenharmony_ci	&tvd0_clk.common,
9518c2ecf20Sopenharmony_ci	&tvd1_clk.common,
9528c2ecf20Sopenharmony_ci	&tvd2_clk.common,
9538c2ecf20Sopenharmony_ci	&tvd3_clk.common,
9548c2ecf20Sopenharmony_ci	&gpu_clk.common,
9558c2ecf20Sopenharmony_ci	&outa_clk.common,
9568c2ecf20Sopenharmony_ci	&outb_clk.common,
9578c2ecf20Sopenharmony_ci};
9588c2ecf20Sopenharmony_ci
9598c2ecf20Sopenharmony_ci/* Fixed Factor clocks */
9608c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_FW_NAME(osc12M_clk, "osc12M", "hosc", 2, 1, 0);
9618c2ecf20Sopenharmony_ci
9628c2ecf20Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = {
9638c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common.hw
9648c2ecf20Sopenharmony_ci};
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ci/* We hardcode the divider to 1 for now */
9678c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
9688c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
9698c2ecf20Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
9708c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
9718c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
9728c2ecf20Sopenharmony_ci			    2, 1, CLK_SET_RATE_PARENT);
9738c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
9748c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
9758c2ecf20Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
9768c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
9778c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
9788c2ecf20Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
9798c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x",
9808c2ecf20Sopenharmony_ci			   &pll_periph0_clk.common.hw,
9818c2ecf20Sopenharmony_ci			   1, 2, 0);
9828c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph1_2x_clk, "pll-periph1-2x",
9838c2ecf20Sopenharmony_ci			   &pll_periph1_clk.common.hw,
9848c2ecf20Sopenharmony_ci			   1, 2, 0);
9858c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x",
9868c2ecf20Sopenharmony_ci			   &pll_video0_clk.common.hw,
9878c2ecf20Sopenharmony_ci			   1, 2, 0);
9888c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video1_2x_clk, "pll-video1-2x",
9898c2ecf20Sopenharmony_ci			   &pll_video1_clk.common.hw,
9908c2ecf20Sopenharmony_ci			   1, 2, 0);
9918c2ecf20Sopenharmony_ci
9928c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_r40_hw_clks = {
9938c2ecf20Sopenharmony_ci	.hws	= {
9948c2ecf20Sopenharmony_ci		[CLK_OSC_12M]		= &osc12M_clk.hw,
9958c2ecf20Sopenharmony_ci		[CLK_PLL_CPU]		= &pll_cpu_clk.common.hw,
9968c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
9978c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
9988c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
9998c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
10008c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
10018c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
10028c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO0_2X]	= &pll_video0_2x_clk.hw,
10038c2ecf20Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
10048c2ecf20Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
10058c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
10068c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH0_SATA]	= &pll_periph0_sata_clk.common.hw,
10078c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
10088c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
10098c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
10108c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
10118c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO1_2X]	= &pll_video1_2x_clk.hw,
10128c2ecf20Sopenharmony_ci		[CLK_PLL_SATA]		= &pll_sata_clk.common.hw,
10138c2ecf20Sopenharmony_ci		[CLK_PLL_SATA_OUT]	= &pll_sata_out_clk.common.hw,
10148c2ecf20Sopenharmony_ci		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
10158c2ecf20Sopenharmony_ci		[CLK_PLL_MIPI]		= &pll_mipi_clk.common.hw,
10168c2ecf20Sopenharmony_ci		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
10178c2ecf20Sopenharmony_ci		[CLK_PLL_DDR1]		= &pll_ddr1_clk.common.hw,
10188c2ecf20Sopenharmony_ci		[CLK_CPU]		= &cpu_clk.common.hw,
10198c2ecf20Sopenharmony_ci		[CLK_AXI]		= &axi_clk.common.hw,
10208c2ecf20Sopenharmony_ci		[CLK_AHB1]		= &ahb1_clk.common.hw,
10218c2ecf20Sopenharmony_ci		[CLK_APB1]		= &apb1_clk.common.hw,
10228c2ecf20Sopenharmony_ci		[CLK_APB2]		= &apb2_clk.common.hw,
10238c2ecf20Sopenharmony_ci		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
10248c2ecf20Sopenharmony_ci		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
10258c2ecf20Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
10268c2ecf20Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
10278c2ecf20Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
10288c2ecf20Sopenharmony_ci		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
10298c2ecf20Sopenharmony_ci		[CLK_BUS_MMC3]		= &bus_mmc3_clk.common.hw,
10308c2ecf20Sopenharmony_ci		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
10318c2ecf20Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
10328c2ecf20Sopenharmony_ci		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
10338c2ecf20Sopenharmony_ci		[CLK_BUS_TS]		= &bus_ts_clk.common.hw,
10348c2ecf20Sopenharmony_ci		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
10358c2ecf20Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
10368c2ecf20Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
10378c2ecf20Sopenharmony_ci		[CLK_BUS_SPI2]		= &bus_spi2_clk.common.hw,
10388c2ecf20Sopenharmony_ci		[CLK_BUS_SPI3]		= &bus_spi3_clk.common.hw,
10398c2ecf20Sopenharmony_ci		[CLK_BUS_SATA]		= &bus_sata_clk.common.hw,
10408c2ecf20Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
10418c2ecf20Sopenharmony_ci		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
10428c2ecf20Sopenharmony_ci		[CLK_BUS_EHCI1]		= &bus_ehci1_clk.common.hw,
10438c2ecf20Sopenharmony_ci		[CLK_BUS_EHCI2]		= &bus_ehci2_clk.common.hw,
10448c2ecf20Sopenharmony_ci		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
10458c2ecf20Sopenharmony_ci		[CLK_BUS_OHCI1]		= &bus_ohci1_clk.common.hw,
10468c2ecf20Sopenharmony_ci		[CLK_BUS_OHCI2]		= &bus_ohci2_clk.common.hw,
10478c2ecf20Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
10488c2ecf20Sopenharmony_ci		[CLK_BUS_MP]		= &bus_mp_clk.common.hw,
10498c2ecf20Sopenharmony_ci		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
10508c2ecf20Sopenharmony_ci		[CLK_BUS_CSI0]		= &bus_csi0_clk.common.hw,
10518c2ecf20Sopenharmony_ci		[CLK_BUS_CSI1]		= &bus_csi1_clk.common.hw,
10528c2ecf20Sopenharmony_ci		[CLK_BUS_HDMI0]		= &bus_hdmi0_clk.common.hw,
10538c2ecf20Sopenharmony_ci		[CLK_BUS_HDMI1]		= &bus_hdmi1_clk.common.hw,
10548c2ecf20Sopenharmony_ci		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
10558c2ecf20Sopenharmony_ci		[CLK_BUS_TVE0]		= &bus_tve0_clk.common.hw,
10568c2ecf20Sopenharmony_ci		[CLK_BUS_TVE1]		= &bus_tve1_clk.common.hw,
10578c2ecf20Sopenharmony_ci		[CLK_BUS_TVE_TOP]	= &bus_tve_top_clk.common.hw,
10588c2ecf20Sopenharmony_ci		[CLK_BUS_GMAC]		= &bus_gmac_clk.common.hw,
10598c2ecf20Sopenharmony_ci		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
10608c2ecf20Sopenharmony_ci		[CLK_BUS_TVD0]		= &bus_tvd0_clk.common.hw,
10618c2ecf20Sopenharmony_ci		[CLK_BUS_TVD1]		= &bus_tvd1_clk.common.hw,
10628c2ecf20Sopenharmony_ci		[CLK_BUS_TVD2]		= &bus_tvd2_clk.common.hw,
10638c2ecf20Sopenharmony_ci		[CLK_BUS_TVD3]		= &bus_tvd3_clk.common.hw,
10648c2ecf20Sopenharmony_ci		[CLK_BUS_TVD_TOP]	= &bus_tvd_top_clk.common.hw,
10658c2ecf20Sopenharmony_ci		[CLK_BUS_TCON_LCD0]	= &bus_tcon_lcd0_clk.common.hw,
10668c2ecf20Sopenharmony_ci		[CLK_BUS_TCON_LCD1]	= &bus_tcon_lcd1_clk.common.hw,
10678c2ecf20Sopenharmony_ci		[CLK_BUS_TCON_TV0]	= &bus_tcon_tv0_clk.common.hw,
10688c2ecf20Sopenharmony_ci		[CLK_BUS_TCON_TV1]	= &bus_tcon_tv1_clk.common.hw,
10698c2ecf20Sopenharmony_ci		[CLK_BUS_TCON_TOP]	= &bus_tcon_top_clk.common.hw,
10708c2ecf20Sopenharmony_ci		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
10718c2ecf20Sopenharmony_ci		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
10728c2ecf20Sopenharmony_ci		[CLK_BUS_AC97]		= &bus_ac97_clk.common.hw,
10738c2ecf20Sopenharmony_ci		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
10748c2ecf20Sopenharmony_ci		[CLK_BUS_IR0]		= &bus_ir0_clk.common.hw,
10758c2ecf20Sopenharmony_ci		[CLK_BUS_IR1]		= &bus_ir1_clk.common.hw,
10768c2ecf20Sopenharmony_ci		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
10778c2ecf20Sopenharmony_ci		[CLK_BUS_KEYPAD]	= &bus_keypad_clk.common.hw,
10788c2ecf20Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
10798c2ecf20Sopenharmony_ci		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
10808c2ecf20Sopenharmony_ci		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
10818c2ecf20Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
10828c2ecf20Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
10838c2ecf20Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
10848c2ecf20Sopenharmony_ci		[CLK_BUS_I2C3]		= &bus_i2c3_clk.common.hw,
10858c2ecf20Sopenharmony_ci		[CLK_BUS_CAN]		= &bus_can_clk.common.hw,
10868c2ecf20Sopenharmony_ci		[CLK_BUS_SCR]		= &bus_scr_clk.common.hw,
10878c2ecf20Sopenharmony_ci		[CLK_BUS_PS20]		= &bus_ps20_clk.common.hw,
10888c2ecf20Sopenharmony_ci		[CLK_BUS_PS21]		= &bus_ps21_clk.common.hw,
10898c2ecf20Sopenharmony_ci		[CLK_BUS_I2C4]		= &bus_i2c4_clk.common.hw,
10908c2ecf20Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
10918c2ecf20Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
10928c2ecf20Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
10938c2ecf20Sopenharmony_ci		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
10948c2ecf20Sopenharmony_ci		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
10958c2ecf20Sopenharmony_ci		[CLK_BUS_UART5]		= &bus_uart5_clk.common.hw,
10968c2ecf20Sopenharmony_ci		[CLK_BUS_UART6]		= &bus_uart6_clk.common.hw,
10978c2ecf20Sopenharmony_ci		[CLK_BUS_UART7]		= &bus_uart7_clk.common.hw,
10988c2ecf20Sopenharmony_ci		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
10998c2ecf20Sopenharmony_ci		[CLK_THS]		= &ths_clk.common.hw,
11008c2ecf20Sopenharmony_ci		[CLK_NAND]		= &nand_clk.common.hw,
11018c2ecf20Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
11028c2ecf20Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
11038c2ecf20Sopenharmony_ci		[CLK_MMC2]		= &mmc2_clk.common.hw,
11048c2ecf20Sopenharmony_ci		[CLK_MMC3]		= &mmc3_clk.common.hw,
11058c2ecf20Sopenharmony_ci		[CLK_TS]		= &ts_clk.common.hw,
11068c2ecf20Sopenharmony_ci		[CLK_CE]		= &ce_clk.common.hw,
11078c2ecf20Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
11088c2ecf20Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
11098c2ecf20Sopenharmony_ci		[CLK_SPI2]		= &spi2_clk.common.hw,
11108c2ecf20Sopenharmony_ci		[CLK_SPI3]		= &spi3_clk.common.hw,
11118c2ecf20Sopenharmony_ci		[CLK_I2S0]		= &i2s0_clk.common.hw,
11128c2ecf20Sopenharmony_ci		[CLK_I2S1]		= &i2s1_clk.common.hw,
11138c2ecf20Sopenharmony_ci		[CLK_I2S2]		= &i2s2_clk.common.hw,
11148c2ecf20Sopenharmony_ci		[CLK_AC97]		= &ac97_clk.common.hw,
11158c2ecf20Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
11168c2ecf20Sopenharmony_ci		[CLK_KEYPAD]		= &keypad_clk.common.hw,
11178c2ecf20Sopenharmony_ci		[CLK_SATA]		= &sata_clk.common.hw,
11188c2ecf20Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
11198c2ecf20Sopenharmony_ci		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
11208c2ecf20Sopenharmony_ci		[CLK_USB_PHY2]		= &usb_phy2_clk.common.hw,
11218c2ecf20Sopenharmony_ci		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
11228c2ecf20Sopenharmony_ci		[CLK_USB_OHCI1]		= &usb_ohci1_clk.common.hw,
11238c2ecf20Sopenharmony_ci		[CLK_USB_OHCI2]		= &usb_ohci2_clk.common.hw,
11248c2ecf20Sopenharmony_ci		[CLK_IR0]		= &ir0_clk.common.hw,
11258c2ecf20Sopenharmony_ci		[CLK_IR1]		= &ir1_clk.common.hw,
11268c2ecf20Sopenharmony_ci		[CLK_DRAM]		= &dram_clk.common.hw,
11278c2ecf20Sopenharmony_ci		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
11288c2ecf20Sopenharmony_ci		[CLK_DRAM_CSI0]		= &dram_csi0_clk.common.hw,
11298c2ecf20Sopenharmony_ci		[CLK_DRAM_CSI1]		= &dram_csi1_clk.common.hw,
11308c2ecf20Sopenharmony_ci		[CLK_DRAM_TS]		= &dram_ts_clk.common.hw,
11318c2ecf20Sopenharmony_ci		[CLK_DRAM_TVD]		= &dram_tvd_clk.common.hw,
11328c2ecf20Sopenharmony_ci		[CLK_DRAM_MP]		= &dram_mp_clk.common.hw,
11338c2ecf20Sopenharmony_ci		[CLK_DRAM_DEINTERLACE]	= &dram_deinterlace_clk.common.hw,
11348c2ecf20Sopenharmony_ci		[CLK_DE]		= &de_clk.common.hw,
11358c2ecf20Sopenharmony_ci		[CLK_MP]		= &mp_clk.common.hw,
11368c2ecf20Sopenharmony_ci		[CLK_TCON_LCD0]		= &tcon_lcd0_clk.common.hw,
11378c2ecf20Sopenharmony_ci		[CLK_TCON_LCD1]		= &tcon_lcd1_clk.common.hw,
11388c2ecf20Sopenharmony_ci		[CLK_TCON_TV0]		= &tcon_tv0_clk.common.hw,
11398c2ecf20Sopenharmony_ci		[CLK_TCON_TV1]		= &tcon_tv1_clk.common.hw,
11408c2ecf20Sopenharmony_ci		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
11418c2ecf20Sopenharmony_ci		[CLK_CSI1_MCLK]		= &csi1_mclk_clk.common.hw,
11428c2ecf20Sopenharmony_ci		[CLK_CSI_SCLK]		= &csi_sclk_clk.common.hw,
11438c2ecf20Sopenharmony_ci		[CLK_CSI0_MCLK]		= &csi0_mclk_clk.common.hw,
11448c2ecf20Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
11458c2ecf20Sopenharmony_ci		[CLK_CODEC]		= &codec_clk.common.hw,
11468c2ecf20Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
11478c2ecf20Sopenharmony_ci		[CLK_HDMI]		= &hdmi_clk.common.hw,
11488c2ecf20Sopenharmony_ci		[CLK_HDMI_SLOW]		= &hdmi_slow_clk.common.hw,
11498c2ecf20Sopenharmony_ci		[CLK_MBUS]		= &mbus_clk.common.hw,
11508c2ecf20Sopenharmony_ci		[CLK_DSI_DPHY]		= &dsi_dphy_clk.common.hw,
11518c2ecf20Sopenharmony_ci		[CLK_TVE0]		= &tve0_clk.common.hw,
11528c2ecf20Sopenharmony_ci		[CLK_TVE1]		= &tve1_clk.common.hw,
11538c2ecf20Sopenharmony_ci		[CLK_TVD0]		= &tvd0_clk.common.hw,
11548c2ecf20Sopenharmony_ci		[CLK_TVD1]		= &tvd1_clk.common.hw,
11558c2ecf20Sopenharmony_ci		[CLK_TVD2]		= &tvd2_clk.common.hw,
11568c2ecf20Sopenharmony_ci		[CLK_TVD3]		= &tvd3_clk.common.hw,
11578c2ecf20Sopenharmony_ci		[CLK_GPU]		= &gpu_clk.common.hw,
11588c2ecf20Sopenharmony_ci		[CLK_OUTA]		= &outa_clk.common.hw,
11598c2ecf20Sopenharmony_ci		[CLK_OUTB]		= &outb_clk.common.hw,
11608c2ecf20Sopenharmony_ci	},
11618c2ecf20Sopenharmony_ci	.num	= CLK_NUMBER,
11628c2ecf20Sopenharmony_ci};
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_cistatic struct ccu_reset_map sun8i_r40_ccu_resets[] = {
11658c2ecf20Sopenharmony_ci	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
11668c2ecf20Sopenharmony_ci	[RST_USB_PHY1]		=  { 0x0cc, BIT(1) },
11678c2ecf20Sopenharmony_ci	[RST_USB_PHY2]		=  { 0x0cc, BIT(2) },
11688c2ecf20Sopenharmony_ci
11698c2ecf20Sopenharmony_ci	[RST_DRAM]		=  { 0x0f4, BIT(31) },
11708c2ecf20Sopenharmony_ci	[RST_MBUS]		=  { 0x0fc, BIT(31) },
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_ci	[RST_BUS_MIPI_DSI]	=  { 0x2c0, BIT(1) },
11738c2ecf20Sopenharmony_ci	[RST_BUS_CE]		=  { 0x2c0, BIT(5) },
11748c2ecf20Sopenharmony_ci	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
11758c2ecf20Sopenharmony_ci	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
11768c2ecf20Sopenharmony_ci	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
11778c2ecf20Sopenharmony_ci	[RST_BUS_MMC2]		=  { 0x2c0, BIT(10) },
11788c2ecf20Sopenharmony_ci	[RST_BUS_MMC3]		=  { 0x2c0, BIT(11) },
11798c2ecf20Sopenharmony_ci	[RST_BUS_NAND]		=  { 0x2c0, BIT(13) },
11808c2ecf20Sopenharmony_ci	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
11818c2ecf20Sopenharmony_ci	[RST_BUS_EMAC]		=  { 0x2c0, BIT(17) },
11828c2ecf20Sopenharmony_ci	[RST_BUS_TS]		=  { 0x2c0, BIT(18) },
11838c2ecf20Sopenharmony_ci	[RST_BUS_HSTIMER]	=  { 0x2c0, BIT(19) },
11848c2ecf20Sopenharmony_ci	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
11858c2ecf20Sopenharmony_ci	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
11868c2ecf20Sopenharmony_ci	[RST_BUS_SPI2]		=  { 0x2c0, BIT(22) },
11878c2ecf20Sopenharmony_ci	[RST_BUS_SPI3]		=  { 0x2c0, BIT(23) },
11888c2ecf20Sopenharmony_ci	[RST_BUS_SATA]		=  { 0x2c0, BIT(24) },
11898c2ecf20Sopenharmony_ci	[RST_BUS_OTG]		=  { 0x2c0, BIT(25) },
11908c2ecf20Sopenharmony_ci	[RST_BUS_EHCI0]		=  { 0x2c0, BIT(26) },
11918c2ecf20Sopenharmony_ci	[RST_BUS_EHCI1]		=  { 0x2c0, BIT(27) },
11928c2ecf20Sopenharmony_ci	[RST_BUS_EHCI2]		=  { 0x2c0, BIT(28) },
11938c2ecf20Sopenharmony_ci	[RST_BUS_OHCI0]		=  { 0x2c0, BIT(29) },
11948c2ecf20Sopenharmony_ci	[RST_BUS_OHCI1]		=  { 0x2c0, BIT(30) },
11958c2ecf20Sopenharmony_ci	[RST_BUS_OHCI2]		=  { 0x2c0, BIT(31) },
11968c2ecf20Sopenharmony_ci
11978c2ecf20Sopenharmony_ci	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
11988c2ecf20Sopenharmony_ci	[RST_BUS_MP]		=  { 0x2c4, BIT(2) },
11998c2ecf20Sopenharmony_ci	[RST_BUS_DEINTERLACE]	=  { 0x2c4, BIT(5) },
12008c2ecf20Sopenharmony_ci	[RST_BUS_CSI0]		=  { 0x2c4, BIT(8) },
12018c2ecf20Sopenharmony_ci	[RST_BUS_CSI1]		=  { 0x2c4, BIT(9) },
12028c2ecf20Sopenharmony_ci	[RST_BUS_HDMI0]		=  { 0x2c4, BIT(10) },
12038c2ecf20Sopenharmony_ci	[RST_BUS_HDMI1]		=  { 0x2c4, BIT(11) },
12048c2ecf20Sopenharmony_ci	[RST_BUS_DE]		=  { 0x2c4, BIT(12) },
12058c2ecf20Sopenharmony_ci	[RST_BUS_TVE0]		=  { 0x2c4, BIT(13) },
12068c2ecf20Sopenharmony_ci	[RST_BUS_TVE1]		=  { 0x2c4, BIT(14) },
12078c2ecf20Sopenharmony_ci	[RST_BUS_TVE_TOP]	=  { 0x2c4, BIT(15) },
12088c2ecf20Sopenharmony_ci	[RST_BUS_GMAC]		=  { 0x2c4, BIT(17) },
12098c2ecf20Sopenharmony_ci	[RST_BUS_GPU]		=  { 0x2c4, BIT(20) },
12108c2ecf20Sopenharmony_ci	[RST_BUS_TVD0]		=  { 0x2c4, BIT(21) },
12118c2ecf20Sopenharmony_ci	[RST_BUS_TVD1]		=  { 0x2c4, BIT(22) },
12128c2ecf20Sopenharmony_ci	[RST_BUS_TVD2]		=  { 0x2c4, BIT(23) },
12138c2ecf20Sopenharmony_ci	[RST_BUS_TVD3]		=  { 0x2c4, BIT(24) },
12148c2ecf20Sopenharmony_ci	[RST_BUS_TVD_TOP]	=  { 0x2c4, BIT(25) },
12158c2ecf20Sopenharmony_ci	[RST_BUS_TCON_LCD0]	=  { 0x2c4, BIT(26) },
12168c2ecf20Sopenharmony_ci	[RST_BUS_TCON_LCD1]	=  { 0x2c4, BIT(27) },
12178c2ecf20Sopenharmony_ci	[RST_BUS_TCON_TV0]	=  { 0x2c4, BIT(28) },
12188c2ecf20Sopenharmony_ci	[RST_BUS_TCON_TV1]	=  { 0x2c4, BIT(29) },
12198c2ecf20Sopenharmony_ci	[RST_BUS_TCON_TOP]	=  { 0x2c4, BIT(30) },
12208c2ecf20Sopenharmony_ci	[RST_BUS_DBG]		=  { 0x2c4, BIT(31) },
12218c2ecf20Sopenharmony_ci
12228c2ecf20Sopenharmony_ci	[RST_BUS_LVDS]		=  { 0x2c8, BIT(0) },
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
12258c2ecf20Sopenharmony_ci	[RST_BUS_SPDIF]		=  { 0x2d0, BIT(1) },
12268c2ecf20Sopenharmony_ci	[RST_BUS_AC97]		=  { 0x2d0, BIT(2) },
12278c2ecf20Sopenharmony_ci	[RST_BUS_IR0]		=  { 0x2d0, BIT(6) },
12288c2ecf20Sopenharmony_ci	[RST_BUS_IR1]		=  { 0x2d0, BIT(7) },
12298c2ecf20Sopenharmony_ci	[RST_BUS_THS]		=  { 0x2d0, BIT(8) },
12308c2ecf20Sopenharmony_ci	[RST_BUS_KEYPAD]	=  { 0x2d0, BIT(10) },
12318c2ecf20Sopenharmony_ci	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
12328c2ecf20Sopenharmony_ci	[RST_BUS_I2S1]		=  { 0x2d0, BIT(13) },
12338c2ecf20Sopenharmony_ci	[RST_BUS_I2S2]		=  { 0x2d0, BIT(14) },
12348c2ecf20Sopenharmony_ci
12358c2ecf20Sopenharmony_ci	[RST_BUS_I2C0]		=  { 0x2d8, BIT(0) },
12368c2ecf20Sopenharmony_ci	[RST_BUS_I2C1]		=  { 0x2d8, BIT(1) },
12378c2ecf20Sopenharmony_ci	[RST_BUS_I2C2]		=  { 0x2d8, BIT(2) },
12388c2ecf20Sopenharmony_ci	[RST_BUS_I2C3]		=  { 0x2d8, BIT(3) },
12398c2ecf20Sopenharmony_ci	[RST_BUS_CAN]		=  { 0x2d8, BIT(4) },
12408c2ecf20Sopenharmony_ci	[RST_BUS_SCR]		=  { 0x2d8, BIT(5) },
12418c2ecf20Sopenharmony_ci	[RST_BUS_PS20]		=  { 0x2d8, BIT(6) },
12428c2ecf20Sopenharmony_ci	[RST_BUS_PS21]		=  { 0x2d8, BIT(7) },
12438c2ecf20Sopenharmony_ci	[RST_BUS_I2C4]		=  { 0x2d8, BIT(15) },
12448c2ecf20Sopenharmony_ci	[RST_BUS_UART0]		=  { 0x2d8, BIT(16) },
12458c2ecf20Sopenharmony_ci	[RST_BUS_UART1]		=  { 0x2d8, BIT(17) },
12468c2ecf20Sopenharmony_ci	[RST_BUS_UART2]		=  { 0x2d8, BIT(18) },
12478c2ecf20Sopenharmony_ci	[RST_BUS_UART3]		=  { 0x2d8, BIT(19) },
12488c2ecf20Sopenharmony_ci	[RST_BUS_UART4]		=  { 0x2d8, BIT(20) },
12498c2ecf20Sopenharmony_ci	[RST_BUS_UART5]		=  { 0x2d8, BIT(21) },
12508c2ecf20Sopenharmony_ci	[RST_BUS_UART6]		=  { 0x2d8, BIT(22) },
12518c2ecf20Sopenharmony_ci	[RST_BUS_UART7]		=  { 0x2d8, BIT(23) },
12528c2ecf20Sopenharmony_ci};
12538c2ecf20Sopenharmony_ci
12548c2ecf20Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_r40_ccu_desc = {
12558c2ecf20Sopenharmony_ci	.ccu_clks	= sun8i_r40_ccu_clks,
12568c2ecf20Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(sun8i_r40_ccu_clks),
12578c2ecf20Sopenharmony_ci
12588c2ecf20Sopenharmony_ci	.hw_clks	= &sun8i_r40_hw_clks,
12598c2ecf20Sopenharmony_ci
12608c2ecf20Sopenharmony_ci	.resets		= sun8i_r40_ccu_resets,
12618c2ecf20Sopenharmony_ci	.num_resets	= ARRAY_SIZE(sun8i_r40_ccu_resets),
12628c2ecf20Sopenharmony_ci};
12638c2ecf20Sopenharmony_ci
12648c2ecf20Sopenharmony_cistatic struct ccu_pll_nb sun8i_r40_pll_cpu_nb = {
12658c2ecf20Sopenharmony_ci	.common	= &pll_cpu_clk.common,
12668c2ecf20Sopenharmony_ci	/* copy from pll_cpu_clk */
12678c2ecf20Sopenharmony_ci	.enable	= BIT(31),
12688c2ecf20Sopenharmony_ci	.lock	= BIT(28),
12698c2ecf20Sopenharmony_ci};
12708c2ecf20Sopenharmony_ci
12718c2ecf20Sopenharmony_cistatic struct ccu_mux_nb sun8i_r40_cpu_nb = {
12728c2ecf20Sopenharmony_ci	.common		= &cpu_clk.common,
12738c2ecf20Sopenharmony_ci	.cm		= &cpu_clk.mux,
12748c2ecf20Sopenharmony_ci	.delay_us	= 1, /* > 8 clock cycles at 24 MHz */
12758c2ecf20Sopenharmony_ci	.bypass_index	= 1, /* index of 24 MHz oscillator */
12768c2ecf20Sopenharmony_ci};
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_ci/*
12798c2ecf20Sopenharmony_ci * Add a regmap for the GMAC driver (dwmac-sun8i) to access the
12808c2ecf20Sopenharmony_ci * GMAC configuration register.
12818c2ecf20Sopenharmony_ci * Only this register is allowed to be written, in order to
12828c2ecf20Sopenharmony_ci * prevent overriding critical clock configuration.
12838c2ecf20Sopenharmony_ci */
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_ci#define SUN8I_R40_GMAC_CFG_REG 0x164
12868c2ecf20Sopenharmony_cistatic bool sun8i_r40_ccu_regmap_accessible_reg(struct device *dev,
12878c2ecf20Sopenharmony_ci						unsigned int reg)
12888c2ecf20Sopenharmony_ci{
12898c2ecf20Sopenharmony_ci	if (reg == SUN8I_R40_GMAC_CFG_REG)
12908c2ecf20Sopenharmony_ci		return true;
12918c2ecf20Sopenharmony_ci	return false;
12928c2ecf20Sopenharmony_ci}
12938c2ecf20Sopenharmony_ci
12948c2ecf20Sopenharmony_cistatic struct regmap_config sun8i_r40_ccu_regmap_config = {
12958c2ecf20Sopenharmony_ci	.reg_bits	= 32,
12968c2ecf20Sopenharmony_ci	.val_bits	= 32,
12978c2ecf20Sopenharmony_ci	.reg_stride	= 4,
12988c2ecf20Sopenharmony_ci	.max_register	= 0x320, /* PLL_LOCK_CTRL_REG */
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	/* other devices have no business accessing other registers */
13018c2ecf20Sopenharmony_ci	.readable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
13028c2ecf20Sopenharmony_ci	.writeable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
13038c2ecf20Sopenharmony_ci};
13048c2ecf20Sopenharmony_ci
13058c2ecf20Sopenharmony_ci#define SUN8I_R40_SYS_32K_CLK_REG 0x310
13068c2ecf20Sopenharmony_ci#define SUN8I_R40_SYS_32K_CLK_KEY (0x16AA << 16)
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_cistatic int sun8i_r40_ccu_probe(struct platform_device *pdev)
13098c2ecf20Sopenharmony_ci{
13108c2ecf20Sopenharmony_ci	struct resource *res;
13118c2ecf20Sopenharmony_ci	struct regmap *regmap;
13128c2ecf20Sopenharmony_ci	void __iomem *reg;
13138c2ecf20Sopenharmony_ci	u32 val;
13148c2ecf20Sopenharmony_ci	int ret;
13158c2ecf20Sopenharmony_ci
13168c2ecf20Sopenharmony_ci	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
13178c2ecf20Sopenharmony_ci	reg = devm_ioremap_resource(&pdev->dev, res);
13188c2ecf20Sopenharmony_ci	if (IS_ERR(reg))
13198c2ecf20Sopenharmony_ci		return PTR_ERR(reg);
13208c2ecf20Sopenharmony_ci
13218c2ecf20Sopenharmony_ci	/* Force the PLL-Audio-1x divider to 1 */
13228c2ecf20Sopenharmony_ci	val = readl(reg + SUN8I_R40_PLL_AUDIO_REG);
13238c2ecf20Sopenharmony_ci	val &= ~GENMASK(19, 16);
13248c2ecf20Sopenharmony_ci	writel(val | (0 << 16), reg + SUN8I_R40_PLL_AUDIO_REG);
13258c2ecf20Sopenharmony_ci
13268c2ecf20Sopenharmony_ci	/* Force PLL-MIPI to MIPI mode */
13278c2ecf20Sopenharmony_ci	val = readl(reg + SUN8I_R40_PLL_MIPI_REG);
13288c2ecf20Sopenharmony_ci	val &= ~BIT(16);
13298c2ecf20Sopenharmony_ci	writel(val, reg + SUN8I_R40_PLL_MIPI_REG);
13308c2ecf20Sopenharmony_ci
13318c2ecf20Sopenharmony_ci	/* Force OHCI 12M parent to 12M divided from 48M */
13328c2ecf20Sopenharmony_ci	val = readl(reg + SUN8I_R40_USB_CLK_REG);
13338c2ecf20Sopenharmony_ci	val &= ~GENMASK(25, 20);
13348c2ecf20Sopenharmony_ci	writel(val, reg + SUN8I_R40_USB_CLK_REG);
13358c2ecf20Sopenharmony_ci
13368c2ecf20Sopenharmony_ci	/*
13378c2ecf20Sopenharmony_ci	 * Force SYS 32k (otherwise known as LOSC throughout the CCU)
13388c2ecf20Sopenharmony_ci	 * clock parent to LOSC output from RTC module instead of the
13398c2ecf20Sopenharmony_ci	 * CCU's internal RC oscillator divided output.
13408c2ecf20Sopenharmony_ci	 */
13418c2ecf20Sopenharmony_ci	writel(SUN8I_R40_SYS_32K_CLK_KEY | BIT(8),
13428c2ecf20Sopenharmony_ci	       reg + SUN8I_R40_SYS_32K_CLK_REG);
13438c2ecf20Sopenharmony_ci
13448c2ecf20Sopenharmony_ci	regmap = devm_regmap_init_mmio(&pdev->dev, reg,
13458c2ecf20Sopenharmony_ci				       &sun8i_r40_ccu_regmap_config);
13468c2ecf20Sopenharmony_ci	if (IS_ERR(regmap))
13478c2ecf20Sopenharmony_ci		return PTR_ERR(regmap);
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_r40_ccu_desc);
13508c2ecf20Sopenharmony_ci	if (ret)
13518c2ecf20Sopenharmony_ci		return ret;
13528c2ecf20Sopenharmony_ci
13538c2ecf20Sopenharmony_ci	/* Gate then ungate PLL CPU after any rate changes */
13548c2ecf20Sopenharmony_ci	ccu_pll_notifier_register(&sun8i_r40_pll_cpu_nb);
13558c2ecf20Sopenharmony_ci
13568c2ecf20Sopenharmony_ci	/* Reparent CPU during PLL CPU rate changes */
13578c2ecf20Sopenharmony_ci	ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk,
13588c2ecf20Sopenharmony_ci				  &sun8i_r40_cpu_nb);
13598c2ecf20Sopenharmony_ci
13608c2ecf20Sopenharmony_ci	return 0;
13618c2ecf20Sopenharmony_ci}
13628c2ecf20Sopenharmony_ci
13638c2ecf20Sopenharmony_cistatic const struct of_device_id sun8i_r40_ccu_ids[] = {
13648c2ecf20Sopenharmony_ci	{ .compatible = "allwinner,sun8i-r40-ccu" },
13658c2ecf20Sopenharmony_ci	{ }
13668c2ecf20Sopenharmony_ci};
13678c2ecf20Sopenharmony_ci
13688c2ecf20Sopenharmony_cistatic struct platform_driver sun8i_r40_ccu_driver = {
13698c2ecf20Sopenharmony_ci	.probe	= sun8i_r40_ccu_probe,
13708c2ecf20Sopenharmony_ci	.driver	= {
13718c2ecf20Sopenharmony_ci		.name	= "sun8i-r40-ccu",
13728c2ecf20Sopenharmony_ci		.of_match_table	= sun8i_r40_ccu_ids,
13738c2ecf20Sopenharmony_ci	},
13748c2ecf20Sopenharmony_ci};
13758c2ecf20Sopenharmony_cibuiltin_platform_driver(sun8i_r40_ccu_driver);
1376