mfld.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if (fast_calibrate)
  48. return fast_calibrate;
  49. return 0;
  50. }
  51. static void __init penwell_arch_setup(void)
  52. {
  53. x86_platform.calibrate_tsc = mfld_calibrate_tsc;
  54. pm_power_off = mfld_power_off;
  55. }
  56. void *get_penwell_ops(void)
  57. {
  58. return &penwell_ops;
  59. }
  60. void *get_cloverview_ops(void)
  61. {
  62. return &penwell_ops;
  63. }