]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/i915/intel_uc_fw.h
Merge tag 'drm-amdkfd-next-2017-10-18' of git://people.freedesktop.org/~gabbayo/linux...
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / i915 / intel_uc_fw.h
1 /*
2 * Copyright © 2014-2017 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef _INTEL_UC_FW_H_
26 #define _INTEL_UC_FW_H_
27
28 struct drm_i915_private;
29
30 enum intel_uc_fw_status {
31 INTEL_UC_FIRMWARE_FAIL = -1,
32 INTEL_UC_FIRMWARE_NONE = 0,
33 INTEL_UC_FIRMWARE_PENDING,
34 INTEL_UC_FIRMWARE_SUCCESS
35 };
36
37 enum intel_uc_fw_type {
38 INTEL_UC_FW_TYPE_GUC,
39 INTEL_UC_FW_TYPE_HUC
40 };
41
42 /*
43 * This structure encapsulates all the data needed during the process
44 * of fetching, caching, and loading the firmware image into the uC.
45 */
46 struct intel_uc_fw {
47 const char *path;
48 size_t size;
49 struct drm_i915_gem_object *obj;
50 enum intel_uc_fw_status fetch_status;
51 enum intel_uc_fw_status load_status;
52
53 u16 major_ver_wanted;
54 u16 minor_ver_wanted;
55 u16 major_ver_found;
56 u16 minor_ver_found;
57
58 enum intel_uc_fw_type type;
59 u32 header_size;
60 u32 header_offset;
61 u32 rsa_size;
62 u32 rsa_offset;
63 u32 ucode_size;
64 u32 ucode_offset;
65 };
66
67 static inline
68 const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
69 {
70 switch (status) {
71 case INTEL_UC_FIRMWARE_FAIL:
72 return "FAIL";
73 case INTEL_UC_FIRMWARE_NONE:
74 return "NONE";
75 case INTEL_UC_FIRMWARE_PENDING:
76 return "PENDING";
77 case INTEL_UC_FIRMWARE_SUCCESS:
78 return "SUCCESS";
79 }
80 return "<invalid>";
81 }
82
83 static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
84 {
85 switch (type) {
86 case INTEL_UC_FW_TYPE_GUC:
87 return "GuC";
88 case INTEL_UC_FW_TYPE_HUC:
89 return "HuC";
90 }
91 return "uC";
92 }
93
94 static inline
95 void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type)
96 {
97 uc_fw->path = NULL;
98 uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
99 uc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
100 uc_fw->type = type;
101 }
102
103 void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
104 struct intel_uc_fw *uc_fw);
105 void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
106
107 #endif