blob: 412fbdc4db9333d58be4919afbc758aa84871a5e [file] [log] [blame]
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +00001/*
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
28struct drm_i915_private;
Michal Wajdeczko4502e9e2017-10-16 14:47:21 +000029struct i915_vma;
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +000030
Michal Wajdeczkof1e86ce2017-10-16 14:47:20 +000031/* Home of GuC, HuC and DMC firmwares */
Michal Wajdeczko1e913d22017-10-16 14:47:19 +000032#define INTEL_UC_FIRMWARE_URL "https://01.org/linuxgraphics/downloads/firmware"
33
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +000034enum intel_uc_fw_status {
35 INTEL_UC_FIRMWARE_FAIL = -1,
36 INTEL_UC_FIRMWARE_NONE = 0,
37 INTEL_UC_FIRMWARE_PENDING,
38 INTEL_UC_FIRMWARE_SUCCESS
39};
40
41enum intel_uc_fw_type {
42 INTEL_UC_FW_TYPE_GUC,
43 INTEL_UC_FW_TYPE_HUC
44};
45
46/*
47 * This structure encapsulates all the data needed during the process
48 * of fetching, caching, and loading the firmware image into the uC.
49 */
50struct intel_uc_fw {
51 const char *path;
52 size_t size;
53 struct drm_i915_gem_object *obj;
54 enum intel_uc_fw_status fetch_status;
55 enum intel_uc_fw_status load_status;
56
Michal Wajdeczkod9e2e012017-10-16 14:47:13 +000057 /*
58 * The firmware build process will generate a version header file with major and
59 * minor version defined. The versions are built into CSS header of firmware.
60 * i915 kernel driver set the minimal firmware version required per platform.
61 */
Joonas Lahtinenfaf65482017-10-06 11:49:40 +030062 u16 major_ver_wanted;
63 u16 minor_ver_wanted;
64 u16 major_ver_found;
65 u16 minor_ver_found;
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +000066
67 enum intel_uc_fw_type type;
Joonas Lahtinenfaf65482017-10-06 11:49:40 +030068 u32 header_size;
69 u32 header_offset;
70 u32 rsa_size;
71 u32 rsa_offset;
72 u32 ucode_size;
73 u32 ucode_offset;
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +000074};
75
76static inline
77const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
78{
79 switch (status) {
80 case INTEL_UC_FIRMWARE_FAIL:
81 return "FAIL";
82 case INTEL_UC_FIRMWARE_NONE:
83 return "NONE";
84 case INTEL_UC_FIRMWARE_PENDING:
85 return "PENDING";
86 case INTEL_UC_FIRMWARE_SUCCESS:
87 return "SUCCESS";
88 }
89 return "<invalid>";
90}
91
92static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
93{
94 switch (type) {
95 case INTEL_UC_FW_TYPE_GUC:
96 return "GuC";
97 case INTEL_UC_FW_TYPE_HUC:
98 return "HuC";
99 }
100 return "uC";
101}
102
Michal Wajdeczko959a3b62017-10-04 18:13:43 +0000103static inline
104void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type)
105{
106 uc_fw->path = NULL;
107 uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE;
108 uc_fw->load_status = INTEL_UC_FIRMWARE_NONE;
109 uc_fw->type = type;
110}
111
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +0000112void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,
113 struct intel_uc_fw *uc_fw);
Michal Wajdeczko4502e9e2017-10-16 14:47:21 +0000114int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
115 int (*xfer)(struct intel_uc_fw *uc_fw,
116 struct i915_vma *vma));
Michal Wajdeczkoa16b4312017-10-04 15:33:25 +0000117void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
118
119#endif