18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2016 Maxime Ripard. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
78c2ecf20Sopenharmony_ci#include <linux/io.h>
88c2ecf20Sopenharmony_ci#include <linux/of_address.h>
98c2ecf20Sopenharmony_ci#include <linux/platform_device.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-sun50i-a64.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic struct ccu_nkmp pll_cpux_clk = {
278c2ecf20Sopenharmony_ci	.enable		= BIT(31),
288c2ecf20Sopenharmony_ci	.lock		= BIT(28),
298c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
308c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
318c2ecf20Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 2),
328c2ecf20Sopenharmony_ci	.p		= _SUNXI_CCU_DIV_MAX(16, 2, 4),
338c2ecf20Sopenharmony_ci	.common		= {
348c2ecf20Sopenharmony_ci		.reg		= 0x000,
358c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpux",
368c2ecf20Sopenharmony_ci					      "osc24M",
378c2ecf20Sopenharmony_ci					      &ccu_nkmp_ops,
388c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
398c2ecf20Sopenharmony_ci	},
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/*
438c2ecf20Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
448c2ecf20Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true
458c2ecf20Sopenharmony_ci * pll audio).
468c2ecf20Sopenharmony_ci *
478c2ecf20Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL,
488c2ecf20Sopenharmony_ci * we have to use specific dividers. This means the variable divider
498c2ecf20Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock
508c2ecf20Sopenharmony_ci * rates we support through this mechanism. So we now hard code the
518c2ecf20Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer
528c2ecf20Sopenharmony_ci * match the clock names.
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_ci#define SUN50I_A64_PLL_AUDIO_REG	0x008
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = {
578c2ecf20Sopenharmony_ci	{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
588c2ecf20Sopenharmony_ci	{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
628c2ecf20Sopenharmony_ci				       "osc24M", 0x008,
638c2ecf20Sopenharmony_ci				       8, 7,	/* N */
648c2ecf20Sopenharmony_ci				       0, 5,	/* M */
658c2ecf20Sopenharmony_ci				       pll_audio_sdm_table, BIT(24),
668c2ecf20Sopenharmony_ci				       0x284, BIT(31),
678c2ecf20Sopenharmony_ci				       BIT(31),	/* gate */
688c2ecf20Sopenharmony_ci				       BIT(28),	/* lock */
698c2ecf20Sopenharmony_ci				       CLK_SET_RATE_UNGATE);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
728c2ecf20Sopenharmony_ci						"osc24M", 0x010,
738c2ecf20Sopenharmony_ci						192000000,	/* Minimum rate */
748c2ecf20Sopenharmony_ci						1008000000,	/* Maximum rate */
758c2ecf20Sopenharmony_ci						8, 7,		/* N */
768c2ecf20Sopenharmony_ci						0, 4,		/* M */
778c2ecf20Sopenharmony_ci						BIT(24),	/* frac enable */
788c2ecf20Sopenharmony_ci						BIT(25),	/* frac select */
798c2ecf20Sopenharmony_ci						270000000,	/* frac rate 0 */
808c2ecf20Sopenharmony_ci						297000000,	/* frac rate 1 */
818c2ecf20Sopenharmony_ci						BIT(31),	/* gate */
828c2ecf20Sopenharmony_ci						BIT(28),	/* lock */
838c2ecf20Sopenharmony_ci						CLK_SET_RATE_UNGATE);
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
868c2ecf20Sopenharmony_ci					"osc24M", 0x018,
878c2ecf20Sopenharmony_ci					8, 7,		/* N */
888c2ecf20Sopenharmony_ci					0, 4,		/* M */
898c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
908c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
918c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
928c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
938c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
948c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
958c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
988c2ecf20Sopenharmony_ci				    "osc24M", 0x020,
998c2ecf20Sopenharmony_ci				    8, 5,	/* N */
1008c2ecf20Sopenharmony_ci				    4, 2,	/* K */
1018c2ecf20Sopenharmony_ci				    0, 2,	/* M */
1028c2ecf20Sopenharmony_ci				    BIT(31),	/* gate */
1038c2ecf20Sopenharmony_ci				    BIT(28),	/* lock */
1048c2ecf20Sopenharmony_ci				    CLK_SET_RATE_UNGATE);
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistatic struct ccu_nk pll_periph0_clk = {
1078c2ecf20Sopenharmony_ci	.enable		= BIT(31),
1088c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1098c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1108c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT_MIN(4, 2, 2),
1118c2ecf20Sopenharmony_ci	.fixed_post_div	= 2,
1128c2ecf20Sopenharmony_ci	.common		= {
1138c2ecf20Sopenharmony_ci		.reg		= 0x028,
1148c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1158c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0", "osc24M",
1168c2ecf20Sopenharmony_ci					      &ccu_nk_ops, CLK_SET_RATE_UNGATE),
1178c2ecf20Sopenharmony_ci	},
1188c2ecf20Sopenharmony_ci};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_cistatic struct ccu_nk pll_periph1_clk = {
1218c2ecf20Sopenharmony_ci	.enable		= BIT(31),
1228c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1238c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1248c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT_MIN(4, 2, 2),
1258c2ecf20Sopenharmony_ci	.fixed_post_div	= 2,
1268c2ecf20Sopenharmony_ci	.common		= {
1278c2ecf20Sopenharmony_ci		.reg		= 0x02c,
1288c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
1298c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph1", "osc24M",
1308c2ecf20Sopenharmony_ci					      &ccu_nk_ops, CLK_SET_RATE_UNGATE),
1318c2ecf20Sopenharmony_ci	},
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1",
1358c2ecf20Sopenharmony_ci						"osc24M", 0x030,
1368c2ecf20Sopenharmony_ci						192000000,	/* Minimum rate */
1378c2ecf20Sopenharmony_ci						1008000000,	/* Maximum rate */
1388c2ecf20Sopenharmony_ci						8, 7,		/* N */
1398c2ecf20Sopenharmony_ci						0, 4,		/* M */
1408c2ecf20Sopenharmony_ci						BIT(24),	/* frac enable */
1418c2ecf20Sopenharmony_ci						BIT(25),	/* frac select */
1428c2ecf20Sopenharmony_ci						270000000,	/* frac rate 0 */
1438c2ecf20Sopenharmony_ci						297000000,	/* frac rate 1 */
1448c2ecf20Sopenharmony_ci						BIT(31),	/* gate */
1458c2ecf20Sopenharmony_ci						BIT(28),	/* lock */
1468c2ecf20Sopenharmony_ci						CLK_SET_RATE_UNGATE);
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
1498c2ecf20Sopenharmony_ci					"osc24M", 0x038,
1508c2ecf20Sopenharmony_ci					8, 7,		/* N */
1518c2ecf20Sopenharmony_ci					0, 4,		/* M */
1528c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
1538c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
1548c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
1558c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
1568c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
1578c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
1588c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/*
1618c2ecf20Sopenharmony_ci * The output function can be changed to something more complex that
1628c2ecf20Sopenharmony_ci * we do not handle yet.
1638c2ecf20Sopenharmony_ci *
1648c2ecf20Sopenharmony_ci * Hardcode the mode so that we don't fall in that case.
1658c2ecf20Sopenharmony_ci */
1668c2ecf20Sopenharmony_ci#define SUN50I_A64_PLL_MIPI_REG		0x040
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic struct ccu_nkm pll_mipi_clk = {
1698c2ecf20Sopenharmony_ci	/*
1708c2ecf20Sopenharmony_ci	 * The bit 23 and 22 are called "LDO{1,2}_EN" on the SoC's
1718c2ecf20Sopenharmony_ci	 * user manual, and by experiments the PLL doesn't work without
1728c2ecf20Sopenharmony_ci	 * these bits toggled.
1738c2ecf20Sopenharmony_ci	 */
1748c2ecf20Sopenharmony_ci	.enable		= BIT(31) | BIT(23) | BIT(22),
1758c2ecf20Sopenharmony_ci	.lock		= BIT(28),
1768c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 4),
1778c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT_MIN(4, 2, 2),
1788c2ecf20Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 4),
1798c2ecf20Sopenharmony_ci	.common		= {
1808c2ecf20Sopenharmony_ci		.reg		= 0x040,
1818c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-mipi", "pll-video0",
1828c2ecf20Sopenharmony_ci					      &ccu_nkm_ops, CLK_SET_RATE_UNGATE),
1838c2ecf20Sopenharmony_ci	},
1848c2ecf20Sopenharmony_ci};
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_hsic_clk, "pll-hsic",
1878c2ecf20Sopenharmony_ci					"osc24M", 0x044,
1888c2ecf20Sopenharmony_ci					8, 7,		/* N */
1898c2ecf20Sopenharmony_ci					0, 4,		/* M */
1908c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
1918c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
1928c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
1938c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
1948c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
1958c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
1968c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
1998c2ecf20Sopenharmony_ci					"osc24M", 0x048,
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_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
2118c2ecf20Sopenharmony_ci				   "osc24M", 0x04c,
2128c2ecf20Sopenharmony_ci				   8, 7,	/* N */
2138c2ecf20Sopenharmony_ci				   0, 2,	/* M */
2148c2ecf20Sopenharmony_ci				   BIT(31),	/* gate */
2158c2ecf20Sopenharmony_ci				   BIT(28),	/* lock */
2168c2ecf20Sopenharmony_ci				   CLK_SET_RATE_UNGATE);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic const char * const cpux_parents[] = { "osc32k", "osc24M",
2198c2ecf20Sopenharmony_ci					     "pll-cpux", "pll-cpux" };
2208c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
2218c2ecf20Sopenharmony_ci		     0x050, 16, 2, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M",
2268c2ecf20Sopenharmony_ci					     "axi", "pll-periph0" };
2278c2ecf20Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = {
2288c2ecf20Sopenharmony_ci	{ .index = 3, .shift = 6, .width = 2 },
2298c2ecf20Sopenharmony_ci};
2308c2ecf20Sopenharmony_cistatic struct ccu_div ahb1_clk = {
2318c2ecf20Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	.mux		= {
2348c2ecf20Sopenharmony_ci		.shift	= 12,
2358c2ecf20Sopenharmony_ci		.width	= 2,
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci		.var_predivs	= ahb1_predivs,
2388c2ecf20Sopenharmony_ci		.n_var_predivs	= ARRAY_SIZE(ahb1_predivs),
2398c2ecf20Sopenharmony_ci	},
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	.common		= {
2428c2ecf20Sopenharmony_ci		.reg		= 0x054,
2438c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_VARIABLE_PREDIV,
2448c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb1",
2458c2ecf20Sopenharmony_ci						      ahb1_parents,
2468c2ecf20Sopenharmony_ci						      &ccu_div_ops,
2478c2ecf20Sopenharmony_ci						      0),
2488c2ecf20Sopenharmony_ci	},
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = {
2528c2ecf20Sopenharmony_ci	{ .val = 0, .div = 2 },
2538c2ecf20Sopenharmony_ci	{ .val = 1, .div = 2 },
2548c2ecf20Sopenharmony_ci	{ .val = 2, .div = 4 },
2558c2ecf20Sopenharmony_ci	{ .val = 3, .div = 8 },
2568c2ecf20Sopenharmony_ci	{ /* Sentinel */ },
2578c2ecf20Sopenharmony_ci};
2588c2ecf20Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
2598c2ecf20Sopenharmony_ci			   0x054, 8, 2, apb1_div_table, 0);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M",
2628c2ecf20Sopenharmony_ci					     "pll-periph0-2x",
2638c2ecf20Sopenharmony_ci					     "pll-periph0-2x" };
2648c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
2658c2ecf20Sopenharmony_ci			     0, 5,	/* M */
2668c2ecf20Sopenharmony_ci			     16, 2,	/* P */
2678c2ecf20Sopenharmony_ci			     24, 2,	/* mux */
2688c2ecf20Sopenharmony_ci			     0);
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_cistatic const char * const ahb2_parents[] = { "ahb1", "pll-periph0" };
2718c2ecf20Sopenharmony_cistatic const struct ccu_mux_fixed_prediv ahb2_fixed_predivs[] = {
2728c2ecf20Sopenharmony_ci	{ .index = 1, .div = 2 },
2738c2ecf20Sopenharmony_ci};
2748c2ecf20Sopenharmony_cistatic struct ccu_mux ahb2_clk = {
2758c2ecf20Sopenharmony_ci	.mux		= {
2768c2ecf20Sopenharmony_ci		.shift	= 0,
2778c2ecf20Sopenharmony_ci		.width	= 1,
2788c2ecf20Sopenharmony_ci		.fixed_predivs	= ahb2_fixed_predivs,
2798c2ecf20Sopenharmony_ci		.n_predivs	= ARRAY_SIZE(ahb2_fixed_predivs),
2808c2ecf20Sopenharmony_ci	},
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	.common		= {
2838c2ecf20Sopenharmony_ci		.reg		= 0x05c,
2848c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_PREDIV,
2858c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb2",
2868c2ecf20Sopenharmony_ci						      ahb2_parents,
2878c2ecf20Sopenharmony_ci						      &ccu_mux_ops,
2888c2ecf20Sopenharmony_ci						      0),
2898c2ecf20Sopenharmony_ci	},
2908c2ecf20Sopenharmony_ci};
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk,	"bus-mipi-dsi",	"ahb1",
2938c2ecf20Sopenharmony_ci		      0x060, BIT(1), 0);
2948c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk,	"bus-ce",	"ahb1",
2958c2ecf20Sopenharmony_ci		      0x060, BIT(5), 0);
2968c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb1",
2978c2ecf20Sopenharmony_ci		      0x060, BIT(6), 0);
2988c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb1",
2998c2ecf20Sopenharmony_ci		      0x060, BIT(8), 0);
3008c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb1",
3018c2ecf20Sopenharmony_ci		      0x060, BIT(9), 0);
3028c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk,	"bus-mmc2",	"ahb1",
3038c2ecf20Sopenharmony_ci		      0x060, BIT(10), 0);
3048c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk,	"bus-nand",	"ahb1",
3058c2ecf20Sopenharmony_ci		      0x060, BIT(13), 0);
3068c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb1",
3078c2ecf20Sopenharmony_ci		      0x060, BIT(14), 0);
3088c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk,	"bus-emac",	"ahb2",
3098c2ecf20Sopenharmony_ci		      0x060, BIT(17), 0);
3108c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ts_clk,	"bus-ts",	"ahb1",
3118c2ecf20Sopenharmony_ci		      0x060, BIT(18), 0);
3128c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
3138c2ecf20Sopenharmony_ci		      0x060, BIT(19), 0);
3148c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb1",
3158c2ecf20Sopenharmony_ci		      0x060, BIT(20), 0);
3168c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb1",
3178c2ecf20Sopenharmony_ci		      0x060, BIT(21), 0);
3188c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb1",
3198c2ecf20Sopenharmony_ci		      0x060, BIT(23), 0);
3208c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk,	"bus-ehci0",	"ahb1",
3218c2ecf20Sopenharmony_ci		      0x060, BIT(24), 0);
3228c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk,	"bus-ehci1",	"ahb2",
3238c2ecf20Sopenharmony_ci		      0x060, BIT(25), 0);
3248c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk,	"bus-ohci0",	"ahb1",
3258c2ecf20Sopenharmony_ci		      0x060, BIT(28), 0);
3268c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci1_clk,	"bus-ohci1",	"ahb2",
3278c2ecf20Sopenharmony_ci		      0x060, BIT(29), 0);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
3308c2ecf20Sopenharmony_ci		      0x064, BIT(0), 0);
3318c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon0_clk,	"bus-tcon0",	"ahb1",
3328c2ecf20Sopenharmony_ci		      0x064, BIT(3), 0);
3338c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon1_clk,	"bus-tcon1",	"ahb1",
3348c2ecf20Sopenharmony_ci		      0x064, BIT(4), 0);
3358c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb1",
3368c2ecf20Sopenharmony_ci		      0x064, BIT(5), 0);
3378c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk,	"bus-csi",	"ahb1",
3388c2ecf20Sopenharmony_ci		      0x064, BIT(8), 0);
3398c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi_clk,	"bus-hdmi",	"ahb1",
3408c2ecf20Sopenharmony_ci		      0x064, BIT(11), 0);
3418c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
3428c2ecf20Sopenharmony_ci		      0x064, BIT(12), 0);
3438c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
3448c2ecf20Sopenharmony_ci		      0x064, BIT(20), 0);
3458c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
3468c2ecf20Sopenharmony_ci		      0x064, BIT(21), 0);
3478c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
3488c2ecf20Sopenharmony_ci		      0x064, BIT(22), 0);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb1",
3518c2ecf20Sopenharmony_ci		      0x068, BIT(0), 0);
3528c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk,	"bus-spdif",	"apb1",
3538c2ecf20Sopenharmony_ci		      0x068, BIT(1), 0);
3548c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb1",
3558c2ecf20Sopenharmony_ci		      0x068, BIT(5), 0);
3568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ths_clk,	"bus-ths",	"apb1",
3578c2ecf20Sopenharmony_ci		      0x068, BIT(8), 0);
3588c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb1",
3598c2ecf20Sopenharmony_ci		      0x068, BIT(12), 0);
3608c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk,	"bus-i2s1",	"apb1",
3618c2ecf20Sopenharmony_ci		      0x068, BIT(13), 0);
3628c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk,	"bus-i2s2",	"apb1",
3638c2ecf20Sopenharmony_ci		      0x068, BIT(14), 0);
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb2",
3668c2ecf20Sopenharmony_ci		      0x06c, BIT(0), 0);
3678c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb2",
3688c2ecf20Sopenharmony_ci		      0x06c, BIT(1), 0);
3698c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb2",
3708c2ecf20Sopenharmony_ci		      0x06c, BIT(2), 0);
3718c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_scr_clk,	"bus-scr",	"apb2",
3728c2ecf20Sopenharmony_ci		      0x06c, BIT(5), 0);
3738c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb2",
3748c2ecf20Sopenharmony_ci		      0x06c, BIT(16), 0);
3758c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb2",
3768c2ecf20Sopenharmony_ci		      0x06c, BIT(17), 0);
3778c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
3788c2ecf20Sopenharmony_ci		      0x06c, BIT(18), 0);
3798c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
3808c2ecf20Sopenharmony_ci		      0x06c, BIT(19), 0);
3818c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk,	"bus-uart4",	"apb2",
3828c2ecf20Sopenharmony_ci		      0x06c, BIT(20), 0);
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk,	"bus-dbg",	"ahb1",
3858c2ecf20Sopenharmony_ci		      0x070, BIT(7), 0);
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_cistatic struct clk_div_table ths_div_table[] = {
3888c2ecf20Sopenharmony_ci	{ .val = 0, .div = 1 },
3898c2ecf20Sopenharmony_ci	{ .val = 1, .div = 2 },
3908c2ecf20Sopenharmony_ci	{ .val = 2, .div = 4 },
3918c2ecf20Sopenharmony_ci	{ .val = 3, .div = 6 },
3928c2ecf20Sopenharmony_ci	{ /* Sentinel */ },
3938c2ecf20Sopenharmony_ci};
3948c2ecf20Sopenharmony_cistatic const char * const ths_parents[] = { "osc24M" };
3958c2ecf20Sopenharmony_cistatic struct ccu_div ths_clk = {
3968c2ecf20Sopenharmony_ci	.enable	= BIT(31),
3978c2ecf20Sopenharmony_ci	.div	= _SUNXI_CCU_DIV_TABLE(0, 2, ths_div_table),
3988c2ecf20Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX(24, 2),
3998c2ecf20Sopenharmony_ci	.common	= {
4008c2ecf20Sopenharmony_ci		.reg		= 0x074,
4018c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ths",
4028c2ecf20Sopenharmony_ci						      ths_parents,
4038c2ecf20Sopenharmony_ci						      &ccu_div_ops,
4048c2ecf20Sopenharmony_ci						      0),
4058c2ecf20Sopenharmony_ci	},
4068c2ecf20Sopenharmony_ci};
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
4098c2ecf20Sopenharmony_ci						     "pll-periph1" };
4108c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
4118c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4128c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4138c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
4148c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4158c2ecf20Sopenharmony_ci				  0);
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/*
4188c2ecf20Sopenharmony_ci * MMC clocks are the new timing mode (see A83T & H3) variety, but without
4198c2ecf20Sopenharmony_ci * the mode switch. This means they have a 2x post divider between the clock
4208c2ecf20Sopenharmony_ci * and the MMC module. This is not documented in the manual, but is taken
4218c2ecf20Sopenharmony_ci * into consideration when setting the mmc module clocks in the BSP kernel.
4228c2ecf20Sopenharmony_ci * Without it, MMC performance is degraded.
4238c2ecf20Sopenharmony_ci *
4248c2ecf20Sopenharmony_ci * We model it here to be consistent with other SoCs supporting this mode.
4258c2ecf20Sopenharmony_ci * The alternative would be to add the 2x multiplier when setting the MMC
4268c2ecf20Sopenharmony_ci * module clock in the MMC driver, just for the A64.
4278c2ecf20Sopenharmony_ci */
4288c2ecf20Sopenharmony_cistatic const char * const mmc_default_parents[] = { "osc24M", "pll-periph0-2x",
4298c2ecf20Sopenharmony_ci						    "pll-periph1-2x" };
4308c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0",
4318c2ecf20Sopenharmony_ci					  mmc_default_parents, 0x088,
4328c2ecf20Sopenharmony_ci					  0, 4,		/* M */
4338c2ecf20Sopenharmony_ci					  16, 2,	/* P */
4348c2ecf20Sopenharmony_ci					  24, 2,	/* mux */
4358c2ecf20Sopenharmony_ci					  BIT(31),	/* gate */
4368c2ecf20Sopenharmony_ci					  2,		/* post-div */
4378c2ecf20Sopenharmony_ci					  0);
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1",
4408c2ecf20Sopenharmony_ci					  mmc_default_parents, 0x08c,
4418c2ecf20Sopenharmony_ci					  0, 4,		/* M */
4428c2ecf20Sopenharmony_ci					  16, 2,	/* P */
4438c2ecf20Sopenharmony_ci					  24, 2,	/* mux */
4448c2ecf20Sopenharmony_ci					  BIT(31),	/* gate */
4458c2ecf20Sopenharmony_ci					  2,		/* post-div */
4468c2ecf20Sopenharmony_ci					  0);
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2",
4498c2ecf20Sopenharmony_ci					  mmc_default_parents, 0x090,
4508c2ecf20Sopenharmony_ci					  0, 4,		/* M */
4518c2ecf20Sopenharmony_ci					  16, 2,	/* P */
4528c2ecf20Sopenharmony_ci					  24, 2,	/* mux */
4538c2ecf20Sopenharmony_ci					  BIT(31),	/* gate */
4548c2ecf20Sopenharmony_ci					  2,		/* post-div */
4558c2ecf20Sopenharmony_ci					  0);
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cistatic const char * const ts_parents[] = { "osc24M", "pll-periph0", };
4588c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
4598c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4608c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4618c2ecf20Sopenharmony_ci				  24, 4,	/* mux */
4628c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4638c2ecf20Sopenharmony_ci				  0);
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", mmc_default_parents, 0x09c,
4668c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4678c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4688c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
4698c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4708c2ecf20Sopenharmony_ci				  0);
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
4738c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4748c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4758c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
4768c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4778c2ecf20Sopenharmony_ci				  0);
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
4808c2ecf20Sopenharmony_ci				  0, 4,		/* M */
4818c2ecf20Sopenharmony_ci				  16, 2,	/* P */
4828c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
4838c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
4848c2ecf20Sopenharmony_ci				  0);
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
4878c2ecf20Sopenharmony_ci					    "pll-audio-2x", "pll-audio" };
4888c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
4898c2ecf20Sopenharmony_ci			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
4928c2ecf20Sopenharmony_ci			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
4958c2ecf20Sopenharmony_ci			       0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(spdif_clk, "spdif", "pll-audio",
4988c2ecf20Sopenharmony_ci			     0x0c0, 0, 4, BIT(31), CLK_SET_RATE_PARENT);
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
5018c2ecf20Sopenharmony_ci		      0x0cc, BIT(8), 0);
5028c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
5038c2ecf20Sopenharmony_ci		      0x0cc, BIT(9), 0);
5048c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_clk,	"usb-hsic",	"pll-hsic",
5058c2ecf20Sopenharmony_ci		      0x0cc, BIT(10), 0);
5068c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_12m_clk,	"usb-hsic-12M",	"osc12M",
5078c2ecf20Sopenharmony_ci		      0x0cc, BIT(11), 0);
5088c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk,	"usb-ohci0",	"osc12M",
5098c2ecf20Sopenharmony_ci		      0x0cc, BIT(16), 0);
5108c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci1_clk,	"usb-ohci1",	"usb-ohci0",
5118c2ecf20Sopenharmony_ci		      0x0cc, BIT(17), 0);
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_cistatic const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" };
5148c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
5158c2ecf20Sopenharmony_ci			    0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL);
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"dram",
5188c2ecf20Sopenharmony_ci		      0x100, BIT(0), 0);
5198c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk,	"dram-csi",	"dram",
5208c2ecf20Sopenharmony_ci		      0x100, BIT(1), 0);
5218c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_deinterlace_clk,	"dram-deinterlace",	"dram",
5228c2ecf20Sopenharmony_ci		      0x100, BIT(2), 0);
5238c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ts_clk,	"dram-ts",	"dram",
5248c2ecf20Sopenharmony_ci		      0x100, BIT(3), 0);
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_cistatic const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
5278c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
5288c2ecf20Sopenharmony_ci				 0x104, 0, 4, 24, 3, BIT(31),
5298c2ecf20Sopenharmony_ci				 CLK_SET_RATE_PARENT);
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic const char * const tcon0_parents[] = { "pll-mipi", "pll-video0-2x" };
5328c2ecf20Sopenharmony_cistatic const u8 tcon0_table[] = { 0, 2, };
5338c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_TABLE_WITH_GATE(tcon0_clk, "tcon0", tcon0_parents,
5348c2ecf20Sopenharmony_ci				     tcon0_table, 0x118, 24, 3, BIT(31),
5358c2ecf20Sopenharmony_ci				     CLK_SET_RATE_PARENT);
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_cistatic const char * const tcon1_parents[] = { "pll-video0", "pll-video1" };
5388c2ecf20Sopenharmony_cistatic const u8 tcon1_table[] = { 0, 2, };
5398c2ecf20Sopenharmony_cistatic struct ccu_div tcon1_clk = {
5408c2ecf20Sopenharmony_ci	.enable		= BIT(31),
5418c2ecf20Sopenharmony_ci	.div		= _SUNXI_CCU_DIV(0, 4),
5428c2ecf20Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX_TABLE(24, 2, tcon1_table),
5438c2ecf20Sopenharmony_ci	.common		= {
5448c2ecf20Sopenharmony_ci		.reg		= 0x11c,
5458c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("tcon1",
5468c2ecf20Sopenharmony_ci						      tcon1_parents,
5478c2ecf20Sopenharmony_ci						      &ccu_div_ops,
5488c2ecf20Sopenharmony_ci						      CLK_SET_RATE_PARENT),
5498c2ecf20Sopenharmony_ci	},
5508c2ecf20Sopenharmony_ci};
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_cistatic const char * const deinterlace_parents[] = { "pll-periph0", "pll-periph1" };
5538c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace", deinterlace_parents,
5548c2ecf20Sopenharmony_ci				 0x124, 0, 4, 24, 3, BIT(31), 0);
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(csi_misc_clk,	"csi-misc",	"osc24M",
5578c2ecf20Sopenharmony_ci		      0x130, BIT(31), 0);
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
5608c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
5618c2ecf20Sopenharmony_ci				 0x134, 16, 4, 24, 3, BIT(31), 0);
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "osc24M", "pll-video1", "pll-periph1" };
5648c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_mclk_clk, "csi-mclk", csi_mclk_parents,
5658c2ecf20Sopenharmony_ci				 0x134, 0, 5, 8, 3, BIT(15), 0);
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
5688c2ecf20Sopenharmony_ci			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
5718c2ecf20Sopenharmony_ci		      0x140, BIT(31), CLK_SET_RATE_PARENT);
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_4x_clk,	"ac-dig-4x",	"pll-audio-4x",
5748c2ecf20Sopenharmony_ci		      0x140, BIT(30), CLK_SET_RATE_PARENT);
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
5778c2ecf20Sopenharmony_ci		      0x144, BIT(31), 0);
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_cistatic const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
5808c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
5818c2ecf20Sopenharmony_ci				 0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(hdmi_ddc_clk,	"hdmi-ddc",	"osc24M",
5848c2ecf20Sopenharmony_ci		      0x154, BIT(31), 0);
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
5878c2ecf20Sopenharmony_ci						 "pll-ddr0", "pll-ddr1" };
5888c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
5898c2ecf20Sopenharmony_ci				 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video0", "pll-periph0" };
5928c2ecf20Sopenharmony_cistatic const u8 dsi_dphy_table[] = { 0, 2, };
5938c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_dphy_clk, "dsi-dphy",
5948c2ecf20Sopenharmony_ci				       dsi_dphy_parents, dsi_dphy_table,
5958c2ecf20Sopenharmony_ci				       0x168, 0, 4, 8, 2, BIT(15), CLK_SET_RATE_PARENT);
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
5988c2ecf20Sopenharmony_ci			     0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ci/* Fixed Factor clocks */
6018c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_FW_NAME(osc12M_clk, "osc12M", "hosc", 2, 1, 0);
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = {
6048c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common.hw
6058c2ecf20Sopenharmony_ci};
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci/* We hardcode the divider to 1 for now */
6088c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
6098c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
6108c2ecf20Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
6118c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
6128c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
6138c2ecf20Sopenharmony_ci			    2, 1, CLK_SET_RATE_PARENT);
6148c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
6158c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
6168c2ecf20Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
6178c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
6188c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
6198c2ecf20Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
6208c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x",
6218c2ecf20Sopenharmony_ci			   &pll_periph0_clk.common.hw,
6228c2ecf20Sopenharmony_ci			   1, 2, 0);
6238c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph1_2x_clk, "pll-periph1-2x",
6248c2ecf20Sopenharmony_ci			   &pll_periph1_clk.common.hw,
6258c2ecf20Sopenharmony_ci			   1, 2, 0);
6268c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x",
6278c2ecf20Sopenharmony_ci			   &pll_video0_clk.common.hw,
6288c2ecf20Sopenharmony_ci			   1, 2, CLK_SET_RATE_PARENT);
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_cistatic struct ccu_common *sun50i_a64_ccu_clks[] = {
6318c2ecf20Sopenharmony_ci	&pll_cpux_clk.common,
6328c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common,
6338c2ecf20Sopenharmony_ci	&pll_video0_clk.common,
6348c2ecf20Sopenharmony_ci	&pll_ve_clk.common,
6358c2ecf20Sopenharmony_ci	&pll_ddr0_clk.common,
6368c2ecf20Sopenharmony_ci	&pll_periph0_clk.common,
6378c2ecf20Sopenharmony_ci	&pll_periph1_clk.common,
6388c2ecf20Sopenharmony_ci	&pll_video1_clk.common,
6398c2ecf20Sopenharmony_ci	&pll_gpu_clk.common,
6408c2ecf20Sopenharmony_ci	&pll_mipi_clk.common,
6418c2ecf20Sopenharmony_ci	&pll_hsic_clk.common,
6428c2ecf20Sopenharmony_ci	&pll_de_clk.common,
6438c2ecf20Sopenharmony_ci	&pll_ddr1_clk.common,
6448c2ecf20Sopenharmony_ci	&cpux_clk.common,
6458c2ecf20Sopenharmony_ci	&axi_clk.common,
6468c2ecf20Sopenharmony_ci	&ahb1_clk.common,
6478c2ecf20Sopenharmony_ci	&apb1_clk.common,
6488c2ecf20Sopenharmony_ci	&apb2_clk.common,
6498c2ecf20Sopenharmony_ci	&ahb2_clk.common,
6508c2ecf20Sopenharmony_ci	&bus_mipi_dsi_clk.common,
6518c2ecf20Sopenharmony_ci	&bus_ce_clk.common,
6528c2ecf20Sopenharmony_ci	&bus_dma_clk.common,
6538c2ecf20Sopenharmony_ci	&bus_mmc0_clk.common,
6548c2ecf20Sopenharmony_ci	&bus_mmc1_clk.common,
6558c2ecf20Sopenharmony_ci	&bus_mmc2_clk.common,
6568c2ecf20Sopenharmony_ci	&bus_nand_clk.common,
6578c2ecf20Sopenharmony_ci	&bus_dram_clk.common,
6588c2ecf20Sopenharmony_ci	&bus_emac_clk.common,
6598c2ecf20Sopenharmony_ci	&bus_ts_clk.common,
6608c2ecf20Sopenharmony_ci	&bus_hstimer_clk.common,
6618c2ecf20Sopenharmony_ci	&bus_spi0_clk.common,
6628c2ecf20Sopenharmony_ci	&bus_spi1_clk.common,
6638c2ecf20Sopenharmony_ci	&bus_otg_clk.common,
6648c2ecf20Sopenharmony_ci	&bus_ehci0_clk.common,
6658c2ecf20Sopenharmony_ci	&bus_ehci1_clk.common,
6668c2ecf20Sopenharmony_ci	&bus_ohci0_clk.common,
6678c2ecf20Sopenharmony_ci	&bus_ohci1_clk.common,
6688c2ecf20Sopenharmony_ci	&bus_ve_clk.common,
6698c2ecf20Sopenharmony_ci	&bus_tcon0_clk.common,
6708c2ecf20Sopenharmony_ci	&bus_tcon1_clk.common,
6718c2ecf20Sopenharmony_ci	&bus_deinterlace_clk.common,
6728c2ecf20Sopenharmony_ci	&bus_csi_clk.common,
6738c2ecf20Sopenharmony_ci	&bus_hdmi_clk.common,
6748c2ecf20Sopenharmony_ci	&bus_de_clk.common,
6758c2ecf20Sopenharmony_ci	&bus_gpu_clk.common,
6768c2ecf20Sopenharmony_ci	&bus_msgbox_clk.common,
6778c2ecf20Sopenharmony_ci	&bus_spinlock_clk.common,
6788c2ecf20Sopenharmony_ci	&bus_codec_clk.common,
6798c2ecf20Sopenharmony_ci	&bus_spdif_clk.common,
6808c2ecf20Sopenharmony_ci	&bus_pio_clk.common,
6818c2ecf20Sopenharmony_ci	&bus_ths_clk.common,
6828c2ecf20Sopenharmony_ci	&bus_i2s0_clk.common,
6838c2ecf20Sopenharmony_ci	&bus_i2s1_clk.common,
6848c2ecf20Sopenharmony_ci	&bus_i2s2_clk.common,
6858c2ecf20Sopenharmony_ci	&bus_i2c0_clk.common,
6868c2ecf20Sopenharmony_ci	&bus_i2c1_clk.common,
6878c2ecf20Sopenharmony_ci	&bus_i2c2_clk.common,
6888c2ecf20Sopenharmony_ci	&bus_scr_clk.common,
6898c2ecf20Sopenharmony_ci	&bus_uart0_clk.common,
6908c2ecf20Sopenharmony_ci	&bus_uart1_clk.common,
6918c2ecf20Sopenharmony_ci	&bus_uart2_clk.common,
6928c2ecf20Sopenharmony_ci	&bus_uart3_clk.common,
6938c2ecf20Sopenharmony_ci	&bus_uart4_clk.common,
6948c2ecf20Sopenharmony_ci	&bus_dbg_clk.common,
6958c2ecf20Sopenharmony_ci	&ths_clk.common,
6968c2ecf20Sopenharmony_ci	&nand_clk.common,
6978c2ecf20Sopenharmony_ci	&mmc0_clk.common,
6988c2ecf20Sopenharmony_ci	&mmc1_clk.common,
6998c2ecf20Sopenharmony_ci	&mmc2_clk.common,
7008c2ecf20Sopenharmony_ci	&ts_clk.common,
7018c2ecf20Sopenharmony_ci	&ce_clk.common,
7028c2ecf20Sopenharmony_ci	&spi0_clk.common,
7038c2ecf20Sopenharmony_ci	&spi1_clk.common,
7048c2ecf20Sopenharmony_ci	&i2s0_clk.common,
7058c2ecf20Sopenharmony_ci	&i2s1_clk.common,
7068c2ecf20Sopenharmony_ci	&i2s2_clk.common,
7078c2ecf20Sopenharmony_ci	&spdif_clk.common,
7088c2ecf20Sopenharmony_ci	&usb_phy0_clk.common,
7098c2ecf20Sopenharmony_ci	&usb_phy1_clk.common,
7108c2ecf20Sopenharmony_ci	&usb_hsic_clk.common,
7118c2ecf20Sopenharmony_ci	&usb_hsic_12m_clk.common,
7128c2ecf20Sopenharmony_ci	&usb_ohci0_clk.common,
7138c2ecf20Sopenharmony_ci	&usb_ohci1_clk.common,
7148c2ecf20Sopenharmony_ci	&dram_clk.common,
7158c2ecf20Sopenharmony_ci	&dram_ve_clk.common,
7168c2ecf20Sopenharmony_ci	&dram_csi_clk.common,
7178c2ecf20Sopenharmony_ci	&dram_deinterlace_clk.common,
7188c2ecf20Sopenharmony_ci	&dram_ts_clk.common,
7198c2ecf20Sopenharmony_ci	&de_clk.common,
7208c2ecf20Sopenharmony_ci	&tcon0_clk.common,
7218c2ecf20Sopenharmony_ci	&tcon1_clk.common,
7228c2ecf20Sopenharmony_ci	&deinterlace_clk.common,
7238c2ecf20Sopenharmony_ci	&csi_misc_clk.common,
7248c2ecf20Sopenharmony_ci	&csi_sclk_clk.common,
7258c2ecf20Sopenharmony_ci	&csi_mclk_clk.common,
7268c2ecf20Sopenharmony_ci	&ve_clk.common,
7278c2ecf20Sopenharmony_ci	&ac_dig_clk.common,
7288c2ecf20Sopenharmony_ci	&ac_dig_4x_clk.common,
7298c2ecf20Sopenharmony_ci	&avs_clk.common,
7308c2ecf20Sopenharmony_ci	&hdmi_clk.common,
7318c2ecf20Sopenharmony_ci	&hdmi_ddc_clk.common,
7328c2ecf20Sopenharmony_ci	&mbus_clk.common,
7338c2ecf20Sopenharmony_ci	&dsi_dphy_clk.common,
7348c2ecf20Sopenharmony_ci	&gpu_clk.common,
7358c2ecf20Sopenharmony_ci};
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data sun50i_a64_hw_clks = {
7388c2ecf20Sopenharmony_ci	.hws	= {
7398c2ecf20Sopenharmony_ci		[CLK_OSC_12M]		= &osc12M_clk.hw,
7408c2ecf20Sopenharmony_ci		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
7418c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
7428c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
7438c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
7448c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
7458c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
7468c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
7478c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO0_2X]	= &pll_video0_2x_clk.hw,
7488c2ecf20Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
7498c2ecf20Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
7508c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
7518c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
7528c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
7538c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
7548c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
7558c2ecf20Sopenharmony_ci		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
7568c2ecf20Sopenharmony_ci		[CLK_PLL_MIPI]  	= &pll_mipi_clk.common.hw,
7578c2ecf20Sopenharmony_ci		[CLK_PLL_HSIC]		= &pll_hsic_clk.common.hw,
7588c2ecf20Sopenharmony_ci		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
7598c2ecf20Sopenharmony_ci		[CLK_PLL_DDR1]		= &pll_ddr1_clk.common.hw,
7608c2ecf20Sopenharmony_ci		[CLK_CPUX]		= &cpux_clk.common.hw,
7618c2ecf20Sopenharmony_ci		[CLK_AXI]		= &axi_clk.common.hw,
7628c2ecf20Sopenharmony_ci		[CLK_AHB1]		= &ahb1_clk.common.hw,
7638c2ecf20Sopenharmony_ci		[CLK_APB1]		= &apb1_clk.common.hw,
7648c2ecf20Sopenharmony_ci		[CLK_APB2]		= &apb2_clk.common.hw,
7658c2ecf20Sopenharmony_ci		[CLK_AHB2]		= &ahb2_clk.common.hw,
7668c2ecf20Sopenharmony_ci		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
7678c2ecf20Sopenharmony_ci		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
7688c2ecf20Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
7698c2ecf20Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
7708c2ecf20Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
7718c2ecf20Sopenharmony_ci		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
7728c2ecf20Sopenharmony_ci		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
7738c2ecf20Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
7748c2ecf20Sopenharmony_ci		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
7758c2ecf20Sopenharmony_ci		[CLK_BUS_TS]		= &bus_ts_clk.common.hw,
7768c2ecf20Sopenharmony_ci		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
7778c2ecf20Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
7788c2ecf20Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
7798c2ecf20Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
7808c2ecf20Sopenharmony_ci		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
7818c2ecf20Sopenharmony_ci		[CLK_BUS_EHCI1]		= &bus_ehci1_clk.common.hw,
7828c2ecf20Sopenharmony_ci		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
7838c2ecf20Sopenharmony_ci		[CLK_BUS_OHCI1]		= &bus_ohci1_clk.common.hw,
7848c2ecf20Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
7858c2ecf20Sopenharmony_ci		[CLK_BUS_TCON0]		= &bus_tcon0_clk.common.hw,
7868c2ecf20Sopenharmony_ci		[CLK_BUS_TCON1]		= &bus_tcon1_clk.common.hw,
7878c2ecf20Sopenharmony_ci		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
7888c2ecf20Sopenharmony_ci		[CLK_BUS_CSI]		= &bus_csi_clk.common.hw,
7898c2ecf20Sopenharmony_ci		[CLK_BUS_HDMI]		= &bus_hdmi_clk.common.hw,
7908c2ecf20Sopenharmony_ci		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
7918c2ecf20Sopenharmony_ci		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
7928c2ecf20Sopenharmony_ci		[CLK_BUS_MSGBOX]	= &bus_msgbox_clk.common.hw,
7938c2ecf20Sopenharmony_ci		[CLK_BUS_SPINLOCK]	= &bus_spinlock_clk.common.hw,
7948c2ecf20Sopenharmony_ci		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
7958c2ecf20Sopenharmony_ci		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
7968c2ecf20Sopenharmony_ci		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
7978c2ecf20Sopenharmony_ci		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
7988c2ecf20Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
7998c2ecf20Sopenharmony_ci		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
8008c2ecf20Sopenharmony_ci		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
8018c2ecf20Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
8028c2ecf20Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
8038c2ecf20Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
8048c2ecf20Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
8058c2ecf20Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
8068c2ecf20Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
8078c2ecf20Sopenharmony_ci		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
8088c2ecf20Sopenharmony_ci		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
8098c2ecf20Sopenharmony_ci		[CLK_BUS_SCR]		= &bus_scr_clk.common.hw,
8108c2ecf20Sopenharmony_ci		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
8118c2ecf20Sopenharmony_ci		[CLK_THS]		= &ths_clk.common.hw,
8128c2ecf20Sopenharmony_ci		[CLK_NAND]		= &nand_clk.common.hw,
8138c2ecf20Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
8148c2ecf20Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
8158c2ecf20Sopenharmony_ci		[CLK_MMC2]		= &mmc2_clk.common.hw,
8168c2ecf20Sopenharmony_ci		[CLK_TS]		= &ts_clk.common.hw,
8178c2ecf20Sopenharmony_ci		[CLK_CE]		= &ce_clk.common.hw,
8188c2ecf20Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
8198c2ecf20Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
8208c2ecf20Sopenharmony_ci		[CLK_I2S0]		= &i2s0_clk.common.hw,
8218c2ecf20Sopenharmony_ci		[CLK_I2S1]		= &i2s1_clk.common.hw,
8228c2ecf20Sopenharmony_ci		[CLK_I2S2]		= &i2s2_clk.common.hw,
8238c2ecf20Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
8248c2ecf20Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
8258c2ecf20Sopenharmony_ci		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
8268c2ecf20Sopenharmony_ci		[CLK_USB_HSIC]		= &usb_hsic_clk.common.hw,
8278c2ecf20Sopenharmony_ci		[CLK_USB_HSIC_12M]	= &usb_hsic_12m_clk.common.hw,
8288c2ecf20Sopenharmony_ci		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
8298c2ecf20Sopenharmony_ci		[CLK_USB_OHCI1]		= &usb_ohci1_clk.common.hw,
8308c2ecf20Sopenharmony_ci		[CLK_DRAM]		= &dram_clk.common.hw,
8318c2ecf20Sopenharmony_ci		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
8328c2ecf20Sopenharmony_ci		[CLK_DRAM_CSI]		= &dram_csi_clk.common.hw,
8338c2ecf20Sopenharmony_ci		[CLK_DRAM_DEINTERLACE]	= &dram_deinterlace_clk.common.hw,
8348c2ecf20Sopenharmony_ci		[CLK_DRAM_TS]		= &dram_ts_clk.common.hw,
8358c2ecf20Sopenharmony_ci		[CLK_DE]		= &de_clk.common.hw,
8368c2ecf20Sopenharmony_ci		[CLK_TCON0]		= &tcon0_clk.common.hw,
8378c2ecf20Sopenharmony_ci		[CLK_TCON1]		= &tcon1_clk.common.hw,
8388c2ecf20Sopenharmony_ci		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
8398c2ecf20Sopenharmony_ci		[CLK_CSI_MISC]		= &csi_misc_clk.common.hw,
8408c2ecf20Sopenharmony_ci		[CLK_CSI_SCLK]		= &csi_sclk_clk.common.hw,
8418c2ecf20Sopenharmony_ci		[CLK_CSI_MCLK]		= &csi_mclk_clk.common.hw,
8428c2ecf20Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
8438c2ecf20Sopenharmony_ci		[CLK_AC_DIG]		= &ac_dig_clk.common.hw,
8448c2ecf20Sopenharmony_ci		[CLK_AC_DIG_4X]		= &ac_dig_4x_clk.common.hw,
8458c2ecf20Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
8468c2ecf20Sopenharmony_ci		[CLK_HDMI]		= &hdmi_clk.common.hw,
8478c2ecf20Sopenharmony_ci		[CLK_HDMI_DDC]		= &hdmi_ddc_clk.common.hw,
8488c2ecf20Sopenharmony_ci		[CLK_MBUS]		= &mbus_clk.common.hw,
8498c2ecf20Sopenharmony_ci		[CLK_DSI_DPHY]		= &dsi_dphy_clk.common.hw,
8508c2ecf20Sopenharmony_ci		[CLK_GPU]		= &gpu_clk.common.hw,
8518c2ecf20Sopenharmony_ci	},
8528c2ecf20Sopenharmony_ci	.num	= CLK_NUMBER,
8538c2ecf20Sopenharmony_ci};
8548c2ecf20Sopenharmony_ci
8558c2ecf20Sopenharmony_cistatic struct ccu_reset_map sun50i_a64_ccu_resets[] = {
8568c2ecf20Sopenharmony_ci	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
8578c2ecf20Sopenharmony_ci	[RST_USB_PHY1]		=  { 0x0cc, BIT(1) },
8588c2ecf20Sopenharmony_ci	[RST_USB_HSIC]		=  { 0x0cc, BIT(2) },
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_ci	[RST_DRAM]		=  { 0x0f4, BIT(31) },
8618c2ecf20Sopenharmony_ci	[RST_MBUS]		=  { 0x0fc, BIT(31) },
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ci	[RST_BUS_MIPI_DSI]	=  { 0x2c0, BIT(1) },
8648c2ecf20Sopenharmony_ci	[RST_BUS_CE]		=  { 0x2c0, BIT(5) },
8658c2ecf20Sopenharmony_ci	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
8668c2ecf20Sopenharmony_ci	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
8678c2ecf20Sopenharmony_ci	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
8688c2ecf20Sopenharmony_ci	[RST_BUS_MMC2]		=  { 0x2c0, BIT(10) },
8698c2ecf20Sopenharmony_ci	[RST_BUS_NAND]		=  { 0x2c0, BIT(13) },
8708c2ecf20Sopenharmony_ci	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
8718c2ecf20Sopenharmony_ci	[RST_BUS_EMAC]		=  { 0x2c0, BIT(17) },
8728c2ecf20Sopenharmony_ci	[RST_BUS_TS]		=  { 0x2c0, BIT(18) },
8738c2ecf20Sopenharmony_ci	[RST_BUS_HSTIMER]	=  { 0x2c0, BIT(19) },
8748c2ecf20Sopenharmony_ci	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
8758c2ecf20Sopenharmony_ci	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
8768c2ecf20Sopenharmony_ci	[RST_BUS_OTG]		=  { 0x2c0, BIT(23) },
8778c2ecf20Sopenharmony_ci	[RST_BUS_EHCI0]		=  { 0x2c0, BIT(24) },
8788c2ecf20Sopenharmony_ci	[RST_BUS_EHCI1]		=  { 0x2c0, BIT(25) },
8798c2ecf20Sopenharmony_ci	[RST_BUS_OHCI0]		=  { 0x2c0, BIT(28) },
8808c2ecf20Sopenharmony_ci	[RST_BUS_OHCI1]		=  { 0x2c0, BIT(29) },
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
8838c2ecf20Sopenharmony_ci	[RST_BUS_TCON0]		=  { 0x2c4, BIT(3) },
8848c2ecf20Sopenharmony_ci	[RST_BUS_TCON1]		=  { 0x2c4, BIT(4) },
8858c2ecf20Sopenharmony_ci	[RST_BUS_DEINTERLACE]	=  { 0x2c4, BIT(5) },
8868c2ecf20Sopenharmony_ci	[RST_BUS_CSI]		=  { 0x2c4, BIT(8) },
8878c2ecf20Sopenharmony_ci	[RST_BUS_HDMI0]		=  { 0x2c4, BIT(10) },
8888c2ecf20Sopenharmony_ci	[RST_BUS_HDMI1]		=  { 0x2c4, BIT(11) },
8898c2ecf20Sopenharmony_ci	[RST_BUS_DE]		=  { 0x2c4, BIT(12) },
8908c2ecf20Sopenharmony_ci	[RST_BUS_GPU]		=  { 0x2c4, BIT(20) },
8918c2ecf20Sopenharmony_ci	[RST_BUS_MSGBOX]	=  { 0x2c4, BIT(21) },
8928c2ecf20Sopenharmony_ci	[RST_BUS_SPINLOCK]	=  { 0x2c4, BIT(22) },
8938c2ecf20Sopenharmony_ci	[RST_BUS_DBG]		=  { 0x2c4, BIT(31) },
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ci	[RST_BUS_LVDS]		=  { 0x2c8, BIT(0) },
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_ci	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
8988c2ecf20Sopenharmony_ci	[RST_BUS_SPDIF]		=  { 0x2d0, BIT(1) },
8998c2ecf20Sopenharmony_ci	[RST_BUS_THS]		=  { 0x2d0, BIT(8) },
9008c2ecf20Sopenharmony_ci	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
9018c2ecf20Sopenharmony_ci	[RST_BUS_I2S1]		=  { 0x2d0, BIT(13) },
9028c2ecf20Sopenharmony_ci	[RST_BUS_I2S2]		=  { 0x2d0, BIT(14) },
9038c2ecf20Sopenharmony_ci
9048c2ecf20Sopenharmony_ci	[RST_BUS_I2C0]		=  { 0x2d8, BIT(0) },
9058c2ecf20Sopenharmony_ci	[RST_BUS_I2C1]		=  { 0x2d8, BIT(1) },
9068c2ecf20Sopenharmony_ci	[RST_BUS_I2C2]		=  { 0x2d8, BIT(2) },
9078c2ecf20Sopenharmony_ci	[RST_BUS_SCR]		=  { 0x2d8, BIT(5) },
9088c2ecf20Sopenharmony_ci	[RST_BUS_UART0]		=  { 0x2d8, BIT(16) },
9098c2ecf20Sopenharmony_ci	[RST_BUS_UART1]		=  { 0x2d8, BIT(17) },
9108c2ecf20Sopenharmony_ci	[RST_BUS_UART2]		=  { 0x2d8, BIT(18) },
9118c2ecf20Sopenharmony_ci	[RST_BUS_UART3]		=  { 0x2d8, BIT(19) },
9128c2ecf20Sopenharmony_ci	[RST_BUS_UART4]		=  { 0x2d8, BIT(20) },
9138c2ecf20Sopenharmony_ci};
9148c2ecf20Sopenharmony_ci
9158c2ecf20Sopenharmony_cistatic const struct sunxi_ccu_desc sun50i_a64_ccu_desc = {
9168c2ecf20Sopenharmony_ci	.ccu_clks	= sun50i_a64_ccu_clks,
9178c2ecf20Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(sun50i_a64_ccu_clks),
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_ci	.hw_clks	= &sun50i_a64_hw_clks,
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_ci	.resets		= sun50i_a64_ccu_resets,
9228c2ecf20Sopenharmony_ci	.num_resets	= ARRAY_SIZE(sun50i_a64_ccu_resets),
9238c2ecf20Sopenharmony_ci};
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_cistatic struct ccu_pll_nb sun50i_a64_pll_cpu_nb = {
9268c2ecf20Sopenharmony_ci	.common	= &pll_cpux_clk.common,
9278c2ecf20Sopenharmony_ci	/* copy from pll_cpux_clk */
9288c2ecf20Sopenharmony_ci	.enable	= BIT(31),
9298c2ecf20Sopenharmony_ci	.lock	= BIT(28),
9308c2ecf20Sopenharmony_ci};
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_cistatic struct ccu_mux_nb sun50i_a64_cpu_nb = {
9338c2ecf20Sopenharmony_ci	.common		= &cpux_clk.common,
9348c2ecf20Sopenharmony_ci	.cm		= &cpux_clk.mux,
9358c2ecf20Sopenharmony_ci	.delay_us	= 1, /* > 8 clock cycles at 24 MHz */
9368c2ecf20Sopenharmony_ci	.bypass_index	= 1, /* index of 24 MHz oscillator */
9378c2ecf20Sopenharmony_ci};
9388c2ecf20Sopenharmony_ci
9398c2ecf20Sopenharmony_cistatic int sun50i_a64_ccu_probe(struct platform_device *pdev)
9408c2ecf20Sopenharmony_ci{
9418c2ecf20Sopenharmony_ci	struct resource *res;
9428c2ecf20Sopenharmony_ci	void __iomem *reg;
9438c2ecf20Sopenharmony_ci	u32 val;
9448c2ecf20Sopenharmony_ci	int ret;
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9478c2ecf20Sopenharmony_ci	reg = devm_ioremap_resource(&pdev->dev, res);
9488c2ecf20Sopenharmony_ci	if (IS_ERR(reg))
9498c2ecf20Sopenharmony_ci		return PTR_ERR(reg);
9508c2ecf20Sopenharmony_ci
9518c2ecf20Sopenharmony_ci	/* Force the PLL-Audio-1x divider to 1 */
9528c2ecf20Sopenharmony_ci	val = readl(reg + SUN50I_A64_PLL_AUDIO_REG);
9538c2ecf20Sopenharmony_ci	val &= ~GENMASK(19, 16);
9548c2ecf20Sopenharmony_ci	writel(val | (0 << 16), reg + SUN50I_A64_PLL_AUDIO_REG);
9558c2ecf20Sopenharmony_ci
9568c2ecf20Sopenharmony_ci	writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG);
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_ci	ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc);
9598c2ecf20Sopenharmony_ci	if (ret)
9608c2ecf20Sopenharmony_ci		return ret;
9618c2ecf20Sopenharmony_ci
9628c2ecf20Sopenharmony_ci	/* Gate then ungate PLL CPU after any rate changes */
9638c2ecf20Sopenharmony_ci	ccu_pll_notifier_register(&sun50i_a64_pll_cpu_nb);
9648c2ecf20Sopenharmony_ci
9658c2ecf20Sopenharmony_ci	/* Reparent CPU during PLL CPU rate changes */
9668c2ecf20Sopenharmony_ci	ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
9678c2ecf20Sopenharmony_ci				  &sun50i_a64_cpu_nb);
9688c2ecf20Sopenharmony_ci
9698c2ecf20Sopenharmony_ci	return 0;
9708c2ecf20Sopenharmony_ci}
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_cistatic const struct of_device_id sun50i_a64_ccu_ids[] = {
9738c2ecf20Sopenharmony_ci	{ .compatible = "allwinner,sun50i-a64-ccu" },
9748c2ecf20Sopenharmony_ci	{ }
9758c2ecf20Sopenharmony_ci};
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_cistatic struct platform_driver sun50i_a64_ccu_driver = {
9788c2ecf20Sopenharmony_ci	.probe	= sun50i_a64_ccu_probe,
9798c2ecf20Sopenharmony_ci	.driver	= {
9808c2ecf20Sopenharmony_ci		.name	= "sun50i-a64-ccu",
9818c2ecf20Sopenharmony_ci		.of_match_table	= sun50i_a64_ccu_ids,
9828c2ecf20Sopenharmony_ci	},
9838c2ecf20Sopenharmony_ci};
9848c2ecf20Sopenharmony_cibuiltin_platform_driver(sun50i_a64_ccu_driver);
985