// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd
 * Author: Elaine Zhang <zhangqing@rock-chips.com>
 */

#include <common.h>
#include <bitfield.h>
#include <clk-uclass.h>
#include <dm.h>
#include <errno.h>
#include <syscon.h>
#include <asm/arch-rockchip/cru_rk3568.h>
#include <asm/arch-rockchip/clock.h>
#include <asm/arch-rockchip/hardware.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dt-bindings/clock/rk3568-cru.h>

DECLARE_GLOBAL_DATA_PTR;

#if CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3568_clk_plat {
	struct dtd_rockchip_rk3568_cru dtd;
};

struct rk3568_pmuclk_plat {
	struct dtd_rockchip_rk3568_pmucru dtd;
};
#endif

#define RK3568_CPUCLK_RATE(_rate, _aclk_div, _pclk_div)		\
{								\
	.rate	= _rate##U,					\
	.aclk_div = _aclk_div,					\
	.pclk_div = _pclk_div,					\
}

#define DIV_TO_RATE(input_rate, div)    ((input_rate) / ((div) + 1))

static struct rockchip_cpu_rate_table rk3568_cpu_rates[] = {
	RK3568_CPUCLK_RATE(1416000000, 1, 5),
	RK3568_CPUCLK_RATE(1296000000, 1, 5),
	RK3568_CPUCLK_RATE(1200000000, 1, 3),
	RK3568_CPUCLK_RATE(1104000000, 1, 3),
	RK3568_CPUCLK_RATE(1008000000, 1, 3),
	RK3568_CPUCLK_RATE(912000000, 1, 3),
	RK3568_CPUCLK_RATE(816000000, 1, 3),
	RK3568_CPUCLK_RATE(600000000, 1, 1),
	RK3568_CPUCLK_RATE(408000000, 1, 1),
	{ /* sentinel */ },
};

static struct rockchip_pll_rate_table rk3568_pll_rates[] = {
	/* _mhz, _refdiv, _fbdiv, _postdiv1, _postdiv2, _dsmpd, _frac */
	RK3036_PLL_RATE(1608000000, 1, 67, 1, 1, 1, 0),
	RK3036_PLL_RATE(1416000000, 1, 118, 2, 1, 1, 0),
	RK3036_PLL_RATE(1296000000, 1, 108, 2, 1, 1, 0),
	RK3036_PLL_RATE(1200000000, 1, 100, 2, 1, 1, 0),
	RK3036_PLL_RATE(1188000000, 1, 99, 2, 1, 1, 0),
	RK3036_PLL_RATE(1104000000, 1, 92, 2, 1, 1, 0),
	RK3036_PLL_RATE(1008000000, 1, 84, 2, 1, 1, 0),
	RK3036_PLL_RATE(1000000000, 3, 250, 2, 1, 1, 0),
	RK3036_PLL_RATE(912000000, 1, 76, 2, 1, 1, 0),
	RK3036_PLL_RATE(816000000, 1, 68, 2, 1, 1, 0),
	RK3036_PLL_RATE(600000000, 1, 100, 4, 1, 1, 0),
	RK3036_PLL_RATE(594000000, 1, 99, 4, 1, 1, 0),
	RK3036_PLL_RATE(500000000, 1, 125, 6, 1, 1, 0),
	RK3036_PLL_RATE(408000000, 1, 68, 2, 2, 1, 0),
	RK3036_PLL_RATE(400000000, 1, 100, 6, 1, 1, 0),
	RK3036_PLL_RATE(200000000, 1, 100, 6, 2, 1, 0),
	RK3036_PLL_RATE(100000000, 1, 150, 6, 6, 1, 0),
	{ /* sentinel */ },
};

static struct rockchip_pll_clock rk3568_pll_clks[] = {
	[APLL] = PLL(pll_rk3328, PLL_APLL, RK3568_PLL_CON(0),
		     RK3568_MODE_CON, 0, 10, 0, rk3568_pll_rates),
	[DPLL] = PLL(pll_rk3328, PLL_DPLL, RK3568_PLL_CON(8),
		     RK3568_MODE_CON, 2, 10, 0, NULL),
	[CPLL] = PLL(pll_rk3328, PLL_CPLL, RK3568_PLL_CON(24),
		     RK3568_MODE_CON, 4, 10, 0, rk3568_pll_rates),
	[GPLL] = PLL(pll_rk3328, PLL_HPLL, RK3568_PLL_CON(16),
		     RK3568_MODE_CON, 6, 10, 0, rk3568_pll_rates),
	[NPLL] = PLL(pll_rk3328, PLL_NPLL, RK3568_PLL_CON(32),
		     RK3568_MODE_CON, 10, 10, 0, rk3568_pll_rates),
	[VPLL] = PLL(pll_rk3328, PLL_VPLL, RK3568_PLL_CON(40),
		     RK3568_MODE_CON, 12, 10, 0, rk3568_pll_rates),
	[PPLL] = PLL(pll_rk3328, PLL_PPLL, RK3568_PMU_PLL_CON(0),
		     RK3568_PMU_MODE, 0, 10, 0, rk3568_pll_rates),
	[HPLL] = PLL(pll_rk3328, PLL_HPLL, RK3568_PMU_PLL_CON(16),
		     RK3568_PMU_MODE, 2, 10, 0, rk3568_pll_rates),
};

#ifndef CONFIG_SPL_BUILD
static ulong
rk3568_pmu_pll_set_rate(struct rk3568_clk_priv *priv,
			ulong pll_id, ulong rate)
{
	struct udevice *pmucru_dev;
	struct rk3568_pmuclk_priv *pmu_priv;
	int ret;

	ret = uclass_get_device_by_driver(UCLASS_CLK,
					  DM_DRIVER_GET(rockchip_rk3568_pmucru),
					  &pmucru_dev);
	if (ret) {
		printf("%s: could not find pmucru device\n", __func__);
		return ret;
	}
	pmu_priv = dev_get_priv(pmucru_dev);

	rockchip_pll_set_rate(&rk3568_pll_clks[pll_id],
			      pmu_priv->pmucru, pll_id, rate);

	return 0;
}
#endif

static ulong rk3568_pmu_pll_get_rate(struct rk3568_clk_priv *priv,
				     ulong pll_id)
{
	struct udevice *pmucru_dev;
	struct rk3568_pmuclk_priv *pmu_priv;
	int ret;

	ret = uclass_get_device_by_driver(UCLASS_CLK,
					  DM_DRIVER_GET(rockchip_rk3568_pmucru),
					  &pmucru_dev);
	if (ret) {
		printf("%s: could not find pmucru device\n", __func__);
		return ret;
	}
	pmu_priv = dev_get_priv(pmucru_dev);

	return rockchip_pll_get_rate(&rk3568_pll_clks[pll_id],
				      pmu_priv->pmucru, pll_id);
}

/*
 *
 * rational_best_approximation(31415, 10000,
 *		(1 << 8) - 1, (1 << 5) - 1, &n, &d);
 *
 * you may look at given_numerator as a fixed point number,
 * with the fractional part size described in given_denominator.
 *
 * for theoretical background, see:
 * http://en.wikipedia.org/wiki/Continued_fraction
 */
static void rational_best_approximation(unsigned long given_numerator,
					unsigned long given_denominator,
					unsigned long max_numerator,
					unsigned long max_denominator,
					unsigned long *best_numerator,
					unsigned long *best_denominator)
{
	unsigned long n, d, n0, d0, n1, d1;

	n = given_numerator;
	d = given_denominator;
	n0 = 0;
	d1 = 0;
	n1 = 1;
	d0 = 1;
	for (;;) {
		unsigned long t, a;

		if (n1 > max_numerator || d1 > max_denominator) {
			n1 = n0;
			d1 = d0;
			break;
		}
		if (d == 0)
			break;
		t = d;
		a = n / d;
		d = n % d;
		n = t;
		t = n0 + a * n1;
		n0 = n1;
		n1 = t;
		t = d0 + a * d1;
		d0 = d1;
		d1 = t;
	}
	*best_numerator = n1;
	*best_denominator = d1;
}

static ulong rk3568_rtc32k_get_pmuclk(struct rk3568_pmuclk_priv *priv)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	unsigned long m, n;
	u32 fracdiv;

	fracdiv = readl(&pmucru->pmu_clksel_con[1]);
	m = fracdiv & RTC32K_FRAC_NUMERATOR_MASK;
	m >>= RTC32K_FRAC_NUMERATOR_SHIFT;
	n = fracdiv & RTC32K_FRAC_DENOMINATOR_MASK;
	n >>= RTC32K_FRAC_DENOMINATOR_SHIFT;

	return OSC_HZ * m / n;
}

static ulong rk3568_rtc32k_set_pmuclk(struct rk3568_pmuclk_priv *priv,
				      ulong rate)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	unsigned long m, n, val;

	rk_clrsetreg(&pmucru->pmu_clksel_con[0], RTC32K_SEL_MASK,
		     RTC32K_SEL_OSC0_DIV32K << RTC32K_SEL_SHIFT);

	rational_best_approximation(rate, OSC_HZ,
				    GENMASK(16 - 1, 0),
				    GENMASK(16 - 1, 0),
				    &m, &n);
	val = m << RTC32K_FRAC_NUMERATOR_SHIFT | n;
	writel(val, &pmucru->pmu_clksel_con[1]);

	return rk3568_rtc32k_get_pmuclk(priv);
}

static ulong rk3568_i2c_get_pmuclk(struct rk3568_pmuclk_priv *priv,
				   ulong clk_id)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	u32 div, con;

	switch (clk_id) {
	case CLK_I2C0:
		con = readl(&pmucru->pmu_clksel_con[3]);
		div = (con & CLK_I2C0_DIV_MASK) >> CLK_I2C0_DIV_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	return DIV_TO_RATE(priv->ppll_hz, div);
}

static ulong rk3568_i2c_set_pmuclk(struct rk3568_pmuclk_priv *priv,
				   ulong clk_id, ulong rate)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	int src_clk_div;

	src_clk_div = DIV_ROUND_UP(priv->ppll_hz, rate);
	assert(src_clk_div - 1 <= 127);

	switch (clk_id) {
	case CLK_I2C0:
		rk_clrsetreg(&pmucru->pmu_clksel_con[3], CLK_I2C0_DIV_MASK,
			     (src_clk_div - 1) << CLK_I2C0_DIV_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_i2c_get_pmuclk(priv, clk_id);
}

static ulong rk3568_pwm_get_pmuclk(struct rk3568_pmuclk_priv *priv,
				   ulong clk_id)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	u32 div, sel, con, parent;

	switch (clk_id) {
	case CLK_PWM0:
		con = readl(&pmucru->pmu_clksel_con[6]);
		sel = (con & CLK_PWM0_SEL_MASK) >> CLK_PWM0_SEL_SHIFT;
		div = (con & CLK_PWM0_DIV_MASK) >> CLK_PWM0_DIV_SHIFT;
		if (sel == CLK_PWM0_SEL_XIN24M)
			parent = OSC_HZ;
		else
			parent = priv->ppll_hz;
		break;
	default:
		return -ENOENT;
	}

	return DIV_TO_RATE(parent, div);
}

static ulong rk3568_pwm_set_pmuclk(struct rk3568_pmuclk_priv *priv,
				   ulong clk_id, ulong rate)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	int src_clk_div;

	switch (clk_id) {
	case CLK_PWM0:
		if (rate == OSC_HZ) {
			rk_clrsetreg(&pmucru->pmu_clksel_con[6],
				     CLK_PWM0_SEL_MASK | CLK_PWM0_DIV_MASK,
				     (CLK_PWM0_SEL_XIN24M <<
				      CLK_PWM0_SEL_SHIFT) |
				     0 << CLK_PWM0_SEL_SHIFT);
		} else {
			src_clk_div = DIV_ROUND_UP(priv->ppll_hz, rate);
			assert(src_clk_div - 1 <= 127);
			rk_clrsetreg(&pmucru->pmu_clksel_con[6],
				     CLK_PWM0_DIV_MASK | CLK_PWM0_DIV_MASK,
				     (CLK_PWM0_SEL_PPLL << CLK_PWM0_SEL_SHIFT) |
				     (src_clk_div - 1) << CLK_PWM0_DIV_SHIFT);
		}
		break;
	default:
		return -ENOENT;
	}

	return rk3568_pwm_get_pmuclk(priv, clk_id);
}

static ulong rk3568_pmu_get_pmuclk(struct rk3568_pmuclk_priv *priv)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	u32 div, con, sel, parent;

	con = readl(&pmucru->pmu_clksel_con[2]);
	sel = (con & PCLK_PDPMU_SEL_MASK) >> PCLK_PDPMU_SEL_SHIFT;
	div = (con & PCLK_PDPMU_DIV_MASK) >> PCLK_PDPMU_DIV_SHIFT;
	if (sel)
		parent = GPLL_HZ;
	else
		parent = priv->ppll_hz;

	return DIV_TO_RATE(parent, div);
}

