From: Bo Shen Date: Fri, 24 Oct 2014 16:13:25 +0800 Subject: [U-Boot] [PATCH 1/2] ARM: atmel: spl: make initialization more stable Message-ID: <1414138406-4933-1-git-send-email-voice.shen@atmel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- arch/arm/cpu/at91-common/spl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/cpu/at91-common/spl.c b/arch/arm/cpu/at91-common/spl.c index cbb5a52..1d7770e 100644 --- a/arch/arm/cpu/at91-common/spl.c +++ b/arch/arm/cpu/at91-common/spl.c @@ -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); -- 2.1.0.24.g4109c28