]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: atmel: spl: make initialization more stable
authorBo Shen <voice.shen@atmel.com>
Fri, 24 Oct 2014 08:13:25 +0000 (16:13 +0800)
committerTom Rini <trini@ti.com>
Mon, 17 Nov 2014 13:47:15 +0000 (08:47 -0500)
We need to make sure the main clock ready field in MCFR is set
after switch to main crystal oscillator.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
arch/arm/cpu/at91-common/spl.c

index 674a47061e73f235ff488eb3ef67f2624bc5df9b..57fb04106d9fee48b3a57a3016dea83a3d2a42a4 100644 (file)
@@ -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);