summaryrefslogtreecommitdiffstats
path: root/drivers/clk/sunxi-ng
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2017-05-17 03:40:35 -0400
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-06-07 09:32:13 -0400
commitd754b15951ffe3c85e2581eaa244ed4a82080970 (patch)
tree2869b3d3ebdef28966fb02da07930482b1987e59 /drivers/clk/sunxi-ng
parentea8edcded581ed9bd935ef7c575b0bf58eb56c82 (diff)
clk: sunxi-ng: mux: Change pre-divider application function prototype
The current function name is a bit confusing, and doesn't really allow to create an explicit function to reverse the operation. We also for now change the parent rate through a pointer, while we don't return anything. In order to be less confusing, and easier to use for downstream users, change the function name to something hopefully clearer, and return the adjusted rate instead of changing the pointer. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Diffstat (limited to 'drivers/clk/sunxi-ng')
-rw-r--r--drivers/clk/sunxi-ng/ccu_div.c8
-rw-r--r--drivers/clk/sunxi-ng/ccu_mp.c8
-rw-r--r--drivers/clk/sunxi-ng/ccu_mult.c8
-rw-r--r--drivers/clk/sunxi-ng/ccu_mux.c29
-rw-r--r--drivers/clk/sunxi-ng/ccu_mux.h8
5 files changed, 28 insertions, 33 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
index 419463375bc1..c0e5c10d0091 100644
--- a/drivers/clk/sunxi-ng/ccu_div.c
+++ b/drivers/clk/sunxi-ng/ccu_div.c
@@ -59,8 +59,8 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
59 val = reg >> cd->div.shift; 59 val = reg >> cd->div.shift;
60 val &= (1 << cd->div.width) - 1; 60 val &= (1 << cd->div.width) - 1;
61 61
62 ccu_mux_helper_adjust_parent_for_prediv(&cd->common, &cd->mux, -1, 62 parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
63 &parent_rate); 63 parent_rate);
64 64
65 return divider_recalc_rate(hw, parent_rate, val, cd->div.table, 65 return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
66 cd->div.flags); 66 cd->div.flags);
@@ -83,8 +83,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate,
83 unsigned long val; 83 unsigned long val;
84 u32 reg; 84 u32 reg;
85 85
86 ccu_mux_helper_adjust_parent_for_prediv(&cd->common, &cd->mux, -1, 86 parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
87 &parent_rate); 87 parent_rate);
88 88
89 val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width, 89 val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
90 cd->div.flags); 90 cd->div.flags);
diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
index de02e6c386d8..b917ad7a386c 100644
--- a/drivers/clk/sunxi-ng/ccu_mp.c
+++ b/drivers/clk/sunxi-ng/ccu_mp.c
@@ -87,8 +87,8 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
87 u32 reg; 87 u32 reg;
88 88
89 /* Adjust parent_rate according to pre-dividers */ 89 /* Adjust parent_rate according to pre-dividers */
90 ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, 90 parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->mux, -1,
91 -1, &parent_rate); 91 parent_rate);
92 92
93 reg = readl(cmp->common.base + cmp->common.reg); 93 reg = readl(cmp->common.base + cmp->common.reg);
94 94
@@ -123,8 +123,8 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
123 u32 reg; 123 u32 reg;
124 124
125 /* Adjust parent_rate according to pre-dividers */ 125 /* Adjust parent_rate according to pre-dividers */
126 ccu_mux_helper_adjust_parent_for_prediv(&cmp->common, &cmp->mux, 126 parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->mux, -1,
127 -1, &parent_rate); 127 parent_rate);
128 128
129 max_m = cmp->m.max ?: 1 << cmp->m.width; 129 max_m = cmp->m.max ?: 1 << cmp->m.width;
130 max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); 130 max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
diff --git a/drivers/clk/sunxi-ng/ccu_mult.c b/drivers/clk/sunxi-ng/ccu_mult.c
index 6ee7ba0738fb..20d0300867f2 100644
--- a/drivers/clk/sunxi-ng/ccu_mult.c
+++ b/drivers/clk/sunxi-ng/ccu_mult.c
@@ -88,8 +88,8 @@ static unsigned long ccu_mult_recalc_rate(struct clk_hw *hw,
88 val = reg >> cm->mult.shift; 88 val = reg >> cm->mult.shift;
89 val &= (1 << cm->mult.width) - 1; 89 val &= (1 << cm->mult.width) - 1;
90 90
91 ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, 91 parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
92 &parent_rate); 92 parent_rate);
93 93
94 return parent_rate * (val + cm->mult.offset); 94 return parent_rate * (val + cm->mult.offset);
95} 95}
@@ -116,8 +116,8 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned long rate,
116 else 116 else
117 ccu_frac_helper_disable(&cm->common, &cm->frac); 117 ccu_frac_helper_disable(&cm->common, &cm->frac);
118 118
119 ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, 119 parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
120 &parent_rate); 120 parent_rate);
121 121
122 _cm.min = cm->mult.min; 122 _cm.min = cm->mult.min;
123 123
diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c
index 3eb23d4e6534..c33210972581 100644
--- a/drivers/clk/sunxi-ng/ccu_mux.c
+++ b/drivers/clk/sunxi-ng/ccu_mux.c
@@ -56,13 +56,12 @@ static u16 ccu_mux_get_prediv(struct ccu_common *common,
56 return prediv; 56 return prediv;
57} 57}
58 58
59void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, 59unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
60 struct ccu_mux_internal *cm, 60 struct ccu_mux_internal *cm,
61 int parent_index, 61 int parent_index,
62 unsigned long *parent_rate) 62 unsigned long parent_rate)
63{ 63{
64 *parent_rate = *parent_rate / ccu_mux_get_prediv(common, cm, 64 return parent_rate / ccu_mux_get_prediv(common, cm, parent_index);
65 parent_index);
66} 65}
67 66
68int ccu_mux_helper_determine_rate(struct ccu_common *common, 67int ccu_mux_helper_determine_rate(struct ccu_common *common,
@@ -84,10 +83,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
84 83
85 best_parent = clk_hw_get_parent(hw); 84 best_parent = clk_hw_get_parent(hw);
86 best_parent_rate = clk_hw_get_rate(best_parent); 85 best_parent_rate = clk_hw_get_rate(best_parent);
87 86 adj_parent_rate = ccu_mux_helper_apply_prediv(common, cm, -1,
88 adj_parent_rate = best_parent_rate; 87 best_parent_rate);
89 ccu_mux_helper_adjust_parent_for_prediv(common, cm, -1,
90 &adj_parent_rate);
91 88
92 best_rate = round(cm, best_parent, &adj_parent_rate, 89 best_rate = round(cm, best_parent, &adj_parent_rate,
93 req->rate, data); 90 req->rate, data);
@@ -103,9 +100,9 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
103 if (!parent) 100 if (!parent)
104 continue; 101 continue;
105 102
106 adj_parent_rate = parent_rate = clk_hw_get_rate(parent); 103 parent_rate = clk_hw_get_rate(parent);
107 ccu_mux_helper_adjust_parent_for_prediv(common, cm, i, 104 adj_parent_rate = ccu_mux_helper_apply_prediv(common, cm, i,
108 &adj_parent_rate); 105 parent_rate);
109 106
110 tmp_rate = round(cm, parent, &adj_parent_rate, req->rate, data); 107 tmp_rate = round(cm, parent, &adj_parent_rate, req->rate, data);
111 if (tmp_rate == req->rate) { 108 if (tmp_rate == req->rate) {
@@ -215,10 +212,8 @@ static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw,
215{ 212{
216 struct ccu_mux *cm = hw_to_ccu_mux(hw); 213 struct ccu_mux *cm = hw_to_ccu_mux(hw);
217 214
218 ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1, 215 return ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
219 &parent_rate); 216 parent_rate);
220
221 return parent_rate;
222} 217}
223 218
224const struct clk_ops ccu_mux_ops = { 219const struct clk_ops ccu_mux_ops = {
diff --git a/drivers/clk/sunxi-ng/ccu_mux.h b/drivers/clk/sunxi-ng/ccu_mux.h
index 4be56eee2bfd..dba12c76cf54 100644
--- a/drivers/clk/sunxi-ng/ccu_mux.h
+++ b/drivers/clk/sunxi-ng/ccu_mux.h
@@ -78,10 +78,10 @@ static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
78 78
79extern const struct clk_ops ccu_mux_ops; 79extern const struct clk_ops ccu_mux_ops;
80 80
81void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, 81unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
82 struct ccu_mux_internal *cm, 82 struct ccu_mux_internal *cm,
83 int parent_index, 83 int parent_index,
84 unsigned long *parent_rate); 84 unsigned long parent_rate);
85int ccu_mux_helper_determine_rate(struct ccu_common *common, 85int ccu_mux_helper_determine_rate(struct ccu_common *common,
86 struct ccu_mux_internal *cm, 86 struct ccu_mux_internal *cm,
87 struct clk_rate_request *req, 87 struct clk_rate_request *req,