162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2016 Maxime Ripard. All rights reserved.
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#include "ccu_phase.h"
2362306a36Sopenharmony_ci#include "ccu_sdm.h"
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#include "ccu-sun8i-a23-a33.h"
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic struct ccu_nkmp pll_cpux_clk = {
2962306a36Sopenharmony_ci	.enable = BIT(31),
3062306a36Sopenharmony_ci	.lock	= BIT(28),
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci	.n	= _SUNXI_CCU_MULT(8, 5),
3362306a36Sopenharmony_ci	.k	= _SUNXI_CCU_MULT(4, 2),
3462306a36Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 2),
3562306a36Sopenharmony_ci	.p	= _SUNXI_CCU_DIV_MAX(16, 2, 4),
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci	.common	= {
3862306a36Sopenharmony_ci		.reg		= 0x000,
3962306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpux", "osc24M",
4062306a36Sopenharmony_ci					      &ccu_nkmp_ops,
4162306a36Sopenharmony_ci					      0),
4262306a36Sopenharmony_ci	},
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/*
4662306a36Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
4762306a36Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true
4862306a36Sopenharmony_ci * pll audio).
4962306a36Sopenharmony_ci *
5062306a36Sopenharmony_ci * With sigma-delta modulation for fractional-N on the audio PLL,
5162306a36Sopenharmony_ci * we have to use specific dividers. This means the variable divider
5262306a36Sopenharmony_ci * can no longer be used, as the audio codec requests the exact clock
5362306a36Sopenharmony_ci * rates we support through this mechanism. So we now hard code the
5462306a36Sopenharmony_ci * variable divider to 1. This means the clock rates will no longer
5562306a36Sopenharmony_ci * match the clock names.
5662306a36Sopenharmony_ci */
5762306a36Sopenharmony_ci#define SUN8I_A23_PLL_AUDIO_REG	0x008
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistatic struct ccu_sdm_setting pll_audio_sdm_table[] = {
6062306a36Sopenharmony_ci	{ .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 },
6162306a36Sopenharmony_ci	{ .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 },
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
6562306a36Sopenharmony_ci				       "osc24M", 0x008,
6662306a36Sopenharmony_ci				       8, 7,	/* N */
6762306a36Sopenharmony_ci				       0, 5,	/* M */
6862306a36Sopenharmony_ci				       pll_audio_sdm_table, BIT(24),
6962306a36Sopenharmony_ci				       0x284, BIT(31),
7062306a36Sopenharmony_ci				       BIT(31),	/* gate */
7162306a36Sopenharmony_ci				       BIT(28),	/* lock */
7262306a36Sopenharmony_ci				       CLK_SET_RATE_UNGATE);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video",
7562306a36Sopenharmony_ci					"osc24M", 0x010,
7662306a36Sopenharmony_ci					8, 7,		/* N */
7762306a36Sopenharmony_ci					0, 4,		/* M */
7862306a36Sopenharmony_ci					BIT(24),	/* frac enable */
7962306a36Sopenharmony_ci					BIT(25),	/* frac select */
8062306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
8162306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
8262306a36Sopenharmony_ci					BIT(31),	/* gate */
8362306a36Sopenharmony_ci					BIT(28),	/* lock */
8462306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
8762306a36Sopenharmony_ci					"osc24M", 0x018,
8862306a36Sopenharmony_ci					8, 7,		/* N */
8962306a36Sopenharmony_ci					0, 4,		/* M */
9062306a36Sopenharmony_ci					BIT(24),	/* frac enable */
9162306a36Sopenharmony_ci					BIT(25),	/* frac select */
9262306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
9362306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
9462306a36Sopenharmony_ci					BIT(31),	/* gate */
9562306a36Sopenharmony_ci					BIT(28),	/* lock */
9662306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr_clk, "pll-ddr",
9962306a36Sopenharmony_ci				    "osc24M", 0x020,
10062306a36Sopenharmony_ci				    8, 5,		/* N */
10162306a36Sopenharmony_ci				    4, 2,		/* K */
10262306a36Sopenharmony_ci				    0, 2,		/* M */
10362306a36Sopenharmony_ci				    BIT(31),		/* gate */
10462306a36Sopenharmony_ci				    BIT(28),		/* lock */
10562306a36Sopenharmony_ci				    0);
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_cistatic SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph_clk, "pll-periph",
10862306a36Sopenharmony_ci					   "osc24M", 0x028,
10962306a36Sopenharmony_ci					   8, 5,	/* N */
11062306a36Sopenharmony_ci					   4, 2,	/* K */
11162306a36Sopenharmony_ci					   BIT(31),	/* gate */
11262306a36Sopenharmony_ci					   BIT(28),	/* lock */
11362306a36Sopenharmony_ci					   2,		/* post-div */
11462306a36Sopenharmony_ci					   CLK_SET_RATE_UNGATE);
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_gpu_clk, "pll-gpu",
11762306a36Sopenharmony_ci					"osc24M", 0x038,
11862306a36Sopenharmony_ci					8, 7,		/* N */
11962306a36Sopenharmony_ci					0, 4,		/* M */
12062306a36Sopenharmony_ci					BIT(24),	/* frac enable */
12162306a36Sopenharmony_ci					BIT(25),	/* frac select */
12262306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
12362306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
12462306a36Sopenharmony_ci					BIT(31),	/* gate */
12562306a36Sopenharmony_ci					BIT(28),	/* lock */
12662306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/*
12962306a36Sopenharmony_ci * The MIPI PLL has 2 modes: "MIPI" and "HDMI".
13062306a36Sopenharmony_ci *
13162306a36Sopenharmony_ci * The MIPI mode is a standard NKM-style clock. The HDMI mode is an
13262306a36Sopenharmony_ci * integer / fractional clock with switchable multipliers and dividers.
13362306a36Sopenharmony_ci * This is not supported here. We hardcode the PLL to MIPI mode.
13462306a36Sopenharmony_ci */
13562306a36Sopenharmony_ci#define SUN8I_A23_PLL_MIPI_REG	0x040
13662306a36Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi",
13762306a36Sopenharmony_ci				    "pll-video", 0x040,
13862306a36Sopenharmony_ci				    8, 4,		/* N */
13962306a36Sopenharmony_ci				    4, 2,		/* K */
14062306a36Sopenharmony_ci				    0, 4,		/* M */
14162306a36Sopenharmony_ci				    BIT(31) | BIT(23) | BIT(22), /* gate */
14262306a36Sopenharmony_ci				    BIT(28),		/* lock */
14362306a36Sopenharmony_ci				    CLK_SET_RATE_UNGATE);
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_hsic_clk, "pll-hsic",
14662306a36Sopenharmony_ci					"osc24M", 0x044,
14762306a36Sopenharmony_ci					8, 7,		/* N */
14862306a36Sopenharmony_ci					0, 4,		/* M */
14962306a36Sopenharmony_ci					BIT(24),	/* frac enable */
15062306a36Sopenharmony_ci					BIT(25),	/* frac select */
15162306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
15262306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
15362306a36Sopenharmony_ci					BIT(31),	/* gate */
15462306a36Sopenharmony_ci					BIT(28),	/* lock */
15562306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, "pll-de",
15862306a36Sopenharmony_ci					"osc24M", 0x048,
15962306a36Sopenharmony_ci					8, 7,		/* N */
16062306a36Sopenharmony_ci					0, 4,		/* M */
16162306a36Sopenharmony_ci					BIT(24),	/* frac enable */
16262306a36Sopenharmony_ci					BIT(25),	/* frac select */
16362306a36Sopenharmony_ci					270000000,	/* frac rate 0 */
16462306a36Sopenharmony_ci					297000000,	/* frac rate 1 */
16562306a36Sopenharmony_ci					BIT(31),	/* gate */
16662306a36Sopenharmony_ci					BIT(28),	/* lock */
16762306a36Sopenharmony_ci					CLK_SET_RATE_UNGATE);
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_cistatic const char * const cpux_parents[] = { "osc32k", "osc24M",
17062306a36Sopenharmony_ci					     "pll-cpux" , "pll-cpux" };
17162306a36Sopenharmony_cistatic SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
17262306a36Sopenharmony_ci		     0x050, 16, 2, CLK_IS_CRITICAL);
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cistatic SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_cistatic const char * const ahb1_parents[] = { "osc32k", "osc24M",
17762306a36Sopenharmony_ci					     "axi" , "pll-periph" };
17862306a36Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb1_predivs[] = {
17962306a36Sopenharmony_ci	{ .index = 3, .shift = 6, .width = 2 },
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_cistatic struct ccu_div ahb1_clk = {
18262306a36Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci	.mux		= {
18562306a36Sopenharmony_ci		.shift	= 12,
18662306a36Sopenharmony_ci		.width	= 2,
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci		.var_predivs	= ahb1_predivs,
18962306a36Sopenharmony_ci		.n_var_predivs	= ARRAY_SIZE(ahb1_predivs),
19062306a36Sopenharmony_ci	},
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	.common		= {
19362306a36Sopenharmony_ci		.reg		= 0x054,
19462306a36Sopenharmony_ci		.features	= CCU_FEATURE_VARIABLE_PREDIV,
19562306a36Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb1",
19662306a36Sopenharmony_ci						      ahb1_parents,
19762306a36Sopenharmony_ci						      &ccu_div_ops,
19862306a36Sopenharmony_ci						      0),
19962306a36Sopenharmony_ci	},
20062306a36Sopenharmony_ci};
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_cistatic struct clk_div_table apb1_div_table[] = {
20362306a36Sopenharmony_ci	{ .val = 0, .div = 2 },
20462306a36Sopenharmony_ci	{ .val = 1, .div = 2 },
20562306a36Sopenharmony_ci	{ .val = 2, .div = 4 },
20662306a36Sopenharmony_ci	{ .val = 3, .div = 8 },
20762306a36Sopenharmony_ci	{ /* Sentinel */ },
20862306a36Sopenharmony_ci};
20962306a36Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb1_clk, "apb1", "ahb1",
21062306a36Sopenharmony_ci			   0x054, 8, 2, apb1_div_table, 0);
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_cistatic const char * const apb2_parents[] = { "osc32k", "osc24M",
21362306a36Sopenharmony_ci					     "pll-periph" , "pll-periph" };
21462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", apb2_parents, 0x058,
21562306a36Sopenharmony_ci			     0, 5,	/* M */
21662306a36Sopenharmony_ci			     16, 2,	/* P */
21762306a36Sopenharmony_ci			     24, 2,	/* mux */
21862306a36Sopenharmony_ci			     0);
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mipi_dsi_clk,	"bus-mipi-dsi",	"ahb1",
22162306a36Sopenharmony_ci		      0x060, BIT(1), 0);
22262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb1",
22362306a36Sopenharmony_ci		      0x060, BIT(6), 0);
22462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb1",
22562306a36Sopenharmony_ci		      0x060, BIT(8), 0);
22662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb1",
22762306a36Sopenharmony_ci		      0x060, BIT(9), 0);
22862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc2_clk,	"bus-mmc2",	"ahb1",
22962306a36Sopenharmony_ci		      0x060, BIT(10), 0);
23062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_nand_clk,	"bus-nand",	"ahb1",
23162306a36Sopenharmony_ci		      0x060, BIT(13), 0);
23262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb1",
23362306a36Sopenharmony_ci		      0x060, BIT(14), 0);
23462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
23562306a36Sopenharmony_ci		      0x060, BIT(19), 0);
23662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb1",
23762306a36Sopenharmony_ci		      0x060, BIT(20), 0);
23862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb1",
23962306a36Sopenharmony_ci		      0x060, BIT(21), 0);
24062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb1",
24162306a36Sopenharmony_ci		      0x060, BIT(24), 0);
24262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ehci_clk,	"bus-ehci",	"ahb1",
24362306a36Sopenharmony_ci		      0x060, BIT(26), 0);
24462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ohci_clk,	"bus-ohci",	"ahb1",
24562306a36Sopenharmony_ci		      0x060, BIT(29), 0);
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb1",
24862306a36Sopenharmony_ci		      0x064, BIT(0), 0);
24962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_lcd_clk,	"bus-lcd",	"ahb1",
25062306a36Sopenharmony_ci		      0x064, BIT(4), 0);
25162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk,	"bus-csi",	"ahb1",
25262306a36Sopenharmony_ci		      0x064, BIT(8), 0);
25362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_be_clk,	"bus-de-be",	"ahb1",
25462306a36Sopenharmony_ci		      0x064, BIT(12), 0);
25562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_fe_clk,	"bus-de-fe",	"ahb1",
25662306a36Sopenharmony_ci		      0x064, BIT(14), 0);
25762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
25862306a36Sopenharmony_ci		      0x064, BIT(20), 0);
25962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
26062306a36Sopenharmony_ci		      0x064, BIT(21), 0);
26162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
26262306a36Sopenharmony_ci		      0x064, BIT(22), 0);
26362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_drc_clk,	"bus-drc",	"ahb1",
26462306a36Sopenharmony_ci		      0x064, BIT(25), 0);
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb1",
26762306a36Sopenharmony_ci		      0x068, BIT(0), 0);
26862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb1",
26962306a36Sopenharmony_ci		      0x068, BIT(5), 0);
27062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb1",
27162306a36Sopenharmony_ci		      0x068, BIT(12), 0);
27262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s1_clk,	"bus-i2s1",	"apb1",
27362306a36Sopenharmony_ci		      0x068, BIT(13), 0);
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb2",
27662306a36Sopenharmony_ci		      0x06c, BIT(0), 0);
27762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb2",
27862306a36Sopenharmony_ci		      0x06c, BIT(1), 0);
27962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb2",
28062306a36Sopenharmony_ci		      0x06c, BIT(2), 0);
28162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb2",
28262306a36Sopenharmony_ci		      0x06c, BIT(16), 0);
28362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb2",
28462306a36Sopenharmony_ci		      0x06c, BIT(17), 0);
28562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb2",
28662306a36Sopenharmony_ci		      0x06c, BIT(18), 0);
28762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart3_clk,	"bus-uart3",	"apb2",
28862306a36Sopenharmony_ci		      0x06c, BIT(19), 0);
28962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart4_clk,	"bus-uart4",	"apb2",
29062306a36Sopenharmony_ci		      0x06c, BIT(20), 0);
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph" };
29362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(nand_clk, "nand", mod0_default_parents, 0x080,
29462306a36Sopenharmony_ci				  0, 4,		/* M */
29562306a36Sopenharmony_ci				  16, 2,	/* P */
29662306a36Sopenharmony_ci				  24, 2,	/* mux */
29762306a36Sopenharmony_ci				  BIT(31),	/* gate */
29862306a36Sopenharmony_ci				  0);
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
30162306a36Sopenharmony_ci				  0, 4,		/* M */
30262306a36Sopenharmony_ci				  16, 2,	/* P */
30362306a36Sopenharmony_ci				  24, 2,	/* mux */
30462306a36Sopenharmony_ci				  BIT(31),	/* gate */
30562306a36Sopenharmony_ci				  0);
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0",
30862306a36Sopenharmony_ci		       0x088, 20, 3, 0);
30962306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0",
31062306a36Sopenharmony_ci		       0x088, 8, 3, 0);
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
31362306a36Sopenharmony_ci				  0, 4,		/* M */
31462306a36Sopenharmony_ci				  16, 2,	/* P */
31562306a36Sopenharmony_ci				  24, 2,	/* mux */
31662306a36Sopenharmony_ci				  BIT(31),	/* gate */
31762306a36Sopenharmony_ci				  0);
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1",
32062306a36Sopenharmony_ci		       0x08c, 20, 3, 0);
32162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1",
32262306a36Sopenharmony_ci		       0x08c, 8, 3, 0);
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc2_clk, "mmc2", mod0_default_parents, 0x090,
32562306a36Sopenharmony_ci				  0, 4,		/* M */
32662306a36Sopenharmony_ci				  16, 2,	/* P */
32762306a36Sopenharmony_ci				  24, 2,	/* mux */
32862306a36Sopenharmony_ci				  BIT(31),	/* gate */
32962306a36Sopenharmony_ci				  0);
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_sample_clk, "mmc2_sample", "mmc2",
33262306a36Sopenharmony_ci		       0x090, 20, 3, 0);
33362306a36Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc2_output_clk, "mmc2_output", "mmc2",
33462306a36Sopenharmony_ci		       0x090, 8, 3, 0);
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi0_clk, "spi0", mod0_default_parents, 0x0a0,
33762306a36Sopenharmony_ci				  0, 4,		/* M */
33862306a36Sopenharmony_ci				  16, 2,	/* P */
33962306a36Sopenharmony_ci				  24, 2,	/* mux */
34062306a36Sopenharmony_ci				  BIT(31),	/* gate */
34162306a36Sopenharmony_ci				  0);
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(spi1_clk, "spi1", mod0_default_parents, 0x0a4,
34462306a36Sopenharmony_ci				  0, 4,		/* M */
34562306a36Sopenharmony_ci				  16, 2,	/* P */
34662306a36Sopenharmony_ci				  24, 2,	/* mux */
34762306a36Sopenharmony_ci				  BIT(31),	/* gate */
34862306a36Sopenharmony_ci				  0);
34962306a36Sopenharmony_ci
35062306a36Sopenharmony_cistatic const char * const i2s_parents[] = { "pll-audio-8x", "pll-audio-4x",
35162306a36Sopenharmony_ci					    "pll-audio-2x", "pll-audio" };
35262306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s0_clk, "i2s0", i2s_parents,
35362306a36Sopenharmony_ci			       0x0b0, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s1_clk, "i2s1", i2s_parents,
35662306a36Sopenharmony_ci			       0x0b4, 16, 2, BIT(31), CLK_SET_RATE_PARENT);
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci/* TODO: the parent for most of the USB clocks is not known */
35962306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
36062306a36Sopenharmony_ci		      0x0cc, BIT(8), 0);
36162306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy1_clk,	"usb-phy1",	"osc24M",
36262306a36Sopenharmony_ci		      0x0cc, BIT(9), 0);
36362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_clk,	"usb-hsic",	"pll-hsic",
36462306a36Sopenharmony_ci		      0x0cc, BIT(10), 0);
36562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_hsic_12M_clk,	"usb-hsic-12M",	"osc24M",
36662306a36Sopenharmony_ci		      0x0cc, BIT(11), 0);
36762306a36Sopenharmony_cistatic SUNXI_CCU_GATE(usb_ohci_clk,	"usb-ohci",	"osc24M",
36862306a36Sopenharmony_ci		      0x0cc, BIT(16), 0);
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"pll-ddr",
37162306a36Sopenharmony_ci		      0x100, BIT(0), 0);
37262306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk,	"dram-csi",	"pll-ddr",
37362306a36Sopenharmony_ci		      0x100, BIT(1), 0);
37462306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_drc_clk,	"dram-drc",	"pll-ddr",
37562306a36Sopenharmony_ci		      0x100, BIT(16), 0);
37662306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_fe_clk,	"dram-de-fe",	"pll-ddr",
37762306a36Sopenharmony_ci		      0x100, BIT(24), 0);
37862306a36Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_be_clk,	"dram-de-be",	"pll-ddr",
37962306a36Sopenharmony_ci		      0x100, BIT(26), 0);
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_cistatic const char * const de_parents[] = { "pll-video", "pll-periph-2x",
38262306a36Sopenharmony_ci					   "pll-gpu", "pll-de" };
38362306a36Sopenharmony_cistatic const u8 de_table[] = { 0, 2, 3, 5 };
38462306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_be_clk, "de-be",
38562306a36Sopenharmony_ci				       de_parents, de_table,
38662306a36Sopenharmony_ci				       0x104, 0, 4, 24, 3, BIT(31), 0);
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_fe_clk, "de-fe",
38962306a36Sopenharmony_ci				       de_parents, de_table,
39062306a36Sopenharmony_ci				       0x10c, 0, 4, 24, 3, BIT(31), 0);
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_cistatic const char * const lcd_ch0_parents[] = { "pll-video", "pll-video-2x",
39362306a36Sopenharmony_ci						"pll-mipi" };
39462306a36Sopenharmony_cistatic const u8 lcd_ch0_table[] = { 0, 2, 4 };
39562306a36Sopenharmony_cistatic SUNXI_CCU_MUX_TABLE_WITH_GATE(lcd_ch0_clk, "lcd-ch0",
39662306a36Sopenharmony_ci				     lcd_ch0_parents, lcd_ch0_table,
39762306a36Sopenharmony_ci				     0x118, 24, 3, BIT(31),
39862306a36Sopenharmony_ci				     CLK_SET_RATE_PARENT);
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_cistatic const char * const lcd_ch1_parents[] = { "pll-video", "pll-video-2x" };
40162306a36Sopenharmony_cistatic const u8 lcd_ch1_table[] = { 0, 2 };
40262306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(lcd_ch1_clk, "lcd-ch1",
40362306a36Sopenharmony_ci				       lcd_ch1_parents, lcd_ch1_table,
40462306a36Sopenharmony_ci				       0x12c, 0, 4, 24, 2, BIT(31), 0);
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_cistatic const char * const csi_sclk_parents[] = { "pll-video", "pll-de",
40762306a36Sopenharmony_ci						 "pll-mipi", "pll-ve" };
40862306a36Sopenharmony_cistatic const u8 csi_sclk_table[] = { 0, 3, 4, 5 };
40962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_sclk_clk, "csi-sclk",
41062306a36Sopenharmony_ci				       csi_sclk_parents, csi_sclk_table,
41162306a36Sopenharmony_ci				       0x134, 16, 4, 24, 3, BIT(31), 0);
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_cistatic const char * const csi_mclk_parents[] = { "pll-video", "pll-de",
41462306a36Sopenharmony_ci						 "osc24M" };
41562306a36Sopenharmony_cistatic const u8 csi_mclk_table[] = { 0, 3, 5 };
41662306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_mclk_clk, "csi-mclk",
41762306a36Sopenharmony_ci				       csi_mclk_parents, csi_mclk_table,
41862306a36Sopenharmony_ci				       0x134, 0, 5, 8, 3, BIT(15), 0);
41962306a36Sopenharmony_ci
42062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(ve_clk, "ve", "pll-ve",
42162306a36Sopenharmony_ci			     0x13c, 16, 3, BIT(31), CLK_SET_RATE_PARENT);
42262306a36Sopenharmony_ci
42362306a36Sopenharmony_cistatic SUNXI_CCU_GATE(ac_dig_clk,	"ac-dig",	"pll-audio",
42462306a36Sopenharmony_ci		      0x140, BIT(31), CLK_SET_RATE_PARENT);
42562306a36Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
42662306a36Sopenharmony_ci		      0x144, BIT(31), 0);
42762306a36Sopenharmony_ci
42862306a36Sopenharmony_cistatic const char * const mbus_parents[] = { "osc24M", "pll-periph-2x",
42962306a36Sopenharmony_ci					     "pll-ddr" };
43062306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(mbus_clk, "mbus", mbus_parents,
43162306a36Sopenharmony_ci				 0x15c, 0, 3, 24, 2, BIT(31), CLK_IS_CRITICAL);
43262306a36Sopenharmony_ci
43362306a36Sopenharmony_cistatic const char * const dsi_sclk_parents[] = { "pll-video", "pll-video-2x" };
43462306a36Sopenharmony_cistatic const u8 dsi_sclk_table[] = { 0, 2 };
43562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_sclk_clk, "dsi-sclk",
43662306a36Sopenharmony_ci				       dsi_sclk_parents, dsi_sclk_table,
43762306a36Sopenharmony_ci				       0x168, 16, 4, 24, 2, BIT(31), 0);
43862306a36Sopenharmony_ci
43962306a36Sopenharmony_cistatic const char * const dsi_dphy_parents[] = { "pll-video", "pll-periph" };
44062306a36Sopenharmony_cistatic const u8 dsi_dphy_table[] = { 0, 2 };
44162306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(dsi_dphy_clk, "dsi-dphy",
44262306a36Sopenharmony_ci				       dsi_dphy_parents, dsi_dphy_table,
44362306a36Sopenharmony_ci				       0x168, 0, 4, 8, 2, BIT(15), 0);
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(drc_clk, "drc",
44662306a36Sopenharmony_ci				       de_parents, de_table,
44762306a36Sopenharmony_ci				       0x180, 0, 4, 24, 3, BIT(31), 0);
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(gpu_clk, "gpu", "pll-gpu",
45062306a36Sopenharmony_ci			     0x1a0, 0, 3, BIT(31), 0);
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_cistatic const char * const ats_parents[] = { "osc24M", "pll-periph" };
45362306a36Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(ats_clk, "ats", ats_parents,
45462306a36Sopenharmony_ci				 0x1b0, 0, 3, 24, 2, BIT(31), 0);
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_cistatic struct ccu_common *sun8i_a23_ccu_clks[] = {
45762306a36Sopenharmony_ci	&pll_cpux_clk.common,
45862306a36Sopenharmony_ci	&pll_audio_base_clk.common,
45962306a36Sopenharmony_ci	&pll_video_clk.common,
46062306a36Sopenharmony_ci	&pll_ve_clk.common,
46162306a36Sopenharmony_ci	&pll_ddr_clk.common,
46262306a36Sopenharmony_ci	&pll_periph_clk.common,
46362306a36Sopenharmony_ci	&pll_gpu_clk.common,
46462306a36Sopenharmony_ci	&pll_mipi_clk.common,
46562306a36Sopenharmony_ci	&pll_hsic_clk.common,
46662306a36Sopenharmony_ci	&pll_de_clk.common,
46762306a36Sopenharmony_ci	&cpux_clk.common,
46862306a36Sopenharmony_ci	&axi_clk.common,
46962306a36Sopenharmony_ci	&ahb1_clk.common,
47062306a36Sopenharmony_ci	&apb1_clk.common,
47162306a36Sopenharmony_ci	&apb2_clk.common,
47262306a36Sopenharmony_ci	&bus_mipi_dsi_clk.common,
47362306a36Sopenharmony_ci	&bus_dma_clk.common,
47462306a36Sopenharmony_ci	&bus_mmc0_clk.common,
47562306a36Sopenharmony_ci	&bus_mmc1_clk.common,
47662306a36Sopenharmony_ci	&bus_mmc2_clk.common,
47762306a36Sopenharmony_ci	&bus_nand_clk.common,
47862306a36Sopenharmony_ci	&bus_dram_clk.common,
47962306a36Sopenharmony_ci	&bus_hstimer_clk.common,
48062306a36Sopenharmony_ci	&bus_spi0_clk.common,
48162306a36Sopenharmony_ci	&bus_spi1_clk.common,
48262306a36Sopenharmony_ci	&bus_otg_clk.common,
48362306a36Sopenharmony_ci	&bus_ehci_clk.common,
48462306a36Sopenharmony_ci	&bus_ohci_clk.common,
48562306a36Sopenharmony_ci	&bus_ve_clk.common,
48662306a36Sopenharmony_ci	&bus_lcd_clk.common,
48762306a36Sopenharmony_ci	&bus_csi_clk.common,
48862306a36Sopenharmony_ci	&bus_de_fe_clk.common,
48962306a36Sopenharmony_ci	&bus_de_be_clk.common,
49062306a36Sopenharmony_ci	&bus_gpu_clk.common,
49162306a36Sopenharmony_ci	&bus_msgbox_clk.common,
49262306a36Sopenharmony_ci	&bus_spinlock_clk.common,
49362306a36Sopenharmony_ci	&bus_drc_clk.common,
49462306a36Sopenharmony_ci	&bus_codec_clk.common,
49562306a36Sopenharmony_ci	&bus_pio_clk.common,
49662306a36Sopenharmony_ci	&bus_i2s0_clk.common,
49762306a36Sopenharmony_ci	&bus_i2s1_clk.common,
49862306a36Sopenharmony_ci	&bus_i2c0_clk.common,
49962306a36Sopenharmony_ci	&bus_i2c1_clk.common,
50062306a36Sopenharmony_ci	&bus_i2c2_clk.common,
50162306a36Sopenharmony_ci	&bus_uart0_clk.common,
50262306a36Sopenharmony_ci	&bus_uart1_clk.common,
50362306a36Sopenharmony_ci	&bus_uart2_clk.common,
50462306a36Sopenharmony_ci	&bus_uart3_clk.common,
50562306a36Sopenharmony_ci	&bus_uart4_clk.common,
50662306a36Sopenharmony_ci	&nand_clk.common,
50762306a36Sopenharmony_ci	&mmc0_clk.common,
50862306a36Sopenharmony_ci	&mmc0_sample_clk.common,
50962306a36Sopenharmony_ci	&mmc0_output_clk.common,
51062306a36Sopenharmony_ci	&mmc1_clk.common,
51162306a36Sopenharmony_ci	&mmc1_sample_clk.common,
51262306a36Sopenharmony_ci	&mmc1_output_clk.common,
51362306a36Sopenharmony_ci	&mmc2_clk.common,
51462306a36Sopenharmony_ci	&mmc2_sample_clk.common,
51562306a36Sopenharmony_ci	&mmc2_output_clk.common,
51662306a36Sopenharmony_ci	&spi0_clk.common,
51762306a36Sopenharmony_ci	&spi1_clk.common,
51862306a36Sopenharmony_ci	&i2s0_clk.common,
51962306a36Sopenharmony_ci	&i2s1_clk.common,
52062306a36Sopenharmony_ci	&usb_phy0_clk.common,
52162306a36Sopenharmony_ci	&usb_phy1_clk.common,
52262306a36Sopenharmony_ci	&usb_hsic_clk.common,
52362306a36Sopenharmony_ci	&usb_hsic_12M_clk.common,
52462306a36Sopenharmony_ci	&usb_ohci_clk.common,
52562306a36Sopenharmony_ci	&dram_ve_clk.common,
52662306a36Sopenharmony_ci	&dram_csi_clk.common,
52762306a36Sopenharmony_ci	&dram_drc_clk.common,
52862306a36Sopenharmony_ci	&dram_de_fe_clk.common,
52962306a36Sopenharmony_ci	&dram_de_be_clk.common,
53062306a36Sopenharmony_ci	&de_be_clk.common,
53162306a36Sopenharmony_ci	&de_fe_clk.common,
53262306a36Sopenharmony_ci	&lcd_ch0_clk.common,
53362306a36Sopenharmony_ci	&lcd_ch1_clk.common,
53462306a36Sopenharmony_ci	&csi_sclk_clk.common,
53562306a36Sopenharmony_ci	&csi_mclk_clk.common,
53662306a36Sopenharmony_ci	&ve_clk.common,
53762306a36Sopenharmony_ci	&ac_dig_clk.common,
53862306a36Sopenharmony_ci	&avs_clk.common,
53962306a36Sopenharmony_ci	&mbus_clk.common,
54062306a36Sopenharmony_ci	&dsi_sclk_clk.common,
54162306a36Sopenharmony_ci	&dsi_dphy_clk.common,
54262306a36Sopenharmony_ci	&drc_clk.common,
54362306a36Sopenharmony_ci	&gpu_clk.common,
54462306a36Sopenharmony_ci	&ats_clk.common,
54562306a36Sopenharmony_ci};
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = {
54862306a36Sopenharmony_ci	&pll_audio_base_clk.common.hw
54962306a36Sopenharmony_ci};
55062306a36Sopenharmony_ci
55162306a36Sopenharmony_ci/* We hardcode the divider to 1 for now */
55262306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
55362306a36Sopenharmony_ci			    clk_parent_pll_audio,
55462306a36Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
55562306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
55662306a36Sopenharmony_ci			    clk_parent_pll_audio,
55762306a36Sopenharmony_ci			    2, 1, CLK_SET_RATE_PARENT);
55862306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
55962306a36Sopenharmony_ci			    clk_parent_pll_audio,
56062306a36Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
56162306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
56262306a36Sopenharmony_ci			    clk_parent_pll_audio,
56362306a36Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
56462306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_periph_2x_clk, "pll-periph-2x",
56562306a36Sopenharmony_ci			   &pll_periph_clk.common.hw,
56662306a36Sopenharmony_ci			   1, 2, 0);
56762306a36Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video_2x_clk, "pll-video-2x",
56862306a36Sopenharmony_ci			   &pll_video_clk.common.hw,
56962306a36Sopenharmony_ci			   1, 2, 0);
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_cistatic struct clk_hw_onecell_data sun8i_a23_hw_clks = {
57262306a36Sopenharmony_ci	.hws	= {
57362306a36Sopenharmony_ci		[CLK_PLL_CPUX]		= &pll_cpux_clk.common.hw,
57462306a36Sopenharmony_ci		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
57562306a36Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
57662306a36Sopenharmony_ci		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
57762306a36Sopenharmony_ci		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
57862306a36Sopenharmony_ci		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
57962306a36Sopenharmony_ci		[CLK_PLL_VIDEO]		= &pll_video_clk.common.hw,
58062306a36Sopenharmony_ci		[CLK_PLL_VIDEO_2X]	= &pll_video_2x_clk.hw,
58162306a36Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
58262306a36Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr_clk.common.hw,
58362306a36Sopenharmony_ci		[CLK_PLL_PERIPH]	= &pll_periph_clk.common.hw,
58462306a36Sopenharmony_ci		[CLK_PLL_PERIPH_2X]	= &pll_periph_2x_clk.hw,
58562306a36Sopenharmony_ci		[CLK_PLL_GPU]		= &pll_gpu_clk.common.hw,
58662306a36Sopenharmony_ci		[CLK_PLL_MIPI]		= &pll_mipi_clk.common.hw,
58762306a36Sopenharmony_ci		[CLK_PLL_HSIC]		= &pll_hsic_clk.common.hw,
58862306a36Sopenharmony_ci		[CLK_PLL_DE]		= &pll_de_clk.common.hw,
58962306a36Sopenharmony_ci		[CLK_CPUX]		= &cpux_clk.common.hw,
59062306a36Sopenharmony_ci		[CLK_AXI]		= &axi_clk.common.hw,
59162306a36Sopenharmony_ci		[CLK_AHB1]		= &ahb1_clk.common.hw,
59262306a36Sopenharmony_ci		[CLK_APB1]		= &apb1_clk.common.hw,
59362306a36Sopenharmony_ci		[CLK_APB2]		= &apb2_clk.common.hw,
59462306a36Sopenharmony_ci		[CLK_BUS_MIPI_DSI]	= &bus_mipi_dsi_clk.common.hw,
59562306a36Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
59662306a36Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
59762306a36Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
59862306a36Sopenharmony_ci		[CLK_BUS_MMC2]		= &bus_mmc2_clk.common.hw,
59962306a36Sopenharmony_ci		[CLK_BUS_NAND]		= &bus_nand_clk.common.hw,
60062306a36Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
60162306a36Sopenharmony_ci		[CLK_BUS_HSTIMER]	= &bus_hstimer_clk.common.hw,
60262306a36Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
60362306a36Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
60462306a36Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
60562306a36Sopenharmony_ci		[CLK_BUS_EHCI]		= &bus_ehci_clk.common.hw,
60662306a36Sopenharmony_ci		[CLK_BUS_OHCI]		= &bus_ohci_clk.common.hw,
60762306a36Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
60862306a36Sopenharmony_ci		[CLK_BUS_LCD]		= &bus_lcd_clk.common.hw,
60962306a36Sopenharmony_ci		[CLK_BUS_CSI]		= &bus_csi_clk.common.hw,
61062306a36Sopenharmony_ci		[CLK_BUS_DE_BE]		= &bus_de_be_clk.common.hw,
61162306a36Sopenharmony_ci		[CLK_BUS_DE_FE]		= &bus_de_fe_clk.common.hw,
61262306a36Sopenharmony_ci		[CLK_BUS_GPU]		= &bus_gpu_clk.common.hw,
61362306a36Sopenharmony_ci		[CLK_BUS_MSGBOX]	= &bus_msgbox_clk.common.hw,
61462306a36Sopenharmony_ci		[CLK_BUS_SPINLOCK]	= &bus_spinlock_clk.common.hw,
61562306a36Sopenharmony_ci		[CLK_BUS_DRC]		= &bus_drc_clk.common.hw,
61662306a36Sopenharmony_ci		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
61762306a36Sopenharmony_ci		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
61862306a36Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
61962306a36Sopenharmony_ci		[CLK_BUS_I2S1]		= &bus_i2s1_clk.common.hw,
62062306a36Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
62162306a36Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
62262306a36Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
62362306a36Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
62462306a36Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
62562306a36Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
62662306a36Sopenharmony_ci		[CLK_BUS_UART3]		= &bus_uart3_clk.common.hw,
62762306a36Sopenharmony_ci		[CLK_BUS_UART4]		= &bus_uart4_clk.common.hw,
62862306a36Sopenharmony_ci		[CLK_NAND]		= &nand_clk.common.hw,
62962306a36Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
63062306a36Sopenharmony_ci		[CLK_MMC0_SAMPLE]	= &mmc0_sample_clk.common.hw,
63162306a36Sopenharmony_ci		[CLK_MMC0_OUTPUT]	= &mmc0_output_clk.common.hw,
63262306a36Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
63362306a36Sopenharmony_ci		[CLK_MMC1_SAMPLE]	= &mmc1_sample_clk.common.hw,
63462306a36Sopenharmony_ci		[CLK_MMC1_OUTPUT]	= &mmc1_output_clk.common.hw,
63562306a36Sopenharmony_ci		[CLK_MMC2]		= &mmc2_clk.common.hw,
63662306a36Sopenharmony_ci		[CLK_MMC2_SAMPLE]	= &mmc2_sample_clk.common.hw,
63762306a36Sopenharmony_ci		[CLK_MMC2_OUTPUT]	= &mmc2_output_clk.common.hw,
63862306a36Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
63962306a36Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
64062306a36Sopenharmony_ci		[CLK_I2S0]		= &i2s0_clk.common.hw,
64162306a36Sopenharmony_ci		[CLK_I2S1]		= &i2s1_clk.common.hw,
64262306a36Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
64362306a36Sopenharmony_ci		[CLK_USB_PHY1]		= &usb_phy1_clk.common.hw,
64462306a36Sopenharmony_ci		[CLK_USB_HSIC]		= &usb_hsic_clk.common.hw,
64562306a36Sopenharmony_ci		[CLK_USB_HSIC_12M]	= &usb_hsic_12M_clk.common.hw,
64662306a36Sopenharmony_ci		[CLK_USB_OHCI]		= &usb_ohci_clk.common.hw,
64762306a36Sopenharmony_ci		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
64862306a36Sopenharmony_ci		[CLK_DRAM_CSI]		= &dram_csi_clk.common.hw,
64962306a36Sopenharmony_ci		[CLK_DRAM_DRC]		= &dram_drc_clk.common.hw,
65062306a36Sopenharmony_ci		[CLK_DRAM_DE_FE]	= &dram_de_fe_clk.common.hw,
65162306a36Sopenharmony_ci		[CLK_DRAM_DE_BE]	= &dram_de_be_clk.common.hw,
65262306a36Sopenharmony_ci		[CLK_DE_BE]		= &de_be_clk.common.hw,
65362306a36Sopenharmony_ci		[CLK_DE_FE]		= &de_fe_clk.common.hw,
65462306a36Sopenharmony_ci		[CLK_LCD_CH0]		= &lcd_ch0_clk.common.hw,
65562306a36Sopenharmony_ci		[CLK_LCD_CH1]		= &lcd_ch1_clk.common.hw,
65662306a36Sopenharmony_ci		[CLK_CSI_SCLK]		= &csi_sclk_clk.common.hw,
65762306a36Sopenharmony_ci		[CLK_CSI_MCLK]		= &csi_mclk_clk.common.hw,
65862306a36Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
65962306a36Sopenharmony_ci		[CLK_AC_DIG]		= &ac_dig_clk.common.hw,
66062306a36Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
66162306a36Sopenharmony_ci		[CLK_MBUS]		= &mbus_clk.common.hw,
66262306a36Sopenharmony_ci		[CLK_DSI_SCLK]		= &dsi_sclk_clk.common.hw,
66362306a36Sopenharmony_ci		[CLK_DSI_DPHY]		= &dsi_dphy_clk.common.hw,
66462306a36Sopenharmony_ci		[CLK_DRC]		= &drc_clk.common.hw,
66562306a36Sopenharmony_ci		[CLK_GPU]		= &gpu_clk.common.hw,
66662306a36Sopenharmony_ci		[CLK_ATS]		= &ats_clk.common.hw,
66762306a36Sopenharmony_ci	},
66862306a36Sopenharmony_ci	.num	= CLK_NUMBER,
66962306a36Sopenharmony_ci};
67062306a36Sopenharmony_ci
67162306a36Sopenharmony_cistatic struct ccu_reset_map sun8i_a23_ccu_resets[] = {
67262306a36Sopenharmony_ci	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
67362306a36Sopenharmony_ci	[RST_USB_PHY1]		=  { 0x0cc, BIT(1) },
67462306a36Sopenharmony_ci	[RST_USB_HSIC]		=  { 0x0cc, BIT(2) },
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci	[RST_MBUS]		=  { 0x0fc, BIT(31) },
67762306a36Sopenharmony_ci
67862306a36Sopenharmony_ci	[RST_BUS_MIPI_DSI]	=  { 0x2c0, BIT(1) },
67962306a36Sopenharmony_ci	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
68062306a36Sopenharmony_ci	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
68162306a36Sopenharmony_ci	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
68262306a36Sopenharmony_ci	[RST_BUS_MMC2]		=  { 0x2c0, BIT(10) },
68362306a36Sopenharmony_ci	[RST_BUS_NAND]		=  { 0x2c0, BIT(13) },
68462306a36Sopenharmony_ci	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
68562306a36Sopenharmony_ci	[RST_BUS_HSTIMER]	=  { 0x2c0, BIT(19) },
68662306a36Sopenharmony_ci	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
68762306a36Sopenharmony_ci	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
68862306a36Sopenharmony_ci	[RST_BUS_OTG]		=  { 0x2c0, BIT(24) },
68962306a36Sopenharmony_ci	[RST_BUS_EHCI]		=  { 0x2c0, BIT(26) },
69062306a36Sopenharmony_ci	[RST_BUS_OHCI]		=  { 0x2c0, BIT(29) },
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
69362306a36Sopenharmony_ci	[RST_BUS_LCD]		=  { 0x2c4, BIT(4) },
69462306a36Sopenharmony_ci	[RST_BUS_CSI]		=  { 0x2c4, BIT(8) },
69562306a36Sopenharmony_ci	[RST_BUS_DE_BE]		=  { 0x2c4, BIT(12) },
69662306a36Sopenharmony_ci	[RST_BUS_DE_FE]		=  { 0x2c4, BIT(14) },
69762306a36Sopenharmony_ci	[RST_BUS_GPU]		=  { 0x2c4, BIT(20) },
69862306a36Sopenharmony_ci	[RST_BUS_MSGBOX]	=  { 0x2c4, BIT(21) },
69962306a36Sopenharmony_ci	[RST_BUS_SPINLOCK]	=  { 0x2c4, BIT(22) },
70062306a36Sopenharmony_ci	[RST_BUS_DRC]		=  { 0x2c4, BIT(25) },
70162306a36Sopenharmony_ci
70262306a36Sopenharmony_ci	[RST_BUS_LVDS]		=  { 0x2c8, BIT(0) },
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_ci	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
70562306a36Sopenharmony_ci	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
70662306a36Sopenharmony_ci	[RST_BUS_I2S1]		=  { 0x2d0, BIT(13) },
70762306a36Sopenharmony_ci
70862306a36Sopenharmony_ci	[RST_BUS_I2C0]		=  { 0x2d8, BIT(0) },
70962306a36Sopenharmony_ci	[RST_BUS_I2C1]		=  { 0x2d8, BIT(1) },
71062306a36Sopenharmony_ci	[RST_BUS_I2C2]		=  { 0x2d8, BIT(2) },
71162306a36Sopenharmony_ci	[RST_BUS_UART0]		=  { 0x2d8, BIT(16) },
71262306a36Sopenharmony_ci	[RST_BUS_UART1]		=  { 0x2d8, BIT(17) },
71362306a36Sopenharmony_ci	[RST_BUS_UART2]		=  { 0x2d8, BIT(18) },
71462306a36Sopenharmony_ci	[RST_BUS_UART3]		=  { 0x2d8, BIT(19) },
71562306a36Sopenharmony_ci	[RST_BUS_UART4]		=  { 0x2d8, BIT(20) },
71662306a36Sopenharmony_ci};
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_cistatic const struct sunxi_ccu_desc sun8i_a23_ccu_desc = {
71962306a36Sopenharmony_ci	.ccu_clks	= sun8i_a23_ccu_clks,
72062306a36Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(sun8i_a23_ccu_clks),
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci	.hw_clks	= &sun8i_a23_hw_clks,
72362306a36Sopenharmony_ci
72462306a36Sopenharmony_ci	.resets		= sun8i_a23_ccu_resets,
72562306a36Sopenharmony_ci	.num_resets	= ARRAY_SIZE(sun8i_a23_ccu_resets),
72662306a36Sopenharmony_ci};
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_cistatic int sun8i_a23_ccu_probe(struct platform_device *pdev)
72962306a36Sopenharmony_ci{
73062306a36Sopenharmony_ci	void __iomem *reg;
73162306a36Sopenharmony_ci	u32 val;
73262306a36Sopenharmony_ci
73362306a36Sopenharmony_ci	reg = devm_platform_ioremap_resource(pdev, 0);
73462306a36Sopenharmony_ci	if (IS_ERR(reg))
73562306a36Sopenharmony_ci		return PTR_ERR(reg);
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_ci	/* Force the PLL-Audio-1x divider to 1 */
73862306a36Sopenharmony_ci	val = readl(reg + SUN8I_A23_PLL_AUDIO_REG);
73962306a36Sopenharmony_ci	val &= ~GENMASK(19, 16);
74062306a36Sopenharmony_ci	writel(val | (0 << 16), reg + SUN8I_A23_PLL_AUDIO_REG);
74162306a36Sopenharmony_ci
74262306a36Sopenharmony_ci	/* Force PLL-MIPI to MIPI mode */
74362306a36Sopenharmony_ci	val = readl(reg + SUN8I_A23_PLL_MIPI_REG);
74462306a36Sopenharmony_ci	val &= ~BIT(16);
74562306a36Sopenharmony_ci	writel(val, reg + SUN8I_A23_PLL_MIPI_REG);
74662306a36Sopenharmony_ci
74762306a36Sopenharmony_ci	return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_a23_ccu_desc);
74862306a36Sopenharmony_ci}
74962306a36Sopenharmony_ci
75062306a36Sopenharmony_cistatic const struct of_device_id sun8i_a23_ccu_ids[] = {
75162306a36Sopenharmony_ci	{ .compatible = "allwinner,sun8i-a23-ccu" },
75262306a36Sopenharmony_ci	{ }
75362306a36Sopenharmony_ci};
75462306a36Sopenharmony_ci
75562306a36Sopenharmony_cistatic struct platform_driver sun8i_a23_ccu_driver = {
75662306a36Sopenharmony_ci	.probe	= sun8i_a23_ccu_probe,
75762306a36Sopenharmony_ci	.driver	= {
75862306a36Sopenharmony_ci		.name			= "sun8i-a23-ccu",
75962306a36Sopenharmony_ci		.suppress_bind_attrs	= true,
76062306a36Sopenharmony_ci		.of_match_table		= sun8i_a23_ccu_ids,
76162306a36Sopenharmony_ci	},
76262306a36Sopenharmony_ci};
76362306a36Sopenharmony_cimodule_platform_driver(sun8i_a23_ccu_driver);
76462306a36Sopenharmony_ci
76562306a36Sopenharmony_ciMODULE_IMPORT_NS(SUNXI_CCU);
76662306a36Sopenharmony_ciMODULE_LICENSE("GPL");
767