clk: sunxi-ng: Add minimums for all the relevant structures and clocks

Modify the current clocks we have to be able to specify the minimum for
each clocks we support, just like we support the max.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Cette révision appartient à :
Maxime Ripard
2016-09-29 22:57:26 +02:00
Parent b8302c7267
révision 6e0d50daa9
5 fichiers modifiés avec 50 ajouts et 23 suppressions

Voir le fichier

@@ -14,9 +14,9 @@
#include "ccu_nkm.h"
struct _ccu_nkm {
unsigned long n, max_n;
unsigned long k, max_k;
unsigned long m, max_m;
unsigned long n, min_n, max_n;
unsigned long k, min_k, max_k;
unsigned long m, min_m, max_m;
};
static void ccu_nkm_find_best(unsigned long parent, unsigned long rate,
@@ -26,9 +26,9 @@ static void ccu_nkm_find_best(unsigned long parent, unsigned long rate,
unsigned long best_n = 0, best_k = 0, best_m = 0;
unsigned long _n, _k, _m;
for (_k = 1; _k <= nkm->max_k; _k++) {
for (_n = 1; _n <= nkm->max_n; _n++) {
for (_m = 1; _n <= nkm->max_m; _m++) {
for (_k = nkm->min_k; _k <= nkm->max_k; _k++) {
for (_n = nkm->min_n; _n <= nkm->max_n; _n++) {
for (_m = nkm->min_m; _m <= nkm->max_m; _m++) {
unsigned long tmp_rate;
tmp_rate = parent * _n * _k / _m;
@@ -100,8 +100,11 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux,
struct ccu_nkm *nkm = data;
struct _ccu_nkm _nkm;
_nkm.min_n = 1;
_nkm.max_n = 1 << nkm->n.width;
_nkm.min_k = 1;
_nkm.max_k = 1 << nkm->k.width;
_nkm.min_m = 1;
_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
ccu_nkm_find_best(parent_rate, rate, &_nkm);
@@ -126,8 +129,11 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long flags;
u32 reg;
_nkm.min_n = 1;
_nkm.max_n = 1 << nkm->n.width;
_nkm.min_k = 1;
_nkm.max_k = 1 << nkm->k.width;
_nkm.min_m = 1;
_nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
ccu_nkm_find_best(parent_rate, rate, &_nkm);