]> git.karo-electronics.de Git - linux-beck.git/commitdiff
clk: rockchip: simplify GRF handling in pll clocks
authorHeiko Stuebner <heiko@sntech.de>
Tue, 15 Mar 2016 15:55:41 +0000 (16:55 +0100)
committerHeiko Stuebner <heiko@sntech.de>
Mon, 9 May 2016 14:04:15 +0000 (16:04 +0200)
With the previous commit, the clock drivers now know at init time if the
GRF regmap is available. That means if it isn't available then, it also
won't become available later and we can therefore switch PLLs, that need
the GRF for the lock-status, to read-only mode - similar behaviour as the
aborting of rate changes we did before.

This saves some conditionals on every rate change and we can also drop
the rockchip_clk_get_grf function completely.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
drivers/clk/rockchip/clk-pll.c
drivers/clk/rockchip/clk.c
drivers/clk/rockchip/clk.h

index 8ac73bc7f93d8a0bdace04519bf2118e906ca2ed..76e278d679ba472584a5dfd5e155bc3c90ae832a 100644 (file)
@@ -92,15 +92,10 @@ static long rockchip_pll_round_rate(struct clk_hw *hw,
  */
 static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll)
 {
-       struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
+       struct regmap *grf = pll->ctx->grf;
        unsigned int val;
        int delay = 24000000, ret;
 
-       if (IS_ERR(grf)) {
-               pr_err("%s: grf regmap not available\n", __func__);
-               return PTR_ERR(grf);
-       }
-
        while (delay > 0) {
                ret = regmap_read(grf, pll->lock_offset, &val);
                if (ret) {
@@ -253,13 +248,6 @@ static int rockchip_rk3036_pll_set_rate(struct clk_hw *hw, unsigned long drate,
        struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
        const struct rockchip_pll_rate_table *rate;
        unsigned long old_rate = rockchip_rk3036_pll_recalc_rate(hw, prate);
-       struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
-
-       if (IS_ERR(grf)) {
-               pr_debug("%s: grf regmap not available, aborting rate change\n",
-                        __func__);
-               return PTR_ERR(grf);
-       }
 
        pr_debug("%s: changing %s from %lu to %lu with a parent rate of %lu\n",
                 __func__, __clk_get_name(hw->clk), old_rate, drate, prate);
@@ -492,13 +480,6 @@ static int rockchip_rk3066_pll_set_rate(struct clk_hw *hw, unsigned long drate,
        struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
        const struct rockchip_pll_rate_table *rate;
        unsigned long old_rate = rockchip_rk3066_pll_recalc_rate(hw, prate);
-       struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
-
-       if (IS_ERR(grf)) {
-               pr_debug("%s: grf regmap not available, aborting rate change\n",
-                        __func__);
-               return PTR_ERR(grf);
-       }
 
        pr_debug("%s: changing %s from %lu to %lu with a parent rate of %lu\n",
                 __func__, clk_hw_get_name(hw), old_rate, drate, prate);
@@ -565,11 +546,6 @@ static void rockchip_rk3066_pll_init(struct clk_hw *hw)
                 rate->no, cur.no, rate->nf, cur.nf, rate->nb, cur.nb);
        if (rate->nr != cur.nr || rate->no != cur.no || rate->nf != cur.nf
                                                     || rate->nb != cur.nb) {
-               struct regmap *grf = rockchip_clk_get_grf(pll->ctx);
-
-               if (IS_ERR(grf))
-                       return;
-
                pr_debug("%s: pll %s: rate params do not match rate table, adjusting\n",
                         __func__, clk_hw_get_name(hw));
                rockchip_rk3066_pll_set_params(pll, rate);
@@ -943,13 +919,13 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
 
        switch (pll_type) {
        case pll_rk3036:
-               if (!pll->rate_table)
+               if (!pll->rate_table || IS_ERR(ctx->grf))
                        init.ops = &rockchip_rk3036_pll_clk_norate_ops;
                else
                        init.ops = &rockchip_rk3036_pll_clk_ops;
                break;
        case pll_rk3066:
-               if (!pll->rate_table)
+               if (!pll->rate_table || IS_ERR(ctx->grf))
                        init.ops = &rockchip_rk3066_pll_clk_norate_ops;
                else
                        init.ops = &rockchip_rk3066_pll_clk_ops;
index 9f99a4213d02a487330ae6c6ce7c2560ac33f026..7ffd134995f222bac2a088146b4dd05d9320eca0 100644 (file)
@@ -365,11 +365,6 @@ void __init rockchip_clk_of_add_provider(struct device_node *np,
                pr_err("%s: could not register clk provider\n", __func__);
 }
 
-struct regmap *rockchip_clk_get_grf(struct rockchip_clk_provider *ctx)
-{
-       return ctx->grf;
-}
-
 void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
                             struct clk *clk, unsigned int id)
 {
index 1abb7d05d1c78a0ea3dd52daae3faeb79a39cc7f..2194ffa8c9fd5a778130d56c97fed31840414bfa 100644 (file)
@@ -600,7 +600,6 @@ struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
                        void __iomem *base, unsigned long nr_clks);
 void rockchip_clk_of_add_provider(struct device_node *np,
                                struct rockchip_clk_provider *ctx);
-struct regmap *rockchip_clk_get_grf(struct rockchip_clk_provider *ctx);
 void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
                             struct clk *clk, unsigned int id);
 void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,