Skip to content

Commit 253795a

Browse files
Frank Oltmannswens
authored andcommitted
clk: sunxi-ng: div: Support finding closest rate
Add initalization macros for divisor clocks with mux (SUNXI_CCU_M_WITH_MUX) to support finding the closest rate. This clock type requires the appropriate flags to be set in the .common structure (for the mux part of the clock) and the .div part. Acked-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Frank Oltmanns <frank@oltmanns.dev> Link: https://lore.kernel.org/r/20230807-pll-mipi_set_rate_parent-v6-9-f173239a4b59@oltmanns.dev Signed-off-by: Chen-Yu Tsai <wens@csie.org>
1 parent 78e7f7d commit 253795a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/clk/sunxi-ng/ccu_div.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,26 @@ struct ccu_div {
143143
}, \
144144
}
145145

146+
#define SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(_struct, _name, \
147+
_parents, _table, \
148+
_reg, \
149+
_mshift, _mwidth, \
150+
_muxshift, _muxwidth, \
151+
_gate, _flags) \
152+
struct ccu_div _struct = { \
153+
.enable = _gate, \
154+
.div = _SUNXI_CCU_DIV_FLAGS(_mshift, _mwidth, CLK_DIVIDER_ROUND_CLOSEST), \
155+
.mux = _SUNXI_CCU_MUX_TABLE(_muxshift, _muxwidth, _table), \
156+
.common = { \
157+
.reg = _reg, \
158+
.hw.init = CLK_HW_INIT_PARENTS(_name, \
159+
_parents, \
160+
&ccu_div_ops, \
161+
_flags), \
162+
.features = CCU_FEATURE_CLOSEST_RATE, \
163+
}, \
164+
}
165+
146166
#define SUNXI_CCU_M_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
147167
_mshift, _mwidth, _muxshift, _muxwidth, \
148168
_gate, _flags) \
@@ -152,6 +172,16 @@ struct ccu_div {
152172
_muxshift, _muxwidth, \
153173
_gate, _flags)
154174

175+
#define SUNXI_CCU_M_WITH_MUX_GATE_CLOSEST(_struct, _name, _parents, \
176+
_reg, _mshift, _mwidth, \
177+
_muxshift, _muxwidth, \
178+
_gate, _flags) \
179+
SUNXI_CCU_M_WITH_MUX_TABLE_GATE_CLOSEST(_struct, _name, \
180+
_parents, NULL, \
181+
_reg, _mshift, _mwidth, \
182+
_muxshift, _muxwidth, \
183+
_gate, _flags)
184+
155185
#define SUNXI_CCU_M_WITH_MUX(_struct, _name, _parents, _reg, \
156186
_mshift, _mwidth, _muxshift, _muxwidth, \
157187
_flags) \

0 commit comments

Comments
 (0)