瀏覽代碼

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: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Jernej Skrabec 7 年之前
父節點
當前提交
a8e5433cdc
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 7 0
      drivers/clk/sunxi-ng/ccu_nkmp.c
  2. 1 0
      drivers/clk/sunxi-ng/ccu_nkmp.h

+ 7 - 0
drivers/clk/sunxi-ng/ccu_nkmp.c

@@ -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
drivers/clk/sunxi-ng/ccu_nkmp.h

@@ -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;
 };