i915_freq.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: MIT
  2. /* Copyright © 2025 Intel Corporation */
  3. #include <drm/drm_print.h>
  4. #include "i915_drv.h"
  5. #include "i915_freq.h"
  6. #include "intel_mchbar_regs.h"
  7. unsigned int i9xx_fsb_freq(struct drm_i915_private *i915)
  8. {
  9. u32 fsb;
  10. /*
  11. * Note that this only reads the state of the FSB
  12. * straps, not the actual FSB frequency. Some BIOSen
  13. * let you configure each independently. Ideally we'd
  14. * read out the actual FSB frequency but sadly we
  15. * don't know which registers have that information,
  16. * and all the relevant docs have gone to bit heaven :(
  17. */
  18. fsb = intel_uncore_read(&i915->uncore, CLKCFG) & CLKCFG_FSB_MASK;
  19. if (IS_PINEVIEW(i915) || IS_MOBILE(i915)) {
  20. switch (fsb) {
  21. case CLKCFG_FSB_400:
  22. return 400000;
  23. case CLKCFG_FSB_533:
  24. return 533333;
  25. case CLKCFG_FSB_667:
  26. return 666667;
  27. case CLKCFG_FSB_800:
  28. return 800000;
  29. case CLKCFG_FSB_1067:
  30. return 1066667;
  31. case CLKCFG_FSB_1333:
  32. return 1333333;
  33. default:
  34. MISSING_CASE(fsb);
  35. return 1333333;
  36. }
  37. } else {
  38. switch (fsb) {
  39. case CLKCFG_FSB_400_ALT:
  40. return 400000;
  41. case CLKCFG_FSB_533:
  42. return 533333;
  43. case CLKCFG_FSB_667:
  44. return 666667;
  45. case CLKCFG_FSB_800:
  46. return 800000;
  47. case CLKCFG_FSB_1067_ALT:
  48. return 1066667;
  49. case CLKCFG_FSB_1333_ALT:
  50. return 1333333;
  51. case CLKCFG_FSB_1600_ALT:
  52. return 1600000;
  53. default:
  54. MISSING_CASE(fsb);
  55. return 1333333;
  56. }
  57. }
  58. }
  59. unsigned int ilk_fsb_freq(struct drm_i915_private *i915)
  60. {
  61. u16 fsb;
  62. fsb = intel_uncore_read16(&i915->uncore, CSIPLL0) & 0x3ff;
  63. switch (fsb) {
  64. case 0x00c:
  65. return 3200000;
  66. case 0x00e:
  67. return 3733333;
  68. case 0x010:
  69. return 4266667;
  70. case 0x012:
  71. return 4800000;
  72. case 0x014:
  73. return 5333333;
  74. case 0x016:
  75. return 5866667;
  76. case 0x018:
  77. return 6400000;
  78. default:
  79. drm_dbg(&i915->drm, "unknown fsb frequency 0x%04x\n", fsb);
  80. return 0;
  81. }
  82. }
  83. unsigned int ilk_mem_freq(struct drm_i915_private *i915)
  84. {
  85. u16 ddrpll;
  86. ddrpll = intel_uncore_read16(&i915->uncore, DDRMPLL1);
  87. switch (ddrpll & 0xff) {
  88. case 0xc:
  89. return 800000;
  90. case 0x10:
  91. return 1066667;
  92. case 0x14:
  93. return 1333333;
  94. case 0x18:
  95. return 1600000;
  96. default:
  97. drm_dbg(&i915->drm, "unknown memory frequency 0x%02x\n",
  98. ddrpll & 0xff);
  99. return 0;
  100. }
  101. }