mrfld.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Intel Merrifield platform specific 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 "intel_mid_weak_decls.h"
  15. static unsigned long __init tangier_calibrate_tsc(void)
  16. {
  17. unsigned long fast_calibrate;
  18. u32 lo, hi, ratio, fsb, bus_freq;
  19. /* *********************** */
  20. /* Compute TSC:Ratio * FSB */
  21. /* *********************** */
  22. /* Compute Ratio */
  23. rdmsr(MSR_PLATFORM_INFO, lo, hi);
  24. pr_debug("IA32 PLATFORM_INFO is 0x%x : %x\n", hi, lo);
  25. ratio = (lo >> 8) & 0xFF;
  26. pr_debug("ratio is %d\n", ratio);
  27. if (!ratio) {
  28. pr_err("Read a zero ratio, force tsc ratio to 4 ...\n");
  29. ratio = 4;
  30. }
  31. /* Compute FSB */
  32. rdmsr(MSR_FSB_FREQ, lo, hi);
  33. pr_debug("Actual FSB frequency detected by SOC 0x%x : %x\n",
  34. hi, lo);
  35. bus_freq = lo & 0x7;
  36. pr_debug("bus_freq = 0x%x\n", bus_freq);
  37. if (bus_freq == 0)
  38. fsb = FSB_FREQ_100SKU;
  39. else if (bus_freq == 1)
  40. fsb = FSB_FREQ_100SKU;
  41. else if (bus_freq == 2)
  42. fsb = FSB_FREQ_133SKU;
  43. else if (bus_freq == 3)
  44. fsb = FSB_FREQ_167SKU;
  45. else if (bus_freq == 4)
  46. fsb = FSB_FREQ_83SKU;
  47. else if (bus_freq == 5)
  48. fsb = FSB_FREQ_400SKU;
  49. else if (bus_freq == 6)
  50. fsb = FSB_FREQ_267SKU;
  51. else if (bus_freq == 7)
  52. fsb = FSB_FREQ_333SKU;
  53. else {
  54. BUG();
  55. pr_err("Invalid bus_freq! Setting to minimal value!\n");
  56. fsb = FSB_FREQ_100SKU;
  57. }
  58. /* TSC = FSB Freq * Resolved HFM Ratio */
  59. fast_calibrate = ratio * fsb;
  60. pr_debug("calculate tangier tsc %lu KHz\n", fast_calibrate);
  61. /* ************************************ */
  62. /* Calculate Local APIC Timer Frequency */
  63. /* ************************************ */
  64. lapic_timer_frequency = (fsb * 1000) / HZ;
  65. pr_debug("Setting lapic_timer_frequency = %d\n",
  66. lapic_timer_frequency);
  67. /* mark tsc clocksource as reliable */
  68. set_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE);
  69. return fast_calibrate;
  70. }
  71. static void __init tangier_arch_setup(void)
  72. {
  73. x86_platform.calibrate_tsc = tangier_calibrate_tsc;
  74. }
  75. /* tangier arch ops */
  76. static struct intel_mid_ops tangier_ops = {
  77. .arch_setup = tangier_arch_setup,
  78. };
  79. void *get_tangier_ops(void)
  80. {
  81. return &tangier_ops;
  82. }