power_status: Read intel perf directly from msr

This fixed CL:217015 that relied on the custom driver from
CL:217014 that is only in chromeos-kernel 3.10

The previous approch has 2 problems
1. Only Intel devices on 3.10 was BYT which is now moved to 4.4
2. The driver in CL:217014 calculated frequency incorrectly.
   Average frequency = base_freq * mperf / aperf
   base_freq = pstate_max_multiplier * bclock
   CL:217014 assumes that bclock is always 100 MHz which is
   not true on BYT.

This fixes the problem above by
1. Read relevant data directly from msr instead of depend on
   custom driver to expose that to sysfs.
2. Fix the frequency calulation described above.

BUG=chromium:412066
TEST=PLT.fast report wavg_cpufreq on eve and winky

Change-Id: If5fd322d04657da7c4f3ceb76df79412503f2485
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1054578
Reviewed-by: Todd Broch <tbroch@chromium.org>
diff --git a/client/bin/utils.py b/client/bin/utils.py
index 2a9f586..0016d6c 100644
--- a/client/bin/utils.py
+++ b/client/bin/utils.py
@@ -383,6 +383,22 @@
     return INTEL_UARCH_TABLE.get(family_model, family_model)
 
 
+INTEL_SILVERMONT_BCLK_TABLE = [83333, 100000, 133333, 116667, 80000];
+
+
+def get_intel_bclk_khz():
+    """Return Intel CPU base clock.
+
+    This only worked with SandyBridge (released in 2011) or newer. Older CPU has
+    133 MHz bclk. See turbostat code for implementation that also works with
+    older CPU. https://git.io/vpyKT
+    """
+    if get_intel_cpu_uarch() == 'Silvermont':
+        MSR_FSB_FREQ = 0xcd
+        return INTEL_SILVERMONT_BCLK_TABLE[utils.rdmsr(MSR_FSB_FREQ) & 0xf]
+    return 100000
+
+
 def get_current_kernel_arch():
     """Get the machine architecture, now just a wrap of 'uname -m'."""
     return os.popen('uname -m').read().rstrip()