x86: Move common Intel CPU info code into a function
[oweals/u-boot.git] / arch / x86 / cpu / intel_common / cpu.c
index d0ac17808c3e3d9f55407446821eb0c4ad378426..9357626b5a6ca4b7237b62e9d9b01632ae2ac41c 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <cpu.h>
 #include <dm.h>
 #include <errno.h>
 #include <asm/cpu_common.h>
@@ -110,3 +111,15 @@ int cpu_set_flex_ratio_to_tdp_nominal(void)
        /* Not reached */
        return -EINVAL;
 }
+
+int cpu_intel_get_info(struct cpu_info *info, int bclk)
+{
+       msr_t msr;
+
+       msr = msr_read(IA32_PERF_CTL);
+       info->cpu_freq = ((msr.lo >> 8) & 0xff) * bclk * 1000000;
+       info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU |
+               1 << CPU_FEAT_UCODE | 1 << CPU_FEAT_DEVICE_ID;
+
+       return 0;
+}