aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2013-04-02 18:36:56 -0400
committerMike Turquette <mturquette@linaro.org>2013-04-03 15:56:30 -0400
commit056b205316cc3dcf8a67cf813a26ff8a72bf3cb9 (patch)
tree3d98f8d116d5e7541cf41eec72847b2d3673324a
parentf640c0fad698c0e4b07e05373681d3681125d6af (diff)
clk: divider: Introduce CLK_DIVIDER_ALLOW_ZERO flag
Dividers which have CLK_DIVIDER_ONE_BASED set have a redundant state, being a divider value of zero. Some hardware implementations allow a zero divider which simply doesn't alter the frequency. I.e. it acts like a divide by one or bypassing the divider. This flag is used to handle such HW in the clk-divider model. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/clk-divider.c5
-rw-r--r--include/linux/clk-provider.h8
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 68b402101170..6d9674160430 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -109,8 +109,9 @@ static unsigned long clk_divider_recalc_rate(struct clk_hw *hw,
109 109
110 div = _get_div(divider, val); 110 div = _get_div(divider, val);
111 if (!div) { 111 if (!div) {
112 WARN(1, "%s: Invalid divisor for clock %s\n", __func__, 112 WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO),
113 __clk_get_name(hw->clk)); 113 "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
114 __clk_get_name(hw->clk));
114 return parent_rate; 115 return parent_rate;
115 } 116 }
116 117
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index b1675074fe7c..9fdfae74d669 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -249,9 +249,14 @@ struct clk_div_table {
249 * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the 249 * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the
250 * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is 250 * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is
251 * the raw value read from the register, with the value of zero considered 251 * the raw value read from the register, with the value of zero considered
252 * invalid 252 * invalid, unless CLK_DIVIDER_ALLOW_ZERO is set.
253 * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from 253 * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from
254 * the hardware register 254 * the hardware register
255 * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors. For dividers which have
256 * CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero divisor.
257 * Some hardware implementations gracefully handle this case and allow a
258 * zero divisor by not modifying their input clock
259 * (divide by one / bypass).
255 */ 260 */
256struct clk_divider { 261struct clk_divider {
257 struct clk_hw hw; 262 struct clk_hw hw;
@@ -265,6 +270,7 @@ struct clk_divider {
265 270
266#define CLK_DIVIDER_ONE_BASED BIT(0) 271#define CLK_DIVIDER_ONE_BASED BIT(0)
267#define CLK_DIVIDER_POWER_OF_TWO BIT(1) 272#define CLK_DIVIDER_POWER_OF_TWO BIT(1)
273#define CLK_DIVIDER_ALLOW_ZERO BIT(2)
268 274
269extern const struct clk_ops clk_divider_ops; 275extern const struct clk_ops clk_divider_ops;
270struct clk *clk_register_divider(struct device *dev, const char *name, 276struct clk *clk_register_divider(struct device *dev, const char *name,