static ulong rk3568_pmu_set_pmuclk(struct rk3568_pmuclk_priv *priv,
				   ulong rate)
{
	struct rk3568_pmucru *pmucru = priv->pmucru;
	int src_clk_div;

	src_clk_div = DIV_ROUND_UP(priv->ppll_hz, rate);
	assert(src_clk_div - 1 <= 31);

	rk_clrsetreg(&pmucru->pmu_clksel_con[2],
		     PCLK_PDPMU_DIV_MASK | PCLK_PDPMU_SEL_MASK,
		     (PCLK_PDPMU_SEL_PPLL << PCLK_PDPMU_SEL_SHIFT) |
		     ((src_clk_div - 1) << PCLK_PDPMU_DIV_SHIFT));

	return rk3568_pmu_get_pmuclk(priv);
}

static ulong rk3568_pmuclk_get_rate(struct clk *clk)
{
	struct rk3568_pmuclk_priv *priv = dev_get_priv(clk->dev);
	ulong rate = 0;

	if (!priv->ppll_hz) {
		printf("%s ppll=%lu\n", __func__, priv->ppll_hz);
		return -ENOENT;
	}

	debug("%s %ld\n", __func__, clk->id);
	switch (clk->id) {
	case PLL_PPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[PPLL],
					     priv->pmucru, PPLL);
		break;
	case PLL_HPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[HPLL],
					     priv->pmucru, HPLL);
		break;
	case CLK_RTC_32K:
	case CLK_RTC32K_FRAC:
		rate = rk3568_rtc32k_get_pmuclk(priv);
		break;
	case CLK_I2C0:
		rate = rk3568_i2c_get_pmuclk(priv, clk->id);
		break;
	case CLK_PWM0:
		rate = rk3568_pwm_get_pmuclk(priv, clk->id);
		break;
	case PCLK_PMU:
		rate = rk3568_pmu_get_pmuclk(priv);
		break;
	default:
		return -ENOENT;
	}

	return rate;
}

static ulong rk3568_pmuclk_set_rate(struct clk *clk, ulong rate)
{
	struct rk3568_pmuclk_priv *priv = dev_get_priv(clk->dev);
	ulong ret = 0;

	if (!priv->ppll_hz) {
		printf("%s ppll=%lu\n", __func__, priv->ppll_hz);
		return -ENOENT;
	}

	debug("%s %ld %ld\n", __func__, clk->id, rate);
	switch (clk->id) {
	case PLL_PPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[PPLL],
					    priv->pmucru, PPLL, rate);
		priv->ppll_hz = rockchip_pll_get_rate(&rk3568_pll_clks[PPLL],
						      priv->pmucru, PPLL);
		break;
	case PLL_HPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[HPLL],
					    priv->pmucru, HPLL, rate);
		priv->hpll_hz = rockchip_pll_get_rate(&rk3568_pll_clks[HPLL],
						      priv->pmucru, HPLL);
		break;
	case CLK_RTC_32K:
	case CLK_RTC32K_FRAC:
		ret = rk3568_rtc32k_set_pmuclk(priv, rate);
		break;
	case CLK_I2C0:
		ret = rk3568_i2c_set_pmuclk(priv, clk->id, rate);
		break;
	case CLK_PWM0:
		ret = rk3568_pwm_set_pmuclk(priv, clk->id, rate);
		break;
	case PCLK_PMU:
		ret = rk3568_pmu_set_pmuclk(priv, rate);
		break;
	case CLK_PCIEPHY0_REF:
	case CLK_PCIEPHY1_REF:
	case CLK_PCIEPHY2_REF:
		return 0;
	default:
		return -ENOENT;
	}

	return ret;
}

static int rk3568_rtc32k_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_pmuclk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_pmucru *pmucru = priv->pmucru;

	if (parent->id == CLK_RTC32K_FRAC)
		rk_clrsetreg(&pmucru->pmu_clksel_con[0], RTC32K_SEL_MASK,
			     RTC32K_SEL_OSC0_DIV32K << RTC32K_SEL_SHIFT);
	else
		rk_clrsetreg(&pmucru->pmu_clksel_con[0], RTC32K_SEL_MASK,
			     RTC32K_SEL_OSC1_32K << RTC32K_SEL_SHIFT);

	return 0;
}

static int rk3568_pmuclk_set_parent(struct clk *clk, struct clk *parent)
{
	switch (clk->id) {
	case CLK_RTC_32K:
		return rk3568_rtc32k_set_parent(clk, parent);
	default:
		return -ENOENT;
	}
}

static struct clk_ops rk3568_pmuclk_ops = {
	.get_rate = rk3568_pmuclk_get_rate,
	.set_rate = rk3568_pmuclk_set_rate,
	.set_parent = rk3568_pmuclk_set_parent,
};

static int rk3568_pmuclk_probe(struct udevice *dev)
{
	struct rk3568_pmuclk_priv *priv = dev_get_priv(dev);
	int ret = 0;

	if (priv->ppll_hz != PPLL_HZ) {
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[PPLL],
					    priv->pmucru,
					    PPLL, PPLL_HZ);
		if (!ret)
			priv->ppll_hz = PPLL_HZ;
	}

	/* Ungate PCIe30phy refclk_m and refclk_n */
	rk_clrsetreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13, 0 << 13);
	return 0;
}

static int rk3568_pmuclk_ofdata_to_platdata(struct udevice *dev)
{
	struct rk3568_pmuclk_priv *priv = dev_get_priv(dev);

	priv->pmucru = dev_read_addr_ptr(dev);

	return 0;
}

static int rk3568_pmuclk_bind(struct udevice *dev)
{
#if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
	int ret = 0;

	ret = offsetof(struct rk3568_pmucru, pmu_softrst_con[0]);
	ret = rockchip_reset_bind(dev, ret, 1);
	if (ret)
		debug("Warning: pmucru software reset driver bind failed\n");
#endif

	return 0;
}

static const struct udevice_id rk3568_pmuclk_ids[] = {
	{ .compatible = "rockchip,rk3568-pmucru" },
	{ }
};

U_BOOT_DRIVER(rockchip_rk3568_pmucru) = {
	.name		= "rockchip_rk3568_pmucru",
	.id		= UCLASS_CLK,
	.of_match	= rk3568_pmuclk_ids,
	.priv_auto = sizeof(struct rk3568_pmuclk_priv),
	.of_to_plat = rk3568_pmuclk_ofdata_to_platdata,
	.ops		= &rk3568_pmuclk_ops,
	.bind		= rk3568_pmuclk_bind,
	.probe		= rk3568_pmuclk_probe,
#if CONFIG_IS_ENABLED(OF_PLATDATA)
	.plat_auto	= sizeof(struct rk3568_pmuclk_plat),
#endif

};

static int rk3568_armclk_set_clk(struct rk3568_clk_priv *priv, ulong hz)
{
	struct rk3568_cru *cru = priv->cru;
	const struct rockchip_cpu_rate_table *rate;
	ulong old_rate;

	rate = rockchip_get_cpu_settings(rk3568_cpu_rates, hz);
	if (!rate) {
		printf("%s unsupported rate\n", __func__);
		return -EINVAL;
	}

	rk_clrsetreg(&cru->clksel_con[0],
		     CLK_CORE_PRE_SEL_MASK,
		     (CLK_CORE_PRE_SEL_SRC << CLK_CORE_PRE_SEL_SHIFT));
	rk_clrsetreg(&cru->clksel_con[2],
		     SCLK_CORE_PRE_SEL_MASK |
		     SCLK_CORE_SRC_SEL_MASK |
		     SCLK_CORE_SRC_DIV_MASK,
		     (SCLK_CORE_PRE_SEL_SRC <<
		      SCLK_CORE_PRE_SEL_SHIFT) |
		     (SCLK_CORE_SRC_SEL_APLL <<
		      SCLK_CORE_SRC_SEL_SHIFT) |
		     (1 << SCLK_CORE_SRC_DIV_SHIFT));

	/*
	 * set up dependent divisors for DBG and ACLK clocks.
	 */
	old_rate = rockchip_pll_get_rate(&rk3568_pll_clks[APLL],
					 priv->cru, APLL);
	if (old_rate > hz) {
		if (rockchip_pll_set_rate(&rk3568_pll_clks[APLL],
					  priv->cru, APLL, hz))
			return -EINVAL;
		rk_clrsetreg(&cru->clksel_con[3],
			     GICCLK_CORE_DIV_MASK | ATCLK_CORE_DIV_MASK,
			     rate->pclk_div << GICCLK_CORE_DIV_SHIFT |
			     rate->pclk_div << ATCLK_CORE_DIV_SHIFT);
		rk_clrsetreg(&cru->clksel_con[4],
			     PERIPHCLK_CORE_PRE_DIV_MASK |
			     PCLK_CORE_PRE_DIV_MASK,
			     rate->pclk_div << PCLK_CORE_PRE_DIV_SHIFT |
			     rate->pclk_div << PERIPHCLK_CORE_PRE_DIV_SHIFT);
		rk_clrsetreg(&cru->clksel_con[5],
			     ACLK_CORE_NDFT_DIV_MASK,
			     rate->aclk_div << ACLK_CORE_NDFT_DIV_SHIFT);
	} else if (old_rate < hz) {
		rk_clrsetreg(&cru->clksel_con[3],
			     GICCLK_CORE_DIV_MASK | ATCLK_CORE_DIV_MASK,
			     rate->pclk_div << GICCLK_CORE_DIV_SHIFT |
			     rate->pclk_div << ATCLK_CORE_DIV_SHIFT);
		rk_clrsetreg(&cru->clksel_con[4],
			     PERIPHCLK_CORE_PRE_DIV_MASK |
			     PCLK_CORE_PRE_DIV_MASK,
			     rate->pclk_div << PCLK_CORE_PRE_DIV_SHIFT |
			     rate->pclk_div << PERIPHCLK_CORE_PRE_DIV_SHIFT);
		rk_clrsetreg(&cru->clksel_con[5],
			     ACLK_CORE_NDFT_DIV_MASK,
			     rate->aclk_div << ACLK_CORE_NDFT_DIV_SHIFT);
		if (rockchip_pll_set_rate(&rk3568_pll_clks[APLL],
					  priv->cru, APLL, hz))
			return -EINVAL;
	}

	return 0;
}

