mfld.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  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. #include <linux/init.h>
  12. #include <asm/apic.h>
  13. #include <asm/intel-mid.h>
  14. #include <asm/intel_mid_vrtc.h>
  15. #include "intel_mid_weak_decls.h"
  16. static void penwell_arch_setup(void);
  17. /* penwell arch ops */
  18. static struct intel_mid_ops penwell_ops = {
  19. .arch_setup = penwell_arch_setup,
  20. };
  21. static void mfld_power_off(void)
  22. {
  23. }
  24. static unsigned long __init mfld_calibrate_tsc(void)
  25. {
  26. unsigned long fast_calibrate;
  27. u32 lo, hi, ratio, fsb;
  28. rdmsr(MSR_IA32_PERF_STATUS, lo, hi);
  29. pr_debug("IA32 perf status is 0x%x, 0x%0x\n", lo, hi);
  30. ratio = (hi >> 8) & 0x1f;
  31. pr_debug("ratio is %d\n", ratio);
  32. if (!ratio) {
  33. pr_err("read a zero ratio, should be incorrect!\n");
  34. pr_err("force tsc ratio to 16 ...\n");
  35. ratio = 16;
  36. }
  37. rdmsr(MSR_FSB_FREQ, lo, hi);
  38. if ((lo & 0x7) == 0x7)
  39. fsb = FSB_FREQ_83SKU;
  40. else
  41. fsb = FSB_FREQ_100SKU;
  42. fast_calibrate = ratio * fsb;
  43. pr_debug("read penwell tsc %lu khz\n", fast_calibrate);
  44. lapic_timer_frequency = fsb * 1000 / HZ;
  45. /* mark tsc clocksource as reliable */
  46. set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
  47. return fast_calibrate;
  48. }
  49. static void __init penwell_arch_setup(void)
  50. {
  51. x86_platform.calibrate_tsc = mfld_calibrate_tsc;
  52. pm_power_off = mfld_power_off;
  53. }
  54. void *get_penwell_ops(void)
  55. {
  56. return &penwell_ops;
  57. }
  58. void *get_cloverview_ops(void)
  59. {
  60. return &penwell_ops;
  61. }