From 6aa9f1f0eb97e315ab4db8e6da1d13db7ee7858f Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Thu, 7 Nov 2013 12:47:35 -0800 Subject: baytrail: Add BCLK and IACORE to pattrs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bus clock speed is needed when building ACPI P-state tables so extract that function and have the value be saved in pattrs. The various IACORE values are also needed, but rather than have the ACPI code to the bit manipulation have the pattrs store an array of the possible values for it to use directly. BUG=chrome-os-partner:23505 BRANCH=none TEST=build and boot on rambi Change-Id: I5ac06ccf66e9109186dd01342dbb6ccdd334ca69 Signed-off-by: Duncan Laurie Reviewed-on: https://chromium-review.googlesource.com/176140 Reviewed-by: Aaron Durbin Commit-Queue: Aaron Durbin Signed-off-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/4953 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki --- src/soc/intel/baytrail/tsc_freq.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/soc/intel/baytrail/tsc_freq.c') diff --git a/src/soc/intel/baytrail/tsc_freq.c b/src/soc/intel/baytrail/tsc_freq.c index 7795ab45b0..90f154c896 100644 --- a/src/soc/intel/baytrail/tsc_freq.c +++ b/src/soc/intel/baytrail/tsc_freq.c @@ -22,28 +22,32 @@ #include #include -unsigned long tsc_freq_mhz(void) +unsigned bus_freq_khz(void) { - msr_t platform_info; - msr_t clk_info; - unsigned long bclk_khz; - - platform_info = rdmsr(MSR_PLATFORM_INFO); - clk_info = rdmsr(MSR_BSEL_CR_OVERCLOCK_CONTROL); + msr_t clk_info = rdmsr(MSR_BSEL_CR_OVERCLOCK_CONTROL); switch (clk_info.lo & 0x3) { case 0: - bclk_khz = 83333; - break; + return 83333; case 1: - bclk_khz = 100000; - break; + return 100000; case 2: - bclk_khz = 133333; - break; + return 133333; case 3: - bclk_khz = 116666; - break; + return 116666; + default: + return 0; } +} + +unsigned long tsc_freq_mhz(void) +{ + msr_t platform_info; + unsigned bclk_khz = bus_freq_khz(); + + if (!bclk_khz) + return 0; + + platform_info = rdmsr(MSR_PLATFORM_INFO); return (bclk_khz * ((platform_info.lo >> 8) & 0xff)) / 1000; } -- cgit v1.2.3