Skip to content

Commit 2d2b61c

Browse files
jernejskmripard
authored andcommitted
clk: sunxi-ng: Add check for minimal rate to NM PLLs
Some NM PLLs doesn't work well when their output clock rate is set below certain rate. Add support for that constrain. Signed-off-by: Jernej Skrabec <[email protected]> Signed-off-by: Maxime Ripard <[email protected]>
1 parent a5ebc33 commit 2d2b61c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/clk/sunxi-ng/ccu_nm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
117117
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
118118
rate *= nm->fixed_post_div;
119119

120+
if (rate < nm->min_rate) {
121+
rate = nm->min_rate;
122+
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
123+
rate /= nm->fixed_post_div;
124+
return rate;
125+
}
126+
120127
if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
121128
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
122129
rate /= nm->fixed_post_div;

drivers/clk/sunxi-ng/ccu_nm.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct ccu_nm {
3737
struct ccu_sdm_internal sdm;
3838

3939
unsigned int fixed_post_div;
40+
unsigned int min_rate;
4041

4142
struct ccu_common common;
4243
};
@@ -88,6 +89,32 @@ struct ccu_nm {
8889
}, \
8990
}
9091

92+
#define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(_struct, _name, _parent, \
93+
_reg, _min_rate, \
94+
_nshift, _nwidth, \
95+
_mshift, _mwidth, \
96+
_frac_en, _frac_sel, \
97+
_frac_rate_0, _frac_rate_1,\
98+
_gate, _lock, _flags) \
99+
struct ccu_nm _struct = { \
100+
.enable = _gate, \
101+
.lock = _lock, \
102+
.n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
103+
.m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
104+
.frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
105+
_frac_rate_0, \
106+
_frac_rate_1), \
107+
.min_rate = _min_rate, \
108+
.common = { \
109+
.reg = _reg, \
110+
.features = CCU_FEATURE_FRACTIONAL, \
111+
.hw.init = CLK_HW_INIT(_name, \
112+
_parent, \
113+
&ccu_nm_ops, \
114+
_flags), \
115+
}, \
116+
}
117+
91118
#define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
92119
_nshift, _nwidth, \
93120
_mshift, _mwidth, \

0 commit comments

Comments
 (0)