Skip to contentSkip to conversation

clk: at91: allow 24 Mhz clock as input for PLL

PATCH Applied [email protected] 4 participants 7 messages Sep 11, 2019 – Sep 18, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: at91: allow 24 Mhz clock as input for PLL

From: Eugen Hristev <[email protected]>

The PLL input range needs to be able to allow 24 Mhz crystal as input Update the range accordingly in plla characteristics struct

---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 6509d09..0de1108 100644
@@ -21,7 +21,7 @@ static const struct clk_range plla_outputs[] = {
 };
 
 static const struct clk_pll_characteristics plla_characteristics = {
-	.input = { .min = 12000000, .max = 12000000 },
+	.input = { .min = 12000000, .max = 24000000 },
 	.num_output = ARRAY_SIZE(plla_outputs),
 	.output = plla_outputs,
 	.icpll = plla_icpll,
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On 11/09/2019 at 08:39, Eugen Hristev - M18282 wrote:

From: Eugen Hristev <[email protected]>

The PLL input range needs to be able to allow 24 Mhz crystal as input Update the range accordingly in plla characteristics struct

Thanks Eugen!

Best regards,
Nicolas

Quoted 18 lines
---
  drivers/clk/at91/sama5d2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 6509d09..0de1108 100644
@@ -21,7 +21,7 @@ static const struct clk_range plla_outputs[] = {
  };
 
  static const struct clk_pll_characteristics plla_characteristics = {
-	.input = { .min = 12000000, .max = 12000000 },
+	.input = { .min = 12000000, .max = 24000000 },
  	.num_output = ARRAY_SIZE(plla_outputs),
  	.output = plla_outputs,
  	.icpll = plla_icpll,
Signature · 1 line
Nicolas Ferre
#2 lore raw
In reply to [email protected]

Hello,

out of curiosity: The SAMA5D27-SOM1-EK board has a 24 MHz crystal, that is also what /sys/kernel/debug/clk/clk_summary says and the board runs without obvious problems. What is this change improving in real practice then?

Greets
Alex

Am Mittwoch, 11. September 2019, 06:39:20 CEST schrieb [email protected]:

Quoted 23 lines

From: Eugen Hristev <[email protected]>

The PLL input range needs to be able to allow 24 Mhz crystal as input Update the range accordingly in plla characteristics struct

---
 drivers/clk/at91/sama5d2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 6509d09..0de1108 100644
@@ -21,7 +21,7 @@ static const struct clk_range plla_outputs[] = {
 };
 
 static const struct clk_pll_characteristics plla_characteristics = {
-	.input = { .min = 12000000, .max = 12000000 },
+	.input = { .min = 12000000, .max = 24000000 },
 	.num_output = ARRAY_SIZE(plla_outputs),
 	.output = plla_outputs,
 	.icpll = plla_icpll,
#3 lore raw
Quoted 7 lines · Alexander Dahl

Hello,

out of curiosity: The SAMA5D27-SOM1-EK board has a 24 MHz crystal, that is also what /sys/kernel/debug/clk/clk_summary says and the board runs without obvious problems. What is this change improving in real practice then?

The board works, but, the characteristics of the PLL are incorrect. This can lead to unwanted behavior, like calculating wrong minimum values for multipliers, or other issues

In this code here in clk-pll.c for example

if (parent_rate > characteristics->input.max) {
tmpdiv = DIV_ROUND_UP(parent_rate,

characteristics->input.max);
                 if (tmpdiv > PLL_DIV_MAX) 

                         return -ERANGE; 

 

                 if (tmpdiv > mindiv) 

                         mindiv = tmpdiv; 

         }

The divisor is capped by checks, but at another possible requested parent rate, this may lead to something wrong, like here, the minimum divisor might be greater than what is the real possible one. So in some cases it can happen that unwanted results occur.

We may consider at some points to rely on these values more, so, it's obvious that they should be correct in the characteristics

So short answer: no improve in your case , where the rates required are around 492 Mhz cpu/132 mhz bus (IIRC), but the characteristics need to be correct to cover all possible cases.

Eugen

Quoted 32 lines

Greets
Alex

Am Mittwoch, 11. September 2019, 06:39:20 CEST schrieb [email protected]:

Quoted 23 lines

From: Eugen Hristev <[email protected]>

The PLL input range needs to be able to allow 24 Mhz crystal as input Update the range accordingly in plla characteristics struct

---
  drivers/clk/at91/sama5d2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sama5d2.c +1 -1
index 6509d09..0de1108 100644
@@ -21,7 +21,7 @@ static const struct clk_range plla_outputs[] = {
  };
 
  static const struct clk_pll_characteristics plla_characteristics = {
-	.input = { .min = 12000000, .max = 12000000 },
+	.input = { .min = 12000000, .max = 24000000 },
  	.num_output = ARRAY_SIZE(plla_outputs),
  	.output = plla_outputs,
  	.icpll = plla_icpll,
#5 lore raw
Quoted 11 lines · Stephen Boyd

Quoting [email protected] (2019-09-10 23:39:20)

Quoted 7 lines

From: Eugen Hristev <[email protected]>

The PLL input range needs to be able to allow 24 Mhz crystal as input Update the range accordingly in plla characteristics struct

---

Is there a Fixes: tag for this? Seems like it was always wrong?

Hi Stephen,

At the initial design , the 12 Mhz was the only possibility for the boards themselves. But, with the commit who added this:

Fixes c561e41ce4d2 ("clk: at91: add sama5d2 PMC driver")

Eugen