Skip to contentSkip to conversation

ARM: atmel: spl: make initialization more stable

PATCH New Bo Shen 2 participants 4 messages Oct 24, 2014 – Nov 17, 2014

Subsystems (2)
lore
Share & tools
lore

Bo Shen

author
#0 lore raw

PATCH 1/2 ARM: atmel: spl: make initialization more stable

We need to make sure the main clock ready field in MCFR is set after switch to main crystal oscillator.

---

 arch/arm/cpu/at91-common/spl.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/at91-common/spl.c +4 -0
index cbb5a52..1d7770e 100644
@@ -50,6 +50,10 @@ static void switch_to_main_crystal_osc(void)
 	while (!(readl(&pmc->sr) & AT91_PMC_IXR_MOSCSELS))
 		;
 
+	/* Wait until MAINRDY field is set to make sure main clock is stable */
+	while (!(readl(&pmc->mcfr) & AT91_PMC_MAINRDY))
+		;
+
 	tmp = readl(&pmc->mor);
 	tmp &= ~AT91_PMC_MOR_MOSCRCEN;
 	tmp &= ~AT91_PMC_MOR_KEY(0xff);
Signature · 1 line
2.1.0.24.g4109c28
author
#1 lore raw

PATCH 2/2 ARM: atmel: spl: make css field configurable

The clock source for master clock can be slow clock, main clock, plla clock or upll clock. So, make the clock source selection field in mckr can be configured.

---

 arch/arm/cpu/at91-common/spl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/cpu/at91-common/spl.c +4 -2
index 1d7770e..3ceb31b 100644
@@ -76,10 +76,12 @@ void at91_mck_init(u32 mckr)
 	u32 tmp;
 
 	tmp = readl(&pmc->mckr);
-	tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
+	tmp &= ~(AT91_PMC_MCKR_CSS_MASK |
+		 AT91_PMC_MCKR_PRES_MASK |
 		 AT91_PMC_MCKR_MDIV_MASK |
 		 AT91_PMC_MCKR_PLLADIV_2);
-	tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
+	tmp |= mckr & (AT91_PMC_MCKR_CSS_MASK |
+		       AT91_PMC_MCKR_PRES_MASK |
 		       AT91_PMC_MCKR_MDIV_MASK |
 		       AT91_PMC_MCKR_PLLADIV_2);
 	writel(tmp, &pmc->mckr);
Signature · 1 line
2.1.0.24.g4109c28
#2 lore raw

PATCH 2/2 ARM: atmel: spl: make css field configurable

Dear Bo Shen,

Quoted 9 lines · Bo Shen

The clock source for master clock can be slow clock, main clock, plla clock or upll clock. So, make the clock source selection field in mckr can be configured.

---

arch/arm/cpu/at91-common/spl.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#3 lore raw

PATCH 1/2 ARM: atmel: spl: make initialization more stable

In reply to Bo Shen

Dear Bo Shen,

Quoted 8 lines · Bo Shen

We need to make sure the main clock ready field in MCFR is set after switch to main crystal oscillator.

---

arch/arm/cpu/at91-common/spl.c | 4 ++++

1 file changed, 4 insertions(+)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann