Commit 10a8d9b9 authored by Maxime Ripard's avatar Maxime Ripard

clk: sunxi-ng: Pass the parent and a pointer to the clocks round rate

The clocks might need to modify their parent clocks. In order to make that
possible, give them access to the parent clock being evaluated, and to a
pointer to the parent rate so that they can modify it if needed.
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarChen-Yu Tsai <wens@csie.org>
parent 22833a91
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include "ccu_div.h" #include "ccu_div.h"
static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *parent,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
...@@ -26,10 +27,10 @@ static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux, ...@@ -26,10 +27,10 @@ static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux,
* several parents, while we might be called to evaluate * several parents, while we might be called to evaluate
* several different parents. * several different parents.
*/ */
val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width, val = divider_get_val(rate, *parent_rate, cd->div.table, cd->div.width,
cd->div.flags); cd->div.flags);
return divider_recalc_rate(&cd->common.hw, parent_rate, val, return divider_recalc_rate(&cd->common.hw, *parent_rate, val,
cd->div.table, cd->div.flags); cd->div.table, cd->div.flags);
} }
......
...@@ -41,7 +41,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate, ...@@ -41,7 +41,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate,
} }
static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *hw,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
...@@ -52,9 +53,9 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, ...@@ -52,9 +53,9 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux,
max_m = cmp->m.max ?: 1 << cmp->m.width; max_m = cmp->m.max ?: 1 << cmp->m.width;
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
ccu_mp_find_best(parent_rate, rate, max_m, max_p, &m, &p); ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
return parent_rate / p / m; return *parent_rate / p / m;
} }
static void ccu_mp_disable(struct clk_hw *hw) static void ccu_mp_disable(struct clk_hw *hw)
......
...@@ -33,9 +33,10 @@ static void ccu_mult_find_best(unsigned long parent, unsigned long rate, ...@@ -33,9 +33,10 @@ static void ccu_mult_find_best(unsigned long parent, unsigned long rate,
} }
static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *parent,
unsigned long rate, unsigned long *parent_rate,
void *data) unsigned long rate,
void *data)
{ {
struct ccu_mult *cm = data; struct ccu_mult *cm = data;
struct _ccu_mult _cm; struct _ccu_mult _cm;
...@@ -47,9 +48,9 @@ static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux, ...@@ -47,9 +48,9 @@ static unsigned long ccu_mult_round_rate(struct ccu_mux_internal *mux,
else else
_cm.max = (1 << cm->mult.width) + cm->mult.offset - 1; _cm.max = (1 << cm->mult.width) + cm->mult.offset - 1;
ccu_mult_find_best(parent_rate, rate, &_cm); ccu_mult_find_best(*parent_rate, rate, &_cm);
return parent_rate * _cm.mult; return *parent_rate * _cm.mult;
} }
static void ccu_mult_disable(struct clk_hw *hw) static void ccu_mult_disable(struct clk_hw *hw)
......
...@@ -61,7 +61,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, ...@@ -61,7 +61,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
struct clk_rate_request *req, struct clk_rate_request *req,
unsigned long (*round)(struct ccu_mux_internal *, unsigned long (*round)(struct ccu_mux_internal *,
unsigned long, struct clk_hw *,
unsigned long *,
unsigned long, unsigned long,
void *), void *),
void *data) void *data)
...@@ -80,7 +81,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, ...@@ -80,7 +81,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
ccu_mux_helper_adjust_parent_for_prediv(common, cm, -1, ccu_mux_helper_adjust_parent_for_prediv(common, cm, -1,
&adj_parent_rate); &adj_parent_rate);
best_rate = round(cm, adj_parent_rate, req->rate, data); best_rate = round(cm, best_parent, &adj_parent_rate,
req->rate, data);
goto out; goto out;
} }
...@@ -109,7 +111,7 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, ...@@ -109,7 +111,7 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
ccu_mux_helper_adjust_parent_for_prediv(common, cm, i, ccu_mux_helper_adjust_parent_for_prediv(common, cm, i,
&adj_parent_rate); &adj_parent_rate);
tmp_rate = round(cm, adj_parent_rate, req->rate, data); tmp_rate = round(cm, parent, &adj_parent_rate, req->rate, data);
if (tmp_rate == req->rate) { if (tmp_rate == req->rate) {
best_parent = parent; best_parent = parent;
best_parent_rate = parent_rate; best_parent_rate = parent_rate;
......
...@@ -86,7 +86,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, ...@@ -86,7 +86,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
struct ccu_mux_internal *cm, struct ccu_mux_internal *cm,
struct clk_rate_request *req, struct clk_rate_request *req,
unsigned long (*round)(struct ccu_mux_internal *, unsigned long (*round)(struct ccu_mux_internal *,
unsigned long, struct clk_hw *,
unsigned long *,
unsigned long, unsigned long,
void *), void *),
void *data); void *data);
......
...@@ -102,7 +102,8 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw, ...@@ -102,7 +102,8 @@ static unsigned long ccu_nkm_recalc_rate(struct clk_hw *hw,
} }
static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
unsigned long parent_rate, struct clk_hw *hw,
unsigned long *parent_rate,
unsigned long rate, unsigned long rate,
void *data) void *data)
{ {
...@@ -116,9 +117,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, ...@@ -116,9 +117,9 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
_nkm.min_m = 1; _nkm.min_m = 1;
_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
ccu_nkm_find_best(parent_rate, rate, &_nkm); ccu_nkm_find_best(*parent_rate, rate, &_nkm);
return parent_rate * _nkm.n * _nkm.k / _nkm.m; return *parent_rate * _nkm.n * _nkm.k / _nkm.m;
} }
static int ccu_nkm_determine_rate(struct clk_hw *hw, static int ccu_nkm_determine_rate(struct clk_hw *hw,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment