@@ -631,31 +631,38 @@ unsigned long native_calibrate_tsc(void)
631
631
632
632
crystal_khz = ecx_hz / 1000 ;
633
633
634
- if (crystal_khz == 0 ) {
635
- switch (boot_cpu_data .x86_model ) {
636
- case INTEL_FAM6_SKYLAKE_MOBILE :
637
- case INTEL_FAM6_SKYLAKE_DESKTOP :
638
- case INTEL_FAM6_KABYLAKE_MOBILE :
639
- case INTEL_FAM6_KABYLAKE_DESKTOP :
640
- crystal_khz = 24000 ; /* 24.0 MHz */
641
- break ;
642
- case INTEL_FAM6_ATOM_GOLDMONT_X :
643
- crystal_khz = 25000 ; /* 25.0 MHz */
644
- break ;
645
- case INTEL_FAM6_ATOM_GOLDMONT :
646
- crystal_khz = 19200 ; /* 19.2 MHz */
647
- break ;
648
- }
649
- }
634
+ /*
635
+ * Denverton SoCs don't report crystal clock, and also don't support
636
+ * CPUID.0x16 for the calculation below, so hardcode the 25MHz crystal
637
+ * clock.
638
+ */
639
+ if (crystal_khz == 0 &&
640
+ boot_cpu_data .x86_model == INTEL_FAM6_ATOM_GOLDMONT_X )
641
+ crystal_khz = 25000 ;
650
642
651
- if (crystal_khz == 0 )
652
- return 0 ;
653
643
/*
654
- * TSC frequency determined by CPUID is a "hardware reported"
644
+ * TSC frequency reported directly by CPUID is a "hardware reported"
655
645
* frequency and is the most accurate one so far we have. This
656
646
* is considered a known frequency.
657
647
*/
658
- setup_force_cpu_cap (X86_FEATURE_TSC_KNOWN_FREQ );
648
+ if (crystal_khz != 0 )
649
+ setup_force_cpu_cap (X86_FEATURE_TSC_KNOWN_FREQ );
650
+
651
+ /*
652
+ * Some Intel SoCs like Skylake and Kabylake don't report the crystal
653
+ * clock, but we can easily calculate it to a high degree of accuracy
654
+ * by considering the crystal ratio and the CPU speed.
655
+ */
656
+ if (crystal_khz == 0 && boot_cpu_data .cpuid_level >= 0x16 ) {
657
+ unsigned int eax_base_mhz , ebx , ecx , edx ;
658
+
659
+ cpuid (0x16 , & eax_base_mhz , & ebx , & ecx , & edx );
660
+ crystal_khz = eax_base_mhz * 1000 *
661
+ eax_denominator / ebx_numerator ;
662
+ }
663
+
664
+ if (crystal_khz == 0 )
665
+ return 0 ;
659
666
660
667
/*
661
668
* For Atom SoCs TSC is the only reliable clocksource.
0 commit comments