summaryrefslogtreecommitdiffstats
path: root/include/linux/clk-provider.h
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2015-07-07 14:48:08 -0400
committerStephen Boyd <sboyd@codeaurora.org>2015-07-27 21:12:01 -0400
commit0817b62cc037a56c5e4238c7eb7522299ea27aef (patch)
treee49a8eaceb710fd2873c93c86ef71bf4ff502902 /include/linux/clk-provider.h
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
clk: change clk_ops' ->determine_rate() prototype
Clock rates are stored in an unsigned long field, but ->determine_rate() (which returns a rounded rate from a requested one) returns a long value (errors are reported using negative error codes), which can lead to long overflow if the clock rate exceed 2Ghz. Change ->determine_rate() prototype to return 0 or an error code, and pass a pointer to a clk_rate_request structure containing the expected target rate and the rate constraints imposed by clk users. The clk_rate_request structure might be extended in the future to contain other kind of constraints like the rounding policy, the maximum clock inaccuracy or other things that are not yet supported by the CCF (power consumption constraints ?). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> CC: Jonathan Corbet <corbet@lwn.net> CC: Tony Lindgren <tony@atomide.com> CC: Ralf Baechle <ralf@linux-mips.org> CC: "Emilio López" <emilio@elopez.com.ar> CC: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Tero Kristo <t-kristo@ti.com> CC: Peter De Schrijver <pdeschrijver@nvidia.com> CC: Prashant Gaikwad <pgaikwad@nvidia.com> CC: Stephen Warren <swarren@wwwdotorg.org> CC: Thierry Reding <thierry.reding@gmail.com> CC: Alexandre Courbot <gnurou@gmail.com> CC: linux-doc@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org CC: linux-omap@vger.kernel.org CC: linux-mips@linux-mips.org CC: linux-tegra@vger.kernel.org [sboyd@codeaurora.org: Fix parent dereference problem in __clk_determine_rate()] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Tested-by: Romain Perier <romain.perier@gmail.com> Signed-off-by: Heiko Stuebner <heiko@sntech.de> [sboyd@codeaurora.org: Folded in fix from Heiko for fixed-rate clocks without parents or a rate determining op] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'include/linux/clk-provider.h')
-rw-r--r--include/linux/clk-provider.h49
1 files changed, 29 insertions, 20 deletions
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 78842f46f152..14998f05acf2 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -38,6 +38,28 @@ struct clk_core;
38struct dentry; 38struct dentry;
39 39
40/** 40/**
41 * struct clk_rate_request - Structure encoding the clk constraints that
42 * a clock user might require.
43 *
44 * @rate: Requested clock rate. This field will be adjusted by
45 * clock drivers according to hardware capabilities.
46 * @min_rate: Minimum rate imposed by clk users.
47 * @max_rate: Maximum rate a imposed by clk users.
48 * @best_parent_rate: The best parent rate a parent can provide to fulfill the
49 * requested constraints.
50 * @best_parent_hw: The most appropriate parent clock that fulfills the
51 * requested constraints.
52 *
53 */
54struct clk_rate_request {
55 unsigned long rate;
56 unsigned long min_rate;
57 unsigned long max_rate;
58 unsigned long best_parent_rate;
59 struct clk_hw *best_parent_hw;
60};
61
62/**
41 * struct clk_ops - Callback operations for hardware clocks; these are to 63 * struct clk_ops - Callback operations for hardware clocks; these are to
42 * be provided by the clock implementation, and will be called by drivers 64 * be provided by the clock implementation, and will be called by drivers
43 * through the clk_* api. 65 * through the clk_* api.
@@ -176,12 +198,8 @@ struct clk_ops {
176 unsigned long parent_rate); 198 unsigned long parent_rate);
177 long (*round_rate)(struct clk_hw *hw, unsigned long rate, 199 long (*round_rate)(struct clk_hw *hw, unsigned long rate,
178 unsigned long *parent_rate); 200 unsigned long *parent_rate);
179 long (*determine_rate)(struct clk_hw *hw, 201 int (*determine_rate)(struct clk_hw *hw,
180 unsigned long rate, 202 struct clk_rate_request *req);
181 unsigned long min_rate,
182 unsigned long max_rate,
183 unsigned long *best_parent_rate,
184 struct clk_hw **best_parent_hw);
185 int (*set_parent)(struct clk_hw *hw, u8 index); 203 int (*set_parent)(struct clk_hw *hw, u8 index);
186 u8 (*get_parent)(struct clk_hw *hw); 204 u8 (*get_parent)(struct clk_hw *hw);
187 int (*set_rate)(struct clk_hw *hw, unsigned long rate, 205 int (*set_rate)(struct clk_hw *hw, unsigned long rate,
@@ -578,20 +596,11 @@ unsigned long __clk_get_flags(struct clk *clk);
578bool __clk_is_prepared(struct clk *clk); 596bool __clk_is_prepared(struct clk *clk);
579bool __clk_is_enabled(struct clk *clk); 597bool __clk_is_enabled(struct clk *clk);
580struct clk *__clk_lookup(const char *name); 598struct clk *__clk_lookup(const char *name);
581long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, 599int __clk_mux_determine_rate(struct clk_hw *hw,
582 unsigned long min_rate, 600 struct clk_rate_request *req);
583 unsigned long max_rate, 601int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req);
584 unsigned long *best_parent_rate, 602int __clk_mux_determine_rate_closest(struct clk_hw *hw,
585 struct clk_hw **best_parent_p); 603 struct clk_rate_request *req);
586unsigned long __clk_determine_rate(struct clk_hw *core,
587 unsigned long rate,
588 unsigned long min_rate,
589 unsigned long max_rate);
590long __clk_mux_determine_rate_closest(struct clk_hw *hw, unsigned long rate,
591 unsigned long min_rate,
592 unsigned long max_rate,
593 unsigned long *best_parent_rate,
594 struct clk_hw **best_parent_p);
595void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent); 604void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
596 605
597static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src) 606static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src)