static ulong rk3568_cpll_div_get_rate(struct rk3568_clk_priv *priv,
				      ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	int div, mask, shift, con;

	switch (clk_id) {
	case CPLL_500M:
		con = 78;
		mask = CPLL_500M_DIV_MASK;
		shift = CPLL_500M_DIV_SHIFT;
		break;
	case CPLL_333M:
		con = 79;
		mask = CPLL_333M_DIV_MASK;
		shift = CPLL_333M_DIV_SHIFT;
		break;
	case CPLL_250M:
		con = 79;
		mask = CPLL_250M_DIV_MASK;
		shift = CPLL_250M_DIV_SHIFT;
		break;
	case CPLL_125M:
		con = 80;
		mask = CPLL_125M_DIV_MASK;
		shift = CPLL_125M_DIV_SHIFT;
		break;
	case CPLL_100M:
		con = 82;
		mask = CPLL_100M_DIV_MASK;
		shift = CPLL_100M_DIV_SHIFT;
		break;
	case CPLL_62P5M:
		con = 80;
		mask = CPLL_62P5M_DIV_MASK;
		shift = CPLL_62P5M_DIV_SHIFT;
		break;
	case CPLL_50M:
		con = 81;
		mask = CPLL_50M_DIV_MASK;
		shift = CPLL_50M_DIV_SHIFT;
		break;
	case CPLL_25M:
		con = 81;
		mask = CPLL_25M_DIV_MASK;
		shift = CPLL_25M_DIV_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	div = (readl(&cru->clksel_con[con]) & mask) >> shift;
	return DIV_TO_RATE(priv->cpll_hz, div);
}

static ulong rk3568_cpll_div_set_rate(struct rk3568_clk_priv *priv,
				      ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int div, mask, shift, con;

	switch (clk_id) {
	case CPLL_500M:
		con = 78;
		mask = CPLL_500M_DIV_MASK;
		shift = CPLL_500M_DIV_SHIFT;
		break;
	case CPLL_333M:
		con = 79;
		mask = CPLL_333M_DIV_MASK;
		shift = CPLL_333M_DIV_SHIFT;
		break;
	case CPLL_250M:
		con = 79;
		mask = CPLL_250M_DIV_MASK;
		shift = CPLL_250M_DIV_SHIFT;
		break;
	case CPLL_125M:
		con = 80;
		mask = CPLL_125M_DIV_MASK;
		shift = CPLL_125M_DIV_SHIFT;
		break;
	case CPLL_100M:
		con = 82;
		mask = CPLL_100M_DIV_MASK;
		shift = CPLL_100M_DIV_SHIFT;
		break;
	case CPLL_62P5M:
		con = 80;
		mask = CPLL_62P5M_DIV_MASK;
		shift = CPLL_62P5M_DIV_SHIFT;
		break;
	case CPLL_50M:
		con = 81;
		mask = CPLL_50M_DIV_MASK;
		shift = CPLL_50M_DIV_SHIFT;
		break;
	case CPLL_25M:
		con = 81;
		mask = CPLL_25M_DIV_MASK;
		shift = CPLL_25M_DIV_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	div = DIV_ROUND_UP(priv->cpll_hz, rate);
	if (clk_id == CPLL_25M)
		assert(div - 1 <= 63);
	else
		assert(div - 1 <= 31);
	rk_clrsetreg(&cru->clksel_con[con],
		     mask, (div - 1) << shift);
	return rk3568_cpll_div_get_rate(priv, clk_id);
}

static ulong rk3568_bus_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, sel, rate;

	switch (clk_id) {
	case ACLK_BUS:
		con = readl(&cru->clksel_con[50]);
		sel = (con & ACLK_BUS_SEL_MASK) >> ACLK_BUS_SEL_SHIFT;
		if (sel == ACLK_BUS_SEL_200M)
			rate = 200 * MHz;
		else if (sel == ACLK_BUS_SEL_150M)
			rate = 150 * MHz;
		else if (sel == ACLK_BUS_SEL_100M)
			rate = 100 * MHz;
		else
			rate = OSC_HZ;
		break;
	case PCLK_BUS:
	case PCLK_WDT_NS:
		con = readl(&cru->clksel_con[50]);
		sel = (con & PCLK_BUS_SEL_MASK) >> PCLK_BUS_SEL_SHIFT;
		if (sel == PCLK_BUS_SEL_100M)
			rate = 100 * MHz;
		else if (sel == PCLK_BUS_SEL_75M)
			rate = 75 * MHz;
		else if (sel == PCLK_BUS_SEL_50M)
			rate = 50 * MHz;
		else
			rate = OSC_HZ;
		break;
	default:
		return -ENOENT;
	}

	return rate;
}

static ulong rk3568_bus_set_clk(struct rk3568_clk_priv *priv,
				ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (clk_id) {
	case ACLK_BUS:
		if (rate == 200 * MHz)
			src_clk = ACLK_BUS_SEL_200M;
		else if (rate == 150 * MHz)
			src_clk = ACLK_BUS_SEL_150M;
		else if (rate == 100 * MHz)
			src_clk = ACLK_BUS_SEL_100M;
		else
			src_clk = ACLK_BUS_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[50],
			     ACLK_BUS_SEL_MASK,
			     src_clk << ACLK_BUS_SEL_SHIFT);
		break;
	case PCLK_BUS:
	case PCLK_WDT_NS:
		if (rate == 100 * MHz)
			src_clk = PCLK_BUS_SEL_100M;
		else if (rate == 75 * MHz)
			src_clk = PCLK_BUS_SEL_75M;
		else if (rate == 50 * MHz)
			src_clk = PCLK_BUS_SEL_50M;
		else
			src_clk = PCLK_BUS_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[50],
			     PCLK_BUS_SEL_MASK,
			     src_clk << PCLK_BUS_SEL_SHIFT);
		break;

	default:
		printf("do not support this bus freq\n");
		return -EINVAL;
	}

	return rk3568_bus_get_clk(priv, clk_id);
}

static ulong rk3568_perimid_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, sel, rate;

	switch (clk_id) {
	case ACLK_PERIMID:
		con = readl(&cru->clksel_con[10]);
		sel = (con & ACLK_PERIMID_SEL_MASK) >> ACLK_PERIMID_SEL_SHIFT;
		if (sel == ACLK_PERIMID_SEL_300M)
			rate = 300 * MHz;
		else if (sel == ACLK_PERIMID_SEL_200M)
			rate = 200 * MHz;
		else if (sel == ACLK_PERIMID_SEL_100M)
			rate = 100 * MHz;
		else
			rate = OSC_HZ;
		break;
	case HCLK_PERIMID:
		con = readl(&cru->clksel_con[10]);
		sel = (con & HCLK_PERIMID_SEL_MASK) >> HCLK_PERIMID_SEL_SHIFT;
		if (sel == HCLK_PERIMID_SEL_150M)
			rate = 150 * MHz;
		else if (sel == HCLK_PERIMID_SEL_100M)
			rate = 100 * MHz;
		else if (sel == HCLK_PERIMID_SEL_75M)
			rate = 75 * MHz;
		else
			rate = OSC_HZ;
		break;
	default:
		return -ENOENT;
	}

	return rate;
}

static ulong rk3568_perimid_set_clk(struct rk3568_clk_priv *priv,
				    ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (clk_id) {
	case ACLK_PERIMID:
		if (rate == 300 * MHz)
			src_clk = ACLK_PERIMID_SEL_300M;
		else if (rate == 200 * MHz)
			src_clk = ACLK_PERIMID_SEL_200M;
		else if (rate == 100 * MHz)
			src_clk = ACLK_PERIMID_SEL_100M;
		else
			src_clk = ACLK_PERIMID_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[10],
			     ACLK_PERIMID_SEL_MASK,
			     src_clk << ACLK_PERIMID_SEL_SHIFT);
		break;
	case HCLK_PERIMID:
		if (rate == 150 * MHz)
			src_clk = HCLK_PERIMID_SEL_150M;
		else if (rate == 100 * MHz)
			src_clk = HCLK_PERIMID_SEL_100M;
		else if (rate == 75 * MHz)
			src_clk = HCLK_PERIMID_SEL_75M;
		else
			src_clk = HCLK_PERIMID_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[10],
			     HCLK_PERIMID_SEL_MASK,
			     src_clk << HCLK_PERIMID_SEL_SHIFT);
		break;

	default:
		printf("do not support this permid freq\n");
		return -EINVAL;
	}

	return rk3568_perimid_get_clk(priv, clk_id);
}

static ulong rk3568_top_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, sel, rate;

	switch (clk_id) {
	case ACLK_TOP_HIGH:
		con = readl(&cru->clksel_con[73]);
		sel = (con & ACLK_TOP_HIGH_SEL_MASK) >> ACLK_TOP_HIGH_SEL_SHIFT;
		if (sel == ACLK_TOP_HIGH_SEL_500M)
			rate = 500 * MHz;
		else if (sel == ACLK_TOP_HIGH_SEL_400M)
			rate = 400 * MHz;
		else if (sel == ACLK_TOP_HIGH_SEL_300M)
			rate = 300 * MHz;
		else
			rate = OSC_HZ;
		break;
	case ACLK_TOP_LOW:
		con = readl(&cru->clksel_con[73]);
		sel = (con & ACLK_TOP_LOW_SEL_MASK) >> ACLK_TOP_LOW_SEL_SHIFT;
		if (sel == ACLK_TOP_LOW_SEL_400M)
			rate = 400 * MHz;
		else if (sel == ACLK_TOP_LOW_SEL_300M)
			rate = 300 * MHz;
		else if (sel == ACLK_TOP_LOW_SEL_200M)
			rate = 200 * MHz;
		else
			rate = OSC_HZ;
		break;
	case HCLK_TOP:
		con = readl(&cru->clksel_con[73]);
		sel = (con & HCLK_TOP_SEL_MASK) >> HCLK_TOP_SEL_SHIFT;
		if (sel == HCLK_TOP_SEL_150M)
			rate = 150 * MHz;
		else if (sel == HCLK_TOP_SEL_100M)
			rate = 100 * MHz;
		else if (sel == HCLK_TOP_SEL_75M)
			rate = 75 * MHz;
		else
			rate = OSC_HZ;
		break;
	case PCLK_TOP:
		con = readl(&cru->clksel_con[73]);
		sel = (con & PCLK_TOP_SEL_MASK) >> PCLK_TOP_SEL_SHIFT;
		if (sel == PCLK_TOP_SEL_100M)
			rate = 100 * MHz;
		else if (sel == PCLK_TOP_SEL_75M)
			rate = 75 * MHz;
		else if (sel == PCLK_TOP_SEL_50M)
			rate = 50 * MHz;
		else
			rate = OSC_HZ;
		break;
	default:
		return -ENOENT;
	}

	return rate;
}

static ulong rk3568_top_set_clk(struct rk3568_clk_priv *priv,
				ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (clk_id) {
	case ACLK_TOP_HIGH:
		if (rate == 500 * MHz)
			src_clk = ACLK_TOP_HIGH_SEL_500M;
		else if (rate == 400 * MHz)
			src_clk = ACLK_TOP_HIGH_SEL_400M;
		else if (rate == 300 * MHz)
			src_clk = ACLK_TOP_HIGH_SEL_300M;
		else
			src_clk = ACLK_TOP_HIGH_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[73],
			     ACLK_TOP_HIGH_SEL_MASK,
			     src_clk << ACLK_TOP_HIGH_SEL_SHIFT);
		break;
	case ACLK_TOP_LOW:
		if (rate == 400 * MHz)
			src_clk = ACLK_TOP_LOW_SEL_400M;
		else if (rate == 300 * MHz)
			src_clk = ACLK_TOP_LOW_SEL_300M;
		else if (rate == 200 * MHz)
			src_clk = ACLK_TOP_LOW_SEL_200M;
		else
			src_clk = ACLK_TOP_LOW_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[73],
			     ACLK_TOP_LOW_SEL_MASK,
			     src_clk << ACLK_TOP_LOW_SEL_SHIFT);
		break;
	case HCLK_TOP:
		if (rate == 150 * MHz)
			src_clk = HCLK_TOP_SEL_150M;
		else if (rate == 100 * MHz)
			src_clk = HCLK_TOP_SEL_100M;
		else if (rate == 75 * MHz)
			src_clk = HCLK_TOP_SEL_75M;
		else
			src_clk = HCLK_TOP_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[73],
			     HCLK_TOP_SEL_MASK,
			     src_clk << HCLK_TOP_SEL_SHIFT);
		break;
	case PCLK_TOP:
		if (rate == 100 * MHz)
			src_clk = PCLK_TOP_SEL_100M;
		else if (rate == 75 * MHz)
			src_clk = PCLK_TOP_SEL_75M;
		else if (rate == 50 * MHz)
			src_clk = PCLK_TOP_SEL_50M;
		else
			src_clk = PCLK_TOP_SEL_24M;
		rk_clrsetreg(&cru->clksel_con[73],
			     PCLK_TOP_SEL_MASK,
			     src_clk << PCLK_TOP_SEL_SHIFT);
		break;

	default:
		printf("do not support this permid freq\n");
		return -EINVAL;
	}

	return rk3568_top_get_clk(priv, clk_id);
}

static ulong rk3568_i2c_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;
	ulong rate;

	switch (clk_id) {
	case CLK_I2C1:
	case CLK_I2C2:
	case CLK_I2C3:
	case CLK_I2C4:
	case CLK_I2C5:
		con = readl(&cru->clksel_con[71]);
		sel = (con & CLK_I2C_SEL_MASK) >> CLK_I2C_SEL_SHIFT;
		if (sel == CLK_I2C_SEL_200M)
			rate = 200 * MHz;
		else if (sel == CLK_I2C_SEL_100M)
			rate = 100 * MHz;
		else if (sel == CLK_I2C_SEL_CPLL_100M)
			rate = 100 * MHz;
		else
			rate = OSC_HZ;
		break;
	default:
		return -ENOENT;
	}

	return rate;
}

