]> git.karo-electronics.de Git - linux-beck.git/commitdiff
clk: Allow providers to configure min/max rates
authorStephen Boyd <sboyd@codeaurora.org>
Thu, 16 Jul 2015 19:50:27 +0000 (12:50 -0700)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 28 Jul 2015 18:58:50 +0000 (11:58 -0700)
clk providers are using the consumer APIs to set min/max rates on
the clock they're providing. To encourage clk providers to move
away from the consumer APIs, add a provider API to set the
min/max rate of a clock. The assumption is that this is done
before the clock can be requested via clk_get() and that the
clock rate is already within the boundaries of the min/max that's
configured.

Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/clk.c
include/linux/clk-provider.h

index bd6dfbe04cf0b109318c2f0ff45fdc575a4f796c..1ac237fe2fdbcb33301f244f34b91c7e09829a84 100644 (file)
@@ -58,6 +58,8 @@ struct clk_core {
        unsigned long           flags;
        unsigned int            enable_count;
        unsigned int            prepare_count;
+       unsigned long           min_rate;
+       unsigned long           max_rate;
        unsigned long           accuracy;
        int                     phase;
        struct hlist_head       children;
@@ -512,8 +514,8 @@ static void clk_core_get_boundaries(struct clk_core *core,
 {
        struct clk *clk_user;
 
-       *min_rate = 0;
-       *max_rate = ULONG_MAX;
+       *min_rate = core->min_rate;
+       *max_rate = core->max_rate;
 
        hlist_for_each_entry(clk_user, &core->clks, clks_node)
                *min_rate = max(*min_rate, clk_user->min_rate);
@@ -522,6 +524,14 @@ static void clk_core_get_boundaries(struct clk_core *core,
                *max_rate = min(*max_rate, clk_user->max_rate);
 }
 
+void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
+                          unsigned long max_rate)
+{
+       hw->core->min_rate = min_rate;
+       hw->core->max_rate = max_rate;
+}
+EXPORT_SYMBOL_GPL(clk_hw_set_rate_range);
+
 /*
  * Helper for finding best parent to provide a given frequency. This can be used
  * directly as a determine_rate callback (e.g. for a mux), or from a more
@@ -2498,6 +2508,8 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
        core->hw = hw;
        core->flags = hw->init->flags;
        core->num_parents = hw->init->num_parents;
+       core->min_rate = 0;
+       core->max_rate = ULONG_MAX;
        hw->core = core;
 
        /* allocate local copy in case parent_names is __initdata */
index 2116e2b8a5f22f324667eca3d3974abcb2ee4828..d62e7eab1dbefd74a3fc8130d2cd46a3240f3bd5 100644 (file)
@@ -619,6 +619,8 @@ int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req);
 int __clk_mux_determine_rate_closest(struct clk_hw *hw,
                                     struct clk_rate_request *req);
 void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
+void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
+                          unsigned long max_rate);
 
 static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src)
 {