xref: /dflybsd-src/sys/dev/drm/i915/intel_uc_fw.h (revision 3f2dd94a569761201b5b0a18b2f697f97fe1b9dc)
1*3f2dd94aSFrançois Tigeot /*
2*3f2dd94aSFrançois Tigeot  * Copyright © 2014-2017 Intel Corporation
3*3f2dd94aSFrançois Tigeot  *
4*3f2dd94aSFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
5*3f2dd94aSFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
6*3f2dd94aSFrançois Tigeot  * to deal in the Software without restriction, including without limitation
7*3f2dd94aSFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*3f2dd94aSFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
9*3f2dd94aSFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
10*3f2dd94aSFrançois Tigeot  *
11*3f2dd94aSFrançois Tigeot  * The above copyright notice and this permission notice (including the next
12*3f2dd94aSFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
13*3f2dd94aSFrançois Tigeot  * Software.
14*3f2dd94aSFrançois Tigeot  *
15*3f2dd94aSFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*3f2dd94aSFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*3f2dd94aSFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*3f2dd94aSFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*3f2dd94aSFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*3f2dd94aSFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*3f2dd94aSFrançois Tigeot  * IN THE SOFTWARE.
22*3f2dd94aSFrançois Tigeot  *
23*3f2dd94aSFrançois Tigeot  */
24*3f2dd94aSFrançois Tigeot 
25*3f2dd94aSFrançois Tigeot #ifndef _INTEL_UC_FW_H_
26*3f2dd94aSFrançois Tigeot #define _INTEL_UC_FW_H_
27*3f2dd94aSFrançois Tigeot 
28*3f2dd94aSFrançois Tigeot struct drm_printer;
29*3f2dd94aSFrançois Tigeot struct drm_i915_private;
30*3f2dd94aSFrançois Tigeot struct i915_vma;
31*3f2dd94aSFrançois Tigeot 
32*3f2dd94aSFrançois Tigeot /* Home of GuC, HuC and DMC firmwares */
33*3f2dd94aSFrançois Tigeot #define INTEL_UC_FIRMWARE_URL "https://01.org/linuxgraphics/downloads/firmware"
34*3f2dd94aSFrançois Tigeot 
35*3f2dd94aSFrançois Tigeot enum intel_uc_fw_status {
36*3f2dd94aSFrançois Tigeot 	INTEL_UC_FIRMWARE_FAIL = -1,
37*3f2dd94aSFrançois Tigeot 	INTEL_UC_FIRMWARE_NONE = 0,
38*3f2dd94aSFrançois Tigeot 	INTEL_UC_FIRMWARE_PENDING,
39*3f2dd94aSFrançois Tigeot 	INTEL_UC_FIRMWARE_SUCCESS
40*3f2dd94aSFrançois Tigeot };
41*3f2dd94aSFrançois Tigeot 
42*3f2dd94aSFrançois Tigeot enum intel_uc_fw_type {
43*3f2dd94aSFrançois Tigeot 	INTEL_UC_FW_TYPE_GUC,
44*3f2dd94aSFrançois Tigeot 	INTEL_UC_FW_TYPE_HUC
45*3f2dd94aSFrançois Tigeot };
46*3f2dd94aSFrançois Tigeot 
47*3f2dd94aSFrançois Tigeot /*
48*3f2dd94aSFrançois Tigeot  * This structure encapsulates all the data needed during the process
49*3f2dd94aSFrançois Tigeot  * of fetching, caching, and loading the firmware image into the uC.
50*3f2dd94aSFrançois Tigeot  */
51*3f2dd94aSFrançois Tigeot struct intel_uc_fw {
52*3f2dd94aSFrançois Tigeot 	const char *path;
53*3f2dd94aSFrançois Tigeot 	size_t size;
54*3f2dd94aSFrançois Tigeot 	struct drm_i915_gem_object *obj;
55*3f2dd94aSFrançois Tigeot 	enum intel_uc_fw_status fetch_status;
56*3f2dd94aSFrançois Tigeot 	enum intel_uc_fw_status load_status;
57*3f2dd94aSFrançois Tigeot 
58*3f2dd94aSFrançois Tigeot 	/*
59*3f2dd94aSFrançois Tigeot 	 * The firmware build process will generate a version header file with major and
60*3f2dd94aSFrançois Tigeot 	 * minor version defined. The versions are built into CSS header of firmware.
61*3f2dd94aSFrançois Tigeot 	 * i915 kernel driver set the minimal firmware version required per platform.
62*3f2dd94aSFrançois Tigeot 	 */
63*3f2dd94aSFrançois Tigeot 	u16 major_ver_wanted;
64*3f2dd94aSFrançois Tigeot 	u16 minor_ver_wanted;
65*3f2dd94aSFrançois Tigeot 	u16 major_ver_found;
66*3f2dd94aSFrançois Tigeot 	u16 minor_ver_found;
67*3f2dd94aSFrançois Tigeot 
68*3f2dd94aSFrançois Tigeot 	enum intel_uc_fw_type type;
69*3f2dd94aSFrançois Tigeot 	u32 header_size;
70*3f2dd94aSFrançois Tigeot 	u32 header_offset;
71*3f2dd94aSFrançois Tigeot 	u32 rsa_size;
72*3f2dd94aSFrançois Tigeot 	u32 rsa_offset;
73*3f2dd94aSFrançois Tigeot 	u32 ucode_size;
74*3f2dd94aSFrançois Tigeot 	u32 ucode_offset;
75*3f2dd94aSFrançois Tigeot };
76*3f2dd94aSFrançois Tigeot 
77*3f2dd94aSFrançois Tigeot static inline
intel_uc_fw_status_repr(enum intel_uc_fw_status status)78*3f2dd94aSFrançois Tigeot const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
79*3f2dd94aSFrançois Tigeot {
80*3f2dd94aSFrançois Tigeot 	switch (status) {
81*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FIRMWARE_FAIL:
82*3f2dd94aSFrançois Tigeot 		return "FAIL";
83*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FIRMWARE_NONE:
84*3f2dd94aSFrançois Tigeot 		return "NONE";
85*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FIRMWARE_PENDING:
86*3f2dd94aSFrançois Tigeot 		return "PENDING";
87*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FIRMWARE_SUCCESS:
88*3f2dd94aSFrançois Tigeot 		return "SUCCESS";
89*3f2dd94aSFrançois Tigeot 	}
90*3f2dd94aSFrançois Tigeot 	return "<invalid>";
91*3f2dd94aSFrançois Tigeot }
92*3f2dd94aSFrançois Tigeot 
intel_uc_fw_type_repr(enum intel_uc_fw_type type)93*3f2dd94aSFrançois Tigeot static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
94*3f2dd94aSFrançois Tigeot {
95*3f2dd94aSFrançois Tigeot 	switch (type) {
96*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FW_TYPE_GUC:
97*3f2dd94aSFrançois Tigeot 		return "GuC";
98*3f2dd94aSFrançois Tigeot 	case INTEL_UC_FW_TYPE_HUC:
99*3f2dd94aSFrançois Tigeot 		return "HuC";
100*3f2dd94aSFrançois Tigeot 	}
101*3f2dd94aSFrançois Tigeot 	return "uC";
102*3f2dd94aSFrançois Tigeot }
103*3f2dd94aSFrançois Tigeot 
104*3f2dd94aSFrançois Tigeot static inline
intel_uc_fw_init(struct intel_uc_fw * uc_fw,enum intel_uc_fw_type type)105*3f2dd94aSFrançois Tigeot void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type)
106*3f2dd94aSFrançois Tigeot {
107*3f2dd94aSFrançois Tigeot 	uc_fw->path = NULL;
108*3f2dd94aSFrançois Tigeot 	uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
109*3f2dd94aSFrançois Tigeot 	uc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
110*3f2dd94aSFrançois Tigeot 	uc_fw->type = type;
111*3f2dd94aSFrançois Tigeot }
112*3f2dd94aSFrançois Tigeot 
113*3f2dd94aSFrançois Tigeot void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
114*3f2dd94aSFrançois Tigeot 		       struct intel_uc_fw *uc_fw);
115*3f2dd94aSFrançois Tigeot int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
116*3f2dd94aSFrançois Tigeot 		       int (*xfer)(struct intel_uc_fw *uc_fw,
117*3f2dd94aSFrançois Tigeot 				   struct i915_vma *vma));
118*3f2dd94aSFrançois Tigeot void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
119*3f2dd94aSFrançois Tigeot void intel_uc_fw_dump(struct intel_uc_fw *uc_fw, struct drm_printer *p);
120*3f2dd94aSFrançois Tigeot 
121*3f2dd94aSFrançois Tigeot #endif
122