[PATCH 3/5] clk: at91: fix recalc_rate implementation of PLL driver

2014-09-02 Thread Boris BREZILLON
Use the cached values to calculate PLL rate instead of the register values.
This is required to prevent erroneous PLL rate return when the PLL rate
has been configured but the PLL is not prepared yet.

Signed-off-by: Boris BREZILLON 
Reported-by: Gaël PORTAY 
---
 drivers/clk/at91/clk-pll.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
index a1adcf1..6ec79db 100644
--- a/drivers/clk/at91/clk-pll.c
+++ b/drivers/clk/at91/clk-pll.c
@@ -151,16 +151,11 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw 
*hw,
 unsigned long parent_rate)
 {
struct clk_pll *pll = to_clk_pll(hw);
-   const struct clk_pll_layout *layout = pll->layout;
-   struct at91_pmc *pmc = pll->pmc;
-   int offset = PLL_REG(pll->id);
-   u32 tmp = pmc_read(pmc, offset) & layout->pllr_mask;
-   u8 div = PLL_DIV(tmp);
-   u16 mul = PLL_MUL(tmp, layout);
-   if (!div || !mul)
+
+   if (!pll->div || !pll->mul)
return 0;
 
-   return (parent_rate * (mul + 1)) / div;
+   return (parent_rate / pll->div) * (pll->mul + 1);
 }
 
 static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] clk: at91: fix recalc_rate implementation of PLL driver

2014-09-02 Thread Boris BREZILLON
Use the cached values to calculate PLL rate instead of the register values.
This is required to prevent erroneous PLL rate return when the PLL rate
has been configured but the PLL is not prepared yet.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
Reported-by: Gaël PORTAY gael.por...@gmail.com
---
 drivers/clk/at91/clk-pll.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
index a1adcf1..6ec79db 100644
--- a/drivers/clk/at91/clk-pll.c
+++ b/drivers/clk/at91/clk-pll.c
@@ -151,16 +151,11 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw 
*hw,
 unsigned long parent_rate)
 {
struct clk_pll *pll = to_clk_pll(hw);
-   const struct clk_pll_layout *layout = pll-layout;
-   struct at91_pmc *pmc = pll-pmc;
-   int offset = PLL_REG(pll-id);
-   u32 tmp = pmc_read(pmc, offset)  layout-pllr_mask;
-   u8 div = PLL_DIV(tmp);
-   u16 mul = PLL_MUL(tmp, layout);
-   if (!div || !mul)
+
+   if (!pll-div || !pll-mul)
return 0;
 
-   return (parent_rate * (mul + 1)) / div;
+   return (parent_rate / pll-div) * (pll-mul + 1);
 }
 
 static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/