162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io>
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/clk-provider.h>
762306a36Sopenharmony_ci#include <linux/io.h>
862306a36Sopenharmony_ci#include <linux/module.h>
962306a36Sopenharmony_ci#include <linux/platform_device.h>
1062306a36Sopenharmony_ci#include <linux/regmap.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include "ccu_common.h"
1362306a36Sopenharmony_ci#include "ccu_reset.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include "ccu_div.h"
1662306a36Sopenharmony_ci#include "ccu_gate.h"
1762306a36Sopenharmony_ci#include "ccu_mp.h"
1862306a36Sopenharmony_ci#include "ccu_mult.h"
1962306a36Sopenharmony_ci#include "ccu_nk.h"
2062306a36Sopenharmony_ci#include "ccu_nkm.h"
2162306a36Sopenharmony_ci#include "ccu_nkmp.h"
2262306a36Sopenharmony_ci#include "ccu_nm.h"
2362306a36Sopenharmony_ci#include "ccu_phase.h"
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#include "ccu-sun8i-r40.h"
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* TODO: The result of N*K is required to be in [10, 88] range. */
2862306a36Sopenharmony_cistatic struct ccu_nkmp pll_cpu_clk = {
2962306a36Sopenharmony_ci	.enable		= BIT(31),
3062306a36Sopenharmony_ci	.lock		= BIT(28),
3162306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
3262306a36Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
3362306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 2),
3462306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV_MAX(16, 2, 4),
3562306a36Sopenharmony_ci	.common		= {
3662306a36Sopenharmony_ci		.reg		= 0x000,
3762306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpu",
3862306a36Sopenharmony_ci					      "osc24M",
3962306a36Sopenharmony_ci					      &ccu_nkmp_ops,
4062306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
4162306a36Sopenharmony_ci	},
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/*
4562306a36Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
4662306a36Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true
4762306a36Sopenharmony_ci * pll audio).
4862306a36Sopenharmony_ci *
4962306a36Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL,
5062306a36Sopenharmony_ci * we have to use specific dividers. This means the variable divider
5162306a36Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock
5262306a36Sopenharmony_ci * rates we support through this mechanism. So we now hard code the
5362306a36Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer
5462306a36Sopenharmony_ci * match the clock names.
5562306a36Sopenharmony_ci */
5662306a36Sopenharmony_ci#define SUN8I_R40_PLL_AUDIO_REG	0x008
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = {
5962306a36Sopenharmony_ci	{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
6062306a36Sopenharmony_ci	{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
6162306a36Sopenharmony_ci};
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
6462306a36Sopenharmony_ci				       "osc24M", 0x008,
6562306a36Sopenharmony_ci				       8, 7,	/* N */
6662306a36Sopenharmony_ci				       0, 5,	/* M */
6762306a36Sopenharmony_ci				       pll_audio_sdm_table, BIT(24),
6862306a36Sopenharmony_ci				       0x284, BIT(31),
6962306a36Sopenharmony_ci				       BIT(31),	/* gate */
7062306a36Sopenharmony_ci				       BIT(28),	/* lock */
7162306a36Sopenharmony_ci				       CLK_SET_RATE_UNGATE);
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video0_clk, "pll-video0",
7462306a36Sopenharmony_ci						"osc24M", 0x0010,
7562306a36Sopenharmony_ci						192000000,  /* Minimum rate */
7662306a36Sopenharmony_ci						1008000000, /* Maximum rate */
7762306a36Sopenharmony_ci						8, 7,       /* N */
7862306a36Sopenharmony_ci						0, 4,       /* M */
7962306a36Sopenharmony_ci						BIT(24),    /* frac enable */
8062306a36Sopenharmony_ci						BIT(25),    /* frac select */
8162306a36Sopenharmony_ci						270000000,  /* frac rate 0 */
8262306a36Sopenharmony_ci						297000000,  /* frac rate 1 */
8362306a36Sopenharmony_ci						BIT(31),    /* gate */
8462306a36Sopenharmony_ci						BIT(28),    /* lock */
8562306a36Sopenharmony_ci						CLK_SET_RATE_UNGATE);
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
8862306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
8962306a36Sopenharmony_ci					"osc24M", 0x0018,
9062306a36Sopenharmony_ci					8, 7,		/* N */
9162306a36Sopenharmony_ci					0, 4,		/* M */
9262306a36Sopenharmony_ci					BIT(24),	/* frac enable */
9362306a36Sopenharmony_ci					BIT(25),	/* frac select */
9462306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
9562306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
9662306a36Sopenharmony_ci					BIT(31),	/* gate */
9762306a36Sopenharmony_ci					BIT(28),	/* lock */
9862306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci/* TODO: The result of N*K is required to be in [10, 77] range. */
10162306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0",
10262306a36Sopenharmony_ci				    "osc24M", 0x020,
10362306a36Sopenharmony_ci				    8, 5,	/* N */
10462306a36Sopenharmony_ci				    4, 2,	/* K */
10562306a36Sopenharmony_ci				    0, 2,	/* M */
10662306a36Sopenharmony_ci				    BIT(31),	/* gate */
10762306a36Sopenharmony_ci				    BIT(28),	/* lock */
10862306a36Sopenharmony_ci				    CLK_SET_RATE_UNGATE);
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/* TODO: The result of N*K is required to be in [21, 58] range. */
11162306a36Sopenharmony_cistatic struct ccu_nk pll_periph0_clk = {
11262306a36Sopenharmony_ci	.enable		= BIT(31),
11362306a36Sopenharmony_ci	.lock		= BIT(28),
11462306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
11562306a36Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
11662306a36Sopenharmony_ci	.fixed_post_div	= 2,
11762306a36Sopenharmony_ci	.common		= {
11862306a36Sopenharmony_ci		.reg		= 0x028,
11962306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
12062306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0", "osc24M",
12162306a36Sopenharmony_ci					      &ccu_nk_ops,
12262306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
12362306a36Sopenharmony_ci	},
12462306a36Sopenharmony_ci};
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_cistatic struct ccu_div pll_periph0_sata_clk = {
12762306a36Sopenharmony_ci	.enable		= BIT(24),
12862306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV(0, 2),
12962306a36Sopenharmony_ci	/*
13062306a36Sopenharmony_ci	 * The formula of pll-periph0 (1x) is 24MHz*N*K/2, and the formula
13162306a36Sopenharmony_ci	 * of pll-periph0-sata is 24MHz*N*K/M/6, so the postdiv here is
13262306a36Sopenharmony_ci	 * 6/2 = 3.
13362306a36Sopenharmony_ci	 */
13462306a36Sopenharmony_ci	.fixed_post_div	= 3,
13562306a36Sopenharmony_ci	.common		= {
13662306a36Sopenharmony_ci		.reg		= 0x028,
13762306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
13862306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0-sata",
13962306a36Sopenharmony_ci					      "pll-periph0",
14062306a36Sopenharmony_ci					      &ccu_div_ops, 0),
14162306a36Sopenharmony_ci	},
14262306a36Sopenharmony_ci};
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/* TODO: The result of N*K is required to be in [21, 58] range. */
14562306a36Sopenharmony_cistatic struct ccu_nk pll_periph1_clk = {
14662306a36Sopenharmony_ci	.enable		= BIT(31),
14762306a36Sopenharmony_ci	.lock		= BIT(28),
14862306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
14962306a36Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
15062306a36Sopenharmony_ci	.fixed_post_div	= 2,
15162306a36Sopenharmony_ci	.common		= {
15262306a36Sopenharmony_ci		.reg		= 0x02c,
15362306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
15462306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph1", "osc24M",
15562306a36Sopenharmony_ci					      &ccu_nk_ops,
15662306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
15762306a36Sopenharmony_ci	},
15862306a36Sopenharmony_ci};
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(pll_video1_clk, "pll-video1",
16162306a36Sopenharmony_ci						"osc24M", 0x030,
16262306a36Sopenharmony_ci						192000000,  /* Minimum rate */
16362306a36Sopenharmony_ci						1008000000, /* Maximum rate */
16462306a36Sopenharmony_ci						8, 7,       /* N */
16562306a36Sopenharmony_ci						0, 4,       /* M */
16662306a36Sopenharmony_ci						BIT(24),    /* frac enable */
16762306a36Sopenharmony_ci						BIT(25),    /* frac select */
16862306a36Sopenharmony_ci						270000000,  /* frac rate 0 */
16962306a36Sopenharmony_ci						297000000,  /* frac rate 1 */
17062306a36Sopenharmony_ci						BIT(31),    /* gate */
17162306a36Sopenharmony_ci						BIT(28),    /* lock */
17262306a36Sopenharmony_ci						CLK_SET_RATE_UNGATE);
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cistatic struct ccu_nkm pll_sata_clk = {
17562306a36Sopenharmony_ci	.enable		= BIT(31),
17662306a36Sopenharmony_ci	.lock		= BIT(28),
17762306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
17862306a36Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
17962306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 2),
18062306a36Sopenharmony_ci	.fixed_post_div	= 6,
18162306a36Sopenharmony_ci	.common		= {
18262306a36Sopenharmony_ci		.reg		= 0x034,
18362306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
18462306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-sata", "osc24M",
18562306a36Sopenharmony_ci					      &ccu_nkm_ops,
18662306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
18762306a36Sopenharmony_ci	},
18862306a36Sopenharmony_ci};
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_cistatic const char * const pll_sata_out_parents[] = { "pll-sata",
19162306a36Sopenharmony_ci						     "pll-periph0-sata" };
19262306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(pll_sata_out_clk, "pll-sata-out",
19362306a36Sopenharmony_ci			       pll_sata_out_parents, 0x034,
19462306a36Sopenharmony_ci			       30, 1,	/* mux */
19562306a36Sopenharmony_ci			       BIT(14),	/* gate */
19662306a36Sopenharmony_ci			       CLK_SET_RATE_PARENT);
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
19962306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
20062306a36Sopenharmony_ci					"osc24M", 0x038,
20162306a36Sopenharmony_ci					8, 7,		/* N */
20262306a36Sopenharmony_ci					0, 4,		/* M */
20362306a36Sopenharmony_ci					BIT(24),	/* frac enable */
20462306a36Sopenharmony_ci					BIT(25),	/* frac select */
20562306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
20662306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
20762306a36Sopenharmony_ci					BIT(31),	/* gate */
20862306a36Sopenharmony_ci					BIT(28),	/* lock */
20962306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci/*
21262306a36Sopenharmony_ci * The MIPI PLL has 2 modes: "MIPI" and "HDMI".
21362306a36Sopenharmony_ci *
21462306a36Sopenharmony_ci * The MIPI mode is a standard NKM-style clock. The HDMI mode is an
21562306a36Sopenharmony_ci * integer / fractional clock with switchable multipliers and dividers.
21662306a36Sopenharmony_ci * This is not supported here. We hardcode the PLL to MIPI mode.
21762306a36Sopenharmony_ci *
21862306a36Sopenharmony_ci * TODO: In the MIPI mode, M/N is required to be equal or lesser than 3,
21962306a36Sopenharmony_ci * which cannot be implemented now.
22062306a36Sopenharmony_ci */
22162306a36Sopenharmony_ci#define SUN8I_R40_PLL_MIPI_REG	0x040
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_cistatic const char * const pll_mipi_parents[] = { "pll-video0" };
22462306a36Sopenharmony_cistatic struct ccu_nkm pll_mipi_clk = {
22562306a36Sopenharmony_ci	.enable	= BIT(31) | BIT(23) | BIT(22),
22662306a36Sopenharmony_ci	.lock	= BIT(28),
22762306a36Sopenharmony_ci	.n	= _SUNXI_CCU_MULT(8, 4),
22862306a36Sopenharmony_ci	.k	= _SUNXI_CCU_MULT_MIN(4, 2, 2),
22962306a36Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 4),
23062306a36Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX(21, 1),
23162306a36Sopenharmony_ci	.common	= {
23262306a36Sopenharmony_ci		.reg		= 0x040,
23362306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("pll-mipi",
23462306a36Sopenharmony_ci						      pll_mipi_parents,
23562306a36Sopenharmony_ci						      &ccu_nkm_ops,
23662306a36Sopenharmony_ci						      CLK_SET_RATE_UNGATE)
23762306a36Sopenharmony_ci	},
23862306a36Sopenharmony_ci};
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/* TODO: The result of N/M is required to be in [8, 25] range. */
24162306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
24262306a36Sopenharmony_ci					"osc24M", 0x048,
24362306a36Sopenharmony_ci					8, 7,		/* N */
24462306a36Sopenharmony_ci					0, 4,		/* M */
24562306a36Sopenharmony_ci					BIT(24),	/* frac enable */
24662306a36Sopenharmony_ci					BIT(25),	/* frac select */
24762306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
24862306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
24962306a36Sopenharmony_ci					BIT(31),	/* gate */
25062306a36Sopenharmony_ci					BIT(28),	/* lock */
25162306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* TODO: The N factor is required to be in [16, 75] range. */
25462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
25562306a36Sopenharmony_ci				   "osc24M", 0x04c,
25662306a36Sopenharmony_ci				   8, 7,	/* N */
25762306a36Sopenharmony_ci				   0, 2,	/* M */
25862306a36Sopenharmony_ci				   BIT(31),	/* gate */
25962306a36Sopenharmony_ci				   BIT(28),	/* lock */
26062306a36Sopenharmony_ci				   CLK_SET_RATE_UNGATE);
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_cistatic const char * const cpu_parents[] = { "osc32k", "osc24M",
26362306a36Sopenharmony_ci					     "pll-cpu", "pll-cpu" };
26462306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents,
26562306a36Sopenharmony_ci		     0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpu", 0x050, 0, 2, 0);
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M",
27062306a36Sopenharmony_ci					     "axi", "pll-periph0" };
27162306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = {
27262306a36Sopenharmony_ci	{ .index = 3, .shift = 6, .width = 2 },
27362306a36Sopenharmony_ci};
27462306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = {
27562306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci	.mux		= {
27862306a36Sopenharmony_ci		.shift	= 12,
27962306a36Sopenharmony_ci		.width	= 2,
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci		.var_predivs	= ahb1_predivs,
28262306a36Sopenharmony_ci		.n_var_predivs	= ARRAY_SIZE(ahb1_predivs),
28362306a36Sopenharmony_ci	},
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci	.common		= {
28662306a36Sopenharmony_ci		.reg		= 0x054,
28762306a36Sopenharmony_ci		.features	= CCU_FEATURE_VARIABLE_PREDIV,
28862306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb1",
28962306a36Sopenharmony_ci						      ahb1_parents,
29062306a36Sopenharmony_ci						      &ccu_div_ops,
29162306a36Sopenharmony_ci						      0),
29262306a36Sopenharmony_ci	},
29362306a36Sopenharmony_ci};
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = {
29662306a36Sopenharmony_ci	{ .val = 0, .div = 2 },
29762306a36Sopenharmony_ci	{ .val = 1, .div = 2 },
29862306a36Sopenharmony_ci	{ .val = 2, .div = 4 },
29962306a36Sopenharmony_ci	{ .val = 3, .div = 8 },
30062306a36Sopenharmony_ci	{ /* Sentinel */ },
30162306a36Sopenharmony_ci};
30262306a36Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
30362306a36Sopenharmony_ci			   0x054, 8, 2, apb1_div_table, 0);
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M",
30662306a36Sopenharmony_ci					     "pll-periph0-2x",
30762306a36Sopenharmony_ci					     "pll-periph0-2x" };
30862306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
30962306a36Sopenharmony_ci			     0, 5,	/* M */
31062306a36Sopenharmony_ci			     16, 2,	/* P */
31162306a36Sopenharmony_ci			     24, 2,	/* mux */
31262306a36Sopenharmony_ci			     0);
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk,	"bus-mipi-dsi",	"ahb1",
31562306a36Sopenharmony_ci		      0x060, BIT(1), 0);
31662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk,	"bus-ce",	"ahb1",
31762306a36Sopenharmony_ci		      0x060, BIT(5), 0);
31862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb1",
31962306a36Sopenharmony_ci		      0x060, BIT(6), 0);
32062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb1",
32162306a36Sopenharmony_ci		      0x060, BIT(8), 0);
32262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb1",
32362306a36Sopenharmony_ci		      0x060, BIT(9), 0);
32462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk,	"bus-mmc2",	"ahb1",
32562306a36Sopenharmony_ci		      0x060, BIT(10), 0);
32662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc3_clk,	"bus-mmc3",	"ahb1",
32762306a36Sopenharmony_ci		      0x060, BIT(11), 0);
32862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk,	"bus-nand",	"ahb1",
32962306a36Sopenharmony_ci		      0x060, BIT(13), 0);
33062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb1",
33162306a36Sopenharmony_ci		      0x060, BIT(14), 0);
33262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk,	"bus-emac",	"ahb1",
33362306a36Sopenharmony_ci		      0x060, BIT(17), 0);
33462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ts_clk,	"bus-ts",	"ahb1",
33562306a36Sopenharmony_ci		      0x060, BIT(18), 0);
33662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
33762306a36Sopenharmony_ci		      0x060, BIT(19), 0);
33862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb1",
33962306a36Sopenharmony_ci		      0x060, BIT(20), 0);
34062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb1",
34162306a36Sopenharmony_ci		      0x060, BIT(21), 0);
34262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi2_clk,	"bus-spi2",	"ahb1",
34362306a36Sopenharmony_ci		      0x060, BIT(22), 0);
34462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi3_clk,	"bus-spi3",	"ahb1",
34562306a36Sopenharmony_ci		      0x060, BIT(23), 0);
34662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_sata_clk,	"bus-sata",	"ahb1",
34762306a36Sopenharmony_ci		      0x060, BIT(24), 0);
34862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb1",
34962306a36Sopenharmony_ci		      0x060, BIT(25), 0);
35062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk,	"bus-ehci0",	"ahb1",
35162306a36Sopenharmony_ci		      0x060, BIT(26), 0);
35262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk,	"bus-ehci1",	"ahb1",
35362306a36Sopenharmony_ci		      0x060, BIT(27), 0);
35462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci2_clk,	"bus-ehci2",	"ahb1",
35562306a36Sopenharmony_ci		      0x060, BIT(28), 0);
35662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk,	"bus-ohci0",	"ahb1",
35762306a36Sopenharmony_ci		      0x060, BIT(29), 0);
35862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci1_clk,	"bus-ohci1",	"ahb1",
35962306a36Sopenharmony_ci		      0x060, BIT(30), 0);
36062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci2_clk,	"bus-ohci2",	"ahb1",
36162306a36Sopenharmony_ci		      0x060, BIT(31), 0);
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
36462306a36Sopenharmony_ci		      0x064, BIT(0), 0);
36562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mp_clk,	"bus-mp",	"ahb1",
36662306a36Sopenharmony_ci		      0x064, BIT(2), 0);
36762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb1",
36862306a36Sopenharmony_ci		      0x064, BIT(5), 0);
36962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi0_clk,	"bus-csi0",	"ahb1",
37062306a36Sopenharmony_ci		      0x064, BIT(8), 0);
37162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi1_clk,	"bus-csi1",	"ahb1",
37262306a36Sopenharmony_ci		      0x064, BIT(9), 0);
37362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi0_clk,	"bus-hdmi0",	"ahb1",
37462306a36Sopenharmony_ci		      0x064, BIT(10), 0);
37562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hdmi1_clk,	"bus-hdmi1",	"ahb1",
37662306a36Sopenharmony_ci		      0x064, BIT(11), 0);
37762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
37862306a36Sopenharmony_ci		      0x064, BIT(12), 0);
37962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve0_clk,	"bus-tve0",	"ahb1",
38062306a36Sopenharmony_ci		      0x064, BIT(13), 0);
38162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve1_clk,	"bus-tve1",	"ahb1",
38262306a36Sopenharmony_ci		      0x064, BIT(14), 0);
38362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve_top_clk,	"bus-tve-top",	"ahb1",
38462306a36Sopenharmony_ci		      0x064, BIT(15), 0);
38562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gmac_clk,	"bus-gmac",	"ahb1",
38662306a36Sopenharmony_ci		      0x064, BIT(17), 0);
38762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
38862306a36Sopenharmony_ci		      0x064, BIT(20), 0);
38962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd0_clk,	"bus-tvd0",	"ahb1",
39062306a36Sopenharmony_ci		      0x064, BIT(21), 0);
39162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd1_clk,	"bus-tvd1",	"ahb1",
39262306a36Sopenharmony_ci		      0x064, BIT(22), 0);
39362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd2_clk,	"bus-tvd2",	"ahb1",
39462306a36Sopenharmony_ci		      0x064, BIT(23), 0);
39562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd3_clk,	"bus-tvd3",	"ahb1",
39662306a36Sopenharmony_ci		      0x064, BIT(24), 0);
39762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd_top_clk,	"bus-tvd-top",	"ahb1",
39862306a36Sopenharmony_ci		      0x064, BIT(25), 0);
39962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_lcd0_clk,	"bus-tcon-lcd0",	"ahb1",
40062306a36Sopenharmony_ci		      0x064, BIT(26), 0);
40162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_lcd1_clk,	"bus-tcon-lcd1",	"ahb1",
40262306a36Sopenharmony_ci		      0x064, BIT(27), 0);
40362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_tv0_clk,	"bus-tcon-tv0",	"ahb1",
40462306a36Sopenharmony_ci		      0x064, BIT(28), 0);
40562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_tv1_clk,	"bus-tcon-tv1",	"ahb1",
40662306a36Sopenharmony_ci		      0x064, BIT(29), 0);
40762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_top_clk,	"bus-tcon-top",	"ahb1",
40862306a36Sopenharmony_ci		      0x064, BIT(30), 0);
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb1",
41162306a36Sopenharmony_ci		      0x068, BIT(0), 0);
41262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk,	"bus-spdif",	"apb1",
41362306a36Sopenharmony_ci		      0x068, BIT(1), 0);
41462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ac97_clk,	"bus-ac97",	"apb1",
41562306a36Sopenharmony_ci		      0x068, BIT(2), 0);
41662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb1",
41762306a36Sopenharmony_ci		      0x068, BIT(5), 0);
41862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir0_clk,	"bus-ir0",	"apb1",
41962306a36Sopenharmony_ci		      0x068, BIT(6), 0);
42062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir1_clk,	"bus-ir1",	"apb1",
42162306a36Sopenharmony_ci		      0x068, BIT(7), 0);
42262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ths_clk,	"bus-ths",	"apb1",
42362306a36Sopenharmony_ci		      0x068, BIT(8), 0);
42462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_keypad_clk,	"bus-keypad",	"apb1",
42562306a36Sopenharmony_ci		      0x068, BIT(10), 0);
42662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb1",
42762306a36Sopenharmony_ci		      0x068, BIT(12), 0);
42862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk,	"bus-i2s1",	"apb1",
42962306a36Sopenharmony_ci		      0x068, BIT(13), 0);
43062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk,	"bus-i2s2",	"apb1",
43162306a36Sopenharmony_ci		      0x068, BIT(14), 0);
43262306a36Sopenharmony_ci
43362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb2",
43462306a36Sopenharmony_ci		      0x06c, BIT(0), 0);
43562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb2",
43662306a36Sopenharmony_ci		      0x06c, BIT(1), 0);
43762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb2",
43862306a36Sopenharmony_ci		      0x06c, BIT(2), 0);
43962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c3_clk,	"bus-i2c3",	"apb2",
44062306a36Sopenharmony_ci		      0x06c, BIT(3), 0);
44162306a36Sopenharmony_ci/*
44262306a36Sopenharmony_ci * In datasheet here's "Reserved", however the gate exists in BSP soucre
44362306a36Sopenharmony_ci * code.
44462306a36Sopenharmony_ci */
44562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_can_clk,	"bus-can",	"apb2",
44662306a36Sopenharmony_ci		      0x06c, BIT(4), 0);
44762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_scr_clk,	"bus-scr",	"apb2",
44862306a36Sopenharmony_ci		      0x06c, BIT(5), 0);
44962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ps20_clk,	"bus-ps20",	"apb2",
45062306a36Sopenharmony_ci		      0x06c, BIT(6), 0);
45162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ps21_clk,	"bus-ps21",	"apb2",
45262306a36Sopenharmony_ci		      0x06c, BIT(7), 0);
45362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c4_clk,	"bus-i2c4",	"apb2",
45462306a36Sopenharmony_ci		      0x06c, BIT(15), 0);
45562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb2",
45662306a36Sopenharmony_ci		      0x06c, BIT(16), 0);
45762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb2",
45862306a36Sopenharmony_ci		      0x06c, BIT(17), 0);
45962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
46062306a36Sopenharmony_ci		      0x06c, BIT(18), 0);
46162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
46262306a36Sopenharmony_ci		      0x06c, BIT(19), 0);
46362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk,	"bus-uart4",	"apb2",
46462306a36Sopenharmony_ci		      0x06c, BIT(20), 0);
46562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart5_clk,	"bus-uart5",	"apb2",
46662306a36Sopenharmony_ci		      0x06c, BIT(21), 0);
46762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart6_clk,	"bus-uart6",	"apb2",
46862306a36Sopenharmony_ci		      0x06c, BIT(22), 0);
46962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart7_clk,	"bus-uart7",	"apb2",
47062306a36Sopenharmony_ci		      0x06c, BIT(23), 0);
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk,	"bus-dbg",	"ahb1",
47362306a36Sopenharmony_ci		      0x070, BIT(7), 0);
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_cistatic const char * const ths_parents[] = { "osc24M" };
47662306a36Sopenharmony_cistatic struct ccu_div ths_clk = {
47762306a36Sopenharmony_ci	.enable	= BIT(31),
47862306a36Sopenharmony_ci	.div	= _SUNXI_CCU_DIV_FLAGS(0, 2, CLK_DIVIDER_POWER_OF_TWO),
47962306a36Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX(24, 2),
48062306a36Sopenharmony_ci	.common	= {
48162306a36Sopenharmony_ci		.reg		= 0x074,
48262306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ths",
48362306a36Sopenharmony_ci						      ths_parents,
48462306a36Sopenharmony_ci						      &ccu_div_ops,
48562306a36Sopenharmony_ci						      0),
48662306a36Sopenharmony_ci	},
48762306a36Sopenharmony_ci};
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph0",
49062306a36Sopenharmony_ci						     "pll-periph1" };
49162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
49262306a36Sopenharmony_ci				  0, 4,		/* M */
49362306a36Sopenharmony_ci				  16, 2,	/* P */
49462306a36Sopenharmony_ci				  24, 2,	/* mux */
49562306a36Sopenharmony_ci				  BIT(31),	/* gate */
49662306a36Sopenharmony_ci				  0);
49762306a36Sopenharmony_ci
49862306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
49962306a36Sopenharmony_ci				  0, 4,		/* M */
50062306a36Sopenharmony_ci				  16, 2,	/* P */
50162306a36Sopenharmony_ci				  24, 2,	/* mux */
50262306a36Sopenharmony_ci				  BIT(31),	/* gate */
50362306a36Sopenharmony_ci				  0);
50462306a36Sopenharmony_ci
50562306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
50662306a36Sopenharmony_ci				  0, 4,		/* M */
50762306a36Sopenharmony_ci				  16, 2,	/* P */
50862306a36Sopenharmony_ci				  24, 2,	/* mux */
50962306a36Sopenharmony_ci				  BIT(31),	/* gate */
51062306a36Sopenharmony_ci				  0);
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
51362306a36Sopenharmony_ci				  0, 4,		/* M */
51462306a36Sopenharmony_ci				  16, 2,	/* P */
51562306a36Sopenharmony_ci				  24, 2,	/* mux */
51662306a36Sopenharmony_ci				  BIT(31),	/* gate */
51762306a36Sopenharmony_ci				  0);
51862306a36Sopenharmony_ci
51962306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc3_clk, "mmc3", mod0_default_parents, 0x094,
52062306a36Sopenharmony_ci				  0, 4,		/* M */
52162306a36Sopenharmony_ci				  16, 2,	/* P */
52262306a36Sopenharmony_ci				  24, 2,	/* mux */
52362306a36Sopenharmony_ci				  BIT(31),	/* gate */
52462306a36Sopenharmony_ci				  0);
52562306a36Sopenharmony_ci
52662306a36Sopenharmony_cistatic const char * const ts_parents[] = { "osc24M", "pll-periph0", };
52762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ts_clk, "ts", ts_parents, 0x098,
52862306a36Sopenharmony_ci				  0, 4,		/* M */
52962306a36Sopenharmony_ci				  16, 2,	/* P */
53062306a36Sopenharmony_ci				  24, 4,	/* mux */
53162306a36Sopenharmony_ci				  BIT(31),	/* gate */
53262306a36Sopenharmony_ci				  0);
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_cistatic const char * const ce_parents[] = { "osc24M", "pll-periph0-2x",
53562306a36Sopenharmony_ci					   "pll-periph1-2x" };
53662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x09c,
53762306a36Sopenharmony_ci				  0, 4,		/* M */
53862306a36Sopenharmony_ci				  16, 2,	/* P */
53962306a36Sopenharmony_ci				  24, 2,	/* mux */
54062306a36Sopenharmony_ci				  BIT(31),	/* gate */
54162306a36Sopenharmony_ci				  0);
54262306a36Sopenharmony_ci
54362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
54462306a36Sopenharmony_ci				  0, 4,		/* M */
54562306a36Sopenharmony_ci				  16, 2,	/* P */
54662306a36Sopenharmony_ci				  24, 2,	/* mux */
54762306a36Sopenharmony_ci				  BIT(31),	/* gate */
54862306a36Sopenharmony_ci				  0);
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
55162306a36Sopenharmony_ci				  0, 4,		/* M */
55262306a36Sopenharmony_ci				  16, 2,	/* P */
55362306a36Sopenharmony_ci				  24, 2,	/* mux */
55462306a36Sopenharmony_ci				  BIT(31),	/* gate */
55562306a36Sopenharmony_ci				  0);
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", mod0_default_parents, 0x0a8,
55862306a36Sopenharmony_ci				  0, 4,		/* M */
55962306a36Sopenharmony_ci				  16, 2,	/* P */
56062306a36Sopenharmony_ci				  24, 2,	/* mux */
56162306a36Sopenharmony_ci				  BIT(31),	/* gate */
56262306a36Sopenharmony_ci				  0);
56362306a36Sopenharmony_ci
56462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi3_clk, "spi3", mod0_default_parents, 0x0ac,
56562306a36Sopenharmony_ci				  0, 4,		/* M */
56662306a36Sopenharmony_ci				  16, 2,	/* P */
56762306a36Sopenharmony_ci				  24, 2,	/* mux */
56862306a36Sopenharmony_ci				  BIT(31),	/* gate */
56962306a36Sopenharmony_ci				  0);
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
57262306a36Sopenharmony_ci					    "pll-audio-2x", "pll-audio" };
57362306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
57462306a36Sopenharmony_ci			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
57762306a36Sopenharmony_ci			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s2_clk, "i2s2", i2s_parents,
58062306a36Sopenharmony_ci			       0x0b8, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
58162306a36Sopenharmony_ci
58262306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(ac97_clk, "ac97", i2s_parents,
58362306a36Sopenharmony_ci			       0x0bc, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", i2s_parents,
58662306a36Sopenharmony_ci			       0x0c0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_cistatic const char * const keypad_parents[] = { "osc24M", "osc32k" };
58962306a36Sopenharmony_cistatic const u8 keypad_table[] = { 0, 2 };
59062306a36Sopenharmony_cistatic struct ccu_mp keypad_clk = {
59162306a36Sopenharmony_ci	.enable	= BIT(31),
59262306a36Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 5),
59362306a36Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(16, 2),
59462306a36Sopenharmony_ci	.mux	= _SUNXI_CCU_MUX_TABLE(24, 2, keypad_table),
59562306a36Sopenharmony_ci	.common	= {
59662306a36Sopenharmony_ci		.reg		= 0x0c4,
59762306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("keypad",
59862306a36Sopenharmony_ci						      keypad_parents,
59962306a36Sopenharmony_ci						      &ccu_mp_ops,
60062306a36Sopenharmony_ci						      0),
60162306a36Sopenharmony_ci	}
60262306a36Sopenharmony_ci};
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_cistatic const char * const sata_parents[] = { "pll-sata-out", "sata-ext" };
60562306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(sata_clk, "sata", sata_parents,
60662306a36Sopenharmony_ci			       0x0c8, 24, 1, BIT(31), CLK_SET_RATE_PARENT);
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ci/*
60962306a36Sopenharmony_ci * There are 3 OHCI 12M clock source selection bits in this register.
61062306a36Sopenharmony_ci * We will force them to 0 (12M divided from 48M).
61162306a36Sopenharmony_ci */
61262306a36Sopenharmony_ci#define SUN8I_R40_USB_CLK_REG	0x0cc
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
61562306a36Sopenharmony_ci		      0x0cc, BIT(8), 0);
61662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
61762306a36Sopenharmony_ci		      0x0cc, BIT(9), 0);
61862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy2_clk,	"usb-phy2",	"osc24M",
61962306a36Sopenharmony_ci		      0x0cc, BIT(10), 0);
62062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk,	"usb-ohci0",	"osc12M",
62162306a36Sopenharmony_ci		      0x0cc, BIT(16), 0);
62262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci1_clk,	"usb-ohci1",	"osc12M",
62362306a36Sopenharmony_ci		      0x0cc, BIT(17), 0);
62462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci2_clk,	"usb-ohci2",	"osc12M",
62562306a36Sopenharmony_ci		      0x0cc, BIT(18), 0);
62662306a36Sopenharmony_ci
62762306a36Sopenharmony_cistatic const char * const ir_parents[] = { "osc24M", "pll-periph0",
62862306a36Sopenharmony_ci					   "pll-periph1", "osc32k" };
62962306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir0_clk, "ir0", ir_parents, 0x0d0,
63062306a36Sopenharmony_ci				  0, 4,		/* M */
63162306a36Sopenharmony_ci				  16, 2,	/* P */
63262306a36Sopenharmony_ci				  24, 2,	/* mux */
63362306a36Sopenharmony_ci				  BIT(31),	/* gate */
63462306a36Sopenharmony_ci				  0);
63562306a36Sopenharmony_ci
63662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir1_clk, "ir1", ir_parents, 0x0d4,
63762306a36Sopenharmony_ci				  0, 4,		/* M */
63862306a36Sopenharmony_ci				  16, 2,	/* P */
63962306a36Sopenharmony_ci				  24, 2,	/* mux */
64062306a36Sopenharmony_ci				  BIT(31),	/* gate */
64162306a36Sopenharmony_ci				  0);
64262306a36Sopenharmony_ci
64362306a36Sopenharmony_cistatic const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1" };
64462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents,
64562306a36Sopenharmony_ci			    0x0f4, 0, 2, 20, 2, CLK_IS_CRITICAL);
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"dram",
64862306a36Sopenharmony_ci		      0x100, BIT(0), 0);
64962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi0_clk,	"dram-csi0",	"dram",
65062306a36Sopenharmony_ci		      0x100, BIT(1), 0);
65162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi1_clk,	"dram-csi1",	"dram",
65262306a36Sopenharmony_ci		      0x100, BIT(2), 0);
65362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ts_clk,	"dram-ts",	"dram",
65462306a36Sopenharmony_ci		      0x100, BIT(3), 0);
65562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_tvd_clk,	"dram-tvd",	"dram",
65662306a36Sopenharmony_ci		      0x100, BIT(4), 0);
65762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_mp_clk,	"dram-mp",	"dram",
65862306a36Sopenharmony_ci		      0x100, BIT(5), 0);
65962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_deinterlace_clk,	"dram-deinterlace",	"dram",
66062306a36Sopenharmony_ci		      0x100, BIT(6), 0);
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-periph0-2x", "pll-de" };
66362306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents,
66462306a36Sopenharmony_ci				 0x104, 0, 4, 24, 3, BIT(31),
66562306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
66662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mp_clk, "mp", de_parents,
66762306a36Sopenharmony_ci				 0x108, 0, 4, 24, 3, BIT(31), 0);
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_cistatic const char * const tcon_parents[] = { "pll-video0", "pll-video1",
67062306a36Sopenharmony_ci					     "pll-video0-2x", "pll-video1-2x",
67162306a36Sopenharmony_ci					     "pll-mipi" };
67262306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(tcon_lcd0_clk, "tcon-lcd0", tcon_parents,
67362306a36Sopenharmony_ci			       0x110, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
67462306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(tcon_lcd1_clk, "tcon-lcd1", tcon_parents,
67562306a36Sopenharmony_ci			       0x114, 24, 3, BIT(31), CLK_SET_RATE_PARENT);
67662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv0_clk, "tcon-tv0", tcon_parents,
67762306a36Sopenharmony_ci				 0x118, 0, 4, 24, 3, BIT(31),
67862306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
67962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tcon_tv1_clk, "tcon-tv1", tcon_parents,
68062306a36Sopenharmony_ci				 0x11c, 0, 4, 24, 3, BIT(31),
68162306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
68262306a36Sopenharmony_ci
68362306a36Sopenharmony_cistatic const char * const deinterlace_parents[] = { "pll-periph0",
68462306a36Sopenharmony_ci						    "pll-periph1" };
68562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk, "deinterlace",
68662306a36Sopenharmony_ci				 deinterlace_parents, 0x124, 0, 4, 24, 3,
68762306a36Sopenharmony_ci				 BIT(31), 0);
68862306a36Sopenharmony_ci
68962306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "osc24M", "pll-video1",
69062306a36Sopenharmony_ci						 "pll-periph1" };
69162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi1-mclk", csi_mclk_parents,
69262306a36Sopenharmony_ci				 0x130, 0, 5, 8, 3, BIT(15), 0);
69362306a36Sopenharmony_ci
69462306a36Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-periph0", "pll-periph1" };
69562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_sclk_clk, "csi-sclk", csi_sclk_parents,
69662306a36Sopenharmony_ci				 0x134, 16, 4, 24, 3, BIT(31), 0);
69762306a36Sopenharmony_ci
69862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk", csi_mclk_parents,
69962306a36Sopenharmony_ci				 0x134, 0, 5, 8, 3, BIT(15), 0);
70062306a36Sopenharmony_ci
70162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
70262306a36Sopenharmony_ci			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(codec_clk,	"codec",	"pll-audio",
70562306a36Sopenharmony_ci		      0x140, BIT(31), CLK_SET_RATE_PARENT);
70662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
70762306a36Sopenharmony_ci		      0x144, BIT(31), 0);
70862306a36Sopenharmony_ci
70962306a36Sopenharmony_cistatic const char * const hdmi_parents[] = { "pll-video0", "pll-video1" };
71062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
71162306a36Sopenharmony_ci				 0x150, 0, 4, 24, 2, BIT(31),
71262306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(hdmi_slow_clk,	"hdmi-slow",	"osc24M",
71562306a36Sopenharmony_ci		      0x154, BIT(31), 0);
71662306a36Sopenharmony_ci
71762306a36Sopenharmony_ci/*
71862306a36Sopenharmony_ci * In the SoC's user manual, the P factor is mentioned, but not used in
71962306a36Sopenharmony_ci * the frequency formula.
72062306a36Sopenharmony_ci *
72162306a36Sopenharmony_ci * Here the factor is included, according to the BSP kernel source,
72262306a36Sopenharmony_ci * which contains the P factor of this clock.
72362306a36Sopenharmony_ci */
72462306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph0-2x",
72562306a36Sopenharmony_ci					     "pll-ddr0" };
72662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x15c,
72762306a36Sopenharmony_ci				  0, 4,		/* M */
72862306a36Sopenharmony_ci				  16, 2,	/* P */
72962306a36Sopenharmony_ci				  24, 2,	/* mux */
73062306a36Sopenharmony_ci				  BIT(31),	/* gate */
73162306a36Sopenharmony_ci				  CLK_IS_CRITICAL);
73262306a36Sopenharmony_ci
73362306a36Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video0", "pll-video1",
73462306a36Sopenharmony_ci						 "pll-periph0" };
73562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(dsi_dphy_clk, "dsi-dphy", dsi_dphy_parents,
73662306a36Sopenharmony_ci				 0x168, 0, 4, 8, 2, BIT(15), 0);
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tve0_clk, "tve0", tcon_parents,
73962306a36Sopenharmony_ci				 0x180, 0, 4, 24, 3, BIT(31), 0);
74062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tve1_clk, "tve1", tcon_parents,
74162306a36Sopenharmony_ci				 0x184, 0, 4, 24, 3, BIT(31), 0);
74262306a36Sopenharmony_ci
74362306a36Sopenharmony_cistatic const char * const tvd_parents[] = { "pll-video0", "pll-video1",
74462306a36Sopenharmony_ci					    "pll-video0-2x", "pll-video1-2x" };
74562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd0_clk, "tvd0", tvd_parents,
74662306a36Sopenharmony_ci				 0x188, 0, 4, 24, 3, BIT(31), 0);
74762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd1_clk, "tvd1", tvd_parents,
74862306a36Sopenharmony_ci				 0x18c, 0, 4, 24, 3, BIT(31), 0);
74962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd2_clk, "tvd2", tvd_parents,
75062306a36Sopenharmony_ci				 0x190, 0, 4, 24, 3, BIT(31), 0);
75162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd3_clk, "tvd3", tvd_parents,
75262306a36Sopenharmony_ci				 0x194, 0, 4, 24, 3, BIT(31), 0);
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
75562306a36Sopenharmony_ci			     0x1a0, 0, 3, BIT(31), CLK_SET_RATE_PARENT);
75662306a36Sopenharmony_ci
75762306a36Sopenharmony_cistatic const char * const out_parents[] = { "osc24M", "osc32k", "osc24M" };
75862306a36Sopenharmony_cistatic const struct ccu_mux_fixed_prediv out_predivs[] = {
75962306a36Sopenharmony_ci	{ .index = 0, .div = 750, },
76062306a36Sopenharmony_ci};
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_cistatic struct ccu_mp outa_clk = {
76362306a36Sopenharmony_ci	.enable	= BIT(31),
76462306a36Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(8, 5),
76562306a36Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(20, 2),
76662306a36Sopenharmony_ci	.mux	= {
76762306a36Sopenharmony_ci		.shift		= 24,
76862306a36Sopenharmony_ci		.width		= 2,
76962306a36Sopenharmony_ci		.fixed_predivs	= out_predivs,
77062306a36Sopenharmony_ci		.n_predivs	= ARRAY_SIZE(out_predivs),
77162306a36Sopenharmony_ci	},
77262306a36Sopenharmony_ci	.common	= {
77362306a36Sopenharmony_ci		.reg		= 0x1f0,
77462306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_PREDIV,
77562306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("outa", out_parents,
77662306a36Sopenharmony_ci						      &ccu_mp_ops,
77762306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
77862306a36Sopenharmony_ci	}
77962306a36Sopenharmony_ci};
78062306a36Sopenharmony_ci
78162306a36Sopenharmony_cistatic struct ccu_mp outb_clk = {
78262306a36Sopenharmony_ci	.enable	= BIT(31),
78362306a36Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(8, 5),
78462306a36Sopenharmony_ci	.p	= _SUNXI_CCU_DIV(20, 2),
78562306a36Sopenharmony_ci	.mux	= {
78662306a36Sopenharmony_ci		.shift		= 24,
78762306a36Sopenharmony_ci		.width		= 2,
78862306a36Sopenharmony_ci		.fixed_predivs	= out_predivs,
78962306a36Sopenharmony_ci		.n_predivs	= ARRAY_SIZE(out_predivs),
79062306a36Sopenharmony_ci	},
79162306a36Sopenharmony_ci	.common	= {
79262306a36Sopenharmony_ci		.reg		= 0x1f4,
79362306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_PREDIV,
79462306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("outb", out_parents,
79562306a36Sopenharmony_ci						      &ccu_mp_ops,
79662306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
79762306a36Sopenharmony_ci	}
79862306a36Sopenharmony_ci};
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_cistatic struct ccu_common *sun8i_r40_ccu_clks[] = {
80162306a36Sopenharmony_ci	&pll_cpu_clk.common,
80262306a36Sopenharmony_ci	&pll_audio_base_clk.common,
80362306a36Sopenharmony_ci	&pll_video0_clk.common,
80462306a36Sopenharmony_ci	&pll_ve_clk.common,
80562306a36Sopenharmony_ci	&pll_ddr0_clk.common,
80662306a36Sopenharmony_ci	&pll_periph0_clk.common,
80762306a36Sopenharmony_ci	&pll_periph0_sata_clk.common,
80862306a36Sopenharmony_ci	&pll_periph1_clk.common,
80962306a36Sopenharmony_ci	&pll_video1_clk.common,
81062306a36Sopenharmony_ci	&pll_sata_clk.common,
81162306a36Sopenharmony_ci	&pll_sata_out_clk.common,
81262306a36Sopenharmony_ci	&pll_gpu_clk.common,
81362306a36Sopenharmony_ci	&pll_mipi_clk.common,
81462306a36Sopenharmony_ci	&pll_de_clk.common,
81562306a36Sopenharmony_ci	&pll_ddr1_clk.common,
81662306a36Sopenharmony_ci	&cpu_clk.common,
81762306a36Sopenharmony_ci	&axi_clk.common,
81862306a36Sopenharmony_ci	&ahb1_clk.common,
81962306a36Sopenharmony_ci	&apb1_clk.common,
82062306a36Sopenharmony_ci	&apb2_clk.common,
82162306a36Sopenharmony_ci	&bus_mipi_dsi_clk.common,
82262306a36Sopenharmony_ci	&bus_ce_clk.common,
82362306a36Sopenharmony_ci	&bus_dma_clk.common,
82462306a36Sopenharmony_ci	&bus_mmc0_clk.common,
82562306a36Sopenharmony_ci	&bus_mmc1_clk.common,
82662306a36Sopenharmony_ci	&bus_mmc2_clk.common,
82762306a36Sopenharmony_ci	&bus_mmc3_clk.common,
82862306a36Sopenharmony_ci	&bus_nand_clk.common,
82962306a36Sopenharmony_ci	&bus_dram_clk.common,
83062306a36Sopenharmony_ci	&bus_emac_clk.common,
83162306a36Sopenharmony_ci	&bus_ts_clk.common,
83262306a36Sopenharmony_ci	&bus_hstimer_clk.common,
83362306a36Sopenharmony_ci	&bus_spi0_clk.common,
83462306a36Sopenharmony_ci	&bus_spi1_clk.common,
83562306a36Sopenharmony_ci	&bus_spi2_clk.common,
83662306a36Sopenharmony_ci	&bus_spi3_clk.common,
83762306a36Sopenharmony_ci	&bus_sata_clk.common,
83862306a36Sopenharmony_ci	&bus_otg_clk.common,
83962306a36Sopenharmony_ci	&bus_ehci0_clk.common,
84062306a36Sopenharmony_ci	&bus_ehci1_clk.common,
84162306a36Sopenharmony_ci	&bus_ehci2_clk.common,
84262306a36Sopenharmony_ci	&bus_ohci0_clk.common,
84362306a36Sopenharmony_ci	&bus_ohci1_clk.common,
84462306a36Sopenharmony_ci	&bus_ohci2_clk.common,
84562306a36Sopenharmony_ci	&bus_ve_clk.common,
84662306a36Sopenharmony_ci	&bus_mp_clk.common,
84762306a36Sopenharmony_ci	&bus_deinterlace_clk.common,
84862306a36Sopenharmony_ci	&bus_csi0_clk.common,
84962306a36Sopenharmony_ci	&bus_csi1_clk.common,
85062306a36Sopenharmony_ci	&bus_hdmi0_clk.common,
85162306a36Sopenharmony_ci	&bus_hdmi1_clk.common,
85262306a36Sopenharmony_ci	&bus_de_clk.common,
85362306a36Sopenharmony_ci	&bus_tve0_clk.common,
85462306a36Sopenharmony_ci	&bus_tve1_clk.common,
85562306a36Sopenharmony_ci	&bus_tve_top_clk.common,
85662306a36Sopenharmony_ci	&bus_gmac_clk.common,
85762306a36Sopenharmony_ci	&bus_gpu_clk.common,
85862306a36Sopenharmony_ci	&bus_tvd0_clk.common,
85962306a36Sopenharmony_ci	&bus_tvd1_clk.common,
86062306a36Sopenharmony_ci	&bus_tvd2_clk.common,
86162306a36Sopenharmony_ci	&bus_tvd3_clk.common,
86262306a36Sopenharmony_ci	&bus_tvd_top_clk.common,
86362306a36Sopenharmony_ci	&bus_tcon_lcd0_clk.common,
86462306a36Sopenharmony_ci	&bus_tcon_lcd1_clk.common,
86562306a36Sopenharmony_ci	&bus_tcon_tv0_clk.common,
86662306a36Sopenharmony_ci	&bus_tcon_tv1_clk.common,
86762306a36Sopenharmony_ci	&bus_tcon_top_clk.common,
86862306a36Sopenharmony_ci	&bus_codec_clk.common,
86962306a36Sopenharmony_ci	&bus_spdif_clk.common,
87062306a36Sopenharmony_ci	&bus_ac97_clk.common,
87162306a36Sopenharmony_ci	&bus_pio_clk.common,
87262306a36Sopenharmony_ci	&bus_ir0_clk.common,
87362306a36Sopenharmony_ci	&bus_ir1_clk.common,
87462306a36Sopenharmony_ci	&bus_ths_clk.common,
87562306a36Sopenharmony_ci	&bus_keypad_clk.common,
87662306a36Sopenharmony_ci	&bus_i2s0_clk.common,
87762306a36Sopenharmony_ci	&bus_i2s1_clk.common,
87862306a36Sopenharmony_ci	&bus_i2s2_clk.common,
87962306a36Sopenharmony_ci	&bus_i2c0_clk.common,
88062306a36Sopenharmony_ci	&bus_i2c1_clk.common,
88162306a36Sopenharmony_ci	&bus_i2c2_clk.common,
88262306a36Sopenharmony_ci	&bus_i2c3_clk.common,
88362306a36Sopenharmony_ci	&bus_can_clk.common,
88462306a36Sopenharmony_ci	&bus_scr_clk.common,
88562306a36Sopenharmony_ci	&bus_ps20_clk.common,
88662306a36Sopenharmony_ci	&bus_ps21_clk.common,
88762306a36Sopenharmony_ci	&bus_i2c4_clk.common,
88862306a36Sopenharmony_ci	&bus_uart0_clk.common,
88962306a36Sopenharmony_ci	&bus_uart1_clk.common,
89062306a36Sopenharmony_ci	&bus_uart2_clk.common,
89162306a36Sopenharmony_ci	&bus_uart3_clk.common,
89262306a36Sopenharmony_ci	&bus_uart4_clk.common,
89362306a36Sopenharmony_ci	&bus_uart5_clk.common,
89462306a36Sopenharmony_ci	&bus_uart6_clk.common,
89562306a36Sopenharmony_ci	&bus_uart7_clk.common,
89662306a36Sopenharmony_ci	&bus_dbg_clk.common,
89762306a36Sopenharmony_ci	&ths_clk.common,
89862306a36Sopenharmony_ci	&nand_clk.common,
89962306a36Sopenharmony_ci	&mmc0_clk.common,
90062306a36Sopenharmony_ci	&mmc1_clk.common,
90162306a36Sopenharmony_ci	&mmc2_clk.common,
90262306a36Sopenharmony_ci	&mmc3_clk.common,
90362306a36Sopenharmony_ci	&ts_clk.common,
90462306a36Sopenharmony_ci	&ce_clk.common,
90562306a36Sopenharmony_ci	&spi0_clk.common,
90662306a36Sopenharmony_ci	&spi1_clk.common,
90762306a36Sopenharmony_ci	&spi2_clk.common,
90862306a36Sopenharmony_ci	&spi3_clk.common,
90962306a36Sopenharmony_ci	&i2s0_clk.common,
91062306a36Sopenharmony_ci	&i2s1_clk.common,
91162306a36Sopenharmony_ci	&i2s2_clk.common,
91262306a36Sopenharmony_ci	&ac97_clk.common,
91362306a36Sopenharmony_ci	&spdif_clk.common,
91462306a36Sopenharmony_ci	&keypad_clk.common,
91562306a36Sopenharmony_ci	&sata_clk.common,
91662306a36Sopenharmony_ci	&usb_phy0_clk.common,
91762306a36Sopenharmony_ci	&usb_phy1_clk.common,
91862306a36Sopenharmony_ci	&usb_phy2_clk.common,
91962306a36Sopenharmony_ci	&usb_ohci0_clk.common,
92062306a36Sopenharmony_ci	&usb_ohci1_clk.common,
92162306a36Sopenharmony_ci	&usb_ohci2_clk.common,
92262306a36Sopenharmony_ci	&ir0_clk.common,
92362306a36Sopenharmony_ci	&ir1_clk.common,
92462306a36Sopenharmony_ci	&dram_clk.common,
92562306a36Sopenharmony_ci	&dram_ve_clk.common,
92662306a36Sopenharmony_ci	&dram_csi0_clk.common,
92762306a36Sopenharmony_ci	&dram_csi1_clk.common,
92862306a36Sopenharmony_ci	&dram_ts_clk.common,
92962306a36Sopenharmony_ci	&dram_tvd_clk.common,
93062306a36Sopenharmony_ci	&dram_mp_clk.common,
93162306a36Sopenharmony_ci	&dram_deinterlace_clk.common,
93262306a36Sopenharmony_ci	&de_clk.common,
93362306a36Sopenharmony_ci	&mp_clk.common,
93462306a36Sopenharmony_ci	&tcon_lcd0_clk.common,
93562306a36Sopenharmony_ci	&tcon_lcd1_clk.common,
93662306a36Sopenharmony_ci	&tcon_tv0_clk.common,
93762306a36Sopenharmony_ci	&tcon_tv1_clk.common,
93862306a36Sopenharmony_ci	&deinterlace_clk.common,
93962306a36Sopenharmony_ci	&csi1_mclk_clk.common,
94062306a36Sopenharmony_ci	&csi_sclk_clk.common,
94162306a36Sopenharmony_ci	&csi0_mclk_clk.common,
94262306a36Sopenharmony_ci	&ve_clk.common,
94362306a36Sopenharmony_ci	&codec_clk.common,
94462306a36Sopenharmony_ci	&avs_clk.common,
94562306a36Sopenharmony_ci	&hdmi_clk.common,
94662306a36Sopenharmony_ci	&hdmi_slow_clk.common,
94762306a36Sopenharmony_ci	&mbus_clk.common,
94862306a36Sopenharmony_ci	&dsi_dphy_clk.common,
94962306a36Sopenharmony_ci	&tve0_clk.common,
95062306a36Sopenharmony_ci	&tve1_clk.common,
95162306a36Sopenharmony_ci	&tvd0_clk.common,
95262306a36Sopenharmony_ci	&tvd1_clk.common,
95362306a36Sopenharmony_ci	&tvd2_clk.common,
95462306a36Sopenharmony_ci	&tvd3_clk.common,
95562306a36Sopenharmony_ci	&gpu_clk.common,
95662306a36Sopenharmony_ci	&outa_clk.common,
95762306a36Sopenharmony_ci	&outb_clk.common,
95862306a36Sopenharmony_ci};
95962306a36Sopenharmony_ci
96062306a36Sopenharmony_ci/* Fixed Factor clocks */
96162306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_FW_NAME(osc12M_clk, "osc12M", "hosc", 2, 1, 0);
96262306a36Sopenharmony_ci
96362306a36Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = {
96462306a36Sopenharmony_ci	&pll_audio_base_clk.common.hw
96562306a36Sopenharmony_ci};
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_ci/* We hardcode the divider to 1 for now */
96862306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
96962306a36Sopenharmony_ci			    clk_parent_pll_audio,
97062306a36Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
97162306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
97262306a36Sopenharmony_ci			    clk_parent_pll_audio,
97362306a36Sopenharmony_ci			    2, 1, CLK_SET_RATE_PARENT);
97462306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
97562306a36Sopenharmony_ci			    clk_parent_pll_audio,
97662306a36Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
97762306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
97862306a36Sopenharmony_ci			    clk_parent_pll_audio,
97962306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
98062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x",
98162306a36Sopenharmony_ci			   &pll_periph0_clk.common.hw,
98262306a36Sopenharmony_ci			   1, 2, 0);
98362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph1_2x_clk, "pll-periph1-2x",
98462306a36Sopenharmony_ci			   &pll_periph1_clk.common.hw,
98562306a36Sopenharmony_ci			   1, 2, 0);
98662306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video0_2x_clk, "pll-video0-2x",
98762306a36Sopenharmony_ci			   &pll_video0_clk.common.hw,
98862306a36Sopenharmony_ci			   1, 2, 0);
98962306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video1_2x_clk, "pll-video1-2x",
99062306a36Sopenharmony_ci			   &pll_video1_clk.common.hw,
99162306a36Sopenharmony_ci			   1, 2, 0);
99262306a36Sopenharmony_ci
99362306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_r40_hw_clks = {
99462306a36Sopenharmony_ci	.hws	= {
99562306a36Sopenharmony_ci		[CLK_OSC_12M]		= &osc12M_clk.hw,
99662306a36Sopenharmony_ci		[CLK_PLL_CPU]		= &pll_cpu_clk.common.hw,
99762306a36Sopenharmony_ci		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
99862306a36Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
99962306a36Sopenharmony_ci		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
100062306a36Sopenharmony_ci		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
100162306a36Sopenharmony_ci		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
100262306a36Sopenharmony_ci		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
100362306a36Sopenharmony_ci		[CLK_PLL_VIDEO0_2X]	= &pll_video0_2x_clk.hw,
100462306a36Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
100562306a36Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
100662306a36Sopenharmony_ci		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
100762306a36Sopenharmony_ci		[CLK_PLL_PERIPH0_SATA]	= &pll_periph0_sata_clk.common.hw,
100862306a36Sopenharmony_ci		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
100962306a36Sopenharmony_ci		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
101062306a36Sopenharmony_ci		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
101162306a36Sopenharmony_ci		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
101262306a36Sopenharmony_ci		[CLK_PLL_VIDEO1_2X]	= &pll_video1_2x_clk.hw,
101362306a36Sopenharmony_ci		[CLK_PLL_SATA]		= &pll_sata_clk.common.hw,
101462306a36Sopenharmony_ci		[CLK_PLL_SATA_OUT]	= &pll_sata_out_clk.common.hw,
101562306a36Sopenharmony_ci		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
101662306a36Sopenharmony_ci		[CLK_PLL_MIPI]		= &pll_mipi_clk.common.hw,
101762306a36Sopenharmony_ci		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
101862306a36Sopenharmony_ci		[CLK_PLL_DDR1]		= &pll_ddr1_clk.common.hw,
101962306a36Sopenharmony_ci		[CLK_CPU]		= &cpu_clk.common.hw,
102062306a36Sopenharmony_ci		[CLK_AXI]		= &axi_clk.common.hw,
102162306a36Sopenharmony_ci		[CLK_AHB1]		= &ahb1_clk.common.hw,
102262306a36Sopenharmony_ci		[CLK_APB1]		= &apb1_clk.common.hw,
102362306a36Sopenharmony_ci		[CLK_APB2]		= &apb2_clk.common.hw,
102462306a36Sopenharmony_ci		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
102562306a36Sopenharmony_ci		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
102662306a36Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
102762306a36Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
102862306a36Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
102962306a36Sopenharmony_ci		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
103062306a36Sopenharmony_ci		[CLK_BUS_MMC3]		= &bus_mmc3_clk.common.hw,
103162306a36Sopenharmony_ci		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
103262306a36Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
103362306a36Sopenharmony_ci		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
103462306a36Sopenharmony_ci		[CLK_BUS_TS]		= &bus_ts_clk.common.hw,
103562306a36Sopenharmony_ci		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
103662306a36Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
103762306a36Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
103862306a36Sopenharmony_ci		[CLK_BUS_SPI2]		= &bus_spi2_clk.common.hw,
103962306a36Sopenharmony_ci		[CLK_BUS_SPI3]		= &bus_spi3_clk.common.hw,
104062306a36Sopenharmony_ci		[CLK_BUS_SATA]		= &bus_sata_clk.common.hw,
104162306a36Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
104262306a36Sopenharmony_ci		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
104362306a36Sopenharmony_ci		[CLK_BUS_EHCI1]		= &bus_ehci1_clk.common.hw,
104462306a36Sopenharmony_ci		[CLK_BUS_EHCI2]		= &bus_ehci2_clk.common.hw,
104562306a36Sopenharmony_ci		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
104662306a36Sopenharmony_ci		[CLK_BUS_OHCI1]		= &bus_ohci1_clk.common.hw,
104762306a36Sopenharmony_ci		[CLK_BUS_OHCI2]		= &bus_ohci2_clk.common.hw,
104862306a36Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
104962306a36Sopenharmony_ci		[CLK_BUS_MP]		= &bus_mp_clk.common.hw,
105062306a36Sopenharmony_ci		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
105162306a36Sopenharmony_ci		[CLK_BUS_CSI0]		= &bus_csi0_clk.common.hw,
105262306a36Sopenharmony_ci		[CLK_BUS_CSI1]		= &bus_csi1_clk.common.hw,
105362306a36Sopenharmony_ci		[CLK_BUS_HDMI0]		= &bus_hdmi0_clk.common.hw,
105462306a36Sopenharmony_ci		[CLK_BUS_HDMI1]		= &bus_hdmi1_clk.common.hw,
105562306a36Sopenharmony_ci		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
105662306a36Sopenharmony_ci		[CLK_BUS_TVE0]		= &bus_tve0_clk.common.hw,
105762306a36Sopenharmony_ci		[CLK_BUS_TVE1]		= &bus_tve1_clk.common.hw,
105862306a36Sopenharmony_ci		[CLK_BUS_TVE_TOP]	= &bus_tve_top_clk.common.hw,
105962306a36Sopenharmony_ci		[CLK_BUS_GMAC]		= &bus_gmac_clk.common.hw,
106062306a36Sopenharmony_ci		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
106162306a36Sopenharmony_ci		[CLK_BUS_TVD0]		= &bus_tvd0_clk.common.hw,
106262306a36Sopenharmony_ci		[CLK_BUS_TVD1]		= &bus_tvd1_clk.common.hw,
106362306a36Sopenharmony_ci		[CLK_BUS_TVD2]		= &bus_tvd2_clk.common.hw,
106462306a36Sopenharmony_ci		[CLK_BUS_TVD3]		= &bus_tvd3_clk.common.hw,
106562306a36Sopenharmony_ci		[CLK_BUS_TVD_TOP]	= &bus_tvd_top_clk.common.hw,
106662306a36Sopenharmony_ci		[CLK_BUS_TCON_LCD0]	= &bus_tcon_lcd0_clk.common.hw,
106762306a36Sopenharmony_ci		[CLK_BUS_TCON_LCD1]	= &bus_tcon_lcd1_clk.common.hw,
106862306a36Sopenharmony_ci		[CLK_BUS_TCON_TV0]	= &bus_tcon_tv0_clk.common.hw,
106962306a36Sopenharmony_ci		[CLK_BUS_TCON_TV1]	= &bus_tcon_tv1_clk.common.hw,
107062306a36Sopenharmony_ci		[CLK_BUS_TCON_TOP]	= &bus_tcon_top_clk.common.hw,
107162306a36Sopenharmony_ci		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
107262306a36Sopenharmony_ci		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
107362306a36Sopenharmony_ci		[CLK_BUS_AC97]		= &bus_ac97_clk.common.hw,
107462306a36Sopenharmony_ci		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
107562306a36Sopenharmony_ci		[CLK_BUS_IR0]		= &bus_ir0_clk.common.hw,
107662306a36Sopenharmony_ci		[CLK_BUS_IR1]		= &bus_ir1_clk.common.hw,
107762306a36Sopenharmony_ci		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
107862306a36Sopenharmony_ci		[CLK_BUS_KEYPAD]	= &bus_keypad_clk.common.hw,
107962306a36Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
108062306a36Sopenharmony_ci		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
108162306a36Sopenharmony_ci		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
108262306a36Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
108362306a36Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
108462306a36Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
108562306a36Sopenharmony_ci		[CLK_BUS_I2C3]		= &bus_i2c3_clk.common.hw,
108662306a36Sopenharmony_ci		[CLK_BUS_CAN]		= &bus_can_clk.common.hw,
108762306a36Sopenharmony_ci		[CLK_BUS_SCR]		= &bus_scr_clk.common.hw,
108862306a36Sopenharmony_ci		[CLK_BUS_PS20]		= &bus_ps20_clk.common.hw,
108962306a36Sopenharmony_ci		[CLK_BUS_PS21]		= &bus_ps21_clk.common.hw,
109062306a36Sopenharmony_ci		[CLK_BUS_I2C4]		= &bus_i2c4_clk.common.hw,
109162306a36Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
109262306a36Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
109362306a36Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
109462306a36Sopenharmony_ci		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
109562306a36Sopenharmony_ci		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
109662306a36Sopenharmony_ci		[CLK_BUS_UART5]		= &bus_uart5_clk.common.hw,
109762306a36Sopenharmony_ci		[CLK_BUS_UART6]		= &bus_uart6_clk.common.hw,
109862306a36Sopenharmony_ci		[CLK_BUS_UART7]		= &bus_uart7_clk.common.hw,
109962306a36Sopenharmony_ci		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
110062306a36Sopenharmony_ci		[CLK_THS]		= &ths_clk.common.hw,
110162306a36Sopenharmony_ci		[CLK_NAND]		= &nand_clk.common.hw,
110262306a36Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
110362306a36Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
110462306a36Sopenharmony_ci		[CLK_MMC2]		= &mmc2_clk.common.hw,
110562306a36Sopenharmony_ci		[CLK_MMC3]		= &mmc3_clk.common.hw,
110662306a36Sopenharmony_ci		[CLK_TS]		= &ts_clk.common.hw,
110762306a36Sopenharmony_ci		[CLK_CE]		= &ce_clk.common.hw,
110862306a36Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
110962306a36Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
111062306a36Sopenharmony_ci		[CLK_SPI2]		= &spi2_clk.common.hw,
111162306a36Sopenharmony_ci		[CLK_SPI3]		= &spi3_clk.common.hw,
111262306a36Sopenharmony_ci		[CLK_I2S0]		= &i2s0_clk.common.hw,
111362306a36Sopenharmony_ci		[CLK_I2S1]		= &i2s1_clk.common.hw,
111462306a36Sopenharmony_ci		[CLK_I2S2]		= &i2s2_clk.common.hw,
111562306a36Sopenharmony_ci		[CLK_AC97]		= &ac97_clk.common.hw,
111662306a36Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
111762306a36Sopenharmony_ci		[CLK_KEYPAD]		= &keypad_clk.common.hw,
111862306a36Sopenharmony_ci		[CLK_SATA]		= &sata_clk.common.hw,
111962306a36Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
112062306a36Sopenharmony_ci		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
112162306a36Sopenharmony_ci		[CLK_USB_PHY2]		= &usb_phy2_clk.common.hw,
112262306a36Sopenharmony_ci		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
112362306a36Sopenharmony_ci		[CLK_USB_OHCI1]		= &usb_ohci1_clk.common.hw,
112462306a36Sopenharmony_ci		[CLK_USB_OHCI2]		= &usb_ohci2_clk.common.hw,
112562306a36Sopenharmony_ci		[CLK_IR0]		= &ir0_clk.common.hw,
112662306a36Sopenharmony_ci		[CLK_IR1]		= &ir1_clk.common.hw,
112762306a36Sopenharmony_ci		[CLK_DRAM]		= &dram_clk.common.hw,
112862306a36Sopenharmony_ci		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
112962306a36Sopenharmony_ci		[CLK_DRAM_CSI0]		= &dram_csi0_clk.common.hw,
113062306a36Sopenharmony_ci		[CLK_DRAM_CSI1]		= &dram_csi1_clk.common.hw,
113162306a36Sopenharmony_ci		[CLK_DRAM_TS]		= &dram_ts_clk.common.hw,
113262306a36Sopenharmony_ci		[CLK_DRAM_TVD]		= &dram_tvd_clk.common.hw,
113362306a36Sopenharmony_ci		[CLK_DRAM_MP]		= &dram_mp_clk.common.hw,
113462306a36Sopenharmony_ci		[CLK_DRAM_DEINTERLACE]	= &dram_deinterlace_clk.common.hw,
113562306a36Sopenharmony_ci		[CLK_DE]		= &de_clk.common.hw,
113662306a36Sopenharmony_ci		[CLK_MP]		= &mp_clk.common.hw,
113762306a36Sopenharmony_ci		[CLK_TCON_LCD0]		= &tcon_lcd0_clk.common.hw,
113862306a36Sopenharmony_ci		[CLK_TCON_LCD1]		= &tcon_lcd1_clk.common.hw,
113962306a36Sopenharmony_ci		[CLK_TCON_TV0]		= &tcon_tv0_clk.common.hw,
114062306a36Sopenharmony_ci		[CLK_TCON_TV1]		= &tcon_tv1_clk.common.hw,
114162306a36Sopenharmony_ci		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
114262306a36Sopenharmony_ci		[CLK_CSI1_MCLK]		= &csi1_mclk_clk.common.hw,
114362306a36Sopenharmony_ci		[CLK_CSI_SCLK]		= &csi_sclk_clk.common.hw,
114462306a36Sopenharmony_ci		[CLK_CSI0_MCLK]		= &csi0_mclk_clk.common.hw,
114562306a36Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
114662306a36Sopenharmony_ci		[CLK_CODEC]		= &codec_clk.common.hw,
114762306a36Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
114862306a36Sopenharmony_ci		[CLK_HDMI]		= &hdmi_clk.common.hw,
114962306a36Sopenharmony_ci		[CLK_HDMI_SLOW]		= &hdmi_slow_clk.common.hw,
115062306a36Sopenharmony_ci		[CLK_MBUS]		= &mbus_clk.common.hw,
115162306a36Sopenharmony_ci		[CLK_DSI_DPHY]		= &dsi_dphy_clk.common.hw,
115262306a36Sopenharmony_ci		[CLK_TVE0]		= &tve0_clk.common.hw,
115362306a36Sopenharmony_ci		[CLK_TVE1]		= &tve1_clk.common.hw,
115462306a36Sopenharmony_ci		[CLK_TVD0]		= &tvd0_clk.common.hw,
115562306a36Sopenharmony_ci		[CLK_TVD1]		= &tvd1_clk.common.hw,
115662306a36Sopenharmony_ci		[CLK_TVD2]		= &tvd2_clk.common.hw,
115762306a36Sopenharmony_ci		[CLK_TVD3]		= &tvd3_clk.common.hw,
115862306a36Sopenharmony_ci		[CLK_GPU]		= &gpu_clk.common.hw,
115962306a36Sopenharmony_ci		[CLK_OUTA]		= &outa_clk.common.hw,
116062306a36Sopenharmony_ci		[CLK_OUTB]		= &outb_clk.common.hw,
116162306a36Sopenharmony_ci	},
116262306a36Sopenharmony_ci	.num	= CLK_NUMBER,
116362306a36Sopenharmony_ci};
116462306a36Sopenharmony_ci
116562306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_r40_ccu_resets[] = {
116662306a36Sopenharmony_ci	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
116762306a36Sopenharmony_ci	[RST_USB_PHY1]		=  { 0x0cc, BIT(1) },
116862306a36Sopenharmony_ci	[RST_USB_PHY2]		=  { 0x0cc, BIT(2) },
116962306a36Sopenharmony_ci
117062306a36Sopenharmony_ci	[RST_DRAM]		=  { 0x0f4, BIT(31) },
117162306a36Sopenharmony_ci	[RST_MBUS]		=  { 0x0fc, BIT(31) },
117262306a36Sopenharmony_ci
117362306a36Sopenharmony_ci	[RST_BUS_MIPI_DSI]	=  { 0x2c0, BIT(1) },
117462306a36Sopenharmony_ci	[RST_BUS_CE]		=  { 0x2c0, BIT(5) },
117562306a36Sopenharmony_ci	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
117662306a36Sopenharmony_ci	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
117762306a36Sopenharmony_ci	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
117862306a36Sopenharmony_ci	[RST_BUS_MMC2]		=  { 0x2c0, BIT(10) },
117962306a36Sopenharmony_ci	[RST_BUS_MMC3]		=  { 0x2c0, BIT(11) },
118062306a36Sopenharmony_ci	[RST_BUS_NAND]		=  { 0x2c0, BIT(13) },
118162306a36Sopenharmony_ci	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
118262306a36Sopenharmony_ci	[RST_BUS_EMAC]		=  { 0x2c0, BIT(17) },
118362306a36Sopenharmony_ci	[RST_BUS_TS]		=  { 0x2c0, BIT(18) },
118462306a36Sopenharmony_ci	[RST_BUS_HSTIMER]	=  { 0x2c0, BIT(19) },
118562306a36Sopenharmony_ci	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
118662306a36Sopenharmony_ci	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
118762306a36Sopenharmony_ci	[RST_BUS_SPI2]		=  { 0x2c0, BIT(22) },
118862306a36Sopenharmony_ci	[RST_BUS_SPI3]		=  { 0x2c0, BIT(23) },
118962306a36Sopenharmony_ci	[RST_BUS_SATA]		=  { 0x2c0, BIT(24) },
119062306a36Sopenharmony_ci	[RST_BUS_OTG]		=  { 0x2c0, BIT(25) },
119162306a36Sopenharmony_ci	[RST_BUS_EHCI0]		=  { 0x2c0, BIT(26) },
119262306a36Sopenharmony_ci	[RST_BUS_EHCI1]		=  { 0x2c0, BIT(27) },
119362306a36Sopenharmony_ci	[RST_BUS_EHCI2]		=  { 0x2c0, BIT(28) },
119462306a36Sopenharmony_ci	[RST_BUS_OHCI0]		=  { 0x2c0, BIT(29) },
119562306a36Sopenharmony_ci	[RST_BUS_OHCI1]		=  { 0x2c0, BIT(30) },
119662306a36Sopenharmony_ci	[RST_BUS_OHCI2]		=  { 0x2c0, BIT(31) },
119762306a36Sopenharmony_ci
119862306a36Sopenharmony_ci	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
119962306a36Sopenharmony_ci	[RST_BUS_MP]		=  { 0x2c4, BIT(2) },
120062306a36Sopenharmony_ci	[RST_BUS_DEINTERLACE]	=  { 0x2c4, BIT(5) },
120162306a36Sopenharmony_ci	[RST_BUS_CSI0]		=  { 0x2c4, BIT(8) },
120262306a36Sopenharmony_ci	[RST_BUS_CSI1]		=  { 0x2c4, BIT(9) },
120362306a36Sopenharmony_ci	[RST_BUS_HDMI0]		=  { 0x2c4, BIT(10) },
120462306a36Sopenharmony_ci	[RST_BUS_HDMI1]		=  { 0x2c4, BIT(11) },
120562306a36Sopenharmony_ci	[RST_BUS_DE]		=  { 0x2c4, BIT(12) },
120662306a36Sopenharmony_ci	[RST_BUS_TVE0]		=  { 0x2c4, BIT(13) },
120762306a36Sopenharmony_ci	[RST_BUS_TVE1]		=  { 0x2c4, BIT(14) },
120862306a36Sopenharmony_ci	[RST_BUS_TVE_TOP]	=  { 0x2c4, BIT(15) },
120962306a36Sopenharmony_ci	[RST_BUS_GMAC]		=  { 0x2c4, BIT(17) },
121062306a36Sopenharmony_ci	[RST_BUS_GPU]		=  { 0x2c4, BIT(20) },
121162306a36Sopenharmony_ci	[RST_BUS_TVD0]		=  { 0x2c4, BIT(21) },
121262306a36Sopenharmony_ci	[RST_BUS_TVD1]		=  { 0x2c4, BIT(22) },
121362306a36Sopenharmony_ci	[RST_BUS_TVD2]		=  { 0x2c4, BIT(23) },
121462306a36Sopenharmony_ci	[RST_BUS_TVD3]		=  { 0x2c4, BIT(24) },
121562306a36Sopenharmony_ci	[RST_BUS_TVD_TOP]	=  { 0x2c4, BIT(25) },
121662306a36Sopenharmony_ci	[RST_BUS_TCON_LCD0]	=  { 0x2c4, BIT(26) },
121762306a36Sopenharmony_ci	[RST_BUS_TCON_LCD1]	=  { 0x2c4, BIT(27) },
121862306a36Sopenharmony_ci	[RST_BUS_TCON_TV0]	=  { 0x2c4, BIT(28) },
121962306a36Sopenharmony_ci	[RST_BUS_TCON_TV1]	=  { 0x2c4, BIT(29) },
122062306a36Sopenharmony_ci	[RST_BUS_TCON_TOP]	=  { 0x2c4, BIT(30) },
122162306a36Sopenharmony_ci	[RST_BUS_DBG]		=  { 0x2c4, BIT(31) },
122262306a36Sopenharmony_ci
122362306a36Sopenharmony_ci	[RST_BUS_LVDS]		=  { 0x2c8, BIT(0) },
122462306a36Sopenharmony_ci
122562306a36Sopenharmony_ci	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
122662306a36Sopenharmony_ci	[RST_BUS_SPDIF]		=  { 0x2d0, BIT(1) },
122762306a36Sopenharmony_ci	[RST_BUS_AC97]		=  { 0x2d0, BIT(2) },
122862306a36Sopenharmony_ci	[RST_BUS_IR0]		=  { 0x2d0, BIT(6) },
122962306a36Sopenharmony_ci	[RST_BUS_IR1]		=  { 0x2d0, BIT(7) },
123062306a36Sopenharmony_ci	[RST_BUS_THS]		=  { 0x2d0, BIT(8) },
123162306a36Sopenharmony_ci	[RST_BUS_KEYPAD]	=  { 0x2d0, BIT(10) },
123262306a36Sopenharmony_ci	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
123362306a36Sopenharmony_ci	[RST_BUS_I2S1]		=  { 0x2d0, BIT(13) },
123462306a36Sopenharmony_ci	[RST_BUS_I2S2]		=  { 0x2d0, BIT(14) },
123562306a36Sopenharmony_ci
123662306a36Sopenharmony_ci	[RST_BUS_I2C0]		=  { 0x2d8, BIT(0) },
123762306a36Sopenharmony_ci	[RST_BUS_I2C1]		=  { 0x2d8, BIT(1) },
123862306a36Sopenharmony_ci	[RST_BUS_I2C2]		=  { 0x2d8, BIT(2) },
123962306a36Sopenharmony_ci	[RST_BUS_I2C3]		=  { 0x2d8, BIT(3) },
124062306a36Sopenharmony_ci	[RST_BUS_CAN]		=  { 0x2d8, BIT(4) },
124162306a36Sopenharmony_ci	[RST_BUS_SCR]		=  { 0x2d8, BIT(5) },
124262306a36Sopenharmony_ci	[RST_BUS_PS20]		=  { 0x2d8, BIT(6) },
124362306a36Sopenharmony_ci	[RST_BUS_PS21]		=  { 0x2d8, BIT(7) },
124462306a36Sopenharmony_ci	[RST_BUS_I2C4]		=  { 0x2d8, BIT(15) },
124562306a36Sopenharmony_ci	[RST_BUS_UART0]		=  { 0x2d8, BIT(16) },
124662306a36Sopenharmony_ci	[RST_BUS_UART1]		=  { 0x2d8, BIT(17) },
124762306a36Sopenharmony_ci	[RST_BUS_UART2]		=  { 0x2d8, BIT(18) },
124862306a36Sopenharmony_ci	[RST_BUS_UART3]		=  { 0x2d8, BIT(19) },
124962306a36Sopenharmony_ci	[RST_BUS_UART4]		=  { 0x2d8, BIT(20) },
125062306a36Sopenharmony_ci	[RST_BUS_UART5]		=  { 0x2d8, BIT(21) },
125162306a36Sopenharmony_ci	[RST_BUS_UART6]		=  { 0x2d8, BIT(22) },
125262306a36Sopenharmony_ci	[RST_BUS_UART7]		=  { 0x2d8, BIT(23) },
125362306a36Sopenharmony_ci};
125462306a36Sopenharmony_ci
125562306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_r40_ccu_desc = {
125662306a36Sopenharmony_ci	.ccu_clks	= sun8i_r40_ccu_clks,
125762306a36Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(sun8i_r40_ccu_clks),
125862306a36Sopenharmony_ci
125962306a36Sopenharmony_ci	.hw_clks	= &sun8i_r40_hw_clks,
126062306a36Sopenharmony_ci
126162306a36Sopenharmony_ci	.resets		= sun8i_r40_ccu_resets,
126262306a36Sopenharmony_ci	.num_resets	= ARRAY_SIZE(sun8i_r40_ccu_resets),
126362306a36Sopenharmony_ci};
126462306a36Sopenharmony_ci
126562306a36Sopenharmony_cistatic struct ccu_pll_nb sun8i_r40_pll_cpu_nb = {
126662306a36Sopenharmony_ci	.common	= &pll_cpu_clk.common,
126762306a36Sopenharmony_ci	/* copy from pll_cpu_clk */
126862306a36Sopenharmony_ci	.enable	= BIT(31),
126962306a36Sopenharmony_ci	.lock	= BIT(28),
127062306a36Sopenharmony_ci};
127162306a36Sopenharmony_ci
127262306a36Sopenharmony_cistatic struct ccu_mux_nb sun8i_r40_cpu_nb = {
127362306a36Sopenharmony_ci	.common		= &cpu_clk.common,
127462306a36Sopenharmony_ci	.cm		= &cpu_clk.mux,
127562306a36Sopenharmony_ci	.delay_us	= 1, /* > 8 clock cycles at 24 MHz */
127662306a36Sopenharmony_ci	.bypass_index	= 1, /* index of 24 MHz oscillator */
127762306a36Sopenharmony_ci};
127862306a36Sopenharmony_ci
127962306a36Sopenharmony_ci/*
128062306a36Sopenharmony_ci * Add a regmap for the GMAC driver (dwmac-sun8i) to access the
128162306a36Sopenharmony_ci * GMAC configuration register.
128262306a36Sopenharmony_ci * Only this register is allowed to be written, in order to
128362306a36Sopenharmony_ci * prevent overriding critical clock configuration.
128462306a36Sopenharmony_ci */
128562306a36Sopenharmony_ci
128662306a36Sopenharmony_ci#define SUN8I_R40_GMAC_CFG_REG 0x164
128762306a36Sopenharmony_cistatic bool sun8i_r40_ccu_regmap_accessible_reg(struct device *dev,
128862306a36Sopenharmony_ci						unsigned int reg)
128962306a36Sopenharmony_ci{
129062306a36Sopenharmony_ci	if (reg == SUN8I_R40_GMAC_CFG_REG)
129162306a36Sopenharmony_ci		return true;
129262306a36Sopenharmony_ci	return false;
129362306a36Sopenharmony_ci}
129462306a36Sopenharmony_ci
129562306a36Sopenharmony_cistatic struct regmap_config sun8i_r40_ccu_regmap_config = {
129662306a36Sopenharmony_ci	.reg_bits	= 32,
129762306a36Sopenharmony_ci	.val_bits	= 32,
129862306a36Sopenharmony_ci	.reg_stride	= 4,
129962306a36Sopenharmony_ci	.max_register	= 0x320, /* PLL_LOCK_CTRL_REG */
130062306a36Sopenharmony_ci
130162306a36Sopenharmony_ci	/* other devices have no business accessing other registers */
130262306a36Sopenharmony_ci	.readable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
130362306a36Sopenharmony_ci	.writeable_reg	= sun8i_r40_ccu_regmap_accessible_reg,
130462306a36Sopenharmony_ci};
130562306a36Sopenharmony_ci
130662306a36Sopenharmony_ci#define SUN8I_R40_SYS_32K_CLK_REG 0x310
130762306a36Sopenharmony_ci#define SUN8I_R40_SYS_32K_CLK_KEY (0x16AA << 16)
130862306a36Sopenharmony_ci
130962306a36Sopenharmony_cistatic int sun8i_r40_ccu_probe(struct platform_device *pdev)
131062306a36Sopenharmony_ci{
131162306a36Sopenharmony_ci	struct regmap *regmap;
131262306a36Sopenharmony_ci	void __iomem *reg;
131362306a36Sopenharmony_ci	u32 val;
131462306a36Sopenharmony_ci	int ret;
131562306a36Sopenharmony_ci
131662306a36Sopenharmony_ci	reg = devm_platform_ioremap_resource(pdev, 0);
131762306a36Sopenharmony_ci	if (IS_ERR(reg))
131862306a36Sopenharmony_ci		return PTR_ERR(reg);
131962306a36Sopenharmony_ci
132062306a36Sopenharmony_ci	/* Force the PLL-Audio-1x divider to 1 */
132162306a36Sopenharmony_ci	val = readl(reg + SUN8I_R40_PLL_AUDIO_REG);
132262306a36Sopenharmony_ci	val &= ~GENMASK(19, 16);
132362306a36Sopenharmony_ci	writel(val | (0 << 16), reg + SUN8I_R40_PLL_AUDIO_REG);
132462306a36Sopenharmony_ci
132562306a36Sopenharmony_ci	/* Force PLL-MIPI to MIPI mode */
132662306a36Sopenharmony_ci	val = readl(reg + SUN8I_R40_PLL_MIPI_REG);
132762306a36Sopenharmony_ci	val &= ~BIT(16);
132862306a36Sopenharmony_ci	writel(val, reg + SUN8I_R40_PLL_MIPI_REG);
132962306a36Sopenharmony_ci
133062306a36Sopenharmony_ci	/* Force OHCI 12M parent to 12M divided from 48M */
133162306a36Sopenharmony_ci	val = readl(reg + SUN8I_R40_USB_CLK_REG);
133262306a36Sopenharmony_ci	val &= ~GENMASK(25, 20);
133362306a36Sopenharmony_ci	writel(val, reg + SUN8I_R40_USB_CLK_REG);
133462306a36Sopenharmony_ci
133562306a36Sopenharmony_ci	/*
133662306a36Sopenharmony_ci	 * Force SYS 32k (otherwise known as LOSC throughout the CCU)
133762306a36Sopenharmony_ci	 * clock parent to LOSC output from RTC module instead of the
133862306a36Sopenharmony_ci	 * CCU's internal RC oscillator divided output.
133962306a36Sopenharmony_ci	 */
134062306a36Sopenharmony_ci	writel(SUN8I_R40_SYS_32K_CLK_KEY | BIT(8),
134162306a36Sopenharmony_ci	       reg + SUN8I_R40_SYS_32K_CLK_REG);
134262306a36Sopenharmony_ci
134362306a36Sopenharmony_ci	regmap = devm_regmap_init_mmio(&pdev->dev, reg,
134462306a36Sopenharmony_ci				       &sun8i_r40_ccu_regmap_config);
134562306a36Sopenharmony_ci	if (IS_ERR(regmap))
134662306a36Sopenharmony_ci		return PTR_ERR(regmap);
134762306a36Sopenharmony_ci
134862306a36Sopenharmony_ci	ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_r40_ccu_desc);
134962306a36Sopenharmony_ci	if (ret)
135062306a36Sopenharmony_ci		return ret;
135162306a36Sopenharmony_ci
135262306a36Sopenharmony_ci	/* Gate then ungate PLL CPU after any rate changes */
135362306a36Sopenharmony_ci	ccu_pll_notifier_register(&sun8i_r40_pll_cpu_nb);
135462306a36Sopenharmony_ci
135562306a36Sopenharmony_ci	/* Reparent CPU during PLL CPU rate changes */
135662306a36Sopenharmony_ci	ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk,
135762306a36Sopenharmony_ci				  &sun8i_r40_cpu_nb);
135862306a36Sopenharmony_ci
135962306a36Sopenharmony_ci	return 0;
136062306a36Sopenharmony_ci}
136162306a36Sopenharmony_ci
136262306a36Sopenharmony_cistatic const struct of_device_id sun8i_r40_ccu_ids[] = {
136362306a36Sopenharmony_ci	{ .compatible = "allwinner,sun8i-r40-ccu" },
136462306a36Sopenharmony_ci	{ }
136562306a36Sopenharmony_ci};
136662306a36Sopenharmony_ci
136762306a36Sopenharmony_cistatic struct platform_driver sun8i_r40_ccu_driver = {
136862306a36Sopenharmony_ci	.probe	= sun8i_r40_ccu_probe,
136962306a36Sopenharmony_ci	.driver	= {
137062306a36Sopenharmony_ci		.name	= "sun8i-r40-ccu",
137162306a36Sopenharmony_ci		.suppress_bind_attrs = true,
137262306a36Sopenharmony_ci		.of_match_table	= sun8i_r40_ccu_ids,
137362306a36Sopenharmony_ci	},
137462306a36Sopenharmony_ci};
137562306a36Sopenharmony_cimodule_platform_driver(sun8i_r40_ccu_driver);
137662306a36Sopenharmony_ci
137762306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU);
137862306a36Sopenharmony_ciMODULE_LICENSE("GPL");
1379