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