Unverified Commit a8e5433c authored by Jernej Skrabec's avatar Jernej Skrabec Committed by Maxime Ripard
Browse files

clk: sunxi-ng: nkmp: Add constraint for maximum rate



Some, if not most, NKMP PLLs can be set to higher rate that is really
supported by HW.

Implement support for maximum frequency constrain for NKMP PLLs.

Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
parent b16fb669
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -137,6 +137,13 @@ static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,
	if (nkmp->common.features & CCU_FEATURE_FIXED_POSTDIV)
		rate *= nkmp->fixed_post_div;

	if (nkmp->max_rate && rate > nkmp->max_rate) {
		rate = nkmp->max_rate;
		if (nkmp->common.features & CCU_FEATURE_FIXED_POSTDIV)
			rate /= nkmp->fixed_post_div;
		return rate;
	}

	_nkmp.min_n = nkmp->n.min ?: 1;
	_nkmp.max_n = nkmp->n.max ?: 1 << nkmp->n.width;
	_nkmp.min_k = nkmp->k.min ?: 1;
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ struct ccu_nkmp {
	struct ccu_div_internal		p;

	unsigned int		fixed_post_div;
	unsigned int		max_rate;

	struct ccu_common	common;
};