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_edram.h" 8 #include "i915_reg.h" 9 10 static u32 gen9_edram_size_mb(struct drm_i915_private *i915, u32 cap) 11 { 12 static const u8 ways[8] = { 4, 8, 12, 16, 16, 16, 16, 16 }; 13 static const u8 sets[4] = { 1, 1, 2, 2 }; 14 15 return EDRAM_NUM_BANKS(cap) * 16 ways[EDRAM_WAYS_IDX(cap)] * 17 sets[EDRAM_SETS_IDX(cap)]; 18 } 19 20 void i915_edram_detect(struct drm_i915_private *i915) 21 { 22 u32 edram_cap = 0; 23 24 if (!(IS_HASWELL(i915) || IS_BROADWELL(i915) || GRAPHICS_VER(i915) >= 9)) 25 return; 26 27 edram_cap = intel_uncore_read_fw(&i915->uncore, HSW_EDRAM_CAP); 28 29 /* NB: We can't write IDICR yet because we don't have gt funcs set up */ 30 31 if (!(edram_cap & EDRAM_ENABLED)) 32 return; 33 34 /* 35 * The needed capability bits for size calculation are not there with 36 * pre gen9 so return 128MB always. 37 */ 38 if (GRAPHICS_VER(i915) < 9) 39 i915->edram_size_mb = 128; 40 else 41 i915->edram_size_mb = gen9_edram_size_mb(i915, edram_cap); 42 43 drm_info(&i915->drm, "Found %uMB of eDRAM\n", i915->edram_size_mb); 44 } 45