static ulong rk3568_i2c_set_clk(struct rk3568_clk_priv *priv, ulong clk_id,
				ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	if (rate == 200 * MHz)
		src_clk = CLK_I2C_SEL_200M;
	else if (rate == 100 * MHz)
		src_clk = CLK_I2C_SEL_100M;
	else
		src_clk = CLK_I2C_SEL_24M;

	switch (clk_id) {
	case CLK_I2C1:
	case CLK_I2C2:
	case CLK_I2C3:
	case CLK_I2C4:
	case CLK_I2C5:
		rk_clrsetreg(&cru->clksel_con[71], CLK_I2C_SEL_MASK,
			     src_clk << CLK_I2C_SEL_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_i2c_get_clk(priv, clk_id);
}

static ulong rk3568_spi_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[72]);

	switch (clk_id) {
	case CLK_SPI0:
		sel = (con & CLK_SPI0_SEL_MASK) >> CLK_SPI0_SEL_SHIFT;
		break;
	case CLK_SPI1:
		sel = (con & CLK_SPI1_SEL_MASK) >> CLK_SPI1_SEL_SHIFT;
		break;
	case CLK_SPI2:
		sel = (con & CLK_SPI2_SEL_MASK) >> CLK_SPI2_SEL_SHIFT;
		break;
	case CLK_SPI3:
		sel = (con & CLK_SPI3_SEL_MASK) >> CLK_SPI3_SEL_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	switch (sel) {
	case CLK_SPI_SEL_200M:
		return 200 * MHz;
	case CLK_SPI_SEL_24M:
		return OSC_HZ;
	case CLK_SPI_SEL_CPLL_100M:
		return 100 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_spi_set_clk(struct rk3568_clk_priv *priv,
				ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	if (rate == 200 * MHz)
		src_clk = CLK_SPI_SEL_200M;
	else if (rate == 100 * MHz)
		src_clk = CLK_SPI_SEL_CPLL_100M;
	else
		src_clk = CLK_SPI_SEL_24M;

	switch (clk_id) {
	case CLK_SPI0:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_SPI0_SEL_MASK,
			     src_clk << CLK_SPI0_SEL_SHIFT);
		break;
	case CLK_SPI1:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_SPI1_SEL_MASK,
			     src_clk << CLK_SPI1_SEL_SHIFT);
		break;
	case CLK_SPI2:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_SPI2_SEL_MASK,
			     src_clk << CLK_SPI2_SEL_SHIFT);
		break;
	case CLK_SPI3:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_SPI3_SEL_MASK,
			     src_clk << CLK_SPI3_SEL_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_spi_get_clk(priv, clk_id);
}

static ulong rk3568_pwm_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[72]);

	switch (clk_id) {
	case CLK_PWM1:
		sel = (con & CLK_PWM1_SEL_MASK) >> CLK_PWM1_SEL_SHIFT;
		break;
	case CLK_PWM2:
		sel = (con & CLK_PWM2_SEL_MASK) >> CLK_PWM2_SEL_SHIFT;
		break;
	case CLK_PWM3:
		sel = (con & CLK_PWM3_SEL_MASK) >> CLK_PWM3_SEL_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	switch (sel) {
	case CLK_PWM_SEL_100M:
		return 100 * MHz;
	case CLK_PWM_SEL_24M:
		return OSC_HZ;
	case CLK_PWM_SEL_CPLL_100M:
		return 100 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_pwm_set_clk(struct rk3568_clk_priv *priv,
				ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	if (rate == 100 * MHz)
		src_clk = CLK_PWM_SEL_100M;
	else
		src_clk = CLK_PWM_SEL_24M;

	switch (clk_id) {
	case CLK_PWM1:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_PWM1_SEL_MASK,
			     src_clk << CLK_PWM1_SEL_SHIFT);
		break;
	case CLK_PWM2:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_PWM2_SEL_MASK,
			     src_clk << CLK_PWM2_SEL_SHIFT);
		break;
	case CLK_PWM3:
		rk_clrsetreg(&cru->clksel_con[72],
			     CLK_PWM3_SEL_MASK,
			     src_clk << CLK_PWM3_SEL_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_pwm_get_clk(priv, clk_id);
}

static ulong rk3568_adc_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 div, sel, con, prate;

	switch (clk_id) {
	case CLK_SARADC:
		return OSC_HZ;
	case CLK_TSADC_TSEN:
		con = readl(&cru->clksel_con[51]);
		div = (con & CLK_TSADC_TSEN_DIV_MASK) >>
		      CLK_TSADC_TSEN_DIV_SHIFT;
		sel = (con & CLK_TSADC_TSEN_SEL_MASK) >>
		      CLK_TSADC_TSEN_SEL_SHIFT;
		if (sel == CLK_TSADC_TSEN_SEL_24M)
			prate = OSC_HZ;
		else
			prate = 100 * MHz;
		return DIV_TO_RATE(prate, div);
	case CLK_TSADC:
		con = readl(&cru->clksel_con[51]);
		div = (con & CLK_TSADC_DIV_MASK) >> CLK_TSADC_DIV_SHIFT;
		prate = rk3568_adc_get_clk(priv, CLK_TSADC_TSEN);
		return DIV_TO_RATE(prate, div);
	default:
		return -ENOENT;
	}
}

static ulong rk3568_adc_set_clk(struct rk3568_clk_priv *priv,
				ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk_div;
	ulong prate = 0;

	switch (clk_id) {
	case CLK_SARADC:
		return OSC_HZ;
	case CLK_TSADC_TSEN:
		if (!(OSC_HZ % rate)) {
			src_clk_div = DIV_ROUND_UP(OSC_HZ, rate);
			assert(src_clk_div - 1 <= 7);
			rk_clrsetreg(&cru->clksel_con[51],
				     CLK_TSADC_TSEN_SEL_MASK |
				     CLK_TSADC_TSEN_DIV_MASK,
				     (CLK_TSADC_TSEN_SEL_24M <<
				      CLK_TSADC_TSEN_SEL_SHIFT) |
				     (src_clk_div - 1) <<
				     CLK_TSADC_TSEN_DIV_SHIFT);
		} else {
			src_clk_div = DIV_ROUND_UP(100 * MHz, rate);
			assert(src_clk_div - 1 <= 7);
			rk_clrsetreg(&cru->clksel_con[51],
				     CLK_TSADC_TSEN_SEL_MASK |
				     CLK_TSADC_TSEN_DIV_MASK,
				     (CLK_TSADC_TSEN_SEL_100M <<
				      CLK_TSADC_TSEN_SEL_SHIFT) |
				     (src_clk_div - 1) <<
				     CLK_TSADC_TSEN_DIV_SHIFT);
		}
		break;
	case CLK_TSADC:
			prate = rk3568_adc_get_clk(priv, CLK_TSADC_TSEN);
			src_clk_div = DIV_ROUND_UP(prate, rate);
			assert(src_clk_div - 1 <= 128);
			rk_clrsetreg(&cru->clksel_con[51],
				     CLK_TSADC_DIV_MASK,
				     (src_clk_div - 1) << CLK_TSADC_DIV_SHIFT);
		break;
	default:
		return -ENOENT;
	}
	return rk3568_adc_get_clk(priv, clk_id);
}

static ulong rk3568_crypto_get_rate(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	switch (clk_id) {
	case ACLK_SECURE_FLASH:
	case ACLK_CRYPTO_NS:
		con = readl(&cru->clksel_con[27]);
		sel = (con & ACLK_SECURE_FLASH_SEL_MASK) >>
		      ACLK_SECURE_FLASH_SEL_SHIFT;
		if (sel == ACLK_SECURE_FLASH_SEL_200M)
			return 200 * MHz;
		else if (sel == ACLK_SECURE_FLASH_SEL_150M)
			return 150 * MHz;
		else if (sel == ACLK_SECURE_FLASH_SEL_100M)
			return 100 * MHz;
		else
			return 24 * MHz;
	case HCLK_SECURE_FLASH:
	case HCLK_CRYPTO_NS:
	case CLK_CRYPTO_NS_RNG:
		con = readl(&cru->clksel_con[27]);
		sel = (con & HCLK_SECURE_FLASH_SEL_MASK) >>
		      HCLK_SECURE_FLASH_SEL_SHIFT;
		if (sel == HCLK_SECURE_FLASH_SEL_150M)
			return 150 * MHz;
		else if (sel == HCLK_SECURE_FLASH_SEL_100M)
			return 100 * MHz;
		else if (sel == HCLK_SECURE_FLASH_SEL_75M)
			return 75 * MHz;
		else
			return 24 * MHz;
	case CLK_CRYPTO_NS_CORE:
		con = readl(&cru->clksel_con[27]);
		sel = (con & CLK_CRYPTO_CORE_SEL_MASK) >>
		      CLK_CRYPTO_CORE_SEL_SHIFT;
		if (sel == CLK_CRYPTO_CORE_SEL_200M)
			return 200 * MHz;
		else if (sel == CLK_CRYPTO_CORE_SEL_150M)
			return 150 * MHz;
		else
			return 100 * MHz;
	case CLK_CRYPTO_NS_PKA:
		con = readl(&cru->clksel_con[27]);
		sel = (con & CLK_CRYPTO_PKA_SEL_MASK) >>
		      CLK_CRYPTO_PKA_SEL_SHIFT;
		if (sel == CLK_CRYPTO_PKA_SEL_300M)
			return 300 * MHz;
		else if (sel == CLK_CRYPTO_PKA_SEL_200M)
			return 200 * MHz;
		else
			return 100 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_crypto_set_rate(struct rk3568_clk_priv *priv,
				    ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	u32 src_clk, mask, shift;

	switch (clk_id) {
	case ACLK_SECURE_FLASH:
	case ACLK_CRYPTO_NS:
		mask = ACLK_SECURE_FLASH_SEL_MASK;
		shift = ACLK_SECURE_FLASH_SEL_SHIFT;
		if (rate == 200 * MHz)
			src_clk = ACLK_SECURE_FLASH_SEL_200M;
		else if (rate == 150 * MHz)
			src_clk = ACLK_SECURE_FLASH_SEL_150M;
		else if (rate == 100 * MHz)
			src_clk = ACLK_SECURE_FLASH_SEL_100M;
		else
			src_clk = ACLK_SECURE_FLASH_SEL_24M;
		break;
	case HCLK_SECURE_FLASH:
	case HCLK_CRYPTO_NS:
	case CLK_CRYPTO_NS_RNG:
		mask = HCLK_SECURE_FLASH_SEL_MASK;
		shift = HCLK_SECURE_FLASH_SEL_SHIFT;
		if (rate == 150 * MHz)
			src_clk = HCLK_SECURE_FLASH_SEL_150M;
		else if (rate == 100 * MHz)
			src_clk = HCLK_SECURE_FLASH_SEL_100M;
		else if (rate == 75 * MHz)
			src_clk = HCLK_SECURE_FLASH_SEL_75M;
		else
			src_clk = HCLK_SECURE_FLASH_SEL_24M;
		break;
	case CLK_CRYPTO_NS_CORE:
		mask = CLK_CRYPTO_CORE_SEL_MASK;
		shift = CLK_CRYPTO_CORE_SEL_SHIFT;
		if (rate == 200 * MHz)
			src_clk = CLK_CRYPTO_CORE_SEL_200M;
		else if (rate == 150 * MHz)
			src_clk = CLK_CRYPTO_CORE_SEL_150M;
		else
			src_clk = CLK_CRYPTO_CORE_SEL_100M;
		break;
	case CLK_CRYPTO_NS_PKA:
		mask = CLK_CRYPTO_PKA_SEL_MASK;
		shift = CLK_CRYPTO_PKA_SEL_SHIFT;
		if (rate == 300 * MHz)
			src_clk = CLK_CRYPTO_PKA_SEL_300M;
		else if (rate == 200 * MHz)
			src_clk = CLK_CRYPTO_PKA_SEL_200M;
		else
			src_clk = CLK_CRYPTO_PKA_SEL_100M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[27], mask, src_clk << shift);

	return rk3568_crypto_get_rate(priv, clk_id);
}

static ulong rk3568_sdmmc_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	switch (clk_id) {
	case HCLK_SDMMC0:
	case CLK_SDMMC0:
		con = readl(&cru->clksel_con[30]);
		sel = (con & CLK_SDMMC0_SEL_MASK) >> CLK_SDMMC0_SEL_SHIFT;
		break;
	case CLK_SDMMC1:
		con = readl(&cru->clksel_con[30]);
		sel = (con & CLK_SDMMC1_SEL_MASK) >> CLK_SDMMC1_SEL_SHIFT;
		break;
	case CLK_SDMMC2:
		con = readl(&cru->clksel_con[32]);
		sel = (con & CLK_SDMMC2_SEL_MASK) >> CLK_SDMMC2_SEL_SHIFT;
		break;
	default:
		return -ENOENT;
	}

	switch (sel) {
	case CLK_SDMMC_SEL_24M:
		return OSC_HZ;
	case CLK_SDMMC_SEL_400M:
		return 400 * MHz;
	case CLK_SDMMC_SEL_300M:
		return 300 * MHz;
	case CLK_SDMMC_SEL_100M:
		return 100 * MHz;
	case CLK_SDMMC_SEL_50M:
		return 50 * MHz;
	case CLK_SDMMC_SEL_750K:
		return 750 * KHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_sdmmc_set_clk(struct rk3568_clk_priv *priv,
				  ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case OSC_HZ:
	case 26 * MHz:
	case 25 * MHz:
		src_clk = CLK_SDMMC_SEL_24M;
		break;
	case 400 * MHz:
		src_clk = CLK_SDMMC_SEL_400M;
		break;
	case 300 * MHz:
		src_clk = CLK_SDMMC_SEL_300M;
		break;
	case 100 * MHz:
		src_clk = CLK_SDMMC_SEL_100M;
		break;
	case 52 * MHz:
	case 50 * MHz:
		src_clk = CLK_SDMMC_SEL_50M;
		break;
	case 750 * KHz:
	case 400 * KHz:
		src_clk = CLK_SDMMC_SEL_750K;
		break;
	default:
		return -ENOENT;
	}

	switch (clk_id) {
	case HCLK_SDMMC0:
	case CLK_SDMMC0:
		rk_clrsetreg(&cru->clksel_con[30],
			     CLK_SDMMC0_SEL_MASK,
			     src_clk << CLK_SDMMC0_SEL_SHIFT);
		break;
	case CLK_SDMMC1:
		rk_clrsetreg(&cru->clksel_con[30],
			     CLK_SDMMC1_SEL_MASK,
			     src_clk << CLK_SDMMC1_SEL_SHIFT);
		break;
	case CLK_SDMMC2:
		rk_clrsetreg(&cru->clksel_con[32],
			     CLK_SDMMC2_SEL_MASK,
			     src_clk << CLK_SDMMC2_SEL_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_sdmmc_get_clk(priv, clk_id);
}

static ulong rk3568_sfc_get_clk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[28]);
	sel = (con & SCLK_SFC_SEL_MASK) >> SCLK_SFC_SEL_SHIFT;
	switch (sel) {
	case SCLK_SFC_SEL_24M:
		return OSC_HZ;
	case SCLK_SFC_SEL_50M:
		return 50 * MHz;
	case SCLK_SFC_SEL_75M:
		return 75 * MHz;
	case SCLK_SFC_SEL_100M:
		return 100 * MHz;
	case SCLK_SFC_SEL_125M:
		return 125 * MHz;
	case SCLK_SFC_SEL_150M:
		return 150 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_sfc_set_clk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	if (rate >= 150 * MHz)
		src_clk = SCLK_SFC_SEL_150M;
	else if (rate >= 125 * MHz)
		src_clk = SCLK_SFC_SEL_125M;
	else if (rate >= 100 * MHz)
		src_clk = SCLK_SFC_SEL_100M;
	else if (rate >= 75 * MHz)
		src_clk = SCLK_SFC_SEL_75M;
	else if (rate >= 50 * MHz)
		src_clk = SCLK_SFC_SEL_50M;
	else if (rate >= OSC_HZ)
		src_clk = SCLK_SFC_SEL_24M;
	else
		return -ENOENT;

	rk_clrsetreg(&cru->clksel_con[28],
		     SCLK_SFC_SEL_MASK,
		     src_clk << SCLK_SFC_SEL_SHIFT);

	return rk3568_sfc_get_clk(priv);
}

static ulong rk3568_nand_get_clk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[28]);
	sel = (con & NCLK_NANDC_SEL_MASK) >> NCLK_NANDC_SEL_SHIFT;
	switch (sel) {
	case NCLK_NANDC_SEL_200M:
		return 200 * MHz;
	case NCLK_NANDC_SEL_150M:
		return 150 * MHz;
	case NCLK_NANDC_SEL_100M:
		return 100 * MHz;
	case NCLK_NANDC_SEL_24M:
		return OSC_HZ;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_nand_set_clk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case OSC_HZ:
		src_clk = NCLK_NANDC_SEL_24M;
		break;
	case 100 * MHz:
		src_clk = NCLK_NANDC_SEL_100M;
		break;
	case 150 * MHz:
		src_clk = NCLK_NANDC_SEL_150M;
		break;
	case 200 * MHz:
		src_clk = NCLK_NANDC_SEL_200M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[28],
		     NCLK_NANDC_SEL_MASK,
		     src_clk << NCLK_NANDC_SEL_SHIFT);

	return rk3568_nand_get_clk(priv);
}

static ulong rk3568_emmc_get_clk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[28]);
	sel = (con & CCLK_EMMC_SEL_MASK) >> CCLK_EMMC_SEL_SHIFT;
	switch (sel) {
	case CCLK_EMMC_SEL_200M:
		return 200 * MHz;
	case CCLK_EMMC_SEL_150M:
		return 150 * MHz;
	case CCLK_EMMC_SEL_100M:
		return 100 * MHz;
	case CCLK_EMMC_SEL_50M:
		return 50 * MHz;
	case CCLK_EMMC_SEL_375K:
		return 375 * KHz;
	case CCLK_EMMC_SEL_24M:
		return OSC_HZ;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_emmc_set_clk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case OSC_HZ:
	case 26 * MHz:
	case 25 * MHz:
		src_clk = CCLK_EMMC_SEL_24M;
		break;
	case 52 * MHz:
	case 50 * MHz:
		src_clk = CCLK_EMMC_SEL_50M;
		break;
	case 100 * MHz:
		src_clk = CCLK_EMMC_SEL_100M;
		break;
	case 150 * MHz:
		src_clk = CCLK_EMMC_SEL_150M;
		break;
	case 200 * MHz:
		src_clk = CCLK_EMMC_SEL_200M;
		break;
	case 400 * KHz:
	case 375 * KHz:
		src_clk = CCLK_EMMC_SEL_375K;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[28],
		     CCLK_EMMC_SEL_MASK,
		     src_clk << CCLK_EMMC_SEL_SHIFT);

	return rk3568_emmc_get_clk(priv);
}

