clk: renesas: rzv2h: Support static dividers without RMW
authorBiju Das <biju.das.jz@bp.renesas.com>
Mon, 7 Apr 2025 16:51:56 +0000 (17:51 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 22 Apr 2025 09:27:12 +0000 (11:27 +0200)
Add support for static dividers that do not require read-modify-write
(RMW) operations.  This enables the use of the generic clk_divider_ops
instead of the custom RMW-based implementation.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Co-developed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/20250407165202.197570-4-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
drivers/clk/renesas/rzv2h-cpg.c
drivers/clk/renesas/rzv2h-cpg.h

index eefa31c162d4f3720492cfaee7f13477dd759b4e..020f30fb3d8da8ec1de4ca39ce1e76ffbd3bb7f9 100644 (file)
@@ -374,7 +374,10 @@ rzv2h_cpg_ddiv_clk_register(const struct cpg_core_clk *core,
                return ERR_PTR(-ENOMEM);
 
        init.name = core->name;
-       init.ops = &rzv2h_ddiv_clk_divider_ops;
+       if (cfg_ddiv.no_rmw)
+               init.ops = &clk_divider_ops;
+       else
+               init.ops = &rzv2h_ddiv_clk_divider_ops;
        init.parent_names = &parent_name;
        init.num_parents = 1;
 
index 5e9295d31093d8cab705dd0a88e1e7f511b92d2f..449f8c82e8fbd4993f9f0d6471a140fb4daa60aa 100644 (file)
@@ -37,12 +37,15 @@ struct pll {
  * @shift: position of the divider bit
  * @width: width of the divider
  * @monbit: monitor bit in CPG_CLKSTATUS0 register
+ * @no_rmw: flag to indicate if the register is read-modify-write
+ *        (1: no RMW, 0: RMW)
  */
 struct ddiv {
        unsigned int offset:11;
        unsigned int shift:4;
        unsigned int width:4;
        unsigned int monbit:5;
+       unsigned int no_rmw:1;
 };
 
 /*
@@ -61,6 +64,15 @@ struct ddiv {
                .monbit = _monbit \
        })
 
+#define DDIV_PACK_NO_RMW(_offset, _shift, _width, _monbit) \
+       ((struct ddiv){ \
+               .offset = (_offset), \
+               .shift = (_shift), \
+               .width = (_width), \
+               .monbit = (_monbit), \
+               .no_rmw = 1 \
+       })
+
 /**
  * struct smuxed - Structure for static muxed clocks
  *