Skip to content

Commit 78e7f7d

Browse files
Frank Oltmannswens
authored andcommitted
clk: sunxi-ng: mux: Support finding closest rate
When finding the best rate for a mux clock, consider rates that are higher than the requested rate when CCU_FEATURE_ROUND_CLOSEST is used. Furthermore, introduce an initialization macro that sets this flag. Acked-by: Maxime Ripard <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Signed-off-by: Frank Oltmanns <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Chen-Yu Tsai <[email protected]>
1 parent 088cefc commit 78e7f7d

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

drivers/clk/sunxi-ng/ccu_mux.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,17 @@ static int ccu_mux_set_parent(struct clk_hw *hw, u8 index)
242242
return ccu_mux_helper_set_parent(&cm->common, &cm->mux, index);
243243
}
244244

245+
static int ccu_mux_determine_rate(struct clk_hw *hw,
246+
struct clk_rate_request *req)
247+
{
248+
struct ccu_mux *cm = hw_to_ccu_mux(hw);
249+
250+
if (cm->common.features & CCU_FEATURE_CLOSEST_RATE)
251+
return clk_mux_determine_rate_flags(hw, req, CLK_MUX_ROUND_CLOSEST);
252+
253+
return clk_mux_determine_rate_flags(hw, req, 0);
254+
}
255+
245256
static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw,
246257
unsigned long parent_rate)
247258
{
@@ -259,7 +270,7 @@ const struct clk_ops ccu_mux_ops = {
259270
.get_parent = ccu_mux_get_parent,
260271
.set_parent = ccu_mux_set_parent,
261272

262-
.determine_rate = __clk_mux_determine_rate,
273+
.determine_rate = ccu_mux_determine_rate,
263274
.recalc_rate = ccu_mux_recalc_rate,
264275
};
265276
EXPORT_SYMBOL_NS_GPL(ccu_mux_ops, SUNXI_CCU);

drivers/clk/sunxi-ng/ccu_mux.h

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,36 @@ struct ccu_mux {
4646
struct ccu_common common;
4747
};
4848

49+
#define SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, _table, \
50+
_reg, _shift, _width, _gate, \
51+
_flags, _features) \
52+
struct ccu_mux _struct = { \
53+
.enable = _gate, \
54+
.mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \
55+
.common = { \
56+
.reg = _reg, \
57+
.hw.init = CLK_HW_INIT_PARENTS(_name, \
58+
_parents, \
59+
&ccu_mux_ops, \
60+
_flags), \
61+
.features = _features, \
62+
} \
63+
}
64+
65+
#define SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(_struct, _name, _parents, \
66+
_table, _reg, _shift, \
67+
_width, _gate, _flags) \
68+
SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, \
69+
_table, _reg, _shift, \
70+
_width, _gate, _flags, \
71+
CCU_FEATURE_CLOSEST_RATE)
72+
4973
#define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table, \
5074
_reg, _shift, _width, _gate, \
5175
_flags) \
52-
struct ccu_mux _struct = { \
53-
.enable = _gate, \
54-
.mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \
55-
.common = { \
56-
.reg = _reg, \
57-
.hw.init = CLK_HW_INIT_PARENTS(_name, \
58-
_parents, \
59-
&ccu_mux_ops, \
60-
_flags), \
61-
} \
62-
}
76+
SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, \
77+
_table, _reg, _shift, \
78+
_width, _gate, _flags, 0)
6379

6480
#define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \
6581
_shift, _width, _gate, _flags) \

0 commit comments

Comments
 (0)