aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clk-provider.h
diff options
context:
space:
mode:
authorBoris BREZILLON <b.brezillon@overkiz.com>2013-12-21 04:34:47 -0500
committerMike Turquette <mturquette@linaro.org>2013-12-23 02:14:27 -0500
commit5279fc402ae59361a224d641d5823b21b4206232 (patch)
tree0d6ab9695d994cedc85c32b08f6e8d211acf4207 /include/linux/clk-provider.h
parente8ab2f11bb8fa73280ce7d0fca3c22be456437df (diff)
clk: add clk accuracy retrieval support
The clock accuracy is expressed in ppb (parts per billion) and represents the possible clock drift. Say you have a clock (e.g. an oscillator) which provides a fixed clock of 20MHz with an accuracy of +- 20Hz. This accuracy expressed in ppb is 20Hz/20MHz = 1000 ppb (or 1 ppm). Clock users may need the clock accuracy information in order to choose the best clock (the one with the best accuracy) across several available clocks. This patch adds clk accuracy retrieval support for common clk framework by means of a new function called clk_get_accuracy. This function returns the given clock accuracy expressed in ppb. In order to get the clock accuracy, this implementation adds one callback called recalc_accuracy to the clk_ops structure. This callback is given the parent clock accuracy (if the clock is not a root clock) and should recalculate the given clock accuracy. This callback is optional and may be implemented if the clock is not a perfect clock (accuracy != 0 ppb). Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'include/linux/clk-provider.h')
-rw-r--r--include/linux/clk-provider.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 7e59253b8603..16d182c28ce6 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -29,6 +29,7 @@
29#define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */ 29#define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */
30#define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ 30#define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */
31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ 31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */
32#define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */
32 33
33struct clk_hw; 34struct clk_hw;
34 35
@@ -108,6 +109,13 @@ struct clk_hw;
108 * which is likely helpful for most .set_rate implementation. 109 * which is likely helpful for most .set_rate implementation.
109 * Returns 0 on success, -EERROR otherwise. 110 * Returns 0 on success, -EERROR otherwise.
110 * 111 *
112 * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy
113 * is expressed in ppb (parts per billion). The parent accuracy is
114 * an input parameter.
115 * Returns the calculated accuracy. Optional - if this op is not
116 * set then clock accuracy will be initialized to parent accuracy
117 * or 0 (perfect clock) if clock has no parent.
118 *
111 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow 119 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow
112 * implementations to split any work between atomic (enable) and sleepable 120 * implementations to split any work between atomic (enable) and sleepable
113 * (prepare) contexts. If enabling a clock requires code that might sleep, 121 * (prepare) contexts. If enabling a clock requires code that might sleep,
@@ -139,6 +147,8 @@ struct clk_ops {
139 u8 (*get_parent)(struct clk_hw *hw); 147 u8 (*get_parent)(struct clk_hw *hw);
140 int (*set_rate)(struct clk_hw *hw, unsigned long, 148 int (*set_rate)(struct clk_hw *hw, unsigned long,
141 unsigned long); 149 unsigned long);
150 unsigned long (*recalc_accuracy)(struct clk_hw *hw,
151 unsigned long parent_accuracy);
142 void (*init)(struct clk_hw *hw); 152 void (*init)(struct clk_hw *hw);
143}; 153};
144 154
@@ -433,6 +443,7 @@ struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
433unsigned int __clk_get_enable_count(struct clk *clk); 443unsigned int __clk_get_enable_count(struct clk *clk);
434unsigned int __clk_get_prepare_count(struct clk *clk); 444unsigned int __clk_get_prepare_count(struct clk *clk);
435unsigned long __clk_get_rate(struct clk *clk); 445unsigned long __clk_get_rate(struct clk *clk);
446unsigned long __clk_get_accuracy(struct clk *clk);
436unsigned long __clk_get_flags(struct clk *clk); 447unsigned long __clk_get_flags(struct clk *clk);
437bool __clk_is_prepared(struct clk *clk); 448bool __clk_is_prepared(struct clk *clk);
438bool __clk_is_enabled(struct clk *clk); 449bool __clk_is_enabled(struct clk *clk);