162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2014 MundoReader S.L.
462306a36Sopenharmony_ci * Author: Heiko Stuebner <heiko@sntech.de>
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (c) 2015 Rockchip Electronics Co. Ltd.
762306a36Sopenharmony_ci * Author: Xing Zheng <zhengxing@rock-chips.com>
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * based on
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * samsung/clk.h
1262306a36Sopenharmony_ci * Copyright (c) 2013 Samsung Electronics Co., Ltd.
1362306a36Sopenharmony_ci * Copyright (c) 2013 Linaro Ltd.
1462306a36Sopenharmony_ci * Author: Thomas Abraham <thomas.ab@samsung.com>
1562306a36Sopenharmony_ci */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#ifndef CLK_ROCKCHIP_CLK_H
1862306a36Sopenharmony_ci#define CLK_ROCKCHIP_CLK_H
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#include <linux/io.h>
2162306a36Sopenharmony_ci#include <linux/clk-provider.h>
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistruct clk;
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define HIWORD_UPDATE(val, mask, shift) \
2662306a36Sopenharmony_ci		((val) << (shift) | (mask) << ((shift) + 16))
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* register positions shared by PX30, RV1108, RK2928, RK3036, RK3066, RK3188 and RK3228 */
2962306a36Sopenharmony_ci#define BOOST_PLL_H_CON(x)		((x) * 0x4)
3062306a36Sopenharmony_ci#define BOOST_CLK_CON			0x0008
3162306a36Sopenharmony_ci#define BOOST_BOOST_CON			0x000c
3262306a36Sopenharmony_ci#define BOOST_SWITCH_CNT		0x0010
3362306a36Sopenharmony_ci#define BOOST_HIGH_PERF_CNT0		0x0014
3462306a36Sopenharmony_ci#define BOOST_HIGH_PERF_CNT1		0x0018
3562306a36Sopenharmony_ci#define BOOST_STATIS_THRESHOLD		0x001c
3662306a36Sopenharmony_ci#define BOOST_SHORT_SWITCH_CNT		0x0020
3762306a36Sopenharmony_ci#define BOOST_SWITCH_THRESHOLD		0x0024
3862306a36Sopenharmony_ci#define BOOST_FSM_STATUS		0x0028
3962306a36Sopenharmony_ci#define BOOST_PLL_L_CON(x)		((x) * 0x4 + 0x2c)
4062306a36Sopenharmony_ci#define BOOST_RECOVERY_MASK		0x1
4162306a36Sopenharmony_ci#define BOOST_RECOVERY_SHIFT		1
4262306a36Sopenharmony_ci#define BOOST_SW_CTRL_MASK		0x1
4362306a36Sopenharmony_ci#define BOOST_SW_CTRL_SHIFT		2
4462306a36Sopenharmony_ci#define BOOST_LOW_FREQ_EN_MASK		0x1
4562306a36Sopenharmony_ci#define BOOST_LOW_FREQ_EN_SHIFT		3
4662306a36Sopenharmony_ci#define BOOST_BUSY_STATE		BIT(8)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define PX30_PLL_CON(x)			((x) * 0x4)
4962306a36Sopenharmony_ci#define PX30_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
5062306a36Sopenharmony_ci#define PX30_CLKGATE_CON(x)		((x) * 0x4 + 0x200)
5162306a36Sopenharmony_ci#define PX30_GLB_SRST_FST		0xb8
5262306a36Sopenharmony_ci#define PX30_GLB_SRST_SND		0xbc
5362306a36Sopenharmony_ci#define PX30_SOFTRST_CON(x)		((x) * 0x4 + 0x300)
5462306a36Sopenharmony_ci#define PX30_MODE_CON			0xa0
5562306a36Sopenharmony_ci#define PX30_MISC_CON			0xa4
5662306a36Sopenharmony_ci#define PX30_SDMMC_CON0			0x380
5762306a36Sopenharmony_ci#define PX30_SDMMC_CON1			0x384
5862306a36Sopenharmony_ci#define PX30_SDIO_CON0			0x388
5962306a36Sopenharmony_ci#define PX30_SDIO_CON1			0x38c
6062306a36Sopenharmony_ci#define PX30_EMMC_CON0			0x390
6162306a36Sopenharmony_ci#define PX30_EMMC_CON1			0x394
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define PX30_PMU_PLL_CON(x)		((x) * 0x4)
6462306a36Sopenharmony_ci#define PX30_PMU_CLKSEL_CON(x)		((x) * 0x4 + 0x40)
6562306a36Sopenharmony_ci#define PX30_PMU_CLKGATE_CON(x)		((x) * 0x4 + 0x80)
6662306a36Sopenharmony_ci#define PX30_PMU_MODE			0x0020
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define RV1108_PLL_CON(x)		((x) * 0x4)
6962306a36Sopenharmony_ci#define RV1108_CLKSEL_CON(x)		((x) * 0x4 + 0x60)
7062306a36Sopenharmony_ci#define RV1108_CLKGATE_CON(x)		((x) * 0x4 + 0x120)
7162306a36Sopenharmony_ci#define RV1108_SOFTRST_CON(x)		((x) * 0x4 + 0x180)
7262306a36Sopenharmony_ci#define RV1108_GLB_SRST_FST		0x1c0
7362306a36Sopenharmony_ci#define RV1108_GLB_SRST_SND		0x1c4
7462306a36Sopenharmony_ci#define RV1108_MISC_CON			0x1cc
7562306a36Sopenharmony_ci#define RV1108_SDMMC_CON0		0x1d8
7662306a36Sopenharmony_ci#define RV1108_SDMMC_CON1		0x1dc
7762306a36Sopenharmony_ci#define RV1108_SDIO_CON0		0x1e0
7862306a36Sopenharmony_ci#define RV1108_SDIO_CON1		0x1e4
7962306a36Sopenharmony_ci#define RV1108_EMMC_CON0		0x1e8
8062306a36Sopenharmony_ci#define RV1108_EMMC_CON1		0x1ec
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#define RV1126_PMU_MODE			0x0
8362306a36Sopenharmony_ci#define RV1126_PMU_PLL_CON(x)		((x) * 0x4 + 0x10)
8462306a36Sopenharmony_ci#define RV1126_PMU_CLKSEL_CON(x)	((x) * 0x4 + 0x100)
8562306a36Sopenharmony_ci#define RV1126_PMU_CLKGATE_CON(x)	((x) * 0x4 + 0x180)
8662306a36Sopenharmony_ci#define RV1126_PMU_SOFTRST_CON(x)	((x) * 0x4 + 0x200)
8762306a36Sopenharmony_ci#define RV1126_PLL_CON(x)		((x) * 0x4)
8862306a36Sopenharmony_ci#define RV1126_MODE_CON			0x90
8962306a36Sopenharmony_ci#define RV1126_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
9062306a36Sopenharmony_ci#define RV1126_CLKGATE_CON(x)		((x) * 0x4 + 0x280)
9162306a36Sopenharmony_ci#define RV1126_SOFTRST_CON(x)		((x) * 0x4 + 0x300)
9262306a36Sopenharmony_ci#define RV1126_GLB_SRST_FST		0x408
9362306a36Sopenharmony_ci#define RV1126_GLB_SRST_SND		0x40c
9462306a36Sopenharmony_ci#define RV1126_SDMMC_CON0		0x440
9562306a36Sopenharmony_ci#define RV1126_SDMMC_CON1		0x444
9662306a36Sopenharmony_ci#define RV1126_SDIO_CON0		0x448
9762306a36Sopenharmony_ci#define RV1126_SDIO_CON1		0x44c
9862306a36Sopenharmony_ci#define RV1126_EMMC_CON0		0x450
9962306a36Sopenharmony_ci#define RV1126_EMMC_CON1		0x454
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define RK2928_PLL_CON(x)		((x) * 0x4)
10262306a36Sopenharmony_ci#define RK2928_MODE_CON		0x40
10362306a36Sopenharmony_ci#define RK2928_CLKSEL_CON(x)	((x) * 0x4 + 0x44)
10462306a36Sopenharmony_ci#define RK2928_CLKGATE_CON(x)	((x) * 0x4 + 0xd0)
10562306a36Sopenharmony_ci#define RK2928_GLB_SRST_FST		0x100
10662306a36Sopenharmony_ci#define RK2928_GLB_SRST_SND		0x104
10762306a36Sopenharmony_ci#define RK2928_SOFTRST_CON(x)	((x) * 0x4 + 0x110)
10862306a36Sopenharmony_ci#define RK2928_MISC_CON		0x134
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#define RK3036_SDMMC_CON0		0x144
11162306a36Sopenharmony_ci#define RK3036_SDMMC_CON1		0x148
11262306a36Sopenharmony_ci#define RK3036_SDIO_CON0		0x14c
11362306a36Sopenharmony_ci#define RK3036_SDIO_CON1		0x150
11462306a36Sopenharmony_ci#define RK3036_EMMC_CON0		0x154
11562306a36Sopenharmony_ci#define RK3036_EMMC_CON1		0x158
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci#define RK3228_GLB_SRST_FST		0x1f0
11862306a36Sopenharmony_ci#define RK3228_GLB_SRST_SND		0x1f4
11962306a36Sopenharmony_ci#define RK3228_SDMMC_CON0		0x1c0
12062306a36Sopenharmony_ci#define RK3228_SDMMC_CON1		0x1c4
12162306a36Sopenharmony_ci#define RK3228_SDIO_CON0		0x1c8
12262306a36Sopenharmony_ci#define RK3228_SDIO_CON1		0x1cc
12362306a36Sopenharmony_ci#define RK3228_EMMC_CON0		0x1d8
12462306a36Sopenharmony_ci#define RK3228_EMMC_CON1		0x1dc
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define RK3288_PLL_CON(x)		RK2928_PLL_CON(x)
12762306a36Sopenharmony_ci#define RK3288_MODE_CON			0x50
12862306a36Sopenharmony_ci#define RK3288_CLKSEL_CON(x)		((x) * 0x4 + 0x60)
12962306a36Sopenharmony_ci#define RK3288_CLKGATE_CON(x)		((x) * 0x4 + 0x160)
13062306a36Sopenharmony_ci#define RK3288_GLB_SRST_FST		0x1b0
13162306a36Sopenharmony_ci#define RK3288_GLB_SRST_SND		0x1b4
13262306a36Sopenharmony_ci#define RK3288_SOFTRST_CON(x)		((x) * 0x4 + 0x1b8)
13362306a36Sopenharmony_ci#define RK3288_MISC_CON			0x1e8
13462306a36Sopenharmony_ci#define RK3288_SDMMC_CON0		0x200
13562306a36Sopenharmony_ci#define RK3288_SDMMC_CON1		0x204
13662306a36Sopenharmony_ci#define RK3288_SDIO0_CON0		0x208
13762306a36Sopenharmony_ci#define RK3288_SDIO0_CON1		0x20c
13862306a36Sopenharmony_ci#define RK3288_SDIO1_CON0		0x210
13962306a36Sopenharmony_ci#define RK3288_SDIO1_CON1		0x214
14062306a36Sopenharmony_ci#define RK3288_EMMC_CON0		0x218
14162306a36Sopenharmony_ci#define RK3288_EMMC_CON1		0x21c
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#define RK3308_PLL_CON(x)		RK2928_PLL_CON(x)
14462306a36Sopenharmony_ci#define RK3308_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
14562306a36Sopenharmony_ci#define RK3308_CLKGATE_CON(x)		((x) * 0x4 + 0x300)
14662306a36Sopenharmony_ci#define RK3308_GLB_SRST_FST		0xb8
14762306a36Sopenharmony_ci#define RK3308_SOFTRST_CON(x)		((x) * 0x4 + 0x400)
14862306a36Sopenharmony_ci#define RK3308_MODE_CON			0xa0
14962306a36Sopenharmony_ci#define RK3308_SDMMC_CON0		0x480
15062306a36Sopenharmony_ci#define RK3308_SDMMC_CON1		0x484
15162306a36Sopenharmony_ci#define RK3308_SDIO_CON0		0x488
15262306a36Sopenharmony_ci#define RK3308_SDIO_CON1		0x48c
15362306a36Sopenharmony_ci#define RK3308_EMMC_CON0		0x490
15462306a36Sopenharmony_ci#define RK3308_EMMC_CON1		0x494
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci#define RK3328_PLL_CON(x)		RK2928_PLL_CON(x)
15762306a36Sopenharmony_ci#define RK3328_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
15862306a36Sopenharmony_ci#define RK3328_CLKGATE_CON(x)		((x) * 0x4 + 0x200)
15962306a36Sopenharmony_ci#define RK3328_GRFCLKSEL_CON(x)		((x) * 0x4 + 0x100)
16062306a36Sopenharmony_ci#define RK3328_GLB_SRST_FST		0x9c
16162306a36Sopenharmony_ci#define RK3328_GLB_SRST_SND		0x98
16262306a36Sopenharmony_ci#define RK3328_SOFTRST_CON(x)		((x) * 0x4 + 0x300)
16362306a36Sopenharmony_ci#define RK3328_MODE_CON			0x80
16462306a36Sopenharmony_ci#define RK3328_MISC_CON			0x84
16562306a36Sopenharmony_ci#define RK3328_SDMMC_CON0		0x380
16662306a36Sopenharmony_ci#define RK3328_SDMMC_CON1		0x384
16762306a36Sopenharmony_ci#define RK3328_SDIO_CON0		0x388
16862306a36Sopenharmony_ci#define RK3328_SDIO_CON1		0x38c
16962306a36Sopenharmony_ci#define RK3328_EMMC_CON0		0x390
17062306a36Sopenharmony_ci#define RK3328_EMMC_CON1		0x394
17162306a36Sopenharmony_ci#define RK3328_SDMMC_EXT_CON0		0x398
17262306a36Sopenharmony_ci#define RK3328_SDMMC_EXT_CON1		0x39C
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#define RK3368_PLL_CON(x)		RK2928_PLL_CON(x)
17562306a36Sopenharmony_ci#define RK3368_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
17662306a36Sopenharmony_ci#define RK3368_CLKGATE_CON(x)		((x) * 0x4 + 0x200)
17762306a36Sopenharmony_ci#define RK3368_GLB_SRST_FST		0x280
17862306a36Sopenharmony_ci#define RK3368_GLB_SRST_SND		0x284
17962306a36Sopenharmony_ci#define RK3368_SOFTRST_CON(x)		((x) * 0x4 + 0x300)
18062306a36Sopenharmony_ci#define RK3368_MISC_CON			0x380
18162306a36Sopenharmony_ci#define RK3368_SDMMC_CON0		0x400
18262306a36Sopenharmony_ci#define RK3368_SDMMC_CON1		0x404
18362306a36Sopenharmony_ci#define RK3368_SDIO0_CON0		0x408
18462306a36Sopenharmony_ci#define RK3368_SDIO0_CON1		0x40c
18562306a36Sopenharmony_ci#define RK3368_SDIO1_CON0		0x410
18662306a36Sopenharmony_ci#define RK3368_SDIO1_CON1		0x414
18762306a36Sopenharmony_ci#define RK3368_EMMC_CON0		0x418
18862306a36Sopenharmony_ci#define RK3368_EMMC_CON1		0x41c
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci#define RK3399_PLL_CON(x)		RK2928_PLL_CON(x)
19162306a36Sopenharmony_ci#define RK3399_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
19262306a36Sopenharmony_ci#define RK3399_CLKGATE_CON(x)		((x) * 0x4 + 0x300)
19362306a36Sopenharmony_ci#define RK3399_SOFTRST_CON(x)		((x) * 0x4 + 0x400)
19462306a36Sopenharmony_ci#define RK3399_GLB_SRST_FST		0x500
19562306a36Sopenharmony_ci#define RK3399_GLB_SRST_SND		0x504
19662306a36Sopenharmony_ci#define RK3399_GLB_CNT_TH		0x508
19762306a36Sopenharmony_ci#define RK3399_MISC_CON			0x50c
19862306a36Sopenharmony_ci#define RK3399_RST_CON			0x510
19962306a36Sopenharmony_ci#define RK3399_RST_ST			0x514
20062306a36Sopenharmony_ci#define RK3399_SDMMC_CON0		0x580
20162306a36Sopenharmony_ci#define RK3399_SDMMC_CON1		0x584
20262306a36Sopenharmony_ci#define RK3399_SDIO_CON0		0x588
20362306a36Sopenharmony_ci#define RK3399_SDIO_CON1		0x58c
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci#define RK3399_PMU_PLL_CON(x)		RK2928_PLL_CON(x)
20662306a36Sopenharmony_ci#define RK3399_PMU_CLKSEL_CON(x)	((x) * 0x4 + 0x80)
20762306a36Sopenharmony_ci#define RK3399_PMU_CLKGATE_CON(x)	((x) * 0x4 + 0x100)
20862306a36Sopenharmony_ci#define RK3399_PMU_SOFTRST_CON(x)	((x) * 0x4 + 0x110)
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define RK3568_PLL_CON(x)		RK2928_PLL_CON(x)
21162306a36Sopenharmony_ci#define RK3568_MODE_CON0		0xc0
21262306a36Sopenharmony_ci#define RK3568_MISC_CON0		0xc4
21362306a36Sopenharmony_ci#define RK3568_MISC_CON1		0xc8
21462306a36Sopenharmony_ci#define RK3568_MISC_CON2		0xcc
21562306a36Sopenharmony_ci#define RK3568_GLB_CNT_TH		0xd0
21662306a36Sopenharmony_ci#define RK3568_GLB_SRST_FST		0xd4
21762306a36Sopenharmony_ci#define RK3568_GLB_SRST_SND		0xd8
21862306a36Sopenharmony_ci#define RK3568_GLB_RST_CON		0xdc
21962306a36Sopenharmony_ci#define RK3568_GLB_RST_ST		0xe0
22062306a36Sopenharmony_ci#define RK3568_CLKSEL_CON(x)		((x) * 0x4 + 0x100)
22162306a36Sopenharmony_ci#define RK3568_CLKGATE_CON(x)		((x) * 0x4 + 0x300)
22262306a36Sopenharmony_ci#define RK3568_SOFTRST_CON(x)		((x) * 0x4 + 0x400)
22362306a36Sopenharmony_ci#define RK3568_SDMMC0_CON0		0x580
22462306a36Sopenharmony_ci#define RK3568_SDMMC0_CON1		0x584
22562306a36Sopenharmony_ci#define RK3568_SDMMC1_CON0		0x588
22662306a36Sopenharmony_ci#define RK3568_SDMMC1_CON1		0x58c
22762306a36Sopenharmony_ci#define RK3568_SDMMC2_CON0		0x590
22862306a36Sopenharmony_ci#define RK3568_SDMMC2_CON1		0x594
22962306a36Sopenharmony_ci#define RK3568_EMMC_CON0		0x598
23062306a36Sopenharmony_ci#define RK3568_EMMC_CON1		0x59c
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci#define RK3568_PMU_PLL_CON(x)		RK2928_PLL_CON(x)
23362306a36Sopenharmony_ci#define RK3568_PMU_MODE_CON0		0x80
23462306a36Sopenharmony_ci#define RK3568_PMU_CLKSEL_CON(x)	((x) * 0x4 + 0x100)
23562306a36Sopenharmony_ci#define RK3568_PMU_CLKGATE_CON(x)	((x) * 0x4 + 0x180)
23662306a36Sopenharmony_ci#define RK3568_PMU_SOFTRST_CON(x)	((x) * 0x4 + 0x200)
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci#define RK3588_PHP_CRU_BASE		0x8000
23962306a36Sopenharmony_ci#define RK3588_PMU_CRU_BASE		0x30000
24062306a36Sopenharmony_ci#define RK3588_BIGCORE0_CRU_BASE	0x50000
24162306a36Sopenharmony_ci#define RK3588_BIGCORE1_CRU_BASE	0x52000
24262306a36Sopenharmony_ci#define RK3588_DSU_CRU_BASE		0x58000
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci#define RK3588_PLL_CON(x)		RK2928_PLL_CON(x)
24562306a36Sopenharmony_ci#define RK3588_MODE_CON0		0x280
24662306a36Sopenharmony_ci#define RK3588_B0_PLL_MODE_CON0		(RK3588_BIGCORE0_CRU_BASE + 0x280)
24762306a36Sopenharmony_ci#define RK3588_B1_PLL_MODE_CON0		(RK3588_BIGCORE1_CRU_BASE + 0x280)
24862306a36Sopenharmony_ci#define RK3588_LPLL_MODE_CON0		(RK3588_DSU_CRU_BASE + 0x280)
24962306a36Sopenharmony_ci#define RK3588_CLKSEL_CON(x)		((x) * 0x4 + 0x300)
25062306a36Sopenharmony_ci#define RK3588_CLKGATE_CON(x)		((x) * 0x4 + 0x800)
25162306a36Sopenharmony_ci#define RK3588_SOFTRST_CON(x)		((x) * 0x4 + 0xa00)
25262306a36Sopenharmony_ci#define RK3588_GLB_CNT_TH		0xc00
25362306a36Sopenharmony_ci#define RK3588_GLB_SRST_FST		0xc08
25462306a36Sopenharmony_ci#define RK3588_GLB_SRST_SND		0xc0c
25562306a36Sopenharmony_ci#define RK3588_GLB_RST_CON		0xc10
25662306a36Sopenharmony_ci#define RK3588_GLB_RST_ST		0xc04
25762306a36Sopenharmony_ci#define RK3588_SDIO_CON0		0xC24
25862306a36Sopenharmony_ci#define RK3588_SDIO_CON1		0xC28
25962306a36Sopenharmony_ci#define RK3588_SDMMC_CON0		0xC30
26062306a36Sopenharmony_ci#define RK3588_SDMMC_CON1		0xC34
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci#define RK3588_PHP_CLKGATE_CON(x)	((x) * 0x4 + RK3588_PHP_CRU_BASE + 0x800)
26362306a36Sopenharmony_ci#define RK3588_PHP_SOFTRST_CON(x)	((x) * 0x4 + RK3588_PHP_CRU_BASE + 0xa00)
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci#define RK3588_PMU_PLL_CON(x)		((x) * 0x4 + RK3588_PHP_CRU_BASE)
26662306a36Sopenharmony_ci#define RK3588_PMU_CLKSEL_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x300)
26762306a36Sopenharmony_ci#define RK3588_PMU_CLKGATE_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0x800)
26862306a36Sopenharmony_ci#define RK3588_PMU_SOFTRST_CON(x)	((x) * 0x4 + RK3588_PMU_CRU_BASE + 0xa00)
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci#define RK3588_B0_PLL_CON(x)		((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE)
27162306a36Sopenharmony_ci#define RK3588_BIGCORE0_CLKSEL_CON(x)	((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x300)
27262306a36Sopenharmony_ci#define RK3588_BIGCORE0_CLKGATE_CON(x)	((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0x800)
27362306a36Sopenharmony_ci#define RK3588_BIGCORE0_SOFTRST_CON(x)	((x) * 0x4 + RK3588_BIGCORE0_CRU_BASE + 0xa00)
27462306a36Sopenharmony_ci#define RK3588_B1_PLL_CON(x)		((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE)
27562306a36Sopenharmony_ci#define RK3588_BIGCORE1_CLKSEL_CON(x)	((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x300)
27662306a36Sopenharmony_ci#define RK3588_BIGCORE1_CLKGATE_CON(x)	((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0x800)
27762306a36Sopenharmony_ci#define RK3588_BIGCORE1_SOFTRST_CON(x)	((x) * 0x4 + RK3588_BIGCORE1_CRU_BASE + 0xa00)
27862306a36Sopenharmony_ci#define RK3588_LPLL_CON(x)		((x) * 0x4 + RK3588_DSU_CRU_BASE)
27962306a36Sopenharmony_ci#define RK3588_DSU_CLKSEL_CON(x)	((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x300)
28062306a36Sopenharmony_ci#define RK3588_DSU_CLKGATE_CON(x)	((x) * 0x4 + RK3588_DSU_CRU_BASE + 0x800)
28162306a36Sopenharmony_ci#define RK3588_DSU_SOFTRST_CON(x)	((x) * 0x4 + RK3588_DSU_CRU_BASE + 0xa00)
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_cienum rockchip_pll_type {
28462306a36Sopenharmony_ci	pll_rk3036,
28562306a36Sopenharmony_ci	pll_rk3066,
28662306a36Sopenharmony_ci	pll_rk3328,
28762306a36Sopenharmony_ci	pll_rk3399,
28862306a36Sopenharmony_ci	pll_rk3588,
28962306a36Sopenharmony_ci	pll_rk3588_core,
29062306a36Sopenharmony_ci};
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci#define RK3036_PLL_RATE(_rate, _refdiv, _fbdiv, _postdiv1,	\
29362306a36Sopenharmony_ci			_postdiv2, _dsmpd, _frac)		\
29462306a36Sopenharmony_ci{								\
29562306a36Sopenharmony_ci	.rate	= _rate##U,					\
29662306a36Sopenharmony_ci	.fbdiv = _fbdiv,					\
29762306a36Sopenharmony_ci	.postdiv1 = _postdiv1,					\
29862306a36Sopenharmony_ci	.refdiv = _refdiv,					\
29962306a36Sopenharmony_ci	.postdiv2 = _postdiv2,					\
30062306a36Sopenharmony_ci	.dsmpd = _dsmpd,					\
30162306a36Sopenharmony_ci	.frac = _frac,						\
30262306a36Sopenharmony_ci}
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci#define RK3066_PLL_RATE(_rate, _nr, _nf, _no)	\
30562306a36Sopenharmony_ci{						\
30662306a36Sopenharmony_ci	.rate	= _rate##U,			\
30762306a36Sopenharmony_ci	.nr = _nr,				\
30862306a36Sopenharmony_ci	.nf = _nf,				\
30962306a36Sopenharmony_ci	.no = _no,				\
31062306a36Sopenharmony_ci	.nb = ((_nf) < 2) ? 1 : (_nf) >> 1,	\
31162306a36Sopenharmony_ci}
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci#define RK3066_PLL_RATE_NB(_rate, _nr, _nf, _no, _nb)		\
31462306a36Sopenharmony_ci{								\
31562306a36Sopenharmony_ci	.rate	= _rate##U,					\
31662306a36Sopenharmony_ci	.nr = _nr,						\
31762306a36Sopenharmony_ci	.nf = _nf,						\
31862306a36Sopenharmony_ci	.no = _no,						\
31962306a36Sopenharmony_ci	.nb = _nb,						\
32062306a36Sopenharmony_ci}
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci#define RK3588_PLL_RATE(_rate, _p, _m, _s, _k)			\
32362306a36Sopenharmony_ci{								\
32462306a36Sopenharmony_ci	.rate   = _rate##U,					\
32562306a36Sopenharmony_ci	.p = _p,						\
32662306a36Sopenharmony_ci	.m = _m,						\
32762306a36Sopenharmony_ci	.s = _s,						\
32862306a36Sopenharmony_ci	.k = _k,						\
32962306a36Sopenharmony_ci}
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci/**
33262306a36Sopenharmony_ci * struct rockchip_clk_provider - information about clock provider
33362306a36Sopenharmony_ci * @reg_base: virtual address for the register base.
33462306a36Sopenharmony_ci * @clk_data: holds clock related data like clk* and number of clocks.
33562306a36Sopenharmony_ci * @cru_node: device-node of the clock-provider
33662306a36Sopenharmony_ci * @grf: regmap of the general-register-files syscon
33762306a36Sopenharmony_ci * @lock: maintains exclusion between callbacks for a given clock-provider.
33862306a36Sopenharmony_ci */
33962306a36Sopenharmony_cistruct rockchip_clk_provider {
34062306a36Sopenharmony_ci	void __iomem *reg_base;
34162306a36Sopenharmony_ci	struct clk_onecell_data clk_data;
34262306a36Sopenharmony_ci	struct device_node *cru_node;
34362306a36Sopenharmony_ci	struct regmap *grf;
34462306a36Sopenharmony_ci	spinlock_t lock;
34562306a36Sopenharmony_ci};
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_cistruct rockchip_pll_rate_table {
34862306a36Sopenharmony_ci	unsigned long rate;
34962306a36Sopenharmony_ci	union {
35062306a36Sopenharmony_ci		struct {
35162306a36Sopenharmony_ci			/* for RK3066 */
35262306a36Sopenharmony_ci			unsigned int nr;
35362306a36Sopenharmony_ci			unsigned int nf;
35462306a36Sopenharmony_ci			unsigned int no;
35562306a36Sopenharmony_ci			unsigned int nb;
35662306a36Sopenharmony_ci		};
35762306a36Sopenharmony_ci		struct {
35862306a36Sopenharmony_ci			/* for RK3036/RK3399 */
35962306a36Sopenharmony_ci			unsigned int fbdiv;
36062306a36Sopenharmony_ci			unsigned int postdiv1;
36162306a36Sopenharmony_ci			unsigned int refdiv;
36262306a36Sopenharmony_ci			unsigned int postdiv2;
36362306a36Sopenharmony_ci			unsigned int dsmpd;
36462306a36Sopenharmony_ci			unsigned int frac;
36562306a36Sopenharmony_ci		};
36662306a36Sopenharmony_ci		struct {
36762306a36Sopenharmony_ci			/* for RK3588 */
36862306a36Sopenharmony_ci			unsigned int m;
36962306a36Sopenharmony_ci			unsigned int p;
37062306a36Sopenharmony_ci			unsigned int s;
37162306a36Sopenharmony_ci			unsigned int k;
37262306a36Sopenharmony_ci		};
37362306a36Sopenharmony_ci	};
37462306a36Sopenharmony_ci};
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci/**
37762306a36Sopenharmony_ci * struct rockchip_pll_clock - information about pll clock
37862306a36Sopenharmony_ci * @id: platform specific id of the clock.
37962306a36Sopenharmony_ci * @name: name of this pll clock.
38062306a36Sopenharmony_ci * @parent_names: name of the parent clock.
38162306a36Sopenharmony_ci * @num_parents: number of parents
38262306a36Sopenharmony_ci * @flags: optional flags for basic clock.
38362306a36Sopenharmony_ci * @con_offset: offset of the register for configuring the PLL.
38462306a36Sopenharmony_ci * @mode_offset: offset of the register for configuring the PLL-mode.
38562306a36Sopenharmony_ci * @mode_shift: offset inside the mode-register for the mode of this pll.
38662306a36Sopenharmony_ci * @lock_shift: offset inside the lock register for the lock status.
38762306a36Sopenharmony_ci * @type: Type of PLL to be registered.
38862306a36Sopenharmony_ci * @pll_flags: hardware-specific flags
38962306a36Sopenharmony_ci * @rate_table: Table of usable pll rates
39062306a36Sopenharmony_ci *
39162306a36Sopenharmony_ci * Flags:
39262306a36Sopenharmony_ci * ROCKCHIP_PLL_SYNC_RATE - check rate parameters to match against the
39362306a36Sopenharmony_ci *	rate_table parameters and ajust them if necessary.
39462306a36Sopenharmony_ci */
39562306a36Sopenharmony_cistruct rockchip_pll_clock {
39662306a36Sopenharmony_ci	unsigned int		id;
39762306a36Sopenharmony_ci	const char		*name;
39862306a36Sopenharmony_ci	const char		*const *parent_names;
39962306a36Sopenharmony_ci	u8			num_parents;
40062306a36Sopenharmony_ci	unsigned long		flags;
40162306a36Sopenharmony_ci	int			con_offset;
40262306a36Sopenharmony_ci	int			mode_offset;
40362306a36Sopenharmony_ci	int			mode_shift;
40462306a36Sopenharmony_ci	int			lock_shift;
40562306a36Sopenharmony_ci	enum rockchip_pll_type	type;
40662306a36Sopenharmony_ci	u8			pll_flags;
40762306a36Sopenharmony_ci	struct rockchip_pll_rate_table *rate_table;
40862306a36Sopenharmony_ci};
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci#define ROCKCHIP_PLL_SYNC_RATE		BIT(0)
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci#define PLL(_type, _id, _name, _pnames, _flags, _con, _mode, _mshift,	\
41362306a36Sopenharmony_ci		_lshift, _pflags, _rtable)				\
41462306a36Sopenharmony_ci	{								\
41562306a36Sopenharmony_ci		.id		= _id,					\
41662306a36Sopenharmony_ci		.type		= _type,				\
41762306a36Sopenharmony_ci		.name		= _name,				\
41862306a36Sopenharmony_ci		.parent_names	= _pnames,				\
41962306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(_pnames),			\
42062306a36Sopenharmony_ci		.flags		= CLK_GET_RATE_NOCACHE | _flags,	\
42162306a36Sopenharmony_ci		.con_offset	= _con,					\
42262306a36Sopenharmony_ci		.mode_offset	= _mode,				\
42362306a36Sopenharmony_ci		.mode_shift	= _mshift,				\
42462306a36Sopenharmony_ci		.lock_shift	= _lshift,				\
42562306a36Sopenharmony_ci		.pll_flags	= _pflags,				\
42662306a36Sopenharmony_ci		.rate_table	= _rtable,				\
42762306a36Sopenharmony_ci	}
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_cistruct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
43062306a36Sopenharmony_ci		enum rockchip_pll_type pll_type,
43162306a36Sopenharmony_ci		const char *name, const char *const *parent_names,
43262306a36Sopenharmony_ci		u8 num_parents, int con_offset, int grf_lock_offset,
43362306a36Sopenharmony_ci		int lock_shift, int mode_offset, int mode_shift,
43462306a36Sopenharmony_ci		struct rockchip_pll_rate_table *rate_table,
43562306a36Sopenharmony_ci		unsigned long flags, u8 clk_pll_flags);
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_cistruct rockchip_cpuclk_clksel {
43862306a36Sopenharmony_ci	int reg;
43962306a36Sopenharmony_ci	u32 val;
44062306a36Sopenharmony_ci};
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci#define ROCKCHIP_CPUCLK_NUM_DIVIDERS	6
44362306a36Sopenharmony_ci#define ROCKCHIP_CPUCLK_MAX_CORES	4
44462306a36Sopenharmony_cistruct rockchip_cpuclk_rate_table {
44562306a36Sopenharmony_ci	unsigned long prate;
44662306a36Sopenharmony_ci	struct rockchip_cpuclk_clksel divs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
44762306a36Sopenharmony_ci	struct rockchip_cpuclk_clksel pre_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
44862306a36Sopenharmony_ci	struct rockchip_cpuclk_clksel post_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
44962306a36Sopenharmony_ci};
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci/**
45262306a36Sopenharmony_ci * struct rockchip_cpuclk_reg_data - register offsets and masks of the cpuclock
45362306a36Sopenharmony_ci * @core_reg[]:	register offset of the cores setting register
45462306a36Sopenharmony_ci * @div_core_shift[]:	cores divider offset used to divide the pll value
45562306a36Sopenharmony_ci * @div_core_mask[]:	cores divider mask
45662306a36Sopenharmony_ci * @num_cores:	number of cpu cores
45762306a36Sopenharmony_ci * @mux_core_reg:       register offset of the cores select parent
45862306a36Sopenharmony_ci * @mux_core_alt:       mux value to select alternate parent
45962306a36Sopenharmony_ci * @mux_core_main:	mux value to select main parent of core
46062306a36Sopenharmony_ci * @mux_core_shift:	offset of the core multiplexer
46162306a36Sopenharmony_ci * @mux_core_mask:	core multiplexer mask
46262306a36Sopenharmony_ci */
46362306a36Sopenharmony_cistruct rockchip_cpuclk_reg_data {
46462306a36Sopenharmony_ci	int	core_reg[ROCKCHIP_CPUCLK_MAX_CORES];
46562306a36Sopenharmony_ci	u8	div_core_shift[ROCKCHIP_CPUCLK_MAX_CORES];
46662306a36Sopenharmony_ci	u32	div_core_mask[ROCKCHIP_CPUCLK_MAX_CORES];
46762306a36Sopenharmony_ci	int	num_cores;
46862306a36Sopenharmony_ci	int	mux_core_reg;
46962306a36Sopenharmony_ci	u8	mux_core_alt;
47062306a36Sopenharmony_ci	u8	mux_core_main;
47162306a36Sopenharmony_ci	u8	mux_core_shift;
47262306a36Sopenharmony_ci	u32	mux_core_mask;
47362306a36Sopenharmony_ci};
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_cistruct clk *rockchip_clk_register_cpuclk(const char *name,
47662306a36Sopenharmony_ci			const char *const *parent_names, u8 num_parents,
47762306a36Sopenharmony_ci			const struct rockchip_cpuclk_reg_data *reg_data,
47862306a36Sopenharmony_ci			const struct rockchip_cpuclk_rate_table *rates,
47962306a36Sopenharmony_ci			int nrates, void __iomem *reg_base, spinlock_t *lock);
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_cistruct clk *rockchip_clk_register_mmc(const char *name,
48262306a36Sopenharmony_ci				const char *const *parent_names, u8 num_parents,
48362306a36Sopenharmony_ci				void __iomem *reg, int shift);
48462306a36Sopenharmony_ci
48562306a36Sopenharmony_ci/*
48662306a36Sopenharmony_ci * DDRCLK flags, including method of setting the rate
48762306a36Sopenharmony_ci * ROCKCHIP_DDRCLK_SIP: use SIP call to bl31 to change ddrclk rate.
48862306a36Sopenharmony_ci */
48962306a36Sopenharmony_ci#define ROCKCHIP_DDRCLK_SIP		BIT(0)
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_cistruct clk *rockchip_clk_register_ddrclk(const char *name, int flags,
49262306a36Sopenharmony_ci					 const char *const *parent_names,
49362306a36Sopenharmony_ci					 u8 num_parents, int mux_offset,
49462306a36Sopenharmony_ci					 int mux_shift, int mux_width,
49562306a36Sopenharmony_ci					 int div_shift, int div_width,
49662306a36Sopenharmony_ci					 int ddr_flags, void __iomem *reg_base,
49762306a36Sopenharmony_ci					 spinlock_t *lock);
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ci#define ROCKCHIP_INVERTER_HIWORD_MASK	BIT(0)
50062306a36Sopenharmony_ci
50162306a36Sopenharmony_cistruct clk *rockchip_clk_register_inverter(const char *name,
50262306a36Sopenharmony_ci				const char *const *parent_names, u8 num_parents,
50362306a36Sopenharmony_ci				void __iomem *reg, int shift, int flags,
50462306a36Sopenharmony_ci				spinlock_t *lock);
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_cistruct clk *rockchip_clk_register_muxgrf(const char *name,
50762306a36Sopenharmony_ci				const char *const *parent_names, u8 num_parents,
50862306a36Sopenharmony_ci				int flags, struct regmap *grf, int reg,
50962306a36Sopenharmony_ci				int shift, int width, int mux_flags);
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci#define PNAME(x) static const char *const x[] __initconst
51262306a36Sopenharmony_ci
51362306a36Sopenharmony_cienum rockchip_clk_branch_type {
51462306a36Sopenharmony_ci	branch_composite,
51562306a36Sopenharmony_ci	branch_mux,
51662306a36Sopenharmony_ci	branch_muxgrf,
51762306a36Sopenharmony_ci	branch_divider,
51862306a36Sopenharmony_ci	branch_fraction_divider,
51962306a36Sopenharmony_ci	branch_gate,
52062306a36Sopenharmony_ci	branch_mmc,
52162306a36Sopenharmony_ci	branch_inverter,
52262306a36Sopenharmony_ci	branch_factor,
52362306a36Sopenharmony_ci	branch_ddrclk,
52462306a36Sopenharmony_ci	branch_half_divider,
52562306a36Sopenharmony_ci};
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_cistruct rockchip_clk_branch {
52862306a36Sopenharmony_ci	unsigned int			id;
52962306a36Sopenharmony_ci	enum rockchip_clk_branch_type	branch_type;
53062306a36Sopenharmony_ci	const char			*name;
53162306a36Sopenharmony_ci	const char			*const *parent_names;
53262306a36Sopenharmony_ci	u8				num_parents;
53362306a36Sopenharmony_ci	unsigned long			flags;
53462306a36Sopenharmony_ci	int				muxdiv_offset;
53562306a36Sopenharmony_ci	u8				mux_shift;
53662306a36Sopenharmony_ci	u8				mux_width;
53762306a36Sopenharmony_ci	u8				mux_flags;
53862306a36Sopenharmony_ci	u32				*mux_table;
53962306a36Sopenharmony_ci	int				div_offset;
54062306a36Sopenharmony_ci	u8				div_shift;
54162306a36Sopenharmony_ci	u8				div_width;
54262306a36Sopenharmony_ci	u8				div_flags;
54362306a36Sopenharmony_ci	struct clk_div_table		*div_table;
54462306a36Sopenharmony_ci	int				gate_offset;
54562306a36Sopenharmony_ci	u8				gate_shift;
54662306a36Sopenharmony_ci	u8				gate_flags;
54762306a36Sopenharmony_ci	struct rockchip_clk_branch	*child;
54862306a36Sopenharmony_ci};
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci#define COMPOSITE(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\
55162306a36Sopenharmony_ci		  df, go, gs, gf)				\
55262306a36Sopenharmony_ci	{							\
55362306a36Sopenharmony_ci		.id		= _id,				\
55462306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
55562306a36Sopenharmony_ci		.name		= cname,			\
55662306a36Sopenharmony_ci		.parent_names	= pnames,			\
55762306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
55862306a36Sopenharmony_ci		.flags		= f,				\
55962306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
56062306a36Sopenharmony_ci		.mux_shift	= ms,				\
56162306a36Sopenharmony_ci		.mux_width	= mw,				\
56262306a36Sopenharmony_ci		.mux_flags	= mf,				\
56362306a36Sopenharmony_ci		.div_shift	= ds,				\
56462306a36Sopenharmony_ci		.div_width	= dw,				\
56562306a36Sopenharmony_ci		.div_flags	= df,				\
56662306a36Sopenharmony_ci		.gate_offset	= go,				\
56762306a36Sopenharmony_ci		.gate_shift	= gs,				\
56862306a36Sopenharmony_ci		.gate_flags	= gf,				\
56962306a36Sopenharmony_ci	}
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci#define COMPOSITE_DIV_OFFSET(_id, cname, pnames, f, mo, ms, mw,	\
57262306a36Sopenharmony_ci			     mf, do, ds, dw, df, go, gs, gf)	\
57362306a36Sopenharmony_ci	{							\
57462306a36Sopenharmony_ci		.id		= _id,				\
57562306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
57662306a36Sopenharmony_ci		.name		= cname,			\
57762306a36Sopenharmony_ci		.parent_names	= pnames,			\
57862306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
57962306a36Sopenharmony_ci		.flags		= f,				\
58062306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
58162306a36Sopenharmony_ci		.mux_shift	= ms,				\
58262306a36Sopenharmony_ci		.mux_width	= mw,				\
58362306a36Sopenharmony_ci		.mux_flags	= mf,				\
58462306a36Sopenharmony_ci		.div_offset	= do,				\
58562306a36Sopenharmony_ci		.div_shift	= ds,				\
58662306a36Sopenharmony_ci		.div_width	= dw,				\
58762306a36Sopenharmony_ci		.div_flags	= df,				\
58862306a36Sopenharmony_ci		.gate_offset	= go,				\
58962306a36Sopenharmony_ci		.gate_shift	= gs,				\
59062306a36Sopenharmony_ci		.gate_flags	= gf,				\
59162306a36Sopenharmony_ci	}
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_ci#define COMPOSITE_NOMUX(_id, cname, pname, f, mo, ds, dw, df,	\
59462306a36Sopenharmony_ci			go, gs, gf)				\
59562306a36Sopenharmony_ci	{							\
59662306a36Sopenharmony_ci		.id		= _id,				\
59762306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
59862306a36Sopenharmony_ci		.name		= cname,			\
59962306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
60062306a36Sopenharmony_ci		.num_parents	= 1,				\
60162306a36Sopenharmony_ci		.flags		= f,				\
60262306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
60362306a36Sopenharmony_ci		.div_shift	= ds,				\
60462306a36Sopenharmony_ci		.div_width	= dw,				\
60562306a36Sopenharmony_ci		.div_flags	= df,				\
60662306a36Sopenharmony_ci		.gate_offset	= go,				\
60762306a36Sopenharmony_ci		.gate_shift	= gs,				\
60862306a36Sopenharmony_ci		.gate_flags	= gf,				\
60962306a36Sopenharmony_ci	}
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci#define COMPOSITE_NOMUX_DIVTBL(_id, cname, pname, f, mo, ds, dw,\
61262306a36Sopenharmony_ci			       df, dt, go, gs, gf)		\
61362306a36Sopenharmony_ci	{							\
61462306a36Sopenharmony_ci		.id		= _id,				\
61562306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
61662306a36Sopenharmony_ci		.name		= cname,			\
61762306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
61862306a36Sopenharmony_ci		.num_parents	= 1,				\
61962306a36Sopenharmony_ci		.flags		= f,				\
62062306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
62162306a36Sopenharmony_ci		.div_shift	= ds,				\
62262306a36Sopenharmony_ci		.div_width	= dw,				\
62362306a36Sopenharmony_ci		.div_flags	= df,				\
62462306a36Sopenharmony_ci		.div_table	= dt,				\
62562306a36Sopenharmony_ci		.gate_offset	= go,				\
62662306a36Sopenharmony_ci		.gate_shift	= gs,				\
62762306a36Sopenharmony_ci		.gate_flags	= gf,				\
62862306a36Sopenharmony_ci	}
62962306a36Sopenharmony_ci
63062306a36Sopenharmony_ci#define COMPOSITE_NODIV(_id, cname, pnames, f, mo, ms, mw, mf,	\
63162306a36Sopenharmony_ci			go, gs, gf)				\
63262306a36Sopenharmony_ci	{							\
63362306a36Sopenharmony_ci		.id		= _id,				\
63462306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
63562306a36Sopenharmony_ci		.name		= cname,			\
63662306a36Sopenharmony_ci		.parent_names	= pnames,			\
63762306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
63862306a36Sopenharmony_ci		.flags		= f,				\
63962306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
64062306a36Sopenharmony_ci		.mux_shift	= ms,				\
64162306a36Sopenharmony_ci		.mux_width	= mw,				\
64262306a36Sopenharmony_ci		.mux_flags	= mf,				\
64362306a36Sopenharmony_ci		.gate_offset	= go,				\
64462306a36Sopenharmony_ci		.gate_shift	= gs,				\
64562306a36Sopenharmony_ci		.gate_flags	= gf,				\
64662306a36Sopenharmony_ci	}
64762306a36Sopenharmony_ci
64862306a36Sopenharmony_ci#define COMPOSITE_NOGATE(_id, cname, pnames, f, mo, ms, mw, mf,	\
64962306a36Sopenharmony_ci			 ds, dw, df)				\
65062306a36Sopenharmony_ci	{							\
65162306a36Sopenharmony_ci		.id		= _id,				\
65262306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
65362306a36Sopenharmony_ci		.name		= cname,			\
65462306a36Sopenharmony_ci		.parent_names	= pnames,			\
65562306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
65662306a36Sopenharmony_ci		.flags		= f,				\
65762306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
65862306a36Sopenharmony_ci		.mux_shift	= ms,				\
65962306a36Sopenharmony_ci		.mux_width	= mw,				\
66062306a36Sopenharmony_ci		.mux_flags	= mf,				\
66162306a36Sopenharmony_ci		.div_shift	= ds,				\
66262306a36Sopenharmony_ci		.div_width	= dw,				\
66362306a36Sopenharmony_ci		.div_flags	= df,				\
66462306a36Sopenharmony_ci		.gate_offset	= -1,				\
66562306a36Sopenharmony_ci	}
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ci#define COMPOSITE_NOGATE_DIVTBL(_id, cname, pnames, f, mo, ms,	\
66862306a36Sopenharmony_ci				mw, mf, ds, dw, df, dt)		\
66962306a36Sopenharmony_ci	{							\
67062306a36Sopenharmony_ci		.id		= _id,				\
67162306a36Sopenharmony_ci		.branch_type	= branch_composite,		\
67262306a36Sopenharmony_ci		.name		= cname,			\
67362306a36Sopenharmony_ci		.parent_names	= pnames,			\
67462306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
67562306a36Sopenharmony_ci		.flags		= f,				\
67662306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
67762306a36Sopenharmony_ci		.mux_shift	= ms,				\
67862306a36Sopenharmony_ci		.mux_width	= mw,				\
67962306a36Sopenharmony_ci		.mux_flags	= mf,				\
68062306a36Sopenharmony_ci		.div_shift	= ds,				\
68162306a36Sopenharmony_ci		.div_width	= dw,				\
68262306a36Sopenharmony_ci		.div_flags	= df,				\
68362306a36Sopenharmony_ci		.div_table	= dt,				\
68462306a36Sopenharmony_ci		.gate_offset	= -1,				\
68562306a36Sopenharmony_ci	}
68662306a36Sopenharmony_ci
68762306a36Sopenharmony_ci#define COMPOSITE_FRAC(_id, cname, pname, f, mo, df, go, gs, gf)\
68862306a36Sopenharmony_ci	{							\
68962306a36Sopenharmony_ci		.id		= _id,				\
69062306a36Sopenharmony_ci		.branch_type	= branch_fraction_divider,	\
69162306a36Sopenharmony_ci		.name		= cname,			\
69262306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
69362306a36Sopenharmony_ci		.num_parents	= 1,				\
69462306a36Sopenharmony_ci		.flags		= f,				\
69562306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
69662306a36Sopenharmony_ci		.div_shift	= 16,				\
69762306a36Sopenharmony_ci		.div_width	= 16,				\
69862306a36Sopenharmony_ci		.div_flags	= df,				\
69962306a36Sopenharmony_ci		.gate_offset	= go,				\
70062306a36Sopenharmony_ci		.gate_shift	= gs,				\
70162306a36Sopenharmony_ci		.gate_flags	= gf,				\
70262306a36Sopenharmony_ci	}
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_ci#define COMPOSITE_FRACMUX(_id, cname, pname, f, mo, df, go, gs, gf, ch) \
70562306a36Sopenharmony_ci	{							\
70662306a36Sopenharmony_ci		.id		= _id,				\
70762306a36Sopenharmony_ci		.branch_type	= branch_fraction_divider,	\
70862306a36Sopenharmony_ci		.name		= cname,			\
70962306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
71062306a36Sopenharmony_ci		.num_parents	= 1,				\
71162306a36Sopenharmony_ci		.flags		= f,				\
71262306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
71362306a36Sopenharmony_ci		.div_shift	= 16,				\
71462306a36Sopenharmony_ci		.div_width	= 16,				\
71562306a36Sopenharmony_ci		.div_flags	= df,				\
71662306a36Sopenharmony_ci		.gate_offset	= go,				\
71762306a36Sopenharmony_ci		.gate_shift	= gs,				\
71862306a36Sopenharmony_ci		.gate_flags	= gf,				\
71962306a36Sopenharmony_ci		.child		= ch,				\
72062306a36Sopenharmony_ci	}
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci#define COMPOSITE_FRACMUX_NOGATE(_id, cname, pname, f, mo, df, ch) \
72362306a36Sopenharmony_ci	{							\
72462306a36Sopenharmony_ci		.id		= _id,				\
72562306a36Sopenharmony_ci		.branch_type	= branch_fraction_divider,	\
72662306a36Sopenharmony_ci		.name		= cname,			\
72762306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
72862306a36Sopenharmony_ci		.num_parents	= 1,				\
72962306a36Sopenharmony_ci		.flags		= f,				\
73062306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
73162306a36Sopenharmony_ci		.div_shift	= 16,				\
73262306a36Sopenharmony_ci		.div_width	= 16,				\
73362306a36Sopenharmony_ci		.div_flags	= df,				\
73462306a36Sopenharmony_ci		.gate_offset	= -1,				\
73562306a36Sopenharmony_ci		.child		= ch,				\
73662306a36Sopenharmony_ci	}
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_ci#define COMPOSITE_DDRCLK(_id, cname, pnames, f, mo, ms, mw,	\
73962306a36Sopenharmony_ci			 ds, dw, df)				\
74062306a36Sopenharmony_ci	{							\
74162306a36Sopenharmony_ci		.id		= _id,				\
74262306a36Sopenharmony_ci		.branch_type	= branch_ddrclk,		\
74362306a36Sopenharmony_ci		.name		= cname,			\
74462306a36Sopenharmony_ci		.parent_names	= pnames,			\
74562306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
74662306a36Sopenharmony_ci		.flags		= f,				\
74762306a36Sopenharmony_ci		.muxdiv_offset  = mo,                           \
74862306a36Sopenharmony_ci		.mux_shift      = ms,                           \
74962306a36Sopenharmony_ci		.mux_width      = mw,                           \
75062306a36Sopenharmony_ci		.div_shift      = ds,                           \
75162306a36Sopenharmony_ci		.div_width      = dw,                           \
75262306a36Sopenharmony_ci		.div_flags	= df,				\
75362306a36Sopenharmony_ci		.gate_offset    = -1,                           \
75462306a36Sopenharmony_ci	}
75562306a36Sopenharmony_ci
75662306a36Sopenharmony_ci#define MUX(_id, cname, pnames, f, o, s, w, mf)			\
75762306a36Sopenharmony_ci	{							\
75862306a36Sopenharmony_ci		.id		= _id,				\
75962306a36Sopenharmony_ci		.branch_type	= branch_mux,			\
76062306a36Sopenharmony_ci		.name		= cname,			\
76162306a36Sopenharmony_ci		.parent_names	= pnames,			\
76262306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
76362306a36Sopenharmony_ci		.flags		= f,				\
76462306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
76562306a36Sopenharmony_ci		.mux_shift	= s,				\
76662306a36Sopenharmony_ci		.mux_width	= w,				\
76762306a36Sopenharmony_ci		.mux_flags	= mf,				\
76862306a36Sopenharmony_ci		.gate_offset	= -1,				\
76962306a36Sopenharmony_ci	}
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_ci#define MUXTBL(_id, cname, pnames, f, o, s, w, mf, mt)		\
77262306a36Sopenharmony_ci	{							\
77362306a36Sopenharmony_ci		.id		= _id,				\
77462306a36Sopenharmony_ci		.branch_type	= branch_mux,			\
77562306a36Sopenharmony_ci		.name		= cname,			\
77662306a36Sopenharmony_ci		.parent_names	= pnames,			\
77762306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
77862306a36Sopenharmony_ci		.flags		= f,				\
77962306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
78062306a36Sopenharmony_ci		.mux_shift	= s,				\
78162306a36Sopenharmony_ci		.mux_width	= w,				\
78262306a36Sopenharmony_ci		.mux_flags	= mf,				\
78362306a36Sopenharmony_ci		.gate_offset	= -1,				\
78462306a36Sopenharmony_ci		.mux_table	= mt,				\
78562306a36Sopenharmony_ci	}
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_ci#define MUXGRF(_id, cname, pnames, f, o, s, w, mf)		\
78862306a36Sopenharmony_ci	{							\
78962306a36Sopenharmony_ci		.id		= _id,				\
79062306a36Sopenharmony_ci		.branch_type	= branch_muxgrf,		\
79162306a36Sopenharmony_ci		.name		= cname,			\
79262306a36Sopenharmony_ci		.parent_names	= pnames,			\
79362306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
79462306a36Sopenharmony_ci		.flags		= f,				\
79562306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
79662306a36Sopenharmony_ci		.mux_shift	= s,				\
79762306a36Sopenharmony_ci		.mux_width	= w,				\
79862306a36Sopenharmony_ci		.mux_flags	= mf,				\
79962306a36Sopenharmony_ci		.gate_offset	= -1,				\
80062306a36Sopenharmony_ci	}
80162306a36Sopenharmony_ci
80262306a36Sopenharmony_ci#define DIV(_id, cname, pname, f, o, s, w, df)			\
80362306a36Sopenharmony_ci	{							\
80462306a36Sopenharmony_ci		.id		= _id,				\
80562306a36Sopenharmony_ci		.branch_type	= branch_divider,		\
80662306a36Sopenharmony_ci		.name		= cname,			\
80762306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
80862306a36Sopenharmony_ci		.num_parents	= 1,				\
80962306a36Sopenharmony_ci		.flags		= f,				\
81062306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
81162306a36Sopenharmony_ci		.div_shift	= s,				\
81262306a36Sopenharmony_ci		.div_width	= w,				\
81362306a36Sopenharmony_ci		.div_flags	= df,				\
81462306a36Sopenharmony_ci		.gate_offset	= -1,				\
81562306a36Sopenharmony_ci	}
81662306a36Sopenharmony_ci
81762306a36Sopenharmony_ci#define DIVTBL(_id, cname, pname, f, o, s, w, df, dt)		\
81862306a36Sopenharmony_ci	{							\
81962306a36Sopenharmony_ci		.id		= _id,				\
82062306a36Sopenharmony_ci		.branch_type	= branch_divider,		\
82162306a36Sopenharmony_ci		.name		= cname,			\
82262306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
82362306a36Sopenharmony_ci		.num_parents	= 1,				\
82462306a36Sopenharmony_ci		.flags		= f,				\
82562306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
82662306a36Sopenharmony_ci		.div_shift	= s,				\
82762306a36Sopenharmony_ci		.div_width	= w,				\
82862306a36Sopenharmony_ci		.div_flags	= df,				\
82962306a36Sopenharmony_ci		.div_table	= dt,				\
83062306a36Sopenharmony_ci	}
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_ci#define GATE(_id, cname, pname, f, o, b, gf)			\
83362306a36Sopenharmony_ci	{							\
83462306a36Sopenharmony_ci		.id		= _id,				\
83562306a36Sopenharmony_ci		.branch_type	= branch_gate,			\
83662306a36Sopenharmony_ci		.name		= cname,			\
83762306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
83862306a36Sopenharmony_ci		.num_parents	= 1,				\
83962306a36Sopenharmony_ci		.flags		= f,				\
84062306a36Sopenharmony_ci		.gate_offset	= o,				\
84162306a36Sopenharmony_ci		.gate_shift	= b,				\
84262306a36Sopenharmony_ci		.gate_flags	= gf,				\
84362306a36Sopenharmony_ci	}
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_ci#define MMC(_id, cname, pname, offset, shift)			\
84662306a36Sopenharmony_ci	{							\
84762306a36Sopenharmony_ci		.id		= _id,				\
84862306a36Sopenharmony_ci		.branch_type	= branch_mmc,			\
84962306a36Sopenharmony_ci		.name		= cname,			\
85062306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
85162306a36Sopenharmony_ci		.num_parents	= 1,				\
85262306a36Sopenharmony_ci		.muxdiv_offset	= offset,			\
85362306a36Sopenharmony_ci		.div_shift	= shift,			\
85462306a36Sopenharmony_ci	}
85562306a36Sopenharmony_ci
85662306a36Sopenharmony_ci#define INVERTER(_id, cname, pname, io, is, if)			\
85762306a36Sopenharmony_ci	{							\
85862306a36Sopenharmony_ci		.id		= _id,				\
85962306a36Sopenharmony_ci		.branch_type	= branch_inverter,		\
86062306a36Sopenharmony_ci		.name		= cname,			\
86162306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
86262306a36Sopenharmony_ci		.num_parents	= 1,				\
86362306a36Sopenharmony_ci		.muxdiv_offset	= io,				\
86462306a36Sopenharmony_ci		.div_shift	= is,				\
86562306a36Sopenharmony_ci		.div_flags	= if,				\
86662306a36Sopenharmony_ci	}
86762306a36Sopenharmony_ci
86862306a36Sopenharmony_ci#define FACTOR(_id, cname, pname,  f, fm, fd)			\
86962306a36Sopenharmony_ci	{							\
87062306a36Sopenharmony_ci		.id		= _id,				\
87162306a36Sopenharmony_ci		.branch_type	= branch_factor,		\
87262306a36Sopenharmony_ci		.name		= cname,			\
87362306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
87462306a36Sopenharmony_ci		.num_parents	= 1,				\
87562306a36Sopenharmony_ci		.flags		= f,				\
87662306a36Sopenharmony_ci		.div_shift	= fm,				\
87762306a36Sopenharmony_ci		.div_width	= fd,				\
87862306a36Sopenharmony_ci	}
87962306a36Sopenharmony_ci
88062306a36Sopenharmony_ci#define FACTOR_GATE(_id, cname, pname,  f, fm, fd, go, gb, gf)	\
88162306a36Sopenharmony_ci	{							\
88262306a36Sopenharmony_ci		.id		= _id,				\
88362306a36Sopenharmony_ci		.branch_type	= branch_factor,		\
88462306a36Sopenharmony_ci		.name		= cname,			\
88562306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
88662306a36Sopenharmony_ci		.num_parents	= 1,				\
88762306a36Sopenharmony_ci		.flags		= f,				\
88862306a36Sopenharmony_ci		.div_shift	= fm,				\
88962306a36Sopenharmony_ci		.div_width	= fd,				\
89062306a36Sopenharmony_ci		.gate_offset	= go,				\
89162306a36Sopenharmony_ci		.gate_shift	= gb,				\
89262306a36Sopenharmony_ci		.gate_flags	= gf,				\
89362306a36Sopenharmony_ci	}
89462306a36Sopenharmony_ci
89562306a36Sopenharmony_ci#define COMPOSITE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf, ds, dw,\
89662306a36Sopenharmony_ci			  df, go, gs, gf)				\
89762306a36Sopenharmony_ci	{							\
89862306a36Sopenharmony_ci		.id		= _id,				\
89962306a36Sopenharmony_ci		.branch_type	= branch_half_divider,		\
90062306a36Sopenharmony_ci		.name		= cname,			\
90162306a36Sopenharmony_ci		.parent_names	= pnames,			\
90262306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
90362306a36Sopenharmony_ci		.flags		= f,				\
90462306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
90562306a36Sopenharmony_ci		.mux_shift	= ms,				\
90662306a36Sopenharmony_ci		.mux_width	= mw,				\
90762306a36Sopenharmony_ci		.mux_flags	= mf,				\
90862306a36Sopenharmony_ci		.div_shift	= ds,				\
90962306a36Sopenharmony_ci		.div_width	= dw,				\
91062306a36Sopenharmony_ci		.div_flags	= df,				\
91162306a36Sopenharmony_ci		.gate_offset	= go,				\
91262306a36Sopenharmony_ci		.gate_shift	= gs,				\
91362306a36Sopenharmony_ci		.gate_flags	= gf,				\
91462306a36Sopenharmony_ci	}
91562306a36Sopenharmony_ci
91662306a36Sopenharmony_ci#define COMPOSITE_NOGATE_HALFDIV(_id, cname, pnames, f, mo, ms, mw, mf,	\
91762306a36Sopenharmony_ci				 ds, dw, df)				\
91862306a36Sopenharmony_ci	{							\
91962306a36Sopenharmony_ci		.id		= _id,				\
92062306a36Sopenharmony_ci		.branch_type	= branch_half_divider,		\
92162306a36Sopenharmony_ci		.name		= cname,			\
92262306a36Sopenharmony_ci		.parent_names	= pnames,			\
92362306a36Sopenharmony_ci		.num_parents	= ARRAY_SIZE(pnames),		\
92462306a36Sopenharmony_ci		.flags		= f,				\
92562306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
92662306a36Sopenharmony_ci		.mux_shift	= ms,				\
92762306a36Sopenharmony_ci		.mux_width	= mw,				\
92862306a36Sopenharmony_ci		.mux_flags	= mf,				\
92962306a36Sopenharmony_ci		.div_shift	= ds,				\
93062306a36Sopenharmony_ci		.div_width	= dw,				\
93162306a36Sopenharmony_ci		.div_flags	= df,				\
93262306a36Sopenharmony_ci		.gate_offset	= -1,				\
93362306a36Sopenharmony_ci	}
93462306a36Sopenharmony_ci
93562306a36Sopenharmony_ci#define COMPOSITE_NOMUX_HALFDIV(_id, cname, pname, f, mo, ds, dw, df,	\
93662306a36Sopenharmony_ci			go, gs, gf)				\
93762306a36Sopenharmony_ci	{							\
93862306a36Sopenharmony_ci		.id		= _id,				\
93962306a36Sopenharmony_ci		.branch_type	= branch_half_divider,		\
94062306a36Sopenharmony_ci		.name		= cname,			\
94162306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
94262306a36Sopenharmony_ci		.num_parents	= 1,				\
94362306a36Sopenharmony_ci		.flags		= f,				\
94462306a36Sopenharmony_ci		.muxdiv_offset	= mo,				\
94562306a36Sopenharmony_ci		.div_shift	= ds,				\
94662306a36Sopenharmony_ci		.div_width	= dw,				\
94762306a36Sopenharmony_ci		.div_flags	= df,				\
94862306a36Sopenharmony_ci		.gate_offset	= go,				\
94962306a36Sopenharmony_ci		.gate_shift	= gs,				\
95062306a36Sopenharmony_ci		.gate_flags	= gf,				\
95162306a36Sopenharmony_ci	}
95262306a36Sopenharmony_ci
95362306a36Sopenharmony_ci#define DIV_HALF(_id, cname, pname, f, o, s, w, df)			\
95462306a36Sopenharmony_ci	{							\
95562306a36Sopenharmony_ci		.id		= _id,				\
95662306a36Sopenharmony_ci		.branch_type	= branch_half_divider,		\
95762306a36Sopenharmony_ci		.name		= cname,			\
95862306a36Sopenharmony_ci		.parent_names	= (const char *[]){ pname },	\
95962306a36Sopenharmony_ci		.num_parents	= 1,				\
96062306a36Sopenharmony_ci		.flags		= f,				\
96162306a36Sopenharmony_ci		.muxdiv_offset	= o,				\
96262306a36Sopenharmony_ci		.div_shift	= s,				\
96362306a36Sopenharmony_ci		.div_width	= w,				\
96462306a36Sopenharmony_ci		.div_flags	= df,				\
96562306a36Sopenharmony_ci		.gate_offset	= -1,				\
96662306a36Sopenharmony_ci	}
96762306a36Sopenharmony_ci
96862306a36Sopenharmony_ci/* SGRF clocks are only accessible from secure mode, so not controllable */
96962306a36Sopenharmony_ci#define SGRF_GATE(_id, cname, pname)				\
97062306a36Sopenharmony_ci		FACTOR(_id, cname, pname, 0, 1, 1)
97162306a36Sopenharmony_ci
97262306a36Sopenharmony_cistruct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
97362306a36Sopenharmony_ci			void __iomem *base, unsigned long nr_clks);
97462306a36Sopenharmony_civoid rockchip_clk_of_add_provider(struct device_node *np,
97562306a36Sopenharmony_ci				struct rockchip_clk_provider *ctx);
97662306a36Sopenharmony_civoid rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
97762306a36Sopenharmony_ci				    struct rockchip_clk_branch *list,
97862306a36Sopenharmony_ci				    unsigned int nr_clk);
97962306a36Sopenharmony_civoid rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
98062306a36Sopenharmony_ci				struct rockchip_pll_clock *pll_list,
98162306a36Sopenharmony_ci				unsigned int nr_pll, int grf_lock_offset);
98262306a36Sopenharmony_civoid rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx,
98362306a36Sopenharmony_ci			unsigned int lookup_id, const char *name,
98462306a36Sopenharmony_ci			const char *const *parent_names, u8 num_parents,
98562306a36Sopenharmony_ci			const struct rockchip_cpuclk_reg_data *reg_data,
98662306a36Sopenharmony_ci			const struct rockchip_cpuclk_rate_table *rates,
98762306a36Sopenharmony_ci			int nrates);
98862306a36Sopenharmony_civoid rockchip_clk_protect_critical(const char *const clocks[], int nclocks);
98962306a36Sopenharmony_civoid rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx,
99062306a36Sopenharmony_ci					unsigned int reg, void (*cb)(void));
99162306a36Sopenharmony_ci
99262306a36Sopenharmony_ci#define ROCKCHIP_SOFTRST_HIWORD_MASK	BIT(0)
99362306a36Sopenharmony_ci
99462306a36Sopenharmony_cistruct clk *rockchip_clk_register_halfdiv(const char *name,
99562306a36Sopenharmony_ci					  const char *const *parent_names,
99662306a36Sopenharmony_ci					  u8 num_parents, void __iomem *base,
99762306a36Sopenharmony_ci					  int muxdiv_offset, u8 mux_shift,
99862306a36Sopenharmony_ci					  u8 mux_width, u8 mux_flags,
99962306a36Sopenharmony_ci					  u8 div_shift, u8 div_width,
100062306a36Sopenharmony_ci					  u8 div_flags, int gate_offset,
100162306a36Sopenharmony_ci					  u8 gate_shift, u8 gate_flags,
100262306a36Sopenharmony_ci					  unsigned long flags,
100362306a36Sopenharmony_ci					  spinlock_t *lock);
100462306a36Sopenharmony_ci
100562306a36Sopenharmony_ci#ifdef CONFIG_RESET_CONTROLLER
100662306a36Sopenharmony_civoid rockchip_register_softrst_lut(struct device_node *np,
100762306a36Sopenharmony_ci				   const int *lookup_table,
100862306a36Sopenharmony_ci				   unsigned int num_regs,
100962306a36Sopenharmony_ci				   void __iomem *base, u8 flags);
101062306a36Sopenharmony_ci#else
101162306a36Sopenharmony_cistatic inline void rockchip_register_softrst_lut(struct device_node *np,
101262306a36Sopenharmony_ci				   const int *lookup_table,
101362306a36Sopenharmony_ci				   unsigned int num_regs,
101462306a36Sopenharmony_ci				   void __iomem *base, u8 flags)
101562306a36Sopenharmony_ci{
101662306a36Sopenharmony_ci}
101762306a36Sopenharmony_ci#endif
101862306a36Sopenharmony_ci
101962306a36Sopenharmony_cistatic inline void rockchip_register_softrst(struct device_node *np,
102062306a36Sopenharmony_ci					     unsigned int num_regs,
102162306a36Sopenharmony_ci					     void __iomem *base, u8 flags)
102262306a36Sopenharmony_ci{
102362306a36Sopenharmony_ci	return rockchip_register_softrst_lut(np, NULL, num_regs, base, flags);
102462306a36Sopenharmony_ci}
102562306a36Sopenharmony_ci
102662306a36Sopenharmony_civoid rk3588_rst_init(struct device_node *np, void __iomem *reg_base);
102762306a36Sopenharmony_ci
102862306a36Sopenharmony_ci#endif
1029