aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-04-12 08:50:18 -0400
committerMike Turquette <mturquette@linaro.org>2012-04-24 19:37:40 -0400
commit1c0035d710dd3bfa86d58f851b8737c7f11a9bbc (patch)
tree37ebd1a44c408aecf7df5331d2b5a32e81818baf
parent81536e072b54e30bbfd1a9a6b8094f7b3dd5321c (diff)
clk: pass parent_rate into .set_rate
For most of .set_rate implementation, parent_rate will be used, so just like passing parent_rate into .recalc_rate, let's pass parent_rate into .set_rate too. It also updates the kernel doc for .set_rate ops. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/clk-divider.c5
-rw-r--r--drivers/clk/clk.c2
-rw-r--r--include/linux/clk-provider.h21
3 files changed, 11 insertions, 17 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 03b127c0313b..90627e4069af 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -111,14 +111,15 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
111 return *prate / div; 111 return *prate / div;
112} 112}
113 113
114static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate) 114static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
115 unsigned long parent_rate)
115{ 116{
116 struct clk_divider *divider = to_clk_divider(hw); 117 struct clk_divider *divider = to_clk_divider(hw);
117 unsigned int div; 118 unsigned int div;
118 unsigned long flags = 0; 119 unsigned long flags = 0;
119 u32 val; 120 u32 val;
120 121
121 div = __clk_get_rate(__clk_get_parent(hw->clk)) / rate; 122 div = parent_rate / rate;
122 123
123 if (!(divider->flags & CLK_DIVIDER_ONE_BASED)) 124 if (!(divider->flags & CLK_DIVIDER_ONE_BASED))
124 div--; 125 div--;
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 1ab4f7e5c7ef..62ecac53b0a2 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -848,7 +848,7 @@ static void clk_change_rate(struct clk *clk)
848 old_rate = clk->rate; 848 old_rate = clk->rate;
849 849
850 if (clk->ops->set_rate) 850 if (clk->ops->set_rate)
851 clk->ops->set_rate(clk->hw, clk->new_rate); 851 clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate);
852 852
853 if (clk->ops->recalc_rate) 853 if (clk->ops->recalc_rate)
854 clk->rate = clk->ops->recalc_rate(clk->hw, 854 clk->rate = clk->ops->recalc_rate(clk->hw,
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 3323d24a7be4..cb82918d8fe0 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -88,19 +88,11 @@ struct clk_hw {
88 * array index into the value programmed into the hardware. 88 * array index into the value programmed into the hardware.
89 * Returns 0 on success, -EERROR otherwise. 89 * Returns 0 on success, -EERROR otherwise.
90 * 90 *
91 * @set_rate: Change the rate of this clock. If this callback returns 91 * @set_rate: Change the rate of this clock. The requested rate is specified
92 * CLK_SET_RATE_PARENT, the rate change will be propagated to the 92 * by the second argument, which should typically be the return
93 * parent clock (which may propagate again if the parent clock 93 * of .round_rate call. The third argument gives the parent rate
94 * also sets this flag). The requested rate of the parent is 94 * which is likely helpful for most .set_rate implementation.
95 * passed back from the callback in the second 'unsigned long *' 95 * Returns 0 on success, -EERROR otherwise.
96 * argument. Note that it is up to the hardware clock's set_rate
97 * implementation to insure that clocks do not run out of spec
98 * when propgating the call to set_rate up to the parent. One way
99 * to do this is to gate the clock (via clk_disable and/or
100 * clk_unprepare) before calling clk_set_rate, then ungating it
101 * afterward. If your clock also has the CLK_GATE_SET_RATE flag
102 * set then this will insure safety. Returns 0 on success,
103 * -EERROR otherwise.
104 * 96 *
105 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow 97 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow
106 * implementations to split any work between atomic (enable) and sleepable 98 * implementations to split any work between atomic (enable) and sleepable
@@ -125,7 +117,8 @@ struct clk_ops {
125 unsigned long *); 117 unsigned long *);
126 int (*set_parent)(struct clk_hw *hw, u8 index); 118 int (*set_parent)(struct clk_hw *hw, u8 index);
127 u8 (*get_parent)(struct clk_hw *hw); 119 u8 (*get_parent)(struct clk_hw *hw);
128 int (*set_rate)(struct clk_hw *hw, unsigned long); 120 int (*set_rate)(struct clk_hw *hw, unsigned long,
121 unsigned long);
129 void (*init)(struct clk_hw *hw); 122 void (*init)(struct clk_hw *hw);
130}; 123};
131 124