aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch
diff options
context:
space:
mode:
authorZoltan Herpai <wigyori@uid0.hu>2014-08-27 12:09:46 +0000
committerZoltan Herpai <wigyori@uid0.hu>2014-08-27 12:09:46 +0000
commitf10f009609aac0941d750ae3a1106675e6d6656a (patch)
tree70f62106f833dc3b4882118e914ff183440e1e9d /target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch
parentb3d10005c1ce3b9676580d09001e14458e410f89 (diff)
downloadupstream-f10f009609aac0941d750ae3a1106675e6d6656a.tar.gz
upstream-f10f009609aac0941d750ae3a1106675e6d6656a.tar.bz2
upstream-f10f009609aac0941d750ae3a1106675e6d6656a.zip
sunxi: initial 3.14 patchset
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu> SVN-Revision: 42313
Diffstat (limited to 'target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch')
-rw-r--r--target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch b/target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch
new file mode 100644
index 0000000000..b78b661ed8
--- /dev/null
+++ b/target/linux/sunxi/patches-3.14/187-clk-sunxi-automatic-reparenting.patch
@@ -0,0 +1,73 @@
+From b416520f239aeaa4207ebe84c22247cff2da444f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
+Date: Thu, 5 Sep 2013 19:52:41 -0300
+Subject: [PATCH] clk: sunxi: factors: automatic reparenting support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This commit implements .determine_rate, so that our factor clocks can be
+reparented when needed.
+
+Signed-off-by: Emilio López <emilio@elopez.com.ar>
+---
+ drivers/clk/sunxi/clk-factors.c | 36 ++++++++++++++++++++++++++++++++++++
+ 1 file changed, 36 insertions(+)
+
+diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
+index 9e23264..3806d97 100644
+--- a/drivers/clk/sunxi/clk-factors.c
++++ b/drivers/clk/sunxi/clk-factors.c
+@@ -77,6 +77,41 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate,
+ return rate;
+ }
+
++static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate,
++ unsigned long *best_parent_rate,
++ struct clk **best_parent_p)
++{
++ struct clk *clk = hw->clk, *parent, *best_parent = NULL;
++ int i, num_parents;
++ unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0;
++
++ /* find the parent that can help provide the fastest rate <= rate */
++ num_parents = __clk_get_num_parents(clk);
++ for (i = 0; i < num_parents; i++) {
++ parent = clk_get_parent_by_index(clk, i);
++ if (!parent)
++ continue;
++ if (__clk_get_flags(clk) & CLK_SET_RATE_PARENT)
++ parent_rate = __clk_round_rate(parent, rate);
++ else
++ parent_rate = __clk_get_rate(parent);
++
++ child_rate = clk_factors_round_rate(hw, rate, &parent_rate);
++
++ if (child_rate <= rate && child_rate > best_child_rate) {
++ best_parent = parent;
++ best = parent_rate;
++ best_child_rate = child_rate;
++ }
++ }
++
++ if (best_parent)
++ *best_parent_p = best_parent;
++ *best_parent_rate = best;
++
++ return best_child_rate;
++}
++
+ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+ {
+@@ -113,6 +148,7 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
+ }
+
+ const struct clk_ops clk_factors_ops = {
++ .determine_rate = clk_factors_determine_rate,
+ .recalc_rate = clk_factors_recalc_rate,
+ .round_rate = clk_factors_round_rate,
+ .set_rate = clk_factors_set_rate,
+--
+2.0.3
+