]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
clk: sunxi-ng: Implement minimum for multipliers
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Fri, 30 Sep 2016 20:16:51 +0000 (22:16 +0200)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Tue, 25 Oct 2016 10:40:25 +0000 (12:40 +0200)
Allow the CCU drivers to specify a multiplier for their clocks.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
drivers/clk/sunxi-ng/ccu_mult.c
drivers/clk/sunxi-ng/ccu_mult.h
drivers/clk/sunxi-ng/ccu_nk.c
drivers/clk/sunxi-ng/ccu_nkm.c
drivers/clk/sunxi-ng/ccu_nkmp.c
drivers/clk/sunxi-ng/ccu_nm.c

index 6a02ffee5386005367e00a70caf1ad5a08525351..678b6cb49f01b7b176ca84f425ee5a91d6486728 100644 (file)
@@ -105,7 +105,7 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned long rate,
        ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1,
                                                &parent_rate);
 
-       _cm.min = 1;
+       _cm.min = cm->mult.min;
        _cm.max = 1 << cm->mult.width;
        ccu_mult_find_best(parent_rate, rate, &_cm);
 
index 113780b7558e2fc0e88ae73c39894b0031429ae1..c1a2134bdc711367d239b237f5dae01f1e6af07b 100644 (file)
@@ -7,14 +7,19 @@
 struct ccu_mult_internal {
        u8      shift;
        u8      width;
+       u8      min;
 };
 
-#define _SUNXI_CCU_MULT(_shift, _width)                \
-       {                                       \
-               .shift  = _shift,               \
-               .width  = _width,               \
+#define _SUNXI_CCU_MULT_MIN(_shift, _width, _min)      \
+       {                                               \
+               .shift  = _shift,                       \
+               .width  = _width,                       \
+               .min    = _min,                         \
        }
 
+#define _SUNXI_CCU_MULT(_shift, _width)                \
+       _SUNXI_CCU_MULT_MIN(_shift, _width, 1)
+
 struct ccu_mult {
        u32                     enable;
 
index a42d870ba0ef862b72b810e583e1b33956c10b2d..eaf0fdf78d2ba278299c8eb93c4b40eb20ce4201 100644 (file)
@@ -97,9 +97,9 @@ static long ccu_nk_round_rate(struct clk_hw *hw, unsigned long rate,
        if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
                rate *= nk->fixed_post_div;
 
-       _nk.min_n = 1;
+       _nk.min_n = nk->n.min;
        _nk.max_n = 1 << nk->n.width;
-       _nk.min_k = 1;
+       _nk.min_k = nk->k.min;
        _nk.max_k = 1 << nk->k.width;
 
        ccu_nk_find_best(*parent_rate, rate, &_nk);
@@ -122,9 +122,9 @@ static int ccu_nk_set_rate(struct clk_hw *hw, unsigned long rate,
        if (nk->common.features & CCU_FEATURE_FIXED_POSTDIV)
                rate = rate * nk->fixed_post_div;
 
-       _nk.min_n = 1;
+       _nk.min_n = nk->n.min;
        _nk.max_n = 1 << nk->n.width;
-       _nk.min_k = 1;
+       _nk.min_k = nk->k.min;
        _nk.max_k = 1 << nk->k.width;
 
        ccu_nk_find_best(parent_rate, rate, &_nk);
index 42177320930dd3cf2d40fc5445223690f16643db..9b840a47a94d8774aef65388058dfc7f0d589c5d 100644 (file)
@@ -100,9 +100,9 @@ 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.min_n = nkm->n.min;
        _nkm.max_n = 1 << nkm->n.width;
-       _nkm.min_k = 1;
+       _nkm.min_k = nkm->k.min;
        _nkm.max_k = 1 << nkm->k.width;
        _nkm.min_m = 1;
        _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
@@ -129,9 +129,9 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate,
        unsigned long flags;
        u32 reg;
 
-       _nkm.min_n = 1;
+       _nkm.min_n = nkm->n.min;
        _nkm.max_n = 1 << nkm->n.width;
-       _nkm.min_k = 1;
+       _nkm.min_k = nkm->k.min;
        _nkm.max_k = 1 << nkm->k.width;
        _nkm.min_m = 1;
        _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
index 67c856e381a80281acb673b1df15b4b96a2ad20e..684c42da3ebbf91ac46ab1e06f7ea378b454760d 100644 (file)
@@ -107,9 +107,9 @@ static long ccu_nkmp_round_rate(struct clk_hw *hw, unsigned long rate,
        struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw);
        struct _ccu_nkmp _nkmp;
 
-       _nkmp.min_n = 1;
+       _nkmp.min_n = nkmp->n.min;
        _nkmp.max_n = 1 << nkmp->n.width;
-       _nkmp.min_k = 1;
+       _nkmp.min_k = nkmp->k.min;
        _nkmp.max_k = 1 << nkmp->k.width;
        _nkmp.min_m = 1;
        _nkmp.max_m = nkmp->m.max ?: 1 << nkmp->m.width;
index 1dae4f3ed00d97131d6263f118d6dae142070e43..c9f3b6c982f02e4fd2cacea8ddd516b7344cc239 100644 (file)
@@ -93,7 +93,7 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
        struct ccu_nm *nm = hw_to_ccu_nm(hw);
        struct _ccu_nm _nm;
 
-       _nm.min_n = 1;
+       _nm.min_n = nm->n.min;
        _nm.max_n = 1 << nm->n.width;
        _nm.min_m = 1;
        _nm.max_m = nm->m.max ?: 1 << nm->m.width;