static ulong rk3568_emmc_get_bclk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[28]);
	sel = (con & BCLK_EMMC_SEL_MASK) >> BCLK_EMMC_SEL_SHIFT;
	switch (sel) {
	case BCLK_EMMC_SEL_200M:
		return 200 * MHz;
	case BCLK_EMMC_SEL_150M:
		return 150 * MHz;
	case BCLK_EMMC_SEL_125M:
		return 125 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_emmc_set_bclk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case 200 * MHz:
		src_clk = BCLK_EMMC_SEL_200M;
		break;
	case 150 * MHz:
		src_clk = BCLK_EMMC_SEL_150M;
		break;
	case 125 * MHz:
		src_clk = BCLK_EMMC_SEL_125M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[28],
		     BCLK_EMMC_SEL_MASK,
		     src_clk << BCLK_EMMC_SEL_SHIFT);

	return rk3568_emmc_get_bclk(priv);
}

#ifndef CONFIG_SPL_BUILD
static ulong rk3568_aclk_vop_get_clk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 div, sel, con, parent;

	con = readl(&cru->clksel_con[38]);
	div = (con & ACLK_VOP_PRE_DIV_MASK) >> ACLK_VOP_PRE_DIV_SHIFT;
	sel = (con & ACLK_VOP_PRE_SEL_MASK) >> ACLK_VOP_PRE_SEL_SHIFT;
	if (sel == ACLK_VOP_PRE_SEL_GPLL)
		parent = priv->gpll_hz;
	else if (sel == ACLK_VOP_PRE_SEL_CPLL)
		parent = priv->cpll_hz;
	else if (sel == ACLK_VOP_PRE_SEL_VPLL)
		parent = priv->vpll_hz;
	else
		parent = priv->hpll_hz;

	return DIV_TO_RATE(parent, div);
}

static ulong rk3568_aclk_vop_set_clk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk_div, src_clk_mux;

	if ((priv->cpll_hz % rate) == 0) {
		src_clk_div = DIV_ROUND_UP(priv->cpll_hz, rate);
		src_clk_mux = ACLK_VOP_PRE_SEL_CPLL;
	} else {
		src_clk_div = DIV_ROUND_UP(priv->gpll_hz, rate);
		src_clk_mux = ACLK_VOP_PRE_SEL_GPLL;
	}
	assert(src_clk_div - 1 <= 31);
	rk_clrsetreg(&cru->clksel_con[38],
		     ACLK_VOP_PRE_SEL_MASK | ACLK_VOP_PRE_DIV_MASK,
		     src_clk_mux << ACLK_VOP_PRE_SEL_SHIFT |
		     (src_clk_div - 1) << ACLK_VOP_PRE_DIV_SHIFT);

	return rk3568_aclk_vop_get_clk(priv);
}

static ulong rk3568_dclk_vop_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 conid, div, sel, con, parent;

	switch (clk_id) {
	case DCLK_VOP0:
		conid = 39;
		break;
	case DCLK_VOP1:
		conid = 40;
		break;
	case DCLK_VOP2:
		conid = 41;
		break;
	default:
		return -ENOENT;
	}

	con = readl(&cru->clksel_con[conid]);
	div = (con & DCLK0_VOP_DIV_MASK) >> DCLK0_VOP_DIV_SHIFT;
	sel = (con & DCLK0_VOP_SEL_MASK) >> DCLK0_VOP_SEL_SHIFT;
	if (sel == DCLK_VOP_SEL_HPLL)
		parent = rk3568_pmu_pll_get_rate(priv, HPLL);
	else if (sel == DCLK_VOP_SEL_VPLL)
		parent = rockchip_pll_get_rate(&rk3568_pll_clks[VPLL],
					       priv->cru, VPLL);
	else if (sel == DCLK_VOP_SEL_GPLL)
		parent = priv->gpll_hz;
	else if (sel == DCLK_VOP_SEL_CPLL)
		parent = priv->cpll_hz;
	else
		return -ENOENT;

	return DIV_TO_RATE(parent, div);
}

#define RK3568_VOP_PLL_LIMIT_FREQ 600000000

static ulong rk3568_dclk_vop_set_clk(struct rk3568_clk_priv *priv,
				     ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	ulong pll_rate, now, best_rate = 0;
	u32 i, conid, con, sel, div, best_div = 0, best_sel = 0;

	switch (clk_id) {
	case DCLK_VOP0:
		conid = 39;
		break;
	case DCLK_VOP1:
		conid = 40;
		break;
	case DCLK_VOP2:
		conid = 41;
		break;
	default:
		return -ENOENT;
	}

	con = readl(&cru->clksel_con[conid]);
	sel = (con & DCLK0_VOP_SEL_MASK) >> DCLK0_VOP_SEL_SHIFT;

	if (sel == DCLK_VOP_SEL_HPLL) {
		div = 1;
		rk_clrsetreg(&cru->clksel_con[conid],
			     DCLK0_VOP_DIV_MASK | DCLK0_VOP_SEL_MASK,
			     (DCLK_VOP_SEL_HPLL << DCLK0_VOP_SEL_SHIFT) |
			     ((div - 1) << DCLK0_VOP_DIV_SHIFT));
		rk3568_pmu_pll_set_rate(priv, HPLL, div * rate);
	} else if (sel == DCLK_VOP_SEL_VPLL) {
		div = DIV_ROUND_UP(RK3568_VOP_PLL_LIMIT_FREQ, rate);
		rk_clrsetreg(&cru->clksel_con[conid],
			     DCLK0_VOP_DIV_MASK | DCLK0_VOP_SEL_MASK,
			     (DCLK_VOP_SEL_VPLL << DCLK0_VOP_SEL_SHIFT) |
			     ((div - 1) << DCLK0_VOP_DIV_SHIFT));
		rockchip_pll_set_rate(&rk3568_pll_clks[VPLL],
				      priv->cru, VPLL, div * rate);
	} else {
		for (i = sel; i <= DCLK_VOP_SEL_CPLL; i++) {
			switch (i) {
			case DCLK_VOP_SEL_GPLL:
				pll_rate = priv->gpll_hz;
				break;
			case DCLK_VOP_SEL_CPLL:
				pll_rate = priv->cpll_hz;
				break;
			default:
				printf("do not support this vop pll sel\n");
				return -EINVAL;
			}

			div = DIV_ROUND_UP(pll_rate, rate);
			if (div > 255)
				continue;
			now = pll_rate / div;
			if (abs(rate - now) < abs(rate - best_rate)) {
				best_rate = now;
				best_div = div;
				best_sel = i;
			}
			debug("p_rate=%lu, best_rate=%lu, div=%u, sel=%u\n",
			      pll_rate, best_rate, best_div, best_sel);
		}

		if (best_rate) {
			rk_clrsetreg(&cru->clksel_con[conid],
				     DCLK0_VOP_DIV_MASK | DCLK0_VOP_SEL_MASK,
				     best_sel << DCLK0_VOP_SEL_SHIFT |
				     (best_div - 1) << DCLK0_VOP_DIV_SHIFT);
		} else {
			printf("do not support this vop freq %lu\n", rate);
			return -EINVAL;
		}
	}
	return rk3568_dclk_vop_get_clk(priv, clk_id);
}

