- if (cpuid_info()->cpuid_family != CPU_FAMILY_PENTIUM_M) {
- panic("tsc_init: unknown CPU family: 0x%X\n",
- cpuid_info()->cpuid_family);
- }
+ switch (cpuid_cpufamily()) {
+ case CPUFAMILY_INTEL_HASWELL:
+ case CPUFAMILY_INTEL_IVYBRIDGE:
+ case CPUFAMILY_INTEL_SANDYBRIDGE:
+ case CPUFAMILY_INTEL_WESTMERE:
+ case CPUFAMILY_INTEL_NEHALEM: {
+ uint64_t msr_flex_ratio;
+ uint64_t msr_platform_info;
+
+ /* See if FLEX_RATIO is being used */
+ msr_flex_ratio = rdmsr64(MSR_FLEX_RATIO);
+ msr_platform_info = rdmsr64(MSR_PLATFORM_INFO);
+ flex_ratio_min = (uint32_t)bitfield(msr_platform_info, 47, 40);
+ flex_ratio_max = (uint32_t)bitfield(msr_platform_info, 15, 8);
+ /* No BIOS-programed flex ratio. Use hardware max as default */
+ tscGranularity = flex_ratio_max;
+ if (msr_flex_ratio & bit(16)) {
+ /* Flex Enabled: Use this MSR if less than max */
+ flex_ratio = (uint32_t)bitfield(msr_flex_ratio, 15, 8);
+ if (flex_ratio < flex_ratio_max)
+ tscGranularity = flex_ratio;
+ }
+
+ /* If EFI isn't configured correctly, use a constant
+ * value. See 6036811.
+ */
+ if (busFreq == 0)
+ busFreq = BASE_NHM_CLOCK_SOURCE;