Skip to contentSkip to conversation

add TI DA8xx support: Add DA8xx cpu functions

PATCH Superseded Nick Thompson 1 participant 1 message Oct 26, 2009

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/4 add TI DA8xx support: Add DA8xx cpu functions

Provides initial support for TI OMAP-L1x/DA8xx SoC devices. See http://www.ti.com

Provides:
Low level initialisation.
System clock API.
Timer control.

---
Applies to u-boot-ti

cpu/arm926ejs/davinci/cpu.c +39 -1
index 390cab8..4095d56 100644
@@ -23,7 +23,7 @@
 #include <common.h>
 #include <netdev.h>
 #include <asm/arch/hardware.h>
-
+#include <asm/io.h>
 
 /* offsets from PLL controller base */
 #define PLLC_PLLCTL	0x100
@@ -60,6 +60,44 @@
 #define DDR_PLLDIV	PLLC_PLLDIV1
 #endif
 
+#ifdef CONFIG_SOC_DA8XX
+const unsigned int const sysdiv[9] = {
+	PLL0_DIV1, PLL0_DIV2, PLL0_DIV3, PLL0_DIV4,
+	PLL0_DIV5, PLL0_DIV6, PLL0_DIV7, PLL0_DIV8,
+	PLL0_DIV9
+};
+
+int clk_get(unsigned int id)
+{
+	int pre_div = (readl(PLL0_PREDIV) & 0xff) + 1;
+	int pllm = readl(PLL0_PLLM) + 1;
+	int post_div = (readl(PLL0_POSTDIV) & 0xff) + 1;
+	int pll_out = CONFIG_SYS_OSCIN_FREQ;
+
+	if (id == DAVINCI_AUXCLK_CLKID)
+		goto out;
+
+	/*
+	 * Lets keep this simple. Combining operations can result in
+	 * unexpected approximations
+	 */
+	pll_out /= pre_div;
+	pll_out *= pllm;
+
+	if (id == DAVINCI_PLLM_CLKID)
+		goto out;
+
+	pll_out /= post_div;
+
+	if (id == DAVINCI_PLLC_CLKID)
+		goto out;
+
+	pll_out /= (readl(sysdiv[id - 1]) & 0xff) + 1;
+
+out:
+	return pll_out;
+}
+#endif /* CONFIG_SOC_DA8XX */
 
 #ifdef CONFIG_DISPLAY_CPUINFO
 
cpu/arm926ejs/davinci/psc.c +32 -11

75 lines not on this page · raw message