]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: sunxi-ng: div: support power-of-two dividers
authorChen-Yu Tsai <wens@csie.org>
Thu, 11 Sep 2025 17:47:07 +0000 (01:47 +0800)
committerChen-Yu Tsai <wens@csie.org>
Sat, 13 Sep 2025 05:50:52 +0000 (13:50 +0800)
Some clocks (for timers) on the A523 are mux-divider-gate types
with the divider being values of power-of-two.

Add a macro for these types of clocks so that we can use the divider
types instead of the M-P types without an M divider.

Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20250911174710.3149589-5-wens@kernel.org
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
drivers/clk/sunxi-ng/ccu_div.h

index 90d49ee8e0cc8ddccc468ec5c855cd404ed9d06a..be00b3277e976fb05e30045adb3070f0d6a43d18 100644 (file)
@@ -274,6 +274,24 @@ struct ccu_div {
        SUNXI_CCU_M_HWS_WITH_GATE(_struct, _name, _parent, _reg,        \
                                  _mshift, _mwidth, 0, _flags)
 
+#define SUNXI_CCU_P_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
+                                      _mshift, _mwidth,                \
+                                      _muxshift, _muxwidth,            \
+                                      _gate, _flags)                   \
+       struct ccu_div _struct = {                                      \
+               .enable = _gate,                                        \
+               .div    = _SUNXI_CCU_DIV_FLAGS(_mshift, _mwidth,        \
+                                              CLK_DIVIDER_POWER_OF_TWO), \
+               .mux    = _SUNXI_CCU_MUX(_muxshift, _muxwidth),         \
+               .common = {                                             \
+                       .reg            = _reg,                         \
+                       .hw.init        = CLK_HW_INIT_PARENTS_DATA(_name, \
+                                                                  _parents, \
+                                                                  &ccu_div_ops, \
+                                                                  _flags), \
+               },                                                      \
+       }
+
 static inline struct ccu_div *hw_to_ccu_div(struct clk_hw *hw)
 {
        struct ccu_common *common = hw_to_ccu_common(hw);