xref: /linux/drivers/gpu/drm/xe/xe_guc.h (revision e7d759f31ca295d589f7420719c311870bb3166f)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_GUC_H_
7 #define _XE_GUC_H_
8 
9 #include "xe_gt.h"
10 #include "xe_guc_types.h"
11 #include "xe_hw_engine_types.h"
12 #include "xe_macros.h"
13 
14 struct drm_printer;
15 
16 int xe_guc_init(struct xe_guc *guc);
17 int xe_guc_init_post_hwconfig(struct xe_guc *guc);
18 int xe_guc_post_load_init(struct xe_guc *guc);
19 int xe_guc_reset(struct xe_guc *guc);
20 int xe_guc_upload(struct xe_guc *guc);
21 int xe_guc_min_load_for_hwconfig(struct xe_guc *guc);
22 int xe_guc_enable_communication(struct xe_guc *guc);
23 int xe_guc_suspend(struct xe_guc *guc);
24 void xe_guc_notify(struct xe_guc *guc);
25 int xe_guc_auth_huc(struct xe_guc *guc, u32 rsa_addr);
26 int xe_guc_mmio_send(struct xe_guc *guc, const u32 *request, u32 len);
27 int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request, u32 len,
28 			  u32 *response_buf);
29 int xe_guc_self_cfg32(struct xe_guc *guc, u16 key, u32 val);
30 int xe_guc_self_cfg64(struct xe_guc *guc, u16 key, u64 val);
31 void xe_guc_irq_handler(struct xe_guc *guc, const u16 iir);
32 void xe_guc_sanitize(struct xe_guc *guc);
33 void xe_guc_print_info(struct xe_guc *guc, struct drm_printer *p);
34 int xe_guc_reset_prepare(struct xe_guc *guc);
35 void xe_guc_reset_wait(struct xe_guc *guc);
36 void xe_guc_stop_prepare(struct xe_guc *guc);
37 int xe_guc_stop(struct xe_guc *guc);
38 int xe_guc_start(struct xe_guc *guc);
39 bool xe_guc_in_reset(struct xe_guc *guc);
40 
41 static inline u16 xe_engine_class_to_guc_class(enum xe_engine_class class)
42 {
43 	switch (class) {
44 	case XE_ENGINE_CLASS_RENDER:
45 		return GUC_RENDER_CLASS;
46 	case XE_ENGINE_CLASS_VIDEO_DECODE:
47 		return GUC_VIDEO_CLASS;
48 	case XE_ENGINE_CLASS_VIDEO_ENHANCE:
49 		return GUC_VIDEOENHANCE_CLASS;
50 	case XE_ENGINE_CLASS_COPY:
51 		return GUC_BLITTER_CLASS;
52 	case XE_ENGINE_CLASS_COMPUTE:
53 		return GUC_COMPUTE_CLASS;
54 	case XE_ENGINE_CLASS_OTHER:
55 		return GUC_GSC_OTHER_CLASS;
56 	default:
57 		XE_WARN_ON(class);
58 		return -1;
59 	}
60 }
61 
62 static inline struct xe_gt *guc_to_gt(struct xe_guc *guc)
63 {
64 	return container_of(guc, struct xe_gt, uc.guc);
65 }
66 
67 static inline struct xe_device *guc_to_xe(struct xe_guc *guc)
68 {
69 	return gt_to_xe(guc_to_gt(guc));
70 }
71 
72 #endif
73