blob: 4f7884eebc149a5b0c57645df7b3e471e4edc7f9 [file] [log] [blame]
David Cohenecd69102013-12-16 12:07:36 -08001/*
2 * mfld.c: Intel Medfield platform setup code
3 *
4 * (C) Copyright 2013 Intel Corporation
5 *
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.
10 */
11
12#include <linux/init.h>
13
14#include <asm/apic.h>
15#include <asm/intel-mid.h>
16#include <asm/intel_mid_vrtc.h>
17
Kuppuswamy Sathyanarayanan85611e32013-12-16 12:07:37 -080018#include "intel_mid_weak_decls.h"
19
20static void penwell_arch_setup(void);
21/* penwell arch ops */
22static struct intel_mid_ops penwell_ops = {
23 .arch_setup = penwell_arch_setup,
24};
25
26static void mfld_power_off(void)
David Cohenecd69102013-12-16 12:07:36 -080027{
28}
29
Kuppuswamy Sathyanarayanan85611e32013-12-16 12:07:37 -080030static unsigned long __init mfld_calibrate_tsc(void)
David Cohenecd69102013-12-16 12:07:36 -080031{
32 unsigned long fast_calibrate;
33 u32 lo, hi, ratio, fsb;
34
35 rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
36 pr_debug("IA32 perf status is 0x%x, 0x%0x\n", lo, hi);
37 ratio = (hi >> 8) & 0x1f;
38 pr_debug("ratio is %d\n", ratio);
39 if (!ratio) {
40 pr_err("read a zero ratio, should be incorrect!\n");
41 pr_err("force tsc ratio to 16 ...\n");
42 ratio = 16;
43 }
44 rdmsr(MSR_FSB_FREQ, lo, hi);
45 if ((lo & 0x7) == 0x7)
Kuppuswamy Sathyanarayanan85611e32013-12-16 12:07:37 -080046 fsb = FSB_FREQ_83SKU;
David Cohenecd69102013-12-16 12:07:36 -080047 else
Kuppuswamy Sathyanarayanan85611e32013-12-16 12:07:37 -080048 fsb = FSB_FREQ_100SKU;
David Cohenecd69102013-12-16 12:07:36 -080049 fast_calibrate = ratio * fsb;
50 pr_debug("read penwell tsc %lu khz\n", fast_calibrate);
51 lapic_timer_frequency = fsb * 1000 / HZ;
52 /* mark tsc clocksource as reliable */
53 set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
54
55 if (fast_calibrate)
56 return fast_calibrate;
57
58 return 0;
59}
Kuppuswamy Sathyanarayanan85611e32013-12-16 12:07:37 -080060
61static void __init penwell_arch_setup()
62{
63 x86_platform.calibrate_tsc = mfld_calibrate_tsc;
64 pm_power_off = mfld_power_off;
65}
66
67void * __cpuinit get_penwell_ops()
68{
69 return &penwell_ops;
70}
71
72void * __cpuinit get_cloverview_ops()
73{
74 return &penwell_ops;
75}