1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2021 Intel Corporation 4 */ 5 6 #include <drm/drm_managed.h> 7 #include <drm/drm_print.h> 8 9 #include "i915_drv.h" 10 #include "gt/intel_gt.h" 11 #include "gt/intel_sa_media.h" 12 13 int intel_sa_mediagt_setup(struct intel_gt *gt, phys_addr_t phys_addr, 14 u32 gsi_offset) 15 { 16 struct drm_i915_private *i915 = gt->i915; 17 struct intel_uncore *uncore; 18 19 uncore = drmm_kzalloc(&i915->drm, sizeof(*uncore), GFP_KERNEL); 20 if (!uncore) 21 return -ENOMEM; 22 23 uncore->gsi_offset = gsi_offset; 24 25 gt->irq_lock = to_gt(i915)->irq_lock; 26 intel_gt_common_init_early(gt); 27 intel_uncore_init_early(uncore, gt); 28 29 /* 30 * Standalone media shares the general MMIO space with the primary 31 * GT. We'll reuse the primary GT's mapping. 32 */ 33 uncore->regs = intel_uncore_regs(&i915->uncore); 34 if (drm_WARN_ON(&i915->drm, uncore->regs == NULL)) 35 return -EIO; 36 37 gt->uncore = uncore; 38 gt->phys_addr = phys_addr; 39 40 /* 41 * For current platforms we can assume there's only a single 42 * media GT and cache it for quick lookup. 43 */ 44 drm_WARN_ON(&i915->drm, i915->media_gt); 45 i915->media_gt = gt; 46 47 return 0; 48 } 49