[U-Boot] [RFC PATCH 5/7] arm: atmel: add plla and mck initialize function

Bo Shen voice.shen at atmel.com
Wed Oct 30 10:15:05 CET 2013


Add plla and mck initialize function.

Signed-off-by: Bo Shen <voice.shen at atmel.com>
---
 arch/arm/cpu/armv7/at91/clock.c              |   27 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    2 ++
 2 files changed, 29 insertions(+)

diff --git a/arch/arm/cpu/armv7/at91/clock.c b/arch/arm/cpu/armv7/at91/clock.c
index 1588e0c..ec92950 100644
--- a/arch/arm/cpu/armv7/at91/clock.c
+++ b/arch/arm/cpu/armv7/at91/clock.c
@@ -120,3 +120,30 @@ void at91_periph_clk_enable(int id)
 	else
 		writel(1 << id, &pmc->pcer);
 }
+
+void at91_plla_init(u32 pllar, int timeout)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+	writel(pllar, &pmc->pllar);
+	while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY)))
+		timeout--;
+}
+
+void at91_mck_init(u32 mckr, int timeout)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	u32 tmp;
+
+	tmp = readl(&pmc->mckr);
+	tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
+		 AT91_PMC_MCKR_MDIV_MASK |
+		 AT91_PMC_MCKR_PLLADIV_2);
+	tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
+		       AT91_PMC_MCKR_MDIV_MASK |
+		       AT91_PMC_MCKR_PLLADIV_2);
+	writel(tmp, &pmc->mckr);
+
+	while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+		timeout--;
+}
diff --git a/arch/arm/include/asm/arch-at91/at91_common.h b/arch/arm/include/asm/arch-at91/at91_common.h
index abcb97d..a692275 100644
--- a/arch/arm/include/asm/arch-at91/at91_common.h
+++ b/arch/arm/include/asm/arch-at91/at91_common.h
@@ -22,5 +22,7 @@ void at91_spi1_hw_init(unsigned long cs_mask);
 void at91_udp_hw_init(void);
 void at91_uhp_hw_init(void);
 void at91_lcd_hw_init(void);
+void at91_plla_init(u32 pllar, int timeout);
+void at91_mck_init(u32 mckr, int timeout);
 
 #endif /* AT91_COMMON_H */
-- 
1.7.9.5



More information about the U-Boot mailing list