diff options
author | Jernej Skrabec <jernej.skrabec@siol.net> | 2018-08-09 12:52:13 -0400 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@bootlin.com> | 2018-08-27 03:18:01 -0400 |
commit | cb54fbd21a8fd97c2a82a069e8c80abdedbeb530 (patch) | |
tree | 90a2ebc3f6afe2e5b550b65765b8b8cb1adfa5b2 | |
parent | 58c0f79887d5e425fe6a9fd542778e50df69e9c6 (diff) |
clk: sunxi-ng: Add maximum rate constraint to NM PLLs
On some NM PLLs, frequency can be set above PLL working range.
Add a constraint for maximum supported rate. This way, drivers can
specify which is maximum allowed rate for PLL.
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_nm.c | 7 | ||||
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_nm.h | 30 |
2 files changed, 37 insertions, 0 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c index 4e2073307f34..6fe3c14f7b2d 100644 --- a/drivers/clk/sunxi-ng/ccu_nm.c +++ b/drivers/clk/sunxi-ng/ccu_nm.c | |||
@@ -124,6 +124,13 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate, | |||
124 | return rate; | 124 | return rate; |
125 | } | 125 | } |
126 | 126 | ||
127 | if (nm->max_rate && rate > nm->max_rate) { | ||
128 | rate = nm->max_rate; | ||
129 | if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) | ||
130 | rate /= nm->fixed_post_div; | ||
131 | return rate; | ||
132 | } | ||
133 | |||
127 | if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) { | 134 | if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) { |
128 | if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) | 135 | if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) |
129 | rate /= nm->fixed_post_div; | 136 | rate /= nm->fixed_post_div; |
diff --git a/drivers/clk/sunxi-ng/ccu_nm.h b/drivers/clk/sunxi-ng/ccu_nm.h index 1d8b459c50b7..de232f2199a6 100644 --- a/drivers/clk/sunxi-ng/ccu_nm.h +++ b/drivers/clk/sunxi-ng/ccu_nm.h | |||
@@ -38,6 +38,7 @@ struct ccu_nm { | |||
38 | 38 | ||
39 | unsigned int fixed_post_div; | 39 | unsigned int fixed_post_div; |
40 | unsigned int min_rate; | 40 | unsigned int min_rate; |
41 | unsigned int max_rate; | ||
41 | 42 | ||
42 | struct ccu_common common; | 43 | struct ccu_common common; |
43 | }; | 44 | }; |
@@ -115,6 +116,35 @@ struct ccu_nm { | |||
115 | }, \ | 116 | }, \ |
116 | } | 117 | } |
117 | 118 | ||
119 | #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(_struct, _name, \ | ||
120 | _parent, _reg, \ | ||
121 | _min_rate, _max_rate, \ | ||
122 | _nshift, _nwidth, \ | ||
123 | _mshift, _mwidth, \ | ||
124 | _frac_en, _frac_sel, \ | ||
125 | _frac_rate_0, \ | ||
126 | _frac_rate_1, \ | ||
127 | _gate, _lock, _flags) \ | ||
128 | struct ccu_nm _struct = { \ | ||
129 | .enable = _gate, \ | ||
130 | .lock = _lock, \ | ||
131 | .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \ | ||
132 | .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \ | ||
133 | .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \ | ||
134 | _frac_rate_0, \ | ||
135 | _frac_rate_1), \ | ||
136 | .min_rate = _min_rate, \ | ||
137 | .max_rate = _max_rate, \ | ||
138 | .common = { \ | ||
139 | .reg = _reg, \ | ||
140 | .features = CCU_FEATURE_FRACTIONAL, \ | ||
141 | .hw.init = CLK_HW_INIT(_name, \ | ||
142 | _parent, \ | ||
143 | &ccu_nm_ops, \ | ||
144 | _flags), \ | ||
145 | }, \ | ||
146 | } | ||
147 | |||
118 | #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ | 148 | #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ |
119 | _nshift, _nwidth, \ | 149 | _nshift, _nwidth, \ |
120 | _mshift, _mwidth, \ | 150 | _mshift, _mwidth, \ |