1 /*	$NetBSD: intel_uc.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $	*/
2 
3 /* SPDX-License-Identifier: MIT */
4 /*
5  * Copyright © 2014-2019 Intel Corporation
6  */
7 
8 #ifndef _INTEL_UC_H_
9 #define _INTEL_UC_H_
10 
11 #include "intel_guc.h"
12 #include "intel_huc.h"
13 #include "i915_params.h"
14 
15 struct intel_uc;
16 
17 struct intel_uc_ops {
18 	int (*sanitize)(struct intel_uc *uc);
19 	void (*init_fw)(struct intel_uc *uc);
20 	void (*fini_fw)(struct intel_uc *uc);
21 	void (*init)(struct intel_uc *uc);
22 	void (*fini)(struct intel_uc *uc);
23 	int (*init_hw)(struct intel_uc *uc);
24 	void (*fini_hw)(struct intel_uc *uc);
25 };
26 
27 struct intel_uc {
28 	struct intel_uc_ops const *ops;
29 	struct intel_guc guc;
30 	struct intel_huc huc;
31 
32 	/* Snapshot of GuC log from last failed load */
33 	struct drm_i915_gem_object *load_err_log;
34 };
35 
36 void intel_uc_init_early(struct intel_uc *uc);
37 void intel_uc_driver_late_release(struct intel_uc *uc);
38 void intel_uc_init_mmio(struct intel_uc *uc);
39 void intel_uc_reset_prepare(struct intel_uc *uc);
40 void intel_uc_suspend(struct intel_uc *uc);
41 void intel_uc_runtime_suspend(struct intel_uc *uc);
42 int intel_uc_resume(struct intel_uc *uc);
43 int intel_uc_runtime_resume(struct intel_uc *uc);
44 
intel_uc_supports_guc(struct intel_uc * uc)45 static inline bool intel_uc_supports_guc(struct intel_uc *uc)
46 {
47 	return intel_guc_is_supported(&uc->guc);
48 }
49 
intel_uc_uses_guc(struct intel_uc * uc)50 static inline bool intel_uc_uses_guc(struct intel_uc *uc)
51 {
52 	return intel_guc_is_enabled(&uc->guc);
53 }
54 
intel_uc_supports_guc_submission(struct intel_uc * uc)55 static inline bool intel_uc_supports_guc_submission(struct intel_uc *uc)
56 {
57 	return intel_guc_is_submission_supported(&uc->guc);
58 }
59 
intel_uc_uses_guc_submission(struct intel_uc * uc)60 static inline bool intel_uc_uses_guc_submission(struct intel_uc *uc)
61 {
62 	return intel_guc_is_submission_supported(&uc->guc);
63 }
64 
intel_uc_supports_huc(struct intel_uc * uc)65 static inline bool intel_uc_supports_huc(struct intel_uc *uc)
66 {
67 	return intel_uc_supports_guc(uc);
68 }
69 
intel_uc_uses_huc(struct intel_uc * uc)70 static inline bool intel_uc_uses_huc(struct intel_uc *uc)
71 {
72 	return intel_huc_is_enabled(&uc->huc);
73 }
74 
75 #define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \
76 static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
77 { \
78 	if (uc->ops->_OPS) \
79 		return uc->ops->_OPS(uc); \
80 	return _RET; \
81 }
82 intel_uc_ops_function(sanitize, sanitize, int, 0);
83 intel_uc_ops_function(fetch_firmwares, init_fw, void, );
84 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
85 intel_uc_ops_function(init, init, void, );
86 intel_uc_ops_function(fini, fini, void, );
87 intel_uc_ops_function(init_hw, init_hw, int, 0);
88 intel_uc_ops_function(fini_hw, fini_hw, void, );
89 #undef intel_uc_ops_function
90 
91 #endif
92