OMAP3: Move get_sys_clkin_sel() function to not duplicate code
[pandora-x-loader.git] / cpu / omap3 / sys_info.c
index d6568a9..77b25a5 100644 (file)
@@ -21,6 +21,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/bits.h>
+#include <asm/arch/clocks.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/sys_info.h>
 
@@ -238,3 +239,21 @@ u32 get_sysboot_value(void)
        mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
        return mode;
 }
+
+/*
+ * get_sys_clkin_sel(): returns the sys_clkin_sel field value based on
+ *   input oscillator clock frequency.
+ */
+void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
+{
+       if (osc_clk == S38_4M)
+               *sys_clkin_sel = 4;
+       else if (osc_clk == S26M)
+               *sys_clkin_sel = 3;
+       else if (osc_clk == S19_2M)
+               *sys_clkin_sel = 2;
+       else if (osc_clk == S13M)
+               *sys_clkin_sel = 1;
+       else if (osc_clk == S12M)
+               *sys_clkin_sel = 0;
+}