Skip to content

Commit a8943f7

Browse files
prabhakarladgeertu
authored andcommitted
clk: renesas: rzv2h: Use GENMASK for PLL fields
Replace the older FIELD_GET-wrapping helper macros with plain GENMASK definitions for the PLL CLK1/CLK2 field masks (CPG_PLL_CLK1_KDIV, CPG_PLL_CLK1_MDIV, CPG_PLL_CLK1_PDIV and CPG_PLL_CLK2_SDIV). Update rzv2h_cpg_pll_clk_recalc_rate() to explicitly extract those fields with FIELD_GET and cast the KDIV extraction to s16 to ensure proper sign extension when computing the PLL output rate. Co-developed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Acked-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/20251015192611.241920-3-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 36a2390 commit a8943f7

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

drivers/clk/renesas/rzv2h-cpg.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
#define CPG_PLL_STBY_RESETB BIT(0)
5050
#define CPG_PLL_STBY_RESETB_WEN BIT(16)
5151
#define CPG_PLL_CLK1(x) ((x) + 0x004)
52-
#define CPG_PLL_CLK1_KDIV(x) ((s16)FIELD_GET(GENMASK(31, 16), (x)))
53-
#define CPG_PLL_CLK1_MDIV(x) FIELD_GET(GENMASK(15, 6), (x))
54-
#define CPG_PLL_CLK1_PDIV(x) FIELD_GET(GENMASK(5, 0), (x))
52+
#define CPG_PLL_CLK1_KDIV GENMASK(31, 16)
53+
#define CPG_PLL_CLK1_MDIV GENMASK(15, 6)
54+
#define CPG_PLL_CLK1_PDIV GENMASK(5, 0)
5555
#define CPG_PLL_CLK2(x) ((x) + 0x008)
56-
#define CPG_PLL_CLK2_SDIV(x) FIELD_GET(GENMASK(2, 0), (x))
56+
#define CPG_PLL_CLK2_SDIV GENMASK(2, 0)
5757
#define CPG_PLL_MON(x) ((x) + 0x010)
5858
#define CPG_PLL_MON_RESETB BIT(0)
5959
#define CPG_PLL_MON_LOCK BIT(4)
@@ -231,10 +231,11 @@ static unsigned long rzv2h_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
231231
clk1 = readl(priv->base + CPG_PLL_CLK1(pll.offset));
232232
clk2 = readl(priv->base + CPG_PLL_CLK2(pll.offset));
233233

234-
rate = mul_u64_u32_shr(parent_rate, (CPG_PLL_CLK1_MDIV(clk1) << 16) +
235-
CPG_PLL_CLK1_KDIV(clk1), 16 + CPG_PLL_CLK2_SDIV(clk2));
234+
rate = mul_u64_u32_shr(parent_rate, (FIELD_GET(CPG_PLL_CLK1_MDIV, clk1) << 16) +
235+
(s16)FIELD_GET(CPG_PLL_CLK1_KDIV, clk1),
236+
16 + FIELD_GET(CPG_PLL_CLK2_SDIV, clk2));
236237

237-
return DIV_ROUND_CLOSEST_ULL(rate, CPG_PLL_CLK1_PDIV(clk1));
238+
return DIV_ROUND_CLOSEST_ULL(rate, FIELD_GET(CPG_PLL_CLK1_PDIV, clk1));
238239
}
239240

240241
static const struct clk_ops rzv2h_cpg_pll_ops = {

0 commit comments

Comments
 (0)