Linux 4.18.10
[linux/fpc-iii.git] / arch / x86 / platform / intel-mid / mrfld.c
blobae7bdeb0e507d8890587814befa83b2048744fc8
1 /*
2 * Intel Merrifield platform specific setup code
4 * (C) Copyright 2013 Intel Corporation
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; version 2
9 * of the License.
12 #include <linux/init.h>
14 #include <asm/apic.h>
15 #include <asm/intel-mid.h>
17 #include "intel_mid_weak_decls.h"
19 static unsigned long __init tangier_calibrate_tsc(void)
21 unsigned long fast_calibrate;
22 u32 lo, hi, ratio, fsb, bus_freq;
24 /* *********************** */
25 /* Compute TSC:Ratio * FSB */
26 /* *********************** */
28 /* Compute Ratio */
29 rdmsr(MSR_PLATFORM_INFO, lo, hi);
30 pr_debug("IA32 PLATFORM_INFO is 0x%x : %x\n", hi, lo);
32 ratio = (lo >> 8) & 0xFF;
33 pr_debug("ratio is %d\n", ratio);
34 if (!ratio) {
35 pr_err("Read a zero ratio, force tsc ratio to 4 ...\n");
36 ratio = 4;
39 /* Compute FSB */
40 rdmsr(MSR_FSB_FREQ, lo, hi);
41 pr_debug("Actual FSB frequency detected by SOC 0x%x : %x\n",
42 hi, lo);
44 bus_freq = lo & 0x7;
45 pr_debug("bus_freq = 0x%x\n", bus_freq);
47 if (bus_freq == 0)
48 fsb = FSB_FREQ_100SKU;
49 else if (bus_freq == 1)
50 fsb = FSB_FREQ_100SKU;
51 else if (bus_freq == 2)
52 fsb = FSB_FREQ_133SKU;
53 else if (bus_freq == 3)
54 fsb = FSB_FREQ_167SKU;
55 else if (bus_freq == 4)
56 fsb = FSB_FREQ_83SKU;
57 else if (bus_freq == 5)
58 fsb = FSB_FREQ_400SKU;
59 else if (bus_freq == 6)
60 fsb = FSB_FREQ_267SKU;
61 else if (bus_freq == 7)
62 fsb = FSB_FREQ_333SKU;
63 else {
64 BUG();
65 pr_err("Invalid bus_freq! Setting to minimal value!\n");
66 fsb = FSB_FREQ_100SKU;
69 /* TSC = FSB Freq * Resolved HFM Ratio */
70 fast_calibrate = ratio * fsb;
71 pr_debug("calculate tangier tsc %lu KHz\n", fast_calibrate);
73 /* ************************************ */
74 /* Calculate Local APIC Timer Frequency */
75 /* ************************************ */
76 lapic_timer_frequency = (fsb * 1000) / HZ;
78 pr_debug("Setting lapic_timer_frequency = %d\n",
79 lapic_timer_frequency);
82 * TSC on Intel Atom SoCs is reliable and of known frequency.
83 * See tsc_msr.c for details.
85 setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
86 setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
88 return fast_calibrate;
91 static void __init tangier_arch_setup(void)
93 x86_platform.calibrate_tsc = tangier_calibrate_tsc;
94 x86_platform.legacy.rtc = 1;
97 /* tangier arch ops */
98 static struct intel_mid_ops tangier_ops = {
99 .arch_setup = tangier_arch_setup,
102 void *get_tangier_ops(void)
104 return &tangier_ops;