static ulong rk3568_gmac_src_get_clk(struct rk3568_clk_priv *priv,
				     ulong mac_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[31 + mac_id * 2]);
	sel = (con & CLK_MAC0_2TOP_SEL_MASK) >> CLK_MAC0_2TOP_SEL_SHIFT;

	switch (sel) {
	case CLK_MAC0_2TOP_SEL_125M:
		return 125 * MHz;
	case CLK_MAC0_2TOP_SEL_50M:
		return 50 * MHz;
	case CLK_MAC0_2TOP_SEL_25M:
		return 25 * MHz;
	case CLK_MAC0_2TOP_SEL_PPLL:
		return rk3568_pmu_pll_get_rate(priv, HPLL);
	default:
		return -ENOENT;
	}
}

static ulong rk3568_gmac_src_set_clk(struct rk3568_clk_priv *priv,
				     ulong mac_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case 125 * MHz:
		src_clk = CLK_MAC0_2TOP_SEL_125M;
		break;
	case 50 * MHz:
		src_clk = CLK_MAC0_2TOP_SEL_50M;
		break;
	case 25 * MHz:
		src_clk = CLK_MAC0_2TOP_SEL_25M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[31 + mac_id * 2],
		     CLK_MAC0_2TOP_SEL_MASK,
		     src_clk << CLK_MAC0_2TOP_SEL_SHIFT);

	return rk3568_gmac_src_get_clk(priv, mac_id);
}

static ulong rk3568_gmac_out_get_clk(struct rk3568_clk_priv *priv,
				     ulong mac_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[31 + mac_id * 2]);
	sel = (con & CLK_MAC0_OUT_SEL_MASK) >> CLK_MAC0_OUT_SEL_SHIFT;

	switch (sel) {
	case CLK_MAC0_OUT_SEL_125M:
		return 125 * MHz;
	case CLK_MAC0_OUT_SEL_50M:
		return 50 * MHz;
	case CLK_MAC0_OUT_SEL_25M:
		return 25 * MHz;
	case CLK_MAC0_OUT_SEL_24M:
		return OSC_HZ;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_gmac_out_set_clk(struct rk3568_clk_priv *priv,
				     ulong mac_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case 125 * MHz:
		src_clk = CLK_MAC0_OUT_SEL_125M;
		break;
	case 50 * MHz:
		src_clk = CLK_MAC0_OUT_SEL_50M;
		break;
	case 25 * MHz:
		src_clk = CLK_MAC0_OUT_SEL_25M;
		break;
	case 24 * MHz:
		src_clk = CLK_MAC0_OUT_SEL_24M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[31 + mac_id * 2],
		     CLK_MAC0_OUT_SEL_MASK,
		     src_clk << CLK_MAC0_OUT_SEL_SHIFT);

	return rk3568_gmac_out_get_clk(priv, mac_id);
}

static ulong rk3568_gmac_ptp_ref_get_clk(struct rk3568_clk_priv *priv,
					 ulong mac_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 sel, con;

	con = readl(&cru->clksel_con[31 + mac_id * 2]);
	sel = (con & CLK_GMAC0_PTP_REF_SEL_MASK) >> CLK_GMAC0_PTP_REF_SEL_SHIFT;

	switch (sel) {
	case CLK_GMAC0_PTP_REF_SEL_62_5M:
		return 62500 * KHz;
	case CLK_GMAC0_PTP_REF_SEL_100M:
		return 100 * MHz;
	case CLK_GMAC0_PTP_REF_SEL_50M:
		return 50 * MHz;
	case CLK_GMAC0_PTP_REF_SEL_24M:
		return OSC_HZ;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_gmac_ptp_ref_set_clk(struct rk3568_clk_priv *priv,
					 ulong mac_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk;

	switch (rate) {
	case 62500 * KHz:
		src_clk = CLK_GMAC0_PTP_REF_SEL_62_5M;
		break;
	case 100 * MHz:
		src_clk = CLK_GMAC0_PTP_REF_SEL_100M;
		break;
	case 50 * MHz:
		src_clk = CLK_GMAC0_PTP_REF_SEL_50M;
		break;
	case 24 * MHz:
		src_clk = CLK_GMAC0_PTP_REF_SEL_24M;
		break;
	default:
		return -ENOENT;
	}

	rk_clrsetreg(&cru->clksel_con[31 + mac_id * 2],
		     CLK_GMAC0_PTP_REF_SEL_MASK,
		     src_clk << CLK_GMAC0_PTP_REF_SEL_SHIFT);

	return rk3568_gmac_ptp_ref_get_clk(priv, mac_id);
}

static ulong rk3568_gmac_tx_rx_set_clk(struct rk3568_clk_priv *priv,
				       ulong mac_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, sel, div_sel;

	con = readl(&cru->clksel_con[31 + mac_id * 2]);
	sel = (con & RMII0_MODE_MASK) >> RMII0_MODE_SHIFT;

	if (sel == RMII0_MODE_SEL_RGMII) {
		if (rate == 2500000)
			div_sel = RGMII0_CLK_SEL_2_5M;
		else if (rate == 25000000)
			div_sel = RGMII0_CLK_SEL_25M;
		else
			div_sel = RGMII0_CLK_SEL_125M;
		rk_clrsetreg(&cru->clksel_con[31 + mac_id * 2],
			     RGMII0_CLK_SEL_MASK,
			     div_sel << RGMII0_CLK_SEL_SHIFT);
	} else if (sel == RMII0_MODE_SEL_RMII) {
		if (rate == 2500000)
			div_sel = RMII0_CLK_SEL_2_5M;
		else
			div_sel = RMII0_CLK_SEL_25M;
		rk_clrsetreg(&cru->clksel_con[31 + mac_id * 2],
			     RMII0_CLK_SEL_MASK,
			     div_sel << RMII0_CLK_SEL_SHIFT);
	}

	return 0;
}

static ulong rk3568_ebc_get_clk(struct rk3568_clk_priv *priv)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, div, p_rate;

	con = readl(&cru->clksel_con[79]);
	div = (con & CPLL_333M_DIV_MASK) >> CPLL_333M_DIV_SHIFT;
	p_rate = DIV_TO_RATE(priv->cpll_hz, div);

	con = readl(&cru->clksel_con[43]);
	div = (con & DCLK_EBC_SEL_MASK) >> DCLK_EBC_SEL_SHIFT;
	switch (div) {
	case DCLK_EBC_SEL_GPLL_400M:
		return 400 * MHz;
	case DCLK_EBC_SEL_CPLL_333M:
		return p_rate;
	case DCLK_EBC_SEL_GPLL_200M:
		return 200 * MHz;
	default:
		return -ENOENT;
	}
}

static ulong rk3568_ebc_set_clk(struct rk3568_clk_priv *priv, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk_div;

	src_clk_div = DIV_ROUND_UP(priv->cpll_hz, rate);
	assert(src_clk_div - 1 <= 31);
	rk_clrsetreg(&cru->clksel_con[79],
		     CPLL_333M_DIV_MASK,
		     (src_clk_div - 1) << CPLL_333M_DIV_SHIFT);
	rk_clrsetreg(&cru->clksel_con[43],
		     DCLK_EBC_SEL_MASK,
		     DCLK_EBC_SEL_CPLL_333M << DCLK_EBC_SEL_SHIFT);

	return rk3568_ebc_get_clk(priv);
}

static ulong rk3568_rkvdec_get_clk(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 con, div, src, p_rate;

	switch (clk_id) {
	case ACLK_RKVDEC_PRE:
	case ACLK_RKVDEC:
		con = readl(&cru->clksel_con[47]);
		src = (con & ACLK_RKVDEC_SEL_MASK) >> ACLK_RKVDEC_SEL_SHIFT;
		div = (con & ACLK_RKVDEC_DIV_MASK) >> ACLK_RKVDEC_DIV_SHIFT;
		if (src == ACLK_RKVDEC_SEL_CPLL)
			p_rate = priv->cpll_hz;
		else
			p_rate = priv->gpll_hz;
		return DIV_TO_RATE(p_rate, div);
	case CLK_RKVDEC_CORE:
		con = readl(&cru->clksel_con[49]);
		src = (con & CLK_RKVDEC_CORE_SEL_MASK)
		      >> CLK_RKVDEC_CORE_SEL_SHIFT;
		div = (con & CLK_RKVDEC_CORE_DIV_MASK)
		      >> CLK_RKVDEC_CORE_DIV_SHIFT;
		if (src == CLK_RKVDEC_CORE_SEL_CPLL)
			p_rate = priv->cpll_hz;
		else if (src == CLK_RKVDEC_CORE_SEL_NPLL)
			p_rate = priv->npll_hz;
		else if (src == CLK_RKVDEC_CORE_SEL_VPLL)
			p_rate = priv->vpll_hz;
		else
			p_rate = priv->gpll_hz;
		return DIV_TO_RATE(p_rate, div);
	default:
		return -ENOENT;
	}
}

static ulong rk3568_rkvdec_set_clk(struct rk3568_clk_priv *priv,
				   ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	int src_clk_div, src, p_rate;

	switch (clk_id) {
	case ACLK_RKVDEC_PRE:
	case ACLK_RKVDEC:
		src = (readl(&cru->clksel_con[47]) & ACLK_RKVDEC_SEL_MASK)
		      >> ACLK_RKVDEC_SEL_SHIFT;
		if (src == ACLK_RKVDEC_SEL_CPLL)
			p_rate = priv->cpll_hz;
		else
			p_rate = priv->gpll_hz;
		src_clk_div = DIV_ROUND_UP(p_rate, rate);
		assert(src_clk_div - 1 <= 31);
		rk_clrsetreg(&cru->clksel_con[47],
			     ACLK_RKVDEC_SEL_MASK |
			     ACLK_RKVDEC_DIV_MASK,
			     (src << ACLK_RKVDEC_SEL_SHIFT) |
			     (src_clk_div - 1) << ACLK_RKVDEC_DIV_SHIFT);
		break;
	case CLK_RKVDEC_CORE:
		src = (readl(&cru->clksel_con[49]) & CLK_RKVDEC_CORE_SEL_MASK)
		      >> CLK_RKVDEC_CORE_SEL_SHIFT;
		if (src == CLK_RKVDEC_CORE_SEL_CPLL)
			p_rate = priv->cpll_hz;
		else if (src == CLK_RKVDEC_CORE_SEL_NPLL)
			p_rate = priv->npll_hz;
		else if (src == CLK_RKVDEC_CORE_SEL_VPLL)
			p_rate = priv->vpll_hz;
		else
			p_rate = priv->gpll_hz;
		src_clk_div = DIV_ROUND_UP(p_rate, rate);
		assert(src_clk_div - 1 <= 31);
		rk_clrsetreg(&cru->clksel_con[49],
			     CLK_RKVDEC_CORE_SEL_MASK |
			     CLK_RKVDEC_CORE_DIV_MASK,
			     (src << CLK_RKVDEC_CORE_SEL_SHIFT) |
			     (src_clk_div - 1) << CLK_RKVDEC_CORE_DIV_SHIFT);
		break;
	default:
		return -ENOENT;
	}

	return rk3568_rkvdec_get_clk(priv, clk_id);
}
#endif

static ulong rk3568_uart_get_rate(struct rk3568_clk_priv *priv, ulong clk_id)
{
	struct rk3568_cru *cru = priv->cru;
	u32 reg, con, fracdiv, div, src, p_src, p_rate;
	unsigned long m, n;

	switch (clk_id) {
	case SCLK_UART1:
		reg = 52;
		break;
	case SCLK_UART2:
		reg = 54;
		break;
	case SCLK_UART3:
		reg = 56;
		break;
	case SCLK_UART4:
		reg = 58;
		break;
	case SCLK_UART5:
		reg = 60;
		break;
	case SCLK_UART6:
		reg = 62;
		break;
	case SCLK_UART7:
		reg = 64;
		break;
	case SCLK_UART8:
		reg = 66;
		break;
	case SCLK_UART9:
		reg = 68;
		break;
	default:
		return -ENOENT;
	}
	con = readl(&cru->clksel_con[reg]);
	src = (con & CLK_UART_SEL_MASK) >> CLK_UART_SEL_SHIFT;
	div = (con & CLK_UART_SRC_DIV_MASK) >> CLK_UART_SRC_DIV_SHIFT;
	p_src = (con & CLK_UART_SRC_SEL_MASK) >> CLK_UART_SRC_SEL_SHIFT;
	if (p_src == CLK_UART_SRC_SEL_GPLL)
		p_rate = priv->gpll_hz;
	else if (p_src == CLK_UART_SRC_SEL_CPLL)
		p_rate = priv->cpll_hz;
	else
		p_rate = 480000000;
	if (src == CLK_UART_SEL_SRC) {
		return DIV_TO_RATE(p_rate, div);
	} else if (src == CLK_UART_SEL_FRAC) {
		fracdiv = readl(&cru->clksel_con[reg + 1]);
		n = fracdiv & CLK_UART_FRAC_NUMERATOR_MASK;
		n >>= CLK_UART_FRAC_NUMERATOR_SHIFT;
		m = fracdiv & CLK_UART_FRAC_DENOMINATOR_MASK;
		m >>= CLK_UART_FRAC_DENOMINATOR_SHIFT;
		return DIV_TO_RATE(p_rate, div) * n / m;
	} else {
		return OSC_HZ;
	}
}

static ulong rk3568_uart_set_rate(struct rk3568_clk_priv *priv,
				  ulong clk_id, ulong rate)
{
	struct rk3568_cru *cru = priv->cru;
	u32 reg, clk_src, uart_src, div;
	unsigned long m = 0, n = 0, val;

	if (priv->gpll_hz % rate == 0) {
		clk_src = CLK_UART_SRC_SEL_GPLL;
		uart_src = CLK_UART_SEL_SRC;
		div = DIV_ROUND_UP(priv->gpll_hz, rate);
	} else if (priv->cpll_hz % rate == 0) {
		clk_src = CLK_UART_SRC_SEL_CPLL;
		uart_src = CLK_UART_SEL_SRC;
		div = DIV_ROUND_UP(priv->gpll_hz, rate);
	} else if (rate == OSC_HZ) {
		clk_src = CLK_UART_SRC_SEL_GPLL;
		uart_src = CLK_UART_SEL_XIN24M;
		div = 2;
	} else {
		clk_src = CLK_UART_SRC_SEL_GPLL;
		uart_src = CLK_UART_SEL_FRAC;
		div = 2;
		rational_best_approximation(rate, priv->gpll_hz / div,
					    GENMASK(16 - 1, 0),
					    GENMASK(16 - 1, 0),
					    &m, &n);
	}

	switch (clk_id) {
	case SCLK_UART1:
		reg = 52;
		break;
	case SCLK_UART2:
		reg = 54;
		break;
	case SCLK_UART3:
		reg = 56;
		break;
	case SCLK_UART4:
		reg = 58;
		break;
	case SCLK_UART5:
		reg = 60;
		break;
	case SCLK_UART6:
		reg = 62;
		break;
	case SCLK_UART7:
		reg = 64;
		break;
	case SCLK_UART8:
		reg = 66;
		break;
	case SCLK_UART9:
		reg = 68;
		break;
	default:
		return -ENOENT;
	}
	rk_clrsetreg(&cru->clksel_con[reg],
		     CLK_UART_SEL_MASK | CLK_UART_SRC_SEL_MASK |
		     CLK_UART_SRC_DIV_MASK,
		     (clk_src << CLK_UART_SRC_SEL_SHIFT) |
		     (uart_src << CLK_UART_SEL_SHIFT) |
		     ((div - 1) << CLK_UART_SRC_DIV_SHIFT));
	if (m && n) {
		val = m << CLK_UART_FRAC_NUMERATOR_SHIFT | n;
		writel(val, &cru->clksel_con[reg + 1]);
	}

	return rk3568_uart_get_rate(priv, clk_id);
}

static ulong rk3568_clk_get_rate(struct clk *clk)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	ulong rate = 0;

	if (!priv->gpll_hz) {
		printf("%s gpll=%lu\n", __func__, priv->gpll_hz);
		return -ENOENT;
	}

	switch (clk->id) {
	case PLL_APLL:
	case ARMCLK:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[APLL], priv->cru,
					     APLL);
		break;
	case PLL_CPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[CPLL], priv->cru,
					     CPLL);
		break;
	case PLL_GPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[GPLL], priv->cru,
					     GPLL);
		break;
	case PLL_NPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[NPLL], priv->cru,
					     NPLL);
		break;
	case PLL_VPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[VPLL], priv->cru,
					     VPLL);
		break;
	case PLL_DPLL:
		rate = rockchip_pll_get_rate(&rk3568_pll_clks[DPLL], priv->cru,
					     DPLL);
		break;
	case ACLK_BUS:
	case PCLK_BUS:
	case PCLK_WDT_NS:
		rate = rk3568_bus_get_clk(priv, clk->id);
		break;
	case ACLK_PERIMID:
	case HCLK_PERIMID:
		rate = rk3568_perimid_get_clk(priv, clk->id);
		break;
	case ACLK_TOP_HIGH:
	case ACLK_TOP_LOW:
	case HCLK_TOP:
	case PCLK_TOP:
		rate = rk3568_top_get_clk(priv, clk->id);
		break;
	case CLK_I2C1:
	case CLK_I2C2:
	case CLK_I2C3:
	case CLK_I2C4:
	case CLK_I2C5:
		rate = rk3568_i2c_get_clk(priv, clk->id);
		break;
	case CLK_SPI0:
	case CLK_SPI1:
	case CLK_SPI2:
	case CLK_SPI3:
		rate = rk3568_spi_get_clk(priv, clk->id);
		break;
	case CLK_PWM1:
	case CLK_PWM2:
	case CLK_PWM3:
		rate = rk3568_pwm_get_clk(priv, clk->id);
		break;
	case CLK_SARADC:
	case CLK_TSADC_TSEN:
	case CLK_TSADC:
		rate = rk3568_adc_get_clk(priv, clk->id);
		break;
	case HCLK_SDMMC0:
	case CLK_SDMMC0:
	case CLK_SDMMC1:
	case CLK_SDMMC2:
		rate = rk3568_sdmmc_get_clk(priv, clk->id);
		break;
	case SCLK_SFC:
		rate = rk3568_sfc_get_clk(priv);
		break;
	case NCLK_NANDC:
		rate = rk3568_nand_get_clk(priv);
		break;
	case CCLK_EMMC:
		rate = rk3568_emmc_get_clk(priv);
		break;
	case BCLK_EMMC:
		rate = rk3568_emmc_get_bclk(priv);
		break;
	case CLK_USB3OTG0_REF:
	case CLK_USB3OTG1_REF:
	case TCLK_EMMC:
		rate = OSC_HZ;
		break;
#ifndef CONFIG_SPL_BUILD
	case ACLK_VOP:
		rate = rk3568_aclk_vop_get_clk(priv);
		break;
	case DCLK_VOP0:
	case DCLK_VOP1:
	case DCLK_VOP2:
		rate = rk3568_dclk_vop_get_clk(priv, clk->id);
		break;
	case SCLK_GMAC0:
	case CLK_MAC0_2TOP:
	case CLK_MAC0_REFOUT:
		rate = rk3568_gmac_src_get_clk(priv, 0);
		break;
	case CLK_MAC0_OUT:
		rate = rk3568_gmac_out_get_clk(priv, 0);
		break;
	case CLK_GMAC0_PTP_REF:
		rate = rk3568_gmac_ptp_ref_get_clk(priv, 0);
		break;
	case SCLK_GMAC1:
	case CLK_MAC1_2TOP:
	case CLK_MAC1_REFOUT:
		rate = rk3568_gmac_src_get_clk(priv, 1);
		break;
	case CLK_MAC1_OUT:
		rate = rk3568_gmac_out_get_clk(priv, 1);
		break;
	case CLK_GMAC1_PTP_REF:
		rate = rk3568_gmac_ptp_ref_get_clk(priv, 1);
		break;
	case DCLK_EBC:
		rate = rk3568_ebc_get_clk(priv);
		break;
	case ACLK_RKVDEC_PRE:
	case ACLK_RKVDEC:
	case CLK_RKVDEC_CORE:
		rate = rk3568_rkvdec_get_clk(priv, clk->id);
		break;
	case TCLK_WDT_NS:
		rate = OSC_HZ;
		break;
#endif
	case SCLK_UART1:
	case SCLK_UART2:
	case SCLK_UART3:
	case SCLK_UART4:
	case SCLK_UART5:
	case SCLK_UART6:
	case SCLK_UART7:
	case SCLK_UART8:
	case SCLK_UART9:
		rate = rk3568_uart_get_rate(priv, clk->id);
		break;
	case ACLK_SECURE_FLASH:
	case ACLK_CRYPTO_NS:
	case HCLK_SECURE_FLASH:
	case HCLK_CRYPTO_NS:
	case CLK_CRYPTO_NS_RNG:
	case CLK_CRYPTO_NS_CORE:
	case CLK_CRYPTO_NS_PKA:
		rate = rk3568_crypto_get_rate(priv, clk->id);
		break;
	case CPLL_500M:
	case CPLL_333M:
	case CPLL_250M:
	case CPLL_125M:
	case CPLL_100M:
	case CPLL_62P5M:
	case CPLL_50M:
	case CPLL_25M:
		rate = rk3568_cpll_div_get_rate(priv, clk->id);
		break;
	default:
		return -ENOENT;
	}

	return rate;
};

static ulong rk3568_clk_set_rate(struct clk *clk, ulong rate)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	ulong ret = 0;

	if (!priv->gpll_hz) {
		printf("%s gpll=%lu\n", __func__, priv->gpll_hz);
		return -ENOENT;
	}

	switch (clk->id) {
	case PLL_APLL:
	case ARMCLK:
		if (priv->armclk_hz)
			rk3568_armclk_set_clk(priv, rate);
		priv->armclk_hz = rate;
		break;
	case PLL_CPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[CPLL], priv->cru,
					    CPLL, rate);
		priv->cpll_hz = rockchip_pll_get_rate(&rk3568_pll_clks[CPLL],
						      priv->cru, CPLL);
		break;
	case PLL_GPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[GPLL], priv->cru,
					    GPLL, rate);
		priv->gpll_hz = rockchip_pll_get_rate(&rk3568_pll_clks[GPLL],
						      priv->cru, GPLL);
		break;
	case PLL_NPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[NPLL], priv->cru,
					    NPLL, rate);
		break;
	case PLL_VPLL:
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[VPLL], priv->cru,
					    VPLL, rate);
		priv->vpll_hz = rockchip_pll_get_rate(&rk3568_pll_clks[VPLL],
						      priv->cru,
						      VPLL);
		break;
	case ACLK_BUS:
	case PCLK_BUS:
	case PCLK_WDT_NS:
		ret = rk3568_bus_set_clk(priv, clk->id, rate);
		break;
	case ACLK_PERIMID:
	case HCLK_PERIMID:
		ret = rk3568_perimid_set_clk(priv, clk->id, rate);
		break;
	case ACLK_TOP_HIGH:
	case ACLK_TOP_LOW:
	case HCLK_TOP:
	case PCLK_TOP:
		ret = rk3568_top_set_clk(priv, clk->id, rate);
		break;
	case CLK_I2C1:
	case CLK_I2C2:
	case CLK_I2C3:
	case CLK_I2C4:
	case CLK_I2C5:
		ret = rk3568_i2c_set_clk(priv, clk->id, rate);
		break;
	case CLK_SPI0:
	case CLK_SPI1:
	case CLK_SPI2:
	case CLK_SPI3:
		ret = rk3568_spi_set_clk(priv, clk->id, rate);
		break;
	case CLK_PWM1:
	case CLK_PWM2:
	case CLK_PWM3:
		ret = rk3568_pwm_set_clk(priv, clk->id, rate);
		break;
	case CLK_SARADC:
	case CLK_TSADC_TSEN:
	case CLK_TSADC:
		ret = rk3568_adc_set_clk(priv, clk->id, rate);
		break;
	case HCLK_SDMMC0:
	case CLK_SDMMC0:
	case CLK_SDMMC1:
	case CLK_SDMMC2:
		ret = rk3568_sdmmc_set_clk(priv, clk->id, rate);
		break;
	case SCLK_SFC:
		ret = rk3568_sfc_set_clk(priv, rate);
		break;
	case NCLK_NANDC:
		ret = rk3568_nand_set_clk(priv, rate);
		break;
	case CCLK_EMMC:
		ret = rk3568_emmc_set_clk(priv, rate);
		break;
	case BCLK_EMMC:
		ret = rk3568_emmc_set_bclk(priv, rate);
		break;
	case CLK_USB3OTG0_REF:
	case CLK_USB3OTG1_REF:
	case TCLK_EMMC:
		ret = OSC_HZ;
		break;
#ifndef CONFIG_SPL_BUILD
	case ACLK_VOP:
		ret = rk3568_aclk_vop_set_clk(priv, rate);
		break;
	case DCLK_VOP0:
	case DCLK_VOP1:
	case DCLK_VOP2:
		ret = rk3568_dclk_vop_set_clk(priv, clk->id, rate);
		break;
	case SCLK_GMAC0:
	case CLK_MAC0_2TOP:
	case CLK_MAC0_REFOUT:
		ret = rk3568_gmac_src_set_clk(priv, 0, rate);
		break;
	case CLK_MAC0_OUT:
		ret = rk3568_gmac_out_set_clk(priv, 0, rate);
		break;
	case SCLK_GMAC0_RX_TX:
		ret = rk3568_gmac_tx_rx_set_clk(priv, 0, rate);
		break;
	case CLK_GMAC0_PTP_REF:
		ret = rk3568_gmac_ptp_ref_set_clk(priv, 0, rate);
		break;
	case SCLK_GMAC1:
	case CLK_MAC1_2TOP:
	case CLK_MAC1_REFOUT:
		ret = rk3568_gmac_src_set_clk(priv, 1, rate);
		break;
	case CLK_MAC1_OUT:
		ret = rk3568_gmac_out_set_clk(priv, 1, rate);
		break;
	case SCLK_GMAC1_RX_TX:
		ret = rk3568_gmac_tx_rx_set_clk(priv, 1, rate);
		break;
	case CLK_GMAC1_PTP_REF:
		ret = rk3568_gmac_ptp_ref_set_clk(priv, 1, rate);
		break;
	case DCLK_EBC:
		ret = rk3568_ebc_set_clk(priv, rate);
		break;
	case ACLK_RKVDEC_PRE:
	case ACLK_RKVDEC:
	case CLK_RKVDEC_CORE:
		ret = rk3568_rkvdec_set_clk(priv, clk->id, rate);
		break;
	case TCLK_WDT_NS:
		ret = OSC_HZ;
		break;
#endif
	case SCLK_UART1:
	case SCLK_UART2:
	case SCLK_UART3:
	case SCLK_UART4:
	case SCLK_UART5:
	case SCLK_UART6:
	case SCLK_UART7:
	case SCLK_UART8:
	case SCLK_UART9:
		ret = rk3568_uart_set_rate(priv, clk->id, rate);
		break;
	case ACLK_SECURE_FLASH:
	case ACLK_CRYPTO_NS:
	case HCLK_SECURE_FLASH:
	case HCLK_CRYPTO_NS:
	case CLK_CRYPTO_NS_RNG:
	case CLK_CRYPTO_NS_CORE:
	case CLK_CRYPTO_NS_PKA:
		ret = rk3568_crypto_set_rate(priv, clk->id, rate);
		break;
	case CPLL_500M:
	case CPLL_333M:
	case CPLL_250M:
	case CPLL_125M:
	case CPLL_100M:
	case CPLL_62P5M:
	case CPLL_50M:
	case CPLL_25M:
		ret = rk3568_cpll_div_set_rate(priv, clk->id, rate);
		break;
	default:
		return -ENOENT;
	}

	return ret;
};

#if (IS_ENABLED(OF_CONTROL)) || (!IS_ENABLED(OF_PLATDATA))
static int rk3568_gmac0_src_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;

	if (parent->id == CLK_MAC0_2TOP)
		rk_clrsetreg(&cru->clksel_con[31],
			     RMII0_EXTCLK_SEL_MASK,
			     RMII0_EXTCLK_SEL_MAC0_TOP <<
			     RMII0_EXTCLK_SEL_SHIFT);
	else
		rk_clrsetreg(&cru->clksel_con[31],
			     RMII0_EXTCLK_SEL_MASK,
			     RMII0_EXTCLK_SEL_IO << RMII0_EXTCLK_SEL_SHIFT);
	return 0;
}

static int rk3568_gmac1_src_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;

	if (parent->id == CLK_MAC1_2TOP)
		rk_clrsetreg(&cru->clksel_con[33],
			     RMII0_EXTCLK_SEL_MASK,
			     RMII0_EXTCLK_SEL_MAC0_TOP <<
			     RMII0_EXTCLK_SEL_SHIFT);
	else
		rk_clrsetreg(&cru->clksel_con[33],
			     RMII0_EXTCLK_SEL_MASK,
			     RMII0_EXTCLK_SEL_IO << RMII0_EXTCLK_SEL_SHIFT);
	return 0;
}

static int rk3568_gmac0_tx_rx_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;

	if (parent->id == SCLK_GMAC0_RGMII_SPEED)
		rk_clrsetreg(&cru->clksel_con[31],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_RGMII << RMII0_MODE_SHIFT);
	else if (parent->id == SCLK_GMAC0_RMII_SPEED)
		rk_clrsetreg(&cru->clksel_con[31],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_RMII << RMII0_MODE_SHIFT);
	else
		rk_clrsetreg(&cru->clksel_con[31],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_GMII << RMII0_MODE_SHIFT);

	return 0;
}

static int rk3568_gmac1_tx_rx_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;

	if (parent->id == SCLK_GMAC1_RGMII_SPEED)
		rk_clrsetreg(&cru->clksel_con[33],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_RGMII << RMII0_MODE_SHIFT);
	else if (parent->id == SCLK_GMAC1_RMII_SPEED)
		rk_clrsetreg(&cru->clksel_con[33],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_RMII << RMII0_MODE_SHIFT);
	else
		rk_clrsetreg(&cru->clksel_con[33],
			     RMII0_MODE_MASK,
			     RMII0_MODE_SEL_GMII << RMII0_MODE_SHIFT);

	return 0;
}

static int rk3568_dclk_vop_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;
	u32 con_id;

	switch (clk->id) {
	case DCLK_VOP0:
		con_id = 39;
		break;
	case DCLK_VOP1:
		con_id = 40;
		break;
	case DCLK_VOP2:
		con_id = 41;
		break;
	default:
		return -EINVAL;
	}
	if (parent->id == PLL_VPLL) {
		rk_clrsetreg(&cru->clksel_con[con_id], DCLK0_VOP_SEL_MASK,
			     DCLK_VOP_SEL_VPLL << DCLK0_VOP_SEL_SHIFT);
	} else if (parent->id == PLL_HPLL) {
		rk_clrsetreg(&cru->clksel_con[con_id], DCLK0_VOP_SEL_MASK,
			     DCLK_VOP_SEL_HPLL << DCLK0_VOP_SEL_SHIFT);
	} else if (parent->id == PLL_CPLL) {
		rk_clrsetreg(&cru->clksel_con[con_id], DCLK0_VOP_SEL_MASK,
			     DCLK_VOP_SEL_CPLL << DCLK0_VOP_SEL_SHIFT);
	} else {
		rk_clrsetreg(&cru->clksel_con[con_id], DCLK0_VOP_SEL_MASK,
			     DCLK_VOP_SEL_GPLL << DCLK0_VOP_SEL_SHIFT);
	}

	return 0;
}

static int rk3568_rkvdec_set_parent(struct clk *clk, struct clk *parent)
{
	struct rk3568_clk_priv *priv = dev_get_priv(clk->dev);
	struct rk3568_cru *cru = priv->cru;
	u32 con_id, mask, shift;

	switch (clk->id) {
	case ACLK_RKVDEC_PRE:
		con_id = 47;
		mask = ACLK_RKVDEC_SEL_MASK;
		shift = ACLK_RKVDEC_SEL_SHIFT;
		break;
	case CLK_RKVDEC_CORE:
		con_id = 49;
		mask = CLK_RKVDEC_CORE_SEL_MASK;
		shift = CLK_RKVDEC_CORE_SEL_SHIFT;
		break;
	default:
		return -EINVAL;
	}
	if (parent->id == PLL_CPLL) {
		rk_clrsetreg(&cru->clksel_con[con_id], mask,
			     ACLK_RKVDEC_SEL_CPLL << shift);
	} else {
		rk_clrsetreg(&cru->clksel_con[con_id], mask,
			     ACLK_RKVDEC_SEL_GPLL << shift);
	}

	return 0;
}

static int rk3568_clk_set_parent(struct clk *clk, struct clk *parent)
{
	switch (clk->id) {
	case SCLK_GMAC0:
		return rk3568_gmac0_src_set_parent(clk, parent);
	case SCLK_GMAC1:
		return rk3568_gmac1_src_set_parent(clk, parent);
	case SCLK_GMAC0_RX_TX:
		return rk3568_gmac0_tx_rx_set_parent(clk, parent);
	case SCLK_GMAC1_RX_TX:
		return rk3568_gmac1_tx_rx_set_parent(clk, parent);
	case DCLK_VOP0:
	case DCLK_VOP1:
	case DCLK_VOP2:
		return rk3568_dclk_vop_set_parent(clk, parent);
	case ACLK_RKVDEC_PRE:
	case CLK_RKVDEC_CORE:
		return rk3568_rkvdec_set_parent(clk, parent);
	case I2S1_MCLKOUT_TX:
	case SCLK_GMAC0_RGMII_SPEED:
	case SCLK_GMAC0_RMII_SPEED:
	case SCLK_GMAC1_RGMII_SPEED:
	case SCLK_GMAC1_RMII_SPEED:
		break;
	default:
		return -ENOENT;
	}

	return 0;
}
#endif

static struct clk_ops rk3568_clk_ops = {
	.get_rate = rk3568_clk_get_rate,
	.set_rate = rk3568_clk_set_rate,
#if (IS_ENABLED(OF_CONTROL)) || (!IS_ENABLED(OF_PLATDATA))
	.set_parent = rk3568_clk_set_parent,
#endif
};

static void rk3568_clk_init(struct rk3568_clk_priv *priv)
{
	int ret;

	priv->sync_kernel = false;
	if (!priv->armclk_enter_hz) {
		priv->armclk_enter_hz =
			rockchip_pll_get_rate(&rk3568_pll_clks[APLL],
					      priv->cru, APLL);
		priv->armclk_init_hz = priv->armclk_enter_hz;
	}

	if (priv->armclk_init_hz != APLL_HZ) {
		ret = rk3568_armclk_set_clk(priv, APLL_HZ);
		if (!ret)
			priv->armclk_init_hz = APLL_HZ;
	}
	if (priv->cpll_hz != CPLL_HZ) {
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[CPLL], priv->cru,
					    CPLL, CPLL_HZ);
		if (!ret)
			priv->cpll_hz = CPLL_HZ;
	}
	if (priv->gpll_hz != GPLL_HZ) {
		ret = rockchip_pll_set_rate(&rk3568_pll_clks[GPLL], priv->cru,
					    GPLL, GPLL_HZ);
		if (!ret)
			priv->gpll_hz = GPLL_HZ;
	}

#ifdef CONFIG_SPL_BUILD
	ret = rk3568_bus_set_clk(priv, ACLK_BUS, 150000000);
	if (ret < 0)
		printf("Fail to set the ACLK_BUS clock.\n");
#endif

	priv->ppll_hz = rk3568_pmu_pll_get_rate(priv, PPLL);
	priv->hpll_hz = rk3568_pmu_pll_get_rate(priv, HPLL);
}

static int rk3568_clk_probe(struct udevice *dev)
{
	struct rk3568_clk_priv *priv = dev_get_priv(dev);
	int ret;

	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
	if (IS_ERR(priv->grf))
		return PTR_ERR(priv->grf);

	rk3568_clk_init(priv);

	/* Process 'assigned-{clocks/clock-parents/clock-rates}' properties */
	ret = clk_set_defaults(dev, 1);
	if (ret)
		debug("%s clk_set_defaults failed %d\n", __func__, ret);
	else
		priv->sync_kernel = true;

	return 0;
}

static int rk3568_clk_ofdata_to_platdata(struct udevice *dev)
{
	struct rk3568_clk_priv *priv = dev_get_priv(dev);

	priv->cru = dev_read_addr_ptr(dev);

	return 0;
}

static int rk3568_clk_bind(struct udevice *dev)
{
	int ret;
	struct udevice *sys_child;
	struct sysreset_reg *priv;

	/* The reset driver does not have a device node, so bind it here */
	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
				 &sys_child);
	if (ret) {
		debug("Warning: No sysreset driver: ret=%d\n", ret);
	} else {
		priv = malloc(sizeof(struct sysreset_reg));
		priv->glb_srst_fst_value = offsetof(struct rk3568_cru,
						    glb_srst_fst);
		priv->glb_srst_snd_value = offsetof(struct rk3568_cru,
						    glb_srsr_snd);
		dev_set_priv(sys_child, priv);
	}

#if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
	ret = offsetof(struct rk3568_cru, softrst_con[0]);
	ret = rockchip_reset_bind(dev, ret, 30);
	if (ret)
		debug("Warning: software reset driver bind failed\n");
#endif

	return 0;
}

static const struct udevice_id rk3568_clk_ids[] = {
	{ .compatible = "rockchip,rk3568-cru" },
	{ }
};

U_BOOT_DRIVER(rockchip_rk3568_cru) = {
	.name		= "rockchip_rk3568_cru",
	.id		= UCLASS_CLK,
	.of_match	= rk3568_clk_ids,
	.priv_auto = sizeof(struct rk3568_clk_priv),
	.of_to_plat = rk3568_clk_ofdata_to_platdata,
	.ops		= &rk3568_clk_ops,
	.bind		= rk3568_clk_bind,
	.probe		= rk3568_clk_probe,
#if CONFIG_IS_ENABLED(OF_PLATDATA)
	.plat_auto	= sizeof(struct rk3568_clk_plat),
#endif
};
