aspeed: Make SCU lock/unlock functions part of SCU API
[platform/kernel/u-boot.git] / drivers / clk / aspeed / clk_ast2500.c
index af369cc..5047312 100644 (file)
@@ -35,7 +35,7 @@ static ulong ast2500_get_mpll_rate(ulong clkin, u32 mpll_reg)
        const ulong post_div = (mpll_reg >> SCU_MPLL_POST_SHIFT)
                        & SCU_MPLL_POST_MASK;
 
-       return (clkin * ((num + 1) / (denum + 1))) / post_div;
+       return (clkin * ((num + 1) / (denum + 1))) / (post_div + 1);
 }
 
 /*
@@ -50,7 +50,7 @@ static ulong ast2500_get_hpll_rate(ulong clkin, u32 hpll_reg)
        const ulong post_div = (hpll_reg >> SCU_HPLL_POST_SHIFT)
                        & SCU_HPLL_POST_MASK;
 
-       return (clkin * ((num + 1) / (denum + 1))) / post_div;
+       return (clkin * ((num + 1) / (denum + 1))) / (post_div + 1);
 }
 
 static ulong ast2500_get_clkin(struct ast2500_scu *scu)
@@ -132,20 +132,6 @@ static ulong ast2500_clk_get_rate(struct clk *clk)
        return rate;
 }
 
-static void ast2500_scu_unlock(struct ast2500_scu *scu)
-{
-       writel(SCU_UNLOCK_VALUE, &scu->protection_key);
-       while (!readl(&scu->protection_key))
-               ;
-}
-
-static void ast2500_scu_lock(struct ast2500_scu *scu)
-{
-       writel(~SCU_UNLOCK_VALUE, &scu->protection_key);
-       while (readl(&scu->protection_key))
-               ;
-}
-
 static ulong ast2500_configure_ddr(struct ast2500_scu *scu, ulong rate)
 {
        ulong clkin = ast2500_get_clkin(scu);
@@ -197,9 +183,9 @@ static ulong ast2500_configure_ddr(struct ast2500_scu *scu, ulong rate)
            | (best_num << SCU_MPLL_NUM_SHIFT)
            | (best_denum << SCU_MPLL_DENUM_SHIFT);
 
-       ast2500_scu_unlock(scu);
+       ast_scu_unlock(scu);
        writel(mpll_reg, &scu->m_pll_param);
-       ast2500_scu_lock(scu);
+       ast_scu_lock(scu);
 
        return ast2500_get_mpll_rate(clkin, mpll_reg);
 }