Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915: split out i915_freq.[ch]

The i915 core only needs three rather specific functions from
soc/intel_dram.[ch]: i9xx_fsb_freq(), ilk_fsb_freq(), and
ilk_mem_freq(). Add new i915_freq.[ch] and duplicate those functions for
i915 to reduce the dependency on soc/ code.

Wile duplication in general is bad, here it's a tradeoff to simplify the
i915, xe and display interactions.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/7bac1b194afdc20cd45e625a0a32fcbcd0b1136e.1763578288.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+130 -5
+1
drivers/gpu/drm/i915/Makefile
··· 28 28 i915_driver.o \ 29 29 i915_drm_client.o \ 30 30 i915_edram.o \ 31 + i915_freq.o \ 31 32 i915_getparam.o \ 32 33 i915_ioctl.o \ 33 34 i915_irq.o \
+2 -2
drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
··· 4 4 */ 5 5 6 6 #include "i915_drv.h" 7 + #include "i915_freq.h" 7 8 #include "i915_reg.h" 8 9 #include "intel_gt.h" 9 10 #include "intel_gt_clock_utils.h" 10 11 #include "intel_gt_print.h" 11 12 #include "intel_gt_regs.h" 12 - #include "soc/intel_dram.h" 13 13 14 14 static u32 read_reference_ts_freq(struct intel_uncore *uncore) 15 15 { ··· 148 148 * 149 149 * Testing on actual hardware has shown there is no /16. 150 150 */ 151 - return DIV_ROUND_CLOSEST(intel_fsb_freq(uncore->i915), 4) * 1000; 151 + return DIV_ROUND_CLOSEST(i9xx_fsb_freq(uncore->i915), 4) * 1000; 152 152 } 153 153 154 154 static u32 read_clock_frequency(struct intel_uncore *uncore)
+3 -3
drivers/gpu/drm/i915/gt/intel_rps.c
··· 10 10 11 11 #include "display/intel_display_rps.h" 12 12 #include "display/vlv_clock.h" 13 - #include "soc/intel_dram.h" 14 13 15 14 #include "i915_drv.h" 15 + #include "i915_freq.h" 16 16 #include "i915_irq.h" 17 17 #include "i915_reg.h" 18 18 #include "i915_wait_util.h" ··· 285 285 u32 rgvmodectl; 286 286 int c_m, i; 287 287 288 - fsb_freq = intel_fsb_freq(i915); 289 - mem_freq = intel_mem_freq(i915); 288 + fsb_freq = ilk_fsb_freq(i915); 289 + mem_freq = ilk_mem_freq(i915); 290 290 291 291 if (fsb_freq <= 3200000) 292 292 c_m = 0;
+111
drivers/gpu/drm/i915/i915_freq.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include <drm/drm_print.h> 5 + 6 + #include "i915_drv.h" 7 + #include "i915_freq.h" 8 + #include "intel_mchbar_regs.h" 9 + 10 + unsigned int i9xx_fsb_freq(struct drm_i915_private *i915) 11 + { 12 + u32 fsb; 13 + 14 + /* 15 + * Note that this only reads the state of the FSB 16 + * straps, not the actual FSB frequency. Some BIOSen 17 + * let you configure each independently. Ideally we'd 18 + * read out the actual FSB frequency but sadly we 19 + * don't know which registers have that information, 20 + * and all the relevant docs have gone to bit heaven :( 21 + */ 22 + fsb = intel_uncore_read(&i915->uncore, CLKCFG) & CLKCFG_FSB_MASK; 23 + 24 + if (IS_PINEVIEW(i915) || IS_MOBILE(i915)) { 25 + switch (fsb) { 26 + case CLKCFG_FSB_400: 27 + return 400000; 28 + case CLKCFG_FSB_533: 29 + return 533333; 30 + case CLKCFG_FSB_667: 31 + return 666667; 32 + case CLKCFG_FSB_800: 33 + return 800000; 34 + case CLKCFG_FSB_1067: 35 + return 1066667; 36 + case CLKCFG_FSB_1333: 37 + return 1333333; 38 + default: 39 + MISSING_CASE(fsb); 40 + return 1333333; 41 + } 42 + } else { 43 + switch (fsb) { 44 + case CLKCFG_FSB_400_ALT: 45 + return 400000; 46 + case CLKCFG_FSB_533: 47 + return 533333; 48 + case CLKCFG_FSB_667: 49 + return 666667; 50 + case CLKCFG_FSB_800: 51 + return 800000; 52 + case CLKCFG_FSB_1067_ALT: 53 + return 1066667; 54 + case CLKCFG_FSB_1333_ALT: 55 + return 1333333; 56 + case CLKCFG_FSB_1600_ALT: 57 + return 1600000; 58 + default: 59 + MISSING_CASE(fsb); 60 + return 1333333; 61 + } 62 + } 63 + } 64 + 65 + unsigned int ilk_fsb_freq(struct drm_i915_private *i915) 66 + { 67 + u16 fsb; 68 + 69 + fsb = intel_uncore_read16(&i915->uncore, CSIPLL0) & 0x3ff; 70 + 71 + switch (fsb) { 72 + case 0x00c: 73 + return 3200000; 74 + case 0x00e: 75 + return 3733333; 76 + case 0x010: 77 + return 4266667; 78 + case 0x012: 79 + return 4800000; 80 + case 0x014: 81 + return 5333333; 82 + case 0x016: 83 + return 5866667; 84 + case 0x018: 85 + return 6400000; 86 + default: 87 + drm_dbg(&i915->drm, "unknown fsb frequency 0x%04x\n", fsb); 88 + return 0; 89 + } 90 + } 91 + 92 + unsigned int ilk_mem_freq(struct drm_i915_private *i915) 93 + { 94 + u16 ddrpll; 95 + 96 + ddrpll = intel_uncore_read16(&i915->uncore, DDRMPLL1); 97 + switch (ddrpll & 0xff) { 98 + case 0xc: 99 + return 800000; 100 + case 0x10: 101 + return 1066667; 102 + case 0x14: 103 + return 1333333; 104 + case 0x18: 105 + return 1600000; 106 + default: 107 + drm_dbg(&i915->drm, "unknown memory frequency 0x%02x\n", 108 + ddrpll & 0xff); 109 + return 0; 110 + } 111 + }
+13
drivers/gpu/drm/i915/i915_freq.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __I915_FREQ_H__ 5 + #define __I915_FREQ_H__ 6 + 7 + struct drm_i915_private; 8 + 9 + unsigned int i9xx_fsb_freq(struct drm_i915_private *i915); 10 + unsigned int ilk_fsb_freq(struct drm_i915_private *i915); 11 + unsigned int ilk_mem_freq(struct drm_i915_private *i915); 12 + 13 + #endif /* __I915_FREQ_H__ */