162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2020 Yangtao Li <frank@allwinnertech.com>
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
1162306a36Sopenharmony_ci#include "ccu_common.h"
1262306a36Sopenharmony_ci#include "ccu_reset.h"
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include "ccu_div.h"
1562306a36Sopenharmony_ci#include "ccu_gate.h"
1662306a36Sopenharmony_ci#include "ccu_mp.h"
1762306a36Sopenharmony_ci#include "ccu_mult.h"
1862306a36Sopenharmony_ci#include "ccu_nk.h"
1962306a36Sopenharmony_ci#include "ccu_nkm.h"
2062306a36Sopenharmony_ci#include "ccu_nkmp.h"
2162306a36Sopenharmony_ci#include "ccu_nm.h"
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#include "ccu-sun50i-a100.h"
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define SUN50I_A100_PLL_SDM_ENABLE		BIT(24)
2662306a36Sopenharmony_ci#define SUN50I_A100_PLL_OUTPUT_ENABLE		BIT(27)
2762306a36Sopenharmony_ci#define SUN50I_A100_PLL_LOCK			BIT(28)
2862306a36Sopenharmony_ci#define SUN50I_A100_PLL_LOCK_ENABLE		BIT(29)
2962306a36Sopenharmony_ci#define SUN50I_A100_PLL_ENABLE			BIT(31)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define SUN50I_A100_PLL_PERIPH1_PATTERN0	0xd1303333
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/*
3462306a36Sopenharmony_ci * The CPU PLL is actually NP clock, with P being /1, /2 or /4. However
3562306a36Sopenharmony_ci * P should only be used for output frequencies lower than 288 MHz.
3662306a36Sopenharmony_ci *
3762306a36Sopenharmony_ci * For now we can just model it as a multiplier clock, and force P to /1.
3862306a36Sopenharmony_ci *
3962306a36Sopenharmony_ci * The M factor is present in the register's description, but not in the
4062306a36Sopenharmony_ci * frequency formula, and it's documented as "M is only used for backdoor
4162306a36Sopenharmony_ci * testing", so it's not modelled and then force to 0.
4262306a36Sopenharmony_ci */
4362306a36Sopenharmony_ci#define SUN50I_A100_PLL_CPUX_REG		0x000
4462306a36Sopenharmony_cistatic struct ccu_mult pll_cpux_clk = {
4562306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
4662306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
4762306a36Sopenharmony_ci	.mult		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
4862306a36Sopenharmony_ci	.common		= {
4962306a36Sopenharmony_ci		.reg		= 0x000,
5062306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpux", "dcxo24M",
5162306a36Sopenharmony_ci					      &ccu_mult_ops,
5262306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
5362306a36Sopenharmony_ci	},
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Some PLLs are input * N / div1 / P. Model them as NKMP with no K */
5762306a36Sopenharmony_ci#define SUN50I_A100_PLL_DDR0_REG		0x010
5862306a36Sopenharmony_cistatic struct ccu_nkmp pll_ddr0_clk = {
5962306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
6062306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
6162306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
6262306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
6362306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
6462306a36Sopenharmony_ci	.common		= {
6562306a36Sopenharmony_ci		.reg		= 0x010,
6662306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-ddr0", "dcxo24M",
6762306a36Sopenharmony_ci					      &ccu_nkmp_ops,
6862306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE |
6962306a36Sopenharmony_ci					      CLK_IS_CRITICAL),
7062306a36Sopenharmony_ci	},
7162306a36Sopenharmony_ci};
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define SUN50I_A100_PLL_PERIPH0_REG	0x020
7462306a36Sopenharmony_cistatic struct ccu_nkmp pll_periph0_clk = {
7562306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
7662306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
7762306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
7862306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
7962306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
8062306a36Sopenharmony_ci	.fixed_post_div	= 2,
8162306a36Sopenharmony_ci	.common		= {
8262306a36Sopenharmony_ci		.reg		= 0x020,
8362306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
8462306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph0", "dcxo24M",
8562306a36Sopenharmony_ci					      &ccu_nkmp_ops,
8662306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
8762306a36Sopenharmony_ci	},
8862306a36Sopenharmony_ci};
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define SUN50I_A100_PLL_PERIPH1_REG	0x028
9162306a36Sopenharmony_cistatic struct ccu_nkmp pll_periph1_clk = {
9262306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
9362306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
9462306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
9562306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
9662306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
9762306a36Sopenharmony_ci	.fixed_post_div	= 2,
9862306a36Sopenharmony_ci	.common		= {
9962306a36Sopenharmony_ci		.reg		= 0x028,
10062306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
10162306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph1", "dcxo24M",
10262306a36Sopenharmony_ci					      &ccu_nkmp_ops,
10362306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
10462306a36Sopenharmony_ci	},
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci#define SUN50I_A100_PLL_PERIPH1_PATTERN0_REG	0x128
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#define SUN50I_A100_PLL_GPU_REG		0x030
10962306a36Sopenharmony_cistatic struct ccu_nkmp pll_gpu_clk = {
11062306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
11162306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
11262306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
11362306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
11462306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
11562306a36Sopenharmony_ci	.common		= {
11662306a36Sopenharmony_ci		.reg		= 0x030,
11762306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-gpu", "dcxo24M",
11862306a36Sopenharmony_ci					      &ccu_nkmp_ops,
11962306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
12062306a36Sopenharmony_ci	},
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/*
12462306a36Sopenharmony_ci * For Video PLLs, the output divider is described as "used for testing"
12562306a36Sopenharmony_ci * in the user manual. So it's not modelled and forced to 0.
12662306a36Sopenharmony_ci */
12762306a36Sopenharmony_ci#define SUN50I_A100_PLL_VIDEO0_REG	0x040
12862306a36Sopenharmony_cistatic struct ccu_nm pll_video0_clk = {
12962306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
13062306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
13162306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
13262306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
13362306a36Sopenharmony_ci	.fixed_post_div	= 4,
13462306a36Sopenharmony_ci	.common		= {
13562306a36Sopenharmony_ci		.reg		= 0x040,
13662306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
13762306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-video0", "dcxo24M",
13862306a36Sopenharmony_ci					      &ccu_nm_ops,
13962306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
14062306a36Sopenharmony_ci	},
14162306a36Sopenharmony_ci};
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#define SUN50I_A100_PLL_VIDEO1_REG	0x048
14462306a36Sopenharmony_cistatic struct ccu_nm pll_video1_clk = {
14562306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
14662306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
14762306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
14862306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
14962306a36Sopenharmony_ci	.fixed_post_div	= 4,
15062306a36Sopenharmony_ci	.common		= {
15162306a36Sopenharmony_ci		.reg		= 0x048,
15262306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
15362306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-video1", "dcxo24M",
15462306a36Sopenharmony_ci					      &ccu_nm_ops,
15562306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
15662306a36Sopenharmony_ci	},
15762306a36Sopenharmony_ci};
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define SUN50I_A100_PLL_VIDEO2_REG	0x050
16062306a36Sopenharmony_cistatic struct ccu_nm pll_video2_clk = {
16162306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
16262306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
16362306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
16462306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
16562306a36Sopenharmony_ci	.fixed_post_div	= 4,
16662306a36Sopenharmony_ci	.common		= {
16762306a36Sopenharmony_ci		.reg		= 0x050,
16862306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
16962306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-video2", "dcxo24M",
17062306a36Sopenharmony_ci					      &ccu_nm_ops,
17162306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
17262306a36Sopenharmony_ci	},
17362306a36Sopenharmony_ci};
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci#define SUN50I_A100_PLL_VE_REG		0x058
17662306a36Sopenharmony_cistatic struct ccu_nkmp pll_ve_clk = {
17762306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
17862306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
17962306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
18062306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
18162306a36Sopenharmony_ci	.p		= _SUNXI_CCU_DIV(0, 1), /* output divider */
18262306a36Sopenharmony_ci	.common		= {
18362306a36Sopenharmony_ci		.reg		= 0x058,
18462306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-ve", "dcxo24M",
18562306a36Sopenharmony_ci					      &ccu_nkmp_ops,
18662306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
18762306a36Sopenharmony_ci	},
18862306a36Sopenharmony_ci};
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci/*
19162306a36Sopenharmony_ci * The COM PLL has m0 dividers in addition to the usual N, M
19262306a36Sopenharmony_ci * factors. Since we only need 1 frequencies from this PLL: 45.1584 MHz,
19362306a36Sopenharmony_ci * ignore it for now.
19462306a36Sopenharmony_ci */
19562306a36Sopenharmony_ci#define SUN50I_A100_PLL_COM_REG		0x060
19662306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_com_sdm_table[] = {
19762306a36Sopenharmony_ci	{ .rate = 451584000, .pattern = 0xc0014396, .m = 2, .n = 37 },
19862306a36Sopenharmony_ci};
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_cistatic struct ccu_nm pll_com_clk = {
20162306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
20262306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
20362306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
20462306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(0, 1),
20562306a36Sopenharmony_ci	.sdm		= _SUNXI_CCU_SDM(pll_com_sdm_table, BIT(24),
20662306a36Sopenharmony_ci					 0x160, BIT(31)),
20762306a36Sopenharmony_ci	.common		= {
20862306a36Sopenharmony_ci		.reg		= 0x060,
20962306a36Sopenharmony_ci		.features	= CCU_FEATURE_SIGMA_DELTA_MOD,
21062306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-com", "dcxo24M",
21162306a36Sopenharmony_ci					      &ccu_nm_ops,
21262306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
21362306a36Sopenharmony_ci	},
21462306a36Sopenharmony_ci};
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#define SUN50I_A100_PLL_VIDEO3_REG	0x068
21762306a36Sopenharmony_cistatic struct ccu_nm pll_video3_clk = {
21862306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
21962306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
22062306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
22162306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(1, 1), /* input divider */
22262306a36Sopenharmony_ci	.fixed_post_div	= 4,
22362306a36Sopenharmony_ci	.common		= {
22462306a36Sopenharmony_ci		.reg		= 0x068,
22562306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV,
22662306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-video3", "dcxo24M",
22762306a36Sopenharmony_ci					      &ccu_nm_ops,
22862306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
22962306a36Sopenharmony_ci	},
23062306a36Sopenharmony_ci};
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci/*
23362306a36Sopenharmony_ci * The Audio PLL has m0, m1 dividers in addition to the usual N, M
23462306a36Sopenharmony_ci * factors. Since we only need 4 frequencies from this PLL: 22.5792 MHz,
23562306a36Sopenharmony_ci * 24.576 MHz, 90.3168MHz and 98.304MHz ignore them for now.
23662306a36Sopenharmony_ci * Enforce the default for them, which is m0 = 1, m1 = 0.
23762306a36Sopenharmony_ci */
23862306a36Sopenharmony_ci#define SUN50I_A100_PLL_AUDIO_REG		0x078
23962306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = {
24062306a36Sopenharmony_ci	{ .rate = 45158400, .pattern = 0xc001bcd3, .m = 18, .n = 33 },
24162306a36Sopenharmony_ci	{ .rate = 49152000, .pattern = 0xc001eb85, .m = 20, .n = 40 },
24262306a36Sopenharmony_ci	{ .rate = 180633600, .pattern = 0xc001288d, .m = 3, .n = 22 },
24362306a36Sopenharmony_ci	{ .rate = 196608000, .pattern = 0xc001eb85, .m = 5, .n = 40 },
24462306a36Sopenharmony_ci};
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_cistatic struct ccu_nm pll_audio_clk = {
24762306a36Sopenharmony_ci	.enable		= SUN50I_A100_PLL_OUTPUT_ENABLE,
24862306a36Sopenharmony_ci	.lock		= SUN50I_A100_PLL_LOCK,
24962306a36Sopenharmony_ci	.n		= _SUNXI_CCU_MULT_MIN(8, 8, 12),
25062306a36Sopenharmony_ci	.m		= _SUNXI_CCU_DIV(16, 6),
25162306a36Sopenharmony_ci	.fixed_post_div	= 2,
25262306a36Sopenharmony_ci	.sdm		= _SUNXI_CCU_SDM(pll_audio_sdm_table, BIT(24),
25362306a36Sopenharmony_ci					 0x178, BIT(31)),
25462306a36Sopenharmony_ci	.common		= {
25562306a36Sopenharmony_ci		.reg		= 0x078,
25662306a36Sopenharmony_ci		.features	= CCU_FEATURE_FIXED_POSTDIV |
25762306a36Sopenharmony_ci				  CCU_FEATURE_SIGMA_DELTA_MOD,
25862306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-audio", "dcxo24M",
25962306a36Sopenharmony_ci					      &ccu_nm_ops,
26062306a36Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
26162306a36Sopenharmony_ci	},
26262306a36Sopenharmony_ci};
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_cistatic const char * const cpux_parents[] = { "dcxo24M", "osc32k",
26562306a36Sopenharmony_ci					     "iosc", "pll-cpux",
26662306a36Sopenharmony_ci					      "pll-periph0" };
26762306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
26862306a36Sopenharmony_ci		     0x500, 24, 3, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL);
26962306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x500, 0, 2, 0);
27062306a36Sopenharmony_cistatic SUNXI_CCU_M(cpux_apb_clk, "cpux-apb", "cpux", 0x500, 8, 2, 0);
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_cistatic const char * const psi_ahb1_ahb2_parents[] = { "dcxo24M", "osc32k",
27362306a36Sopenharmony_ci						      "iosc", "pll-periph0",
27462306a36Sopenharmony_ci						      "pll-periph0-2x" };
27562306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(psi_ahb1_ahb2_clk, "psi-ahb1-ahb2",
27662306a36Sopenharmony_ci			     psi_ahb1_ahb2_parents, 0x510,
27762306a36Sopenharmony_ci			     0, 2,	/* M */
27862306a36Sopenharmony_ci			     8, 2,	/* P */
27962306a36Sopenharmony_ci			     24, 3,	/* mux */
28062306a36Sopenharmony_ci			     0);
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_cistatic const char * const ahb3_apb1_apb2_parents[] = { "dcxo24M", "osc32k",
28362306a36Sopenharmony_ci						       "psi-ahb1-ahb2",
28462306a36Sopenharmony_ci						       "pll-periph0",
28562306a36Sopenharmony_ci						       "pll-periph0-2x" };
28662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(ahb3_clk, "ahb3", ahb3_apb1_apb2_parents, 0x51c,
28762306a36Sopenharmony_ci			     0, 2,	/* M */
28862306a36Sopenharmony_ci			     8, 2,	/* P */
28962306a36Sopenharmony_ci			     24, 3,	/* mux */
29062306a36Sopenharmony_ci			     0);
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb1_clk, "apb1", ahb3_apb1_apb2_parents, 0x520,
29362306a36Sopenharmony_ci			     0, 2,	/* M */
29462306a36Sopenharmony_ci			     8, 2,	/* P */
29562306a36Sopenharmony_ci			     24, 3,	/* mux */
29662306a36Sopenharmony_ci			     0);
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", ahb3_apb1_apb2_parents, 0x524,
29962306a36Sopenharmony_ci			     0, 2,	/* M */
30062306a36Sopenharmony_ci			     8, 2,	/* P */
30162306a36Sopenharmony_ci			     24, 3,	/* mux */
30262306a36Sopenharmony_ci			     0);
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "dcxo24M", "pll-ddr0",
30562306a36Sopenharmony_ci					     "pll-periph0",
30662306a36Sopenharmony_ci					     "pll-periph0-2x" };
30762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents, 0x540,
30862306a36Sopenharmony_ci				 0, 3,		/* M */
30962306a36Sopenharmony_ci				 24, 2,		/* mux */
31062306a36Sopenharmony_ci				 BIT(31),	/* gate */
31162306a36Sopenharmony_ci				 CLK_IS_CRITICAL);
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-com", "pll-periph0-2x" };
31462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de0", de_parents, 0x600,
31562306a36Sopenharmony_ci				 0, 4,		/* M */
31662306a36Sopenharmony_ci				 24, 1,		/* mux */
31762306a36Sopenharmony_ci				 BIT(31),	/* gate */
31862306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_clk, "bus-de", "psi-ahb1-ahb2",
32162306a36Sopenharmony_ci		      0x60c, BIT(0), 0);
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_cistatic const char * const g2d_parents[] = { "pll-com", "pll-periph0-2x",
32462306a36Sopenharmony_ci					     "pll-video0-2x", "pll-video1-2x",
32562306a36Sopenharmony_ci					     "pll-video2-2x"};
32662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(g2d_clk, "g2d",
32762306a36Sopenharmony_ci				 g2d_parents,
32862306a36Sopenharmony_ci				 0x630,
32962306a36Sopenharmony_ci				 0, 4,		/* M */
33062306a36Sopenharmony_ci				 24, 3,		/* mux */
33162306a36Sopenharmony_ci				 BIT(31),	/* gate */
33262306a36Sopenharmony_ci				 0);
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_g2d_clk, "bus-g2d", "psi-ahb1-ahb2",
33562306a36Sopenharmony_ci		      0x63c, BIT(0), 0);
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_cistatic const char * const gpu_parents[] = { "pll-gpu" };
33862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
33962306a36Sopenharmony_ci				       0, 2,	/* M */
34062306a36Sopenharmony_ci				       24, 1,	/* mux */
34162306a36Sopenharmony_ci				       BIT(31),	/* gate */
34262306a36Sopenharmony_ci				       0);
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "psi-ahb1-ahb2",
34562306a36Sopenharmony_ci		      0x67c, BIT(0), 0);
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_cistatic const char * const ce_parents[] = { "dcxo24M", "pll-periph0-2x" };
34862306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ce_clk, "ce", ce_parents, 0x680,
34962306a36Sopenharmony_ci				  0, 4,		/* M */
35062306a36Sopenharmony_ci				  8, 2,		/* P */
35162306a36Sopenharmony_ci				  24, 1,	/* mux */
35262306a36Sopenharmony_ci				  BIT(31),	/* gate */
35362306a36Sopenharmony_ci				  0);
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ce_clk, "bus-ce", "psi-ahb1-ahb2",
35662306a36Sopenharmony_ci		      0x68c, BIT(0), 0);
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_cistatic const char * const ve_parents[] = { "pll-ve" };
35962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(ve_clk, "ve", ve_parents, 0x690,
36062306a36Sopenharmony_ci				 0, 3,		/* M */
36162306a36Sopenharmony_ci				 24, 1,		/* mux */
36262306a36Sopenharmony_ci				 BIT(31),	/* gate */
36362306a36Sopenharmony_ci				 CLK_SET_RATE_PARENT);
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk, "bus-ve", "psi-ahb1-ahb2",
36662306a36Sopenharmony_ci		      0x69c, BIT(0), 0);
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "psi-ahb1-ahb2",
36962306a36Sopenharmony_ci		      0x70c, BIT(0), 0);
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "psi-ahb1-ahb2",
37262306a36Sopenharmony_ci		      0x71c, BIT(0), 0);
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "psi-ahb1-ahb2",
37562306a36Sopenharmony_ci		      0x72c, BIT(0), 0);
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "psi-ahb1-ahb2",
37862306a36Sopenharmony_ci		      0x73c, BIT(0), 0);
37962306a36Sopenharmony_ci
38062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "dcxo24M", 0x740, BIT(31), 0);
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dbg_clk, "bus-dbg", "psi-ahb1-ahb2",
38362306a36Sopenharmony_ci		      0x78c, BIT(0), 0);
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_psi_clk, "bus-psi", "psi-ahb1-ahb2",
38662306a36Sopenharmony_ci		      0x79c, BIT(0), 0);
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pwm_clk, "bus-pwm", "apb1", 0x7ac, BIT(0), 0);
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_iommu_clk, "bus-iommu", "apb1", 0x7bc, BIT(0), 0);
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_dma_clk, "mbus-dma", "mbus",
39362306a36Sopenharmony_ci		      0x804, BIT(0), 0);
39462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_ve_clk, "mbus-ve", "mbus",
39562306a36Sopenharmony_ci		      0x804, BIT(1), 0);
39662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_ce_clk, "mbus-ce", "mbus",
39762306a36Sopenharmony_ci		      0x804, BIT(2), 0);
39862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_nand_clk, "mbus-nand", "mbus",
39962306a36Sopenharmony_ci		      0x804, BIT(5), 0);
40062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_csi_clk, "mbus-csi", "mbus",
40162306a36Sopenharmony_ci		      0x804, BIT(8), 0);
40262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_isp_clk, "mbus-isp", "mbus",
40362306a36Sopenharmony_ci		      0x804, BIT(9), 0);
40462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(mbus_g2d_clk, "mbus-g2d", "mbus",
40562306a36Sopenharmony_ci		      0x804, BIT(10), 0);
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk, "bus-dram", "psi-ahb1-ahb2",
40862306a36Sopenharmony_ci		      0x80c, BIT(0), CLK_IS_CRITICAL);
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_cistatic const char * const nand_spi_parents[] = { "dcxo24M",
41162306a36Sopenharmony_ci						 "pll-periph0",
41262306a36Sopenharmony_ci						 "pll-periph1",
41362306a36Sopenharmony_ci						 "pll-periph0-2x",
41462306a36Sopenharmony_ci						 "pll-periph1-2x" };
41562306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand0_clk, "nand0", nand_spi_parents, 0x810,
41662306a36Sopenharmony_ci				  0, 4,		/* M */
41762306a36Sopenharmony_ci				  8, 2,		/* P */
41862306a36Sopenharmony_ci				  24, 3,	/* mux */
41962306a36Sopenharmony_ci				  BIT(31),	/* gate */
42062306a36Sopenharmony_ci				  0);
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand1_clk, "nand1", nand_spi_parents, 0x814,
42362306a36Sopenharmony_ci				  0, 4,		/* M */
42462306a36Sopenharmony_ci				  8, 2,		/* P */
42562306a36Sopenharmony_ci				  24, 3,	/* mux */
42662306a36Sopenharmony_ci				  BIT(31),	/* gate */
42762306a36Sopenharmony_ci				  0);
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk, "bus-nand", "ahb3", 0x82c, BIT(0), 0);
43062306a36Sopenharmony_ci
43162306a36Sopenharmony_cistatic const char * const mmc_parents[] = { "dcxo24M", "pll-periph0-2x",
43262306a36Sopenharmony_ci					    "pll-periph1-2x" };
43362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0", mmc_parents, 0x830,
43462306a36Sopenharmony_ci					  0, 4,		/* M */
43562306a36Sopenharmony_ci					  8, 2,		/* P */
43662306a36Sopenharmony_ci					  24, 2,	/* mux */
43762306a36Sopenharmony_ci					  BIT(31),	/* gate */
43862306a36Sopenharmony_ci					  2,		/* post-div */
43962306a36Sopenharmony_ci					  CLK_SET_RATE_NO_REPARENT);
44062306a36Sopenharmony_ci
44162306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1", mmc_parents, 0x834,
44262306a36Sopenharmony_ci					  0, 4,		/* M */
44362306a36Sopenharmony_ci					  8, 2,		/* P */
44462306a36Sopenharmony_ci					  24, 2,	/* mux */
44562306a36Sopenharmony_ci					  BIT(31),	/* gate */
44662306a36Sopenharmony_ci					  2,		/* post-div */
44762306a36Sopenharmony_ci					  CLK_SET_RATE_NO_REPARENT);
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2", mmc_parents, 0x838,
45062306a36Sopenharmony_ci					  0, 4,		/* M */
45162306a36Sopenharmony_ci					  8, 2,		/* P */
45262306a36Sopenharmony_ci					  24, 2,	/* mux */
45362306a36Sopenharmony_ci					  BIT(31),	/* gate */
45462306a36Sopenharmony_ci					  2,		/* post-div */
45562306a36Sopenharmony_ci					  CLK_SET_RATE_NO_REPARENT);
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk, "bus-mmc0", "ahb3", 0x84c, BIT(0), 0);
45862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk, "bus-mmc1", "ahb3", 0x84c, BIT(1), 0);
45962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk, "bus-mmc2", "ahb3", 0x84c, BIT(2), 0);
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk, "bus-uart0", "apb2", 0x90c, BIT(0), 0);
46262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk, "bus-uart1", "apb2", 0x90c, BIT(1), 0);
46362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk, "bus-uart2", "apb2", 0x90c, BIT(2), 0);
46462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk, "bus-uart3", "apb2", 0x90c, BIT(3), 0);
46562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk, "bus-uart4", "apb2", 0x90c, BIT(4), 0);
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk, "bus-i2c0", "apb2", 0x91c, BIT(0), 0);
46862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk, "bus-i2c1", "apb2", 0x91c, BIT(1), 0);
46962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk, "bus-i2c2", "apb2", 0x91c, BIT(2), 0);
47062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c3_clk, "bus-i2c3", "apb2", 0x91c, BIT(3), 0);
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", nand_spi_parents, 0x940,
47362306a36Sopenharmony_ci				  0, 4,		/* M */
47462306a36Sopenharmony_ci				  8, 2,		/* P */
47562306a36Sopenharmony_ci				  24, 3,	/* mux */
47662306a36Sopenharmony_ci				  BIT(31),	/* gate */
47762306a36Sopenharmony_ci				  0);
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", nand_spi_parents, 0x944,
48062306a36Sopenharmony_ci				  0, 4,		/* M */
48162306a36Sopenharmony_ci				  8, 2,		/* P */
48262306a36Sopenharmony_ci				  24, 3,	/* mux */
48362306a36Sopenharmony_ci				  BIT(31),	/* gate */
48462306a36Sopenharmony_ci				  0);
48562306a36Sopenharmony_ci
48662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi2_clk, "spi2", nand_spi_parents, 0x948,
48762306a36Sopenharmony_ci				  0, 4,		/* M */
48862306a36Sopenharmony_ci				  8, 2,		/* P */
48962306a36Sopenharmony_ci				  24, 3,	/* mux */
49062306a36Sopenharmony_ci				  BIT(31),	/* gate */
49162306a36Sopenharmony_ci				  0);
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk, "bus-spi0", "ahb3", 0x96c, BIT(0), 0);
49462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk, "bus-spi1", "ahb3", 0x96c, BIT(1), 0);
49562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi2_clk, "bus-spi2", "ahb3", 0x96c, BIT(2), 0);
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(emac_25m_clk, "emac-25m", "ahb3", 0x970,
49862306a36Sopenharmony_ci		      BIT(31) | BIT(30), 0);
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_emac_clk, "bus-emac", "ahb3", 0x97c, BIT(0), 0);
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_cistatic const char * const ir_parents[] = { "osc32k", "iosc",
50362306a36Sopenharmony_ci					   "pll-periph0", "pll-periph1" };
50462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir_rx_clk, "ir-rx", ir_parents, 0x990,
50562306a36Sopenharmony_ci				  0, 4,		/* M */
50662306a36Sopenharmony_ci				  8, 2,		/* P */
50762306a36Sopenharmony_ci				  24, 3,	/* mux */
50862306a36Sopenharmony_ci				  BIT(31),	/* gate */
50962306a36Sopenharmony_ci				  0);
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir_rx_clk, "bus-ir-rx", "ahb3", 0x99c, BIT(0), 0);
51262306a36Sopenharmony_ci
51362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ir_tx_clk, "ir-tx", ir_parents, 0x9c0,
51462306a36Sopenharmony_ci				  0, 4,		/* M */
51562306a36Sopenharmony_ci				  8, 2,		/* P */
51662306a36Sopenharmony_ci				  24, 3,	/* mux */
51762306a36Sopenharmony_ci				  BIT(31),	/* gate */
51862306a36Sopenharmony_ci				  0);
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir_tx_clk, "bus-ir-tx", "apb1", 0x9cc, BIT(0), 0);
52162306a36Sopenharmony_ci
52262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpadc_clk, "bus-gpadc", "apb1", 0x9ec, BIT(0), 0);
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ths_clk, "bus-ths", "apb1", 0x9fc, BIT(0), 0);
52562306a36Sopenharmony_ci
52662306a36Sopenharmony_cistatic const char * const audio_parents[] = { "pll-audio", "pll-com-audio" };
52762306a36Sopenharmony_cistatic struct ccu_div i2s0_clk = {
52862306a36Sopenharmony_ci	.enable		= BIT(31),
52962306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
53062306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
53162306a36Sopenharmony_ci	.common		= {
53262306a36Sopenharmony_ci		.reg		= 0xa10,
53362306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("i2s0",
53462306a36Sopenharmony_ci						      audio_parents,
53562306a36Sopenharmony_ci						      &ccu_div_ops,
53662306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
53762306a36Sopenharmony_ci	},
53862306a36Sopenharmony_ci};
53962306a36Sopenharmony_ci
54062306a36Sopenharmony_cistatic struct ccu_div i2s1_clk = {
54162306a36Sopenharmony_ci	.enable		= BIT(31),
54262306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
54362306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
54462306a36Sopenharmony_ci	.common		= {
54562306a36Sopenharmony_ci		.reg		= 0xa14,
54662306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("i2s1",
54762306a36Sopenharmony_ci						      audio_parents,
54862306a36Sopenharmony_ci						      &ccu_div_ops,
54962306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
55062306a36Sopenharmony_ci	},
55162306a36Sopenharmony_ci};
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_cistatic struct ccu_div i2s2_clk = {
55462306a36Sopenharmony_ci	.enable		= BIT(31),
55562306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
55662306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
55762306a36Sopenharmony_ci	.common		= {
55862306a36Sopenharmony_ci		.reg		= 0xa18,
55962306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("i2s2",
56062306a36Sopenharmony_ci						      audio_parents,
56162306a36Sopenharmony_ci						      &ccu_div_ops,
56262306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
56362306a36Sopenharmony_ci	},
56462306a36Sopenharmony_ci};
56562306a36Sopenharmony_ci
56662306a36Sopenharmony_cistatic struct ccu_div i2s3_clk = {
56762306a36Sopenharmony_ci	.enable		= BIT(31),
56862306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
56962306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
57062306a36Sopenharmony_ci	.common		= {
57162306a36Sopenharmony_ci		.reg		= 0xa1c,
57262306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("i2s3",
57362306a36Sopenharmony_ci						      audio_parents,
57462306a36Sopenharmony_ci						      &ccu_div_ops,
57562306a36Sopenharmony_ci						      CLK_SET_RATE_PARENT),
57662306a36Sopenharmony_ci	},
57762306a36Sopenharmony_ci};
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk, "bus-i2s0", "apb1", 0xa20, BIT(0), 0);
58062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk, "bus-i2s1", "apb1", 0xa20, BIT(1), 0);
58162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s2_clk, "bus-i2s2", "apb1", 0xa20, BIT(2), 0);
58262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s3_clk, "bus-i2s3", "apb1", 0xa20, BIT(3), 0);
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_cistatic struct ccu_div spdif_clk = {
58562306a36Sopenharmony_ci	.enable		= BIT(31),
58662306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
58762306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
58862306a36Sopenharmony_ci	.common		= {
58962306a36Sopenharmony_ci		.reg		= 0xa24,
59062306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("spdif",
59162306a36Sopenharmony_ci						      audio_parents,
59262306a36Sopenharmony_ci						      &ccu_div_ops,
59362306a36Sopenharmony_ci						      0),
59462306a36Sopenharmony_ci	},
59562306a36Sopenharmony_ci};
59662306a36Sopenharmony_ci
59762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk, "bus-spdif", "apb1", 0xa2c, BIT(0), 0);
59862306a36Sopenharmony_ci
59962306a36Sopenharmony_cistatic struct ccu_div dmic_clk = {
60062306a36Sopenharmony_ci	.enable		= BIT(31),
60162306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(8, 2, CLK_DIVIDER_POWER_OF_TWO),
60262306a36Sopenharmony_ci	.mux		= _SUNXI_CCU_MUX(24, 2),
60362306a36Sopenharmony_ci	.common		= {
60462306a36Sopenharmony_ci		.reg		= 0xa40,
60562306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("dmic",
60662306a36Sopenharmony_ci						      audio_parents,
60762306a36Sopenharmony_ci						      &ccu_div_ops,
60862306a36Sopenharmony_ci						      0),
60962306a36Sopenharmony_ci	},
61062306a36Sopenharmony_ci};
61162306a36Sopenharmony_ci
61262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dmic_clk, "bus-dmic", "apb1", 0xa4c, BIT(0), 0);
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(audio_codec_dac_clk, "audio-codec-dac",
61562306a36Sopenharmony_ci				 audio_parents, 0xa50,
61662306a36Sopenharmony_ci				 0, 4,		/* M */
61762306a36Sopenharmony_ci				 24, 2,		/* mux */
61862306a36Sopenharmony_ci				 BIT(31),	/* gate */
61962306a36Sopenharmony_ci				 0);
62062306a36Sopenharmony_ci
62162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(audio_codec_adc_clk, "audio-codec-adc",
62262306a36Sopenharmony_ci				 audio_parents, 0xa54,
62362306a36Sopenharmony_ci				 0, 4,		/* M */
62462306a36Sopenharmony_ci				 24, 2,		/* mux */
62562306a36Sopenharmony_ci				 BIT(31),	/* gate */
62662306a36Sopenharmony_ci				 0);
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(audio_codec_4x_clk, "audio-codec-4x",
62962306a36Sopenharmony_ci				 audio_parents, 0xa58,
63062306a36Sopenharmony_ci				 0, 4,		/* M */
63162306a36Sopenharmony_ci				 24, 2,		/* mux */
63262306a36Sopenharmony_ci				 BIT(31),	/* gate */
63362306a36Sopenharmony_ci				 0);
63462306a36Sopenharmony_ci
63562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_audio_codec_clk, "bus-audio-codec", "apb1", 0xa5c,
63662306a36Sopenharmony_ci		      BIT(0), 0);
63762306a36Sopenharmony_ci
63862306a36Sopenharmony_ci/*
63962306a36Sopenharmony_ci * There are OHCI 12M clock source selection bits for 2 USB 2.0 ports.
64062306a36Sopenharmony_ci * We will force them to 0 (12M divided from 48M).
64162306a36Sopenharmony_ci */
64262306a36Sopenharmony_ci#define SUN50I_A100_USB0_CLK_REG		0xa70
64362306a36Sopenharmony_ci#define SUN50I_A100_USB1_CLK_REG		0xa74
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc12M", 0xa70, BIT(31), 0);
64662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "dcxo24M", 0xa70, BIT(29), 0);
64762306a36Sopenharmony_ci
64862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci1_clk, "usb-ohci1", "osc12M", 0xa74, BIT(31), 0);
64962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk, "usb-phy1", "dcxo24M", 0xa74, BIT(29), 0);
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci0_clk, "bus-ohci0", "ahb3", 0xa8c, BIT(0), 0);
65262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci1_clk, "bus-ohci1", "ahb3", 0xa8c, BIT(1), 0);
65362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci0_clk, "bus-ehci0", "ahb3", 0xa8c, BIT(4), 0);
65462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci1_clk, "bus-ehci1", "ahb3", 0xa8c, BIT(5), 0);
65562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk, "bus-otg", "ahb3", 0xa8c, BIT(8), 0);
65662306a36Sopenharmony_ci
65762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_lradc_clk, "bus-lradc", "ahb3", 0xa9c, BIT(0), 0);
65862306a36Sopenharmony_ci
65962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dpss_top0_clk, "bus-dpss-top0", "ahb3",
66062306a36Sopenharmony_ci		      0xabc, BIT(0), 0);
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dpss_top1_clk, "bus-dpss-top1", "ahb3",
66362306a36Sopenharmony_ci		      0xacc, BIT(0), 0);
66462306a36Sopenharmony_ci
66562306a36Sopenharmony_cistatic const char * const mipi_dsi_parents[] = { "dcxo24M", "pll-periph0-2x",
66662306a36Sopenharmony_ci						 "pll-periph0" };
66762306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mipi_dsi_clk, "mipi-dsi",
66862306a36Sopenharmony_ci				 mipi_dsi_parents,
66962306a36Sopenharmony_ci				 0xb24,
67062306a36Sopenharmony_ci				 0, 4,		/* M */
67162306a36Sopenharmony_ci				 24, 2,		/* mux */
67262306a36Sopenharmony_ci				 BIT(31),	/* gate */
67362306a36Sopenharmony_ci				 0);
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk, "bus-mipi-dsi", "ahb3",
67662306a36Sopenharmony_ci		      0xb4c, BIT(0), 0);
67762306a36Sopenharmony_ci
67862306a36Sopenharmony_cistatic const char * const tcon_lcd_parents[] = { "pll-video0-4x",
67962306a36Sopenharmony_ci						  "pll-video1-4x",
68062306a36Sopenharmony_ci						  "pll-video2-4x",
68162306a36Sopenharmony_ci						  "pll-video3-4x",
68262306a36Sopenharmony_ci						  "pll-periph0-2x" };
68362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(tcon_lcd_clk, "tcon-lcd0",
68462306a36Sopenharmony_ci				  tcon_lcd_parents, 0xb60,
68562306a36Sopenharmony_ci				  0, 4,		/* M */
68662306a36Sopenharmony_ci				  8, 2,		/* P */
68762306a36Sopenharmony_ci				  24, 3,	/* mux */
68862306a36Sopenharmony_ci				  BIT(31),	/* gate */
68962306a36Sopenharmony_ci				  0);
69062306a36Sopenharmony_ci
69162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tcon_lcd_clk, "bus-tcon-lcd0", "ahb3",
69262306a36Sopenharmony_ci		      0xb7c, BIT(0), 0);
69362306a36Sopenharmony_ci
69462306a36Sopenharmony_cistatic const char * const ledc_parents[] = { "dcxo24M",
69562306a36Sopenharmony_ci					     "pll-periph0" };
69662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(ledc_clk, "ledc",
69762306a36Sopenharmony_ci				  ledc_parents, 0xbf0,
69862306a36Sopenharmony_ci				  0, 4,		/* M */
69962306a36Sopenharmony_ci				  8, 2,		/* P */
70062306a36Sopenharmony_ci				  24, 3,	/* mux */
70162306a36Sopenharmony_ci				  BIT(31),	/* gate */
70262306a36Sopenharmony_ci				  0);
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ledc_clk, "bus-ledc", "ahb3", 0xbfc, BIT(0), 0);
70562306a36Sopenharmony_ci
70662306a36Sopenharmony_cistatic const char * const csi_top_parents[] = { "pll-periph0-2x",
70762306a36Sopenharmony_ci						"pll-video0-2x",
70862306a36Sopenharmony_ci						"pll-video1-2x",
70962306a36Sopenharmony_ci						"pll-video2-2x",
71062306a36Sopenharmony_ci						"pll-video3-2x" };
71162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_top_clk, "csi-top",
71262306a36Sopenharmony_ci				 csi_top_parents, 0xc04,
71362306a36Sopenharmony_ci				 0, 4,		/* M */
71462306a36Sopenharmony_ci				 24, 3,		/* mux */
71562306a36Sopenharmony_ci				 BIT(31),	/* gate */
71662306a36Sopenharmony_ci				 0);
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_cistatic const char * const csi0_mclk_parents[] = { "dcxo24M", "pll-video2",
71962306a36Sopenharmony_ci						  "pll-video3", "pll-video0",
72062306a36Sopenharmony_ci						  "pll-video1" };
72162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi0_mclk_clk, "csi0-mclk",
72262306a36Sopenharmony_ci				 csi0_mclk_parents, 0xc08,
72362306a36Sopenharmony_ci				 0, 5,		/* M */
72462306a36Sopenharmony_ci				 24, 3,		/* mux */
72562306a36Sopenharmony_ci				 BIT(31),	/* gate */
72662306a36Sopenharmony_ci				 0);
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_cistatic const char * const csi1_mclk_parents[] = { "dcxo24M", "pll-video3",
72962306a36Sopenharmony_ci						  "pll-video0", "pll-video1",
73062306a36Sopenharmony_ci						  "pll-video2" };
73162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi1_mclk_clk, "csi1-mclk",
73262306a36Sopenharmony_ci				 csi1_mclk_parents, 0xc0c,
73362306a36Sopenharmony_ci				 0, 5,		/* M */
73462306a36Sopenharmony_ci				 24, 3,		/* mux */
73562306a36Sopenharmony_ci				 BIT(31),	/* gate */
73662306a36Sopenharmony_ci				 0);
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk, "bus-csi", "ahb3", 0xc1c, BIT(0), 0);
73962306a36Sopenharmony_ci
74062306a36Sopenharmony_cistatic const char * const csi_isp_parents[] = { "pll-periph0-2x",
74162306a36Sopenharmony_ci						"pll-video0-2x",
74262306a36Sopenharmony_ci						"pll-video1-2x",
74362306a36Sopenharmony_ci						"pll-video2-2x",
74462306a36Sopenharmony_ci						"pll-video3-2x" };
74562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(csi_isp_clk, "csi-isp",
74662306a36Sopenharmony_ci				 csi_isp_parents, 0xc20,
74762306a36Sopenharmony_ci				 0, 5,		/* M */
74862306a36Sopenharmony_ci				 24, 3,		/* mux */
74962306a36Sopenharmony_ci				 BIT(31),	/* gate */
75062306a36Sopenharmony_ci				 0);
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci/* Fixed factor clocks */
75362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_FW_NAME(osc12M_clk, "osc12M", "hosc", 2, 1, 0);
75462306a36Sopenharmony_ci
75562306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_com_audio_clk, "pll-com-audio",
75662306a36Sopenharmony_ci			   &pll_com_clk.common.hw,
75762306a36Sopenharmony_ci			   5, 1, CLK_SET_RATE_PARENT);
75862306a36Sopenharmony_ci
75962306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph0_2x_clk, "pll-periph0-2x",
76062306a36Sopenharmony_ci			   &pll_periph0_clk.common.hw,
76162306a36Sopenharmony_ci			   1, 2, 0);
76262306a36Sopenharmony_ci
76362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph1_2x_clk, "pll-periph1-2x",
76462306a36Sopenharmony_ci			   &pll_periph1_clk.common.hw,
76562306a36Sopenharmony_ci			   1, 2, 0);
76662306a36Sopenharmony_ci
76762306a36Sopenharmony_cistatic const struct clk_hw *pll_video0_parents[] = {
76862306a36Sopenharmony_ci	&pll_video0_clk.common.hw
76962306a36Sopenharmony_ci};
77062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video0_4x_clk, "pll-video0-4x",
77162306a36Sopenharmony_ci			    pll_video0_parents,
77262306a36Sopenharmony_ci			    1, 4, CLK_SET_RATE_PARENT);
77362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video0_2x_clk, "pll-video0-2x",
77462306a36Sopenharmony_ci			    pll_video0_parents,
77562306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
77662306a36Sopenharmony_ci
77762306a36Sopenharmony_cistatic const struct clk_hw *pll_video1_parents[] = {
77862306a36Sopenharmony_ci	&pll_video1_clk.common.hw
77962306a36Sopenharmony_ci};
78062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video1_4x_clk, "pll-video1-4x",
78162306a36Sopenharmony_ci			    pll_video1_parents,
78262306a36Sopenharmony_ci			    1, 4, CLK_SET_RATE_PARENT);
78362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video1_2x_clk, "pll-video1-2x",
78462306a36Sopenharmony_ci			    pll_video1_parents,
78562306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_cistatic const struct clk_hw *pll_video2_parents[] = {
78862306a36Sopenharmony_ci	&pll_video2_clk.common.hw
78962306a36Sopenharmony_ci};
79062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video2_4x_clk, "pll-video2-4x",
79162306a36Sopenharmony_ci			    pll_video2_parents,
79262306a36Sopenharmony_ci			    1, 4, CLK_SET_RATE_PARENT);
79362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video2_2x_clk, "pll-video2-2x",
79462306a36Sopenharmony_ci			    pll_video2_parents,
79562306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
79662306a36Sopenharmony_ci
79762306a36Sopenharmony_cistatic const struct clk_hw *pll_video3_parents[] = {
79862306a36Sopenharmony_ci	&pll_video3_clk.common.hw
79962306a36Sopenharmony_ci};
80062306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video3_4x_clk, "pll-video3-4x",
80162306a36Sopenharmony_ci			    pll_video3_parents,
80262306a36Sopenharmony_ci			    1, 4, CLK_SET_RATE_PARENT);
80362306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_video3_2x_clk, "pll-video3-2x",
80462306a36Sopenharmony_ci			    pll_video3_parents,
80562306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
80662306a36Sopenharmony_ci
80762306a36Sopenharmony_cistatic struct ccu_common *sun50i_a100_ccu_clks[] = {
80862306a36Sopenharmony_ci	&pll_cpux_clk.common,
80962306a36Sopenharmony_ci	&pll_ddr0_clk.common,
81062306a36Sopenharmony_ci	&pll_periph0_clk.common,
81162306a36Sopenharmony_ci	&pll_periph1_clk.common,
81262306a36Sopenharmony_ci	&pll_gpu_clk.common,
81362306a36Sopenharmony_ci	&pll_video0_clk.common,
81462306a36Sopenharmony_ci	&pll_video1_clk.common,
81562306a36Sopenharmony_ci	&pll_video2_clk.common,
81662306a36Sopenharmony_ci	&pll_video3_clk.common,
81762306a36Sopenharmony_ci	&pll_ve_clk.common,
81862306a36Sopenharmony_ci	&pll_com_clk.common,
81962306a36Sopenharmony_ci	&pll_audio_clk.common,
82062306a36Sopenharmony_ci	&cpux_clk.common,
82162306a36Sopenharmony_ci	&axi_clk.common,
82262306a36Sopenharmony_ci	&cpux_apb_clk.common,
82362306a36Sopenharmony_ci	&psi_ahb1_ahb2_clk.common,
82462306a36Sopenharmony_ci	&ahb3_clk.common,
82562306a36Sopenharmony_ci	&apb1_clk.common,
82662306a36Sopenharmony_ci	&apb2_clk.common,
82762306a36Sopenharmony_ci	&mbus_clk.common,
82862306a36Sopenharmony_ci	&de_clk.common,
82962306a36Sopenharmony_ci	&bus_de_clk.common,
83062306a36Sopenharmony_ci	&g2d_clk.common,
83162306a36Sopenharmony_ci	&bus_g2d_clk.common,
83262306a36Sopenharmony_ci	&gpu_clk.common,
83362306a36Sopenharmony_ci	&bus_gpu_clk.common,
83462306a36Sopenharmony_ci	&ce_clk.common,
83562306a36Sopenharmony_ci	&bus_ce_clk.common,
83662306a36Sopenharmony_ci	&ve_clk.common,
83762306a36Sopenharmony_ci	&bus_ve_clk.common,
83862306a36Sopenharmony_ci	&bus_dma_clk.common,
83962306a36Sopenharmony_ci	&bus_msgbox_clk.common,
84062306a36Sopenharmony_ci	&bus_spinlock_clk.common,
84162306a36Sopenharmony_ci	&bus_hstimer_clk.common,
84262306a36Sopenharmony_ci	&avs_clk.common,
84362306a36Sopenharmony_ci	&bus_dbg_clk.common,
84462306a36Sopenharmony_ci	&bus_psi_clk.common,
84562306a36Sopenharmony_ci	&bus_pwm_clk.common,
84662306a36Sopenharmony_ci	&bus_iommu_clk.common,
84762306a36Sopenharmony_ci	&mbus_dma_clk.common,
84862306a36Sopenharmony_ci	&mbus_ve_clk.common,
84962306a36Sopenharmony_ci	&mbus_ce_clk.common,
85062306a36Sopenharmony_ci	&mbus_nand_clk.common,
85162306a36Sopenharmony_ci	&mbus_csi_clk.common,
85262306a36Sopenharmony_ci	&mbus_isp_clk.common,
85362306a36Sopenharmony_ci	&mbus_g2d_clk.common,
85462306a36Sopenharmony_ci	&bus_dram_clk.common,
85562306a36Sopenharmony_ci	&nand0_clk.common,
85662306a36Sopenharmony_ci	&nand1_clk.common,
85762306a36Sopenharmony_ci	&bus_nand_clk.common,
85862306a36Sopenharmony_ci	&mmc0_clk.common,
85962306a36Sopenharmony_ci	&mmc1_clk.common,
86062306a36Sopenharmony_ci	&mmc2_clk.common,
86162306a36Sopenharmony_ci	&bus_mmc0_clk.common,
86262306a36Sopenharmony_ci	&bus_mmc1_clk.common,
86362306a36Sopenharmony_ci	&bus_mmc2_clk.common,
86462306a36Sopenharmony_ci	&bus_uart0_clk.common,
86562306a36Sopenharmony_ci	&bus_uart1_clk.common,
86662306a36Sopenharmony_ci	&bus_uart2_clk.common,
86762306a36Sopenharmony_ci	&bus_uart3_clk.common,
86862306a36Sopenharmony_ci	&bus_uart4_clk.common,
86962306a36Sopenharmony_ci	&bus_i2c0_clk.common,
87062306a36Sopenharmony_ci	&bus_i2c1_clk.common,
87162306a36Sopenharmony_ci	&bus_i2c2_clk.common,
87262306a36Sopenharmony_ci	&bus_i2c3_clk.common,
87362306a36Sopenharmony_ci	&spi0_clk.common,
87462306a36Sopenharmony_ci	&spi1_clk.common,
87562306a36Sopenharmony_ci	&spi2_clk.common,
87662306a36Sopenharmony_ci	&bus_spi0_clk.common,
87762306a36Sopenharmony_ci	&bus_spi1_clk.common,
87862306a36Sopenharmony_ci	&bus_spi2_clk.common,
87962306a36Sopenharmony_ci	&emac_25m_clk.common,
88062306a36Sopenharmony_ci	&bus_emac_clk.common,
88162306a36Sopenharmony_ci	&ir_rx_clk.common,
88262306a36Sopenharmony_ci	&bus_ir_rx_clk.common,
88362306a36Sopenharmony_ci	&ir_tx_clk.common,
88462306a36Sopenharmony_ci	&bus_ir_tx_clk.common,
88562306a36Sopenharmony_ci	&bus_gpadc_clk.common,
88662306a36Sopenharmony_ci	&bus_ths_clk.common,
88762306a36Sopenharmony_ci	&i2s0_clk.common,
88862306a36Sopenharmony_ci	&i2s1_clk.common,
88962306a36Sopenharmony_ci	&i2s2_clk.common,
89062306a36Sopenharmony_ci	&i2s3_clk.common,
89162306a36Sopenharmony_ci	&bus_i2s0_clk.common,
89262306a36Sopenharmony_ci	&bus_i2s1_clk.common,
89362306a36Sopenharmony_ci	&bus_i2s2_clk.common,
89462306a36Sopenharmony_ci	&bus_i2s3_clk.common,
89562306a36Sopenharmony_ci	&spdif_clk.common,
89662306a36Sopenharmony_ci	&bus_spdif_clk.common,
89762306a36Sopenharmony_ci	&dmic_clk.common,
89862306a36Sopenharmony_ci	&bus_dmic_clk.common,
89962306a36Sopenharmony_ci	&audio_codec_dac_clk.common,
90062306a36Sopenharmony_ci	&audio_codec_adc_clk.common,
90162306a36Sopenharmony_ci	&audio_codec_4x_clk.common,
90262306a36Sopenharmony_ci	&bus_audio_codec_clk.common,
90362306a36Sopenharmony_ci	&usb_ohci0_clk.common,
90462306a36Sopenharmony_ci	&usb_phy0_clk.common,
90562306a36Sopenharmony_ci	&usb_ohci1_clk.common,
90662306a36Sopenharmony_ci	&usb_phy1_clk.common,
90762306a36Sopenharmony_ci	&bus_ohci0_clk.common,
90862306a36Sopenharmony_ci	&bus_ohci1_clk.common,
90962306a36Sopenharmony_ci	&bus_ehci0_clk.common,
91062306a36Sopenharmony_ci	&bus_ehci1_clk.common,
91162306a36Sopenharmony_ci	&bus_otg_clk.common,
91262306a36Sopenharmony_ci	&bus_lradc_clk.common,
91362306a36Sopenharmony_ci	&bus_dpss_top0_clk.common,
91462306a36Sopenharmony_ci	&bus_dpss_top1_clk.common,
91562306a36Sopenharmony_ci	&mipi_dsi_clk.common,
91662306a36Sopenharmony_ci	&bus_mipi_dsi_clk.common,
91762306a36Sopenharmony_ci	&tcon_lcd_clk.common,
91862306a36Sopenharmony_ci	&bus_tcon_lcd_clk.common,
91962306a36Sopenharmony_ci	&ledc_clk.common,
92062306a36Sopenharmony_ci	&bus_ledc_clk.common,
92162306a36Sopenharmony_ci	&csi_top_clk.common,
92262306a36Sopenharmony_ci	&csi0_mclk_clk.common,
92362306a36Sopenharmony_ci	&csi1_mclk_clk.common,
92462306a36Sopenharmony_ci	&bus_csi_clk.common,
92562306a36Sopenharmony_ci	&csi_isp_clk.common,
92662306a36Sopenharmony_ci};
92762306a36Sopenharmony_ci
92862306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun50i_a100_hw_clks = {
92962306a36Sopenharmony_ci	.hws	= {
93062306a36Sopenharmony_ci		[CLK_OSC12M]		= &osc12M_clk.hw,
93162306a36Sopenharmony_ci		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
93262306a36Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
93362306a36Sopenharmony_ci		[CLK_PLL_PERIPH0]	= &pll_periph0_clk.common.hw,
93462306a36Sopenharmony_ci		[CLK_PLL_PERIPH0_2X]	= &pll_periph0_2x_clk.hw,
93562306a36Sopenharmony_ci		[CLK_PLL_PERIPH1]	= &pll_periph1_clk.common.hw,
93662306a36Sopenharmony_ci		[CLK_PLL_PERIPH1_2X]	= &pll_periph1_2x_clk.hw,
93762306a36Sopenharmony_ci		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
93862306a36Sopenharmony_ci		[CLK_PLL_VIDEO0]	= &pll_video0_clk.common.hw,
93962306a36Sopenharmony_ci		[CLK_PLL_VIDEO0_2X]	= &pll_video0_2x_clk.hw,
94062306a36Sopenharmony_ci		[CLK_PLL_VIDEO0_4X]	= &pll_video0_4x_clk.hw,
94162306a36Sopenharmony_ci		[CLK_PLL_VIDEO1]	= &pll_video1_clk.common.hw,
94262306a36Sopenharmony_ci		[CLK_PLL_VIDEO1_2X]	= &pll_video1_2x_clk.hw,
94362306a36Sopenharmony_ci		[CLK_PLL_VIDEO1_4X]	= &pll_video1_4x_clk.hw,
94462306a36Sopenharmony_ci		[CLK_PLL_VIDEO2]	= &pll_video2_clk.common.hw,
94562306a36Sopenharmony_ci		[CLK_PLL_VIDEO2_2X]	= &pll_video2_2x_clk.hw,
94662306a36Sopenharmony_ci		[CLK_PLL_VIDEO2_4X]	= &pll_video2_4x_clk.hw,
94762306a36Sopenharmony_ci		[CLK_PLL_VIDEO3]	= &pll_video3_clk.common.hw,
94862306a36Sopenharmony_ci		[CLK_PLL_VIDEO3_2X]	= &pll_video3_2x_clk.hw,
94962306a36Sopenharmony_ci		[CLK_PLL_VIDEO3_4X]	= &pll_video3_4x_clk.hw,
95062306a36Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
95162306a36Sopenharmony_ci		[CLK_PLL_COM]		= &pll_com_clk.common.hw,
95262306a36Sopenharmony_ci		[CLK_PLL_COM_AUDIO]	= &pll_com_audio_clk.hw,
95362306a36Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.common.hw,
95462306a36Sopenharmony_ci		[CLK_CPUX]		= &cpux_clk.common.hw,
95562306a36Sopenharmony_ci		[CLK_AXI]		= &axi_clk.common.hw,
95662306a36Sopenharmony_ci		[CLK_CPUX_APB]		= &cpux_apb_clk.common.hw,
95762306a36Sopenharmony_ci		[CLK_PSI_AHB1_AHB2]	= &psi_ahb1_ahb2_clk.common.hw,
95862306a36Sopenharmony_ci		[CLK_AHB3]		= &ahb3_clk.common.hw,
95962306a36Sopenharmony_ci		[CLK_APB1]		= &apb1_clk.common.hw,
96062306a36Sopenharmony_ci		[CLK_APB2]		= &apb2_clk.common.hw,
96162306a36Sopenharmony_ci		[CLK_MBUS]		= &mbus_clk.common.hw,
96262306a36Sopenharmony_ci		[CLK_DE]		= &de_clk.common.hw,
96362306a36Sopenharmony_ci		[CLK_BUS_DE]		= &bus_de_clk.common.hw,
96462306a36Sopenharmony_ci		[CLK_G2D]		= &g2d_clk.common.hw,
96562306a36Sopenharmony_ci		[CLK_BUS_G2D]		= &bus_g2d_clk.common.hw,
96662306a36Sopenharmony_ci		[CLK_GPU]		= &gpu_clk.common.hw,
96762306a36Sopenharmony_ci		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
96862306a36Sopenharmony_ci		[CLK_CE]		= &ce_clk.common.hw,
96962306a36Sopenharmony_ci		[CLK_BUS_CE]		= &bus_ce_clk.common.hw,
97062306a36Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
97162306a36Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
97262306a36Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
97362306a36Sopenharmony_ci		[CLK_BUS_MSGBOX]	= &bus_msgbox_clk.common.hw,
97462306a36Sopenharmony_ci		[CLK_BUS_SPINLOCK]	= &bus_spinlock_clk.common.hw,
97562306a36Sopenharmony_ci		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
97662306a36Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
97762306a36Sopenharmony_ci		[CLK_BUS_DBG]		= &bus_dbg_clk.common.hw,
97862306a36Sopenharmony_ci		[CLK_BUS_PSI]		= &bus_psi_clk.common.hw,
97962306a36Sopenharmony_ci		[CLK_BUS_PWM]		= &bus_pwm_clk.common.hw,
98062306a36Sopenharmony_ci		[CLK_BUS_IOMMU]		= &bus_iommu_clk.common.hw,
98162306a36Sopenharmony_ci		[CLK_MBUS_DMA]		= &mbus_dma_clk.common.hw,
98262306a36Sopenharmony_ci		[CLK_MBUS_VE]		= &mbus_ve_clk.common.hw,
98362306a36Sopenharmony_ci		[CLK_MBUS_CE]		= &mbus_ce_clk.common.hw,
98462306a36Sopenharmony_ci		[CLK_MBUS_NAND]		= &mbus_nand_clk.common.hw,
98562306a36Sopenharmony_ci		[CLK_MBUS_CSI]		= &mbus_csi_clk.common.hw,
98662306a36Sopenharmony_ci		[CLK_MBUS_ISP]		= &mbus_isp_clk.common.hw,
98762306a36Sopenharmony_ci		[CLK_MBUS_G2D]		= &mbus_g2d_clk.common.hw,
98862306a36Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
98962306a36Sopenharmony_ci		[CLK_NAND0]		= &nand0_clk.common.hw,
99062306a36Sopenharmony_ci		[CLK_NAND1]		= &nand1_clk.common.hw,
99162306a36Sopenharmony_ci		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
99262306a36Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
99362306a36Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
99462306a36Sopenharmony_ci		[CLK_MMC2]		= &mmc2_clk.common.hw,
99562306a36Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
99662306a36Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
99762306a36Sopenharmony_ci		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
99862306a36Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
99962306a36Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
100062306a36Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
100162306a36Sopenharmony_ci		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
100262306a36Sopenharmony_ci		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
100362306a36Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
100462306a36Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
100562306a36Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
100662306a36Sopenharmony_ci		[CLK_BUS_I2C3]		= &bus_i2c3_clk.common.hw,
100762306a36Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
100862306a36Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
100962306a36Sopenharmony_ci		[CLK_SPI2]		= &spi2_clk.common.hw,
101062306a36Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
101162306a36Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
101262306a36Sopenharmony_ci		[CLK_BUS_SPI2]		= &bus_spi2_clk.common.hw,
101362306a36Sopenharmony_ci		[CLK_EMAC_25M]		= &emac_25m_clk.common.hw,
101462306a36Sopenharmony_ci		[CLK_BUS_EMAC]		= &bus_emac_clk.common.hw,
101562306a36Sopenharmony_ci		[CLK_IR_RX]		= &ir_rx_clk.common.hw,
101662306a36Sopenharmony_ci		[CLK_BUS_IR_RX]		= &bus_ir_rx_clk.common.hw,
101762306a36Sopenharmony_ci		[CLK_IR_TX]		= &ir_tx_clk.common.hw,
101862306a36Sopenharmony_ci		[CLK_BUS_IR_TX]		= &bus_ir_tx_clk.common.hw,
101962306a36Sopenharmony_ci		[CLK_BUS_GPADC]		= &bus_gpadc_clk.common.hw,
102062306a36Sopenharmony_ci		[CLK_BUS_THS]		= &bus_ths_clk.common.hw,
102162306a36Sopenharmony_ci		[CLK_I2S0]		= &i2s0_clk.common.hw,
102262306a36Sopenharmony_ci		[CLK_I2S1]		= &i2s1_clk.common.hw,
102362306a36Sopenharmony_ci		[CLK_I2S2]		= &i2s2_clk.common.hw,
102462306a36Sopenharmony_ci		[CLK_I2S3]		= &i2s3_clk.common.hw,
102562306a36Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
102662306a36Sopenharmony_ci		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
102762306a36Sopenharmony_ci		[CLK_BUS_I2S2]		= &bus_i2s2_clk.common.hw,
102862306a36Sopenharmony_ci		[CLK_BUS_I2S3]		= &bus_i2s3_clk.common.hw,
102962306a36Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
103062306a36Sopenharmony_ci		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
103162306a36Sopenharmony_ci		[CLK_DMIC]		= &dmic_clk.common.hw,
103262306a36Sopenharmony_ci		[CLK_BUS_DMIC]		= &bus_dmic_clk.common.hw,
103362306a36Sopenharmony_ci		[CLK_AUDIO_DAC]		= &audio_codec_dac_clk.common.hw,
103462306a36Sopenharmony_ci		[CLK_AUDIO_ADC]		= &audio_codec_adc_clk.common.hw,
103562306a36Sopenharmony_ci		[CLK_AUDIO_4X]		= &audio_codec_4x_clk.common.hw,
103662306a36Sopenharmony_ci		[CLK_BUS_AUDIO_CODEC]	= &bus_audio_codec_clk.common.hw,
103762306a36Sopenharmony_ci		[CLK_USB_OHCI0]		= &usb_ohci0_clk.common.hw,
103862306a36Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
103962306a36Sopenharmony_ci		[CLK_USB_OHCI1]		= &usb_ohci1_clk.common.hw,
104062306a36Sopenharmony_ci		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
104162306a36Sopenharmony_ci		[CLK_BUS_OHCI0]		= &bus_ohci0_clk.common.hw,
104262306a36Sopenharmony_ci		[CLK_BUS_OHCI1]		= &bus_ohci1_clk.common.hw,
104362306a36Sopenharmony_ci		[CLK_BUS_EHCI0]		= &bus_ehci0_clk.common.hw,
104462306a36Sopenharmony_ci		[CLK_BUS_EHCI1]		= &bus_ehci1_clk.common.hw,
104562306a36Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
104662306a36Sopenharmony_ci		[CLK_BUS_LRADC]		= &bus_lradc_clk.common.hw,
104762306a36Sopenharmony_ci		[CLK_BUS_DPSS_TOP0]	= &bus_dpss_top0_clk.common.hw,
104862306a36Sopenharmony_ci		[CLK_BUS_DPSS_TOP1]	= &bus_dpss_top1_clk.common.hw,
104962306a36Sopenharmony_ci		[CLK_MIPI_DSI]		= &mipi_dsi_clk.common.hw,
105062306a36Sopenharmony_ci		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
105162306a36Sopenharmony_ci		[CLK_TCON_LCD]		= &tcon_lcd_clk.common.hw,
105262306a36Sopenharmony_ci		[CLK_BUS_TCON_LCD]	= &bus_tcon_lcd_clk.common.hw,
105362306a36Sopenharmony_ci		[CLK_LEDC]		= &ledc_clk.common.hw,
105462306a36Sopenharmony_ci		[CLK_BUS_LEDC]		= &bus_ledc_clk.common.hw,
105562306a36Sopenharmony_ci		[CLK_CSI_TOP]		= &csi_top_clk.common.hw,
105662306a36Sopenharmony_ci		[CLK_CSI0_MCLK]		= &csi0_mclk_clk.common.hw,
105762306a36Sopenharmony_ci		[CLK_CSI1_MCLK]		= &csi1_mclk_clk.common.hw,
105862306a36Sopenharmony_ci		[CLK_BUS_CSI]		= &bus_csi_clk.common.hw,
105962306a36Sopenharmony_ci		[CLK_CSI_ISP]		= &csi_isp_clk.common.hw,
106062306a36Sopenharmony_ci	},
106162306a36Sopenharmony_ci	.num = CLK_NUMBER,
106262306a36Sopenharmony_ci};
106362306a36Sopenharmony_ci
106462306a36Sopenharmony_cistatic struct ccu_reset_map sun50i_a100_ccu_resets[] = {
106562306a36Sopenharmony_ci	[RST_MBUS]		= { 0x540, BIT(30) },
106662306a36Sopenharmony_ci
106762306a36Sopenharmony_ci	[RST_BUS_DE]		= { 0x60c, BIT(16) },
106862306a36Sopenharmony_ci	[RST_BUS_G2D]		= { 0x63c, BIT(16) },
106962306a36Sopenharmony_ci	[RST_BUS_GPU]		= { 0x67c, BIT(16) },
107062306a36Sopenharmony_ci	[RST_BUS_CE]		= { 0x68c, BIT(16) },
107162306a36Sopenharmony_ci	[RST_BUS_VE]		= { 0x69c, BIT(16) },
107262306a36Sopenharmony_ci	[RST_BUS_DMA]		= { 0x70c, BIT(16) },
107362306a36Sopenharmony_ci	[RST_BUS_MSGBOX]	= { 0x71c, BIT(16) },
107462306a36Sopenharmony_ci	[RST_BUS_SPINLOCK]	= { 0x72c, BIT(16) },
107562306a36Sopenharmony_ci	[RST_BUS_HSTIMER]	= { 0x73c, BIT(16) },
107662306a36Sopenharmony_ci	[RST_BUS_DBG]		= { 0x78c, BIT(16) },
107762306a36Sopenharmony_ci	[RST_BUS_PSI]		= { 0x79c, BIT(16) },
107862306a36Sopenharmony_ci	[RST_BUS_PWM]		= { 0x7ac, BIT(16) },
107962306a36Sopenharmony_ci	[RST_BUS_DRAM]		= { 0x80c, BIT(16) },
108062306a36Sopenharmony_ci	[RST_BUS_NAND]		= { 0x82c, BIT(16) },
108162306a36Sopenharmony_ci	[RST_BUS_MMC0]		= { 0x84c, BIT(16) },
108262306a36Sopenharmony_ci	[RST_BUS_MMC1]		= { 0x84c, BIT(17) },
108362306a36Sopenharmony_ci	[RST_BUS_MMC2]		= { 0x84c, BIT(18) },
108462306a36Sopenharmony_ci	[RST_BUS_UART0]		= { 0x90c, BIT(16) },
108562306a36Sopenharmony_ci	[RST_BUS_UART1]		= { 0x90c, BIT(17) },
108662306a36Sopenharmony_ci	[RST_BUS_UART2]		= { 0x90c, BIT(18) },
108762306a36Sopenharmony_ci	[RST_BUS_UART3]		= { 0x90c, BIT(19) },
108862306a36Sopenharmony_ci	[RST_BUS_UART4]		= { 0x90c, BIT(20) },
108962306a36Sopenharmony_ci	[RST_BUS_I2C0]		= { 0x91c, BIT(16) },
109062306a36Sopenharmony_ci	[RST_BUS_I2C1]		= { 0x91c, BIT(17) },
109162306a36Sopenharmony_ci	[RST_BUS_I2C2]		= { 0x91c, BIT(18) },
109262306a36Sopenharmony_ci	[RST_BUS_I2C3]		= { 0x91c, BIT(19) },
109362306a36Sopenharmony_ci	[RST_BUS_SPI0]		= { 0x96c, BIT(16) },
109462306a36Sopenharmony_ci	[RST_BUS_SPI1]		= { 0x96c, BIT(17) },
109562306a36Sopenharmony_ci	[RST_BUS_SPI2]		= { 0x96c, BIT(18) },
109662306a36Sopenharmony_ci	[RST_BUS_EMAC]		= { 0x97c, BIT(16) },
109762306a36Sopenharmony_ci	[RST_BUS_IR_RX]		= { 0x99c, BIT(16) },
109862306a36Sopenharmony_ci	[RST_BUS_IR_TX]		= { 0x9cc, BIT(16) },
109962306a36Sopenharmony_ci	[RST_BUS_GPADC]		= { 0x9ec, BIT(16) },
110062306a36Sopenharmony_ci	[RST_BUS_THS]		= { 0x9fc, BIT(16) },
110162306a36Sopenharmony_ci	[RST_BUS_I2S0]		= { 0xa20, BIT(16) },
110262306a36Sopenharmony_ci	[RST_BUS_I2S1]		= { 0xa20, BIT(17) },
110362306a36Sopenharmony_ci	[RST_BUS_I2S2]		= { 0xa20, BIT(18) },
110462306a36Sopenharmony_ci	[RST_BUS_I2S3]		= { 0xa20, BIT(19) },
110562306a36Sopenharmony_ci	[RST_BUS_SPDIF]		= { 0xa2c, BIT(16) },
110662306a36Sopenharmony_ci	[RST_BUS_DMIC]		= { 0xa4c, BIT(16) },
110762306a36Sopenharmony_ci	[RST_BUS_AUDIO_CODEC]	= { 0xa5c, BIT(16) },
110862306a36Sopenharmony_ci
110962306a36Sopenharmony_ci	[RST_USB_PHY0]		= { 0xa70, BIT(30) },
111062306a36Sopenharmony_ci	[RST_USB_PHY1]		= { 0xa74, BIT(30) },
111162306a36Sopenharmony_ci
111262306a36Sopenharmony_ci	[RST_BUS_OHCI0]		= { 0xa8c, BIT(16) },
111362306a36Sopenharmony_ci	[RST_BUS_OHCI1]		= { 0xa8c, BIT(17) },
111462306a36Sopenharmony_ci	[RST_BUS_EHCI0]		= { 0xa8c, BIT(20) },
111562306a36Sopenharmony_ci	[RST_BUS_EHCI1]		= { 0xa8c, BIT(21) },
111662306a36Sopenharmony_ci	[RST_BUS_OTG]		= { 0xa8c, BIT(24) },
111762306a36Sopenharmony_ci
111862306a36Sopenharmony_ci	[RST_BUS_LRADC]		= { 0xa9c, BIT(16) },
111962306a36Sopenharmony_ci	[RST_BUS_DPSS_TOP0]	= { 0xabc, BIT(16) },
112062306a36Sopenharmony_ci	[RST_BUS_DPSS_TOP1]	= { 0xacc, BIT(16) },
112162306a36Sopenharmony_ci	[RST_BUS_MIPI_DSI]	= { 0xb4c, BIT(16) },
112262306a36Sopenharmony_ci	[RST_BUS_TCON_LCD]	= { 0xb7c, BIT(16) },
112362306a36Sopenharmony_ci	[RST_BUS_LVDS]		= { 0xbac, BIT(16) },
112462306a36Sopenharmony_ci	[RST_BUS_LEDC]		= { 0xbfc, BIT(16) },
112562306a36Sopenharmony_ci	[RST_BUS_CSI]		= { 0xc1c, BIT(16) },
112662306a36Sopenharmony_ci	[RST_BUS_CSI_ISP]	= { 0xc2c, BIT(16) },
112762306a36Sopenharmony_ci};
112862306a36Sopenharmony_ci
112962306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun50i_a100_ccu_desc = {
113062306a36Sopenharmony_ci	.ccu_clks	= sun50i_a100_ccu_clks,
113162306a36Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(sun50i_a100_ccu_clks),
113262306a36Sopenharmony_ci
113362306a36Sopenharmony_ci	.hw_clks	= &sun50i_a100_hw_clks,
113462306a36Sopenharmony_ci
113562306a36Sopenharmony_ci	.resets		= sun50i_a100_ccu_resets,
113662306a36Sopenharmony_ci	.num_resets	= ARRAY_SIZE(sun50i_a100_ccu_resets),
113762306a36Sopenharmony_ci};
113862306a36Sopenharmony_ci
113962306a36Sopenharmony_cistatic const u32 sun50i_a100_pll_regs[] = {
114062306a36Sopenharmony_ci	SUN50I_A100_PLL_CPUX_REG,
114162306a36Sopenharmony_ci	SUN50I_A100_PLL_DDR0_REG,
114262306a36Sopenharmony_ci	SUN50I_A100_PLL_PERIPH0_REG,
114362306a36Sopenharmony_ci	SUN50I_A100_PLL_PERIPH1_REG,
114462306a36Sopenharmony_ci	SUN50I_A100_PLL_GPU_REG,
114562306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO0_REG,
114662306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO1_REG,
114762306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO2_REG,
114862306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO3_REG,
114962306a36Sopenharmony_ci	SUN50I_A100_PLL_VE_REG,
115062306a36Sopenharmony_ci	SUN50I_A100_PLL_COM_REG,
115162306a36Sopenharmony_ci	SUN50I_A100_PLL_AUDIO_REG,
115262306a36Sopenharmony_ci};
115362306a36Sopenharmony_ci
115462306a36Sopenharmony_cistatic const u32 sun50i_a100_pll_video_regs[] = {
115562306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO0_REG,
115662306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO1_REG,
115762306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO2_REG,
115862306a36Sopenharmony_ci	SUN50I_A100_PLL_VIDEO3_REG,
115962306a36Sopenharmony_ci};
116062306a36Sopenharmony_ci
116162306a36Sopenharmony_cistatic const u32 sun50i_a100_usb2_clk_regs[] = {
116262306a36Sopenharmony_ci	SUN50I_A100_USB0_CLK_REG,
116362306a36Sopenharmony_ci	SUN50I_A100_USB1_CLK_REG,
116462306a36Sopenharmony_ci};
116562306a36Sopenharmony_ci
116662306a36Sopenharmony_cistatic struct ccu_pll_nb sun50i_a100_pll_cpu_nb = {
116762306a36Sopenharmony_ci	.common = &pll_cpux_clk.common,
116862306a36Sopenharmony_ci	/* copy from pll_cpux_clk */
116962306a36Sopenharmony_ci	.enable = BIT(27),
117062306a36Sopenharmony_ci	.lock   = BIT(28),
117162306a36Sopenharmony_ci};
117262306a36Sopenharmony_ci
117362306a36Sopenharmony_cistatic struct ccu_mux_nb sun50i_a100_cpu_nb = {
117462306a36Sopenharmony_ci	.common         = &cpux_clk.common,
117562306a36Sopenharmony_ci	.cm             = &cpux_clk.mux,
117662306a36Sopenharmony_ci	.delay_us       = 1,
117762306a36Sopenharmony_ci	.bypass_index   = 4, /* index of pll periph0 */
117862306a36Sopenharmony_ci};
117962306a36Sopenharmony_ci
118062306a36Sopenharmony_cistatic int sun50i_a100_ccu_probe(struct platform_device *pdev)
118162306a36Sopenharmony_ci{
118262306a36Sopenharmony_ci	void __iomem *reg;
118362306a36Sopenharmony_ci	u32 val;
118462306a36Sopenharmony_ci	int i, ret;
118562306a36Sopenharmony_ci
118662306a36Sopenharmony_ci	reg = devm_platform_ioremap_resource(pdev, 0);
118762306a36Sopenharmony_ci	if (IS_ERR(reg))
118862306a36Sopenharmony_ci		return PTR_ERR(reg);
118962306a36Sopenharmony_ci
119062306a36Sopenharmony_ci	/*
119162306a36Sopenharmony_ci	 * Enable lock and enable bits on all PLLs.
119262306a36Sopenharmony_ci	 *
119362306a36Sopenharmony_ci	 * Due to the current design, multiple PLLs share one power switch,
119462306a36Sopenharmony_ci	 * so switching PLL is easy to cause stability problems.
119562306a36Sopenharmony_ci	 * When initializing, we enable them by default. When disable,
119662306a36Sopenharmony_ci	 * we only turn off the output of PLL.
119762306a36Sopenharmony_ci	 */
119862306a36Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(sun50i_a100_pll_regs); i++) {
119962306a36Sopenharmony_ci		val = readl(reg + sun50i_a100_pll_regs[i]);
120062306a36Sopenharmony_ci		val |= SUN50I_A100_PLL_LOCK_ENABLE | SUN50I_A100_PLL_ENABLE;
120162306a36Sopenharmony_ci		writel(val, reg + sun50i_a100_pll_regs[i]);
120262306a36Sopenharmony_ci	}
120362306a36Sopenharmony_ci
120462306a36Sopenharmony_ci	/*
120562306a36Sopenharmony_ci	 * In order to pass the EMI certification, the SDM function of
120662306a36Sopenharmony_ci	 * the peripheral 1 bus is enabled, and the frequency is still
120762306a36Sopenharmony_ci	 * calculated using the previous division factor.
120862306a36Sopenharmony_ci	 */
120962306a36Sopenharmony_ci	writel(SUN50I_A100_PLL_PERIPH1_PATTERN0,
121062306a36Sopenharmony_ci	       reg + SUN50I_A100_PLL_PERIPH1_PATTERN0_REG);
121162306a36Sopenharmony_ci
121262306a36Sopenharmony_ci	val = readl(reg + SUN50I_A100_PLL_PERIPH1_REG);
121362306a36Sopenharmony_ci	val |= SUN50I_A100_PLL_SDM_ENABLE;
121462306a36Sopenharmony_ci	writel(val, reg + SUN50I_A100_PLL_PERIPH1_REG);
121562306a36Sopenharmony_ci
121662306a36Sopenharmony_ci	/*
121762306a36Sopenharmony_ci	 * Force the output divider of video PLLs to 0.
121862306a36Sopenharmony_ci	 *
121962306a36Sopenharmony_ci	 * See the comment before pll-video0 definition for the reason.
122062306a36Sopenharmony_ci	 */
122162306a36Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(sun50i_a100_pll_video_regs); i++) {
122262306a36Sopenharmony_ci		val = readl(reg + sun50i_a100_pll_video_regs[i]);
122362306a36Sopenharmony_ci		val &= ~BIT(0);
122462306a36Sopenharmony_ci		writel(val, reg + sun50i_a100_pll_video_regs[i]);
122562306a36Sopenharmony_ci	}
122662306a36Sopenharmony_ci
122762306a36Sopenharmony_ci	/*
122862306a36Sopenharmony_ci	 * Enforce m1 = 0, m0 = 1 for Audio PLL
122962306a36Sopenharmony_ci	 *
123062306a36Sopenharmony_ci	 * See the comment before pll-audio definition for the reason.
123162306a36Sopenharmony_ci	 */
123262306a36Sopenharmony_ci	val = readl(reg + SUN50I_A100_PLL_AUDIO_REG);
123362306a36Sopenharmony_ci	val &= ~BIT(1);
123462306a36Sopenharmony_ci	val |= BIT(0);
123562306a36Sopenharmony_ci	writel(val, reg + SUN50I_A100_PLL_AUDIO_REG);
123662306a36Sopenharmony_ci
123762306a36Sopenharmony_ci	/*
123862306a36Sopenharmony_ci	 * Force OHCI 12M clock sources to 00 (12MHz divided from 48MHz)
123962306a36Sopenharmony_ci	 *
124062306a36Sopenharmony_ci	 * This clock mux is still mysterious, and the code just enforces
124162306a36Sopenharmony_ci	 * it to have a valid clock parent.
124262306a36Sopenharmony_ci	 */
124362306a36Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(sun50i_a100_usb2_clk_regs); i++) {
124462306a36Sopenharmony_ci		val = readl(reg + sun50i_a100_usb2_clk_regs[i]);
124562306a36Sopenharmony_ci		val &= ~GENMASK(25, 24);
124662306a36Sopenharmony_ci		writel(val, reg + sun50i_a100_usb2_clk_regs[i]);
124762306a36Sopenharmony_ci	}
124862306a36Sopenharmony_ci
124962306a36Sopenharmony_ci	ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a100_ccu_desc);
125062306a36Sopenharmony_ci	if (ret)
125162306a36Sopenharmony_ci		return ret;
125262306a36Sopenharmony_ci
125362306a36Sopenharmony_ci	/* Gate then ungate PLL CPU after any rate changes */
125462306a36Sopenharmony_ci	ccu_pll_notifier_register(&sun50i_a100_pll_cpu_nb);
125562306a36Sopenharmony_ci
125662306a36Sopenharmony_ci	/* Reparent CPU during PLL CPU rate changes */
125762306a36Sopenharmony_ci	ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
125862306a36Sopenharmony_ci				  &sun50i_a100_cpu_nb);
125962306a36Sopenharmony_ci
126062306a36Sopenharmony_ci	return 0;
126162306a36Sopenharmony_ci}
126262306a36Sopenharmony_ci
126362306a36Sopenharmony_cistatic const struct of_device_id sun50i_a100_ccu_ids[] = {
126462306a36Sopenharmony_ci	{ .compatible = "allwinner,sun50i-a100-ccu" },
126562306a36Sopenharmony_ci	{ }
126662306a36Sopenharmony_ci};
126762306a36Sopenharmony_ci
126862306a36Sopenharmony_cistatic struct platform_driver sun50i_a100_ccu_driver = {
126962306a36Sopenharmony_ci	.probe	= sun50i_a100_ccu_probe,
127062306a36Sopenharmony_ci	.driver	= {
127162306a36Sopenharmony_ci		.name	= "sun50i-a100-ccu",
127262306a36Sopenharmony_ci		.suppress_bind_attrs = true,
127362306a36Sopenharmony_ci		.of_match_table	= sun50i_a100_ccu_ids,
127462306a36Sopenharmony_ci	},
127562306a36Sopenharmony_ci};
127662306a36Sopenharmony_cimodule_platform_driver(sun50i_a100_ccu_driver);
127762306a36Sopenharmony_ci
127862306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU);
127962306a36Sopenharmony_ciMODULE_LICENSE("GPL");
1280