1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2022 Intel Corporation
4 */
5
6#ifndef _XE_UC_FW_TYPES_H_
7#define _XE_UC_FW_TYPES_H_
8
9#include <linux/types.h>
10
11struct xe_bo;
12
13/*
14 * +------------+---------------------------------------------------+
15 * | PHASE | FIRMWARE STATUS TRANSITIONS |
16 * +============+===================================================+
17 * | | UNINITIALIZED |
18 * +------------+- / | \ -+
19 * | | DISABLED <--/ | \--> NOT_SUPPORTED |
20 * | init_early | V |
21 * | | SELECTED |
22 * +------------+- / | \ -+
23 * | | MISSING <--/ | \--> ERROR |
24 * | fetch | V |
25 * | | AVAILABLE |
26 * +------------+- | \ -+
27 * | | | \--> INIT FAIL |
28 * | init | V |
29 * | | /------> LOADABLE <----<-----------\ |
30 * +------------+- \ / \ \ \ -+
31 * | | LOAD FAIL <--< \--> TRANSFERRED \ |
32 * | upload | \ / \ / |
33 * | | \---------/ \--> RUNNING |
34 * +------------+---------------------------------------------------+
35 */
36
37/*
38 * FIXME: Ported from the i915 and this is state machine is way too complicated.
39 * Circle back and simplify this.
40 */
41enum xe_uc_fw_status {
42 XE_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW */
43 XE_UC_FIRMWARE_UNINITIALIZED = 0, /* used to catch checks done too early */
44 XE_UC_FIRMWARE_DISABLED, /* disabled */
45 XE_UC_FIRMWARE_SELECTED, /* selected the blob we want to load */
46 XE_UC_FIRMWARE_MISSING, /* blob not found on the system */
47 XE_UC_FIRMWARE_ERROR, /* invalid format or version */
48 XE_UC_FIRMWARE_AVAILABLE, /* blob found and copied in mem */
49 XE_UC_FIRMWARE_INIT_FAIL, /* failed to prepare fw objects for load */
50 XE_UC_FIRMWARE_LOADABLE, /* all fw-required objects are ready */
51 XE_UC_FIRMWARE_LOAD_FAIL, /* failed to xfer or init/auth the fw */
52 XE_UC_FIRMWARE_TRANSFERRED, /* dma xfer done */
53 XE_UC_FIRMWARE_RUNNING, /* init/auth done */
54 XE_UC_FIRMWARE_PRELOADED, /* preloaded by the PF driver */
55};
56
57enum xe_uc_fw_type {
58 XE_UC_FW_TYPE_GUC = 0,
59 XE_UC_FW_TYPE_HUC,
60 XE_UC_FW_TYPE_GSC,
61 XE_UC_FW_NUM_TYPES
62};
63
64/**
65 * struct xe_uc_fw_version - Version for Xe micro controller firmware
66 */
67struct xe_uc_fw_version {
68 /** @branch: branch version of the FW (not always available) */
69 u16 branch;
70 /** @major: major version of the FW */
71 u16 major;
72 /** @minor: minor version of the FW */
73 u16 minor;
74 /** @patch: patch version of the FW */
75 u16 patch;
76 /** @build: build version of the FW (not always available) */
77 u16 build;
78};
79
80enum xe_uc_fw_version_types {
81 XE_UC_FW_VER_RELEASE,
82 XE_UC_FW_VER_COMPATIBILITY,
83 XE_UC_FW_VER_TYPE_COUNT
84};
85
86/**
87 * struct xe_uc_fw - Xe micro controller firmware
88 */
89struct xe_uc_fw {
90 /** @type: type uC firmware */
91 enum xe_uc_fw_type type;
92 union {
93 /** @status: firmware load status */
94 const enum xe_uc_fw_status status;
95 /**
96 * @__status: private firmware load status - only to be used
97 * by firmware loading code
98 */
99 enum xe_uc_fw_status __status;
100 };
101 /** @path: path to uC firmware */
102 const char *path;
103 /** @user_overridden: user provided path to uC firmware via modparam */
104 bool user_overridden;
105 /**
106 * @full_ver_required: driver still under development and not ready
107 * for backward-compatible firmware. To be used only for **new**
108 * platforms, i.e. still under require_force_probe protection and not
109 * supported by i915.
110 */
111 bool full_ver_required;
112 /** @size: size of uC firmware including css header */
113 size_t size;
114
115 /** @bo: Xe BO for uC firmware */
116 struct xe_bo *bo;
117
118 /** @has_gsc_headers: whether the FW image starts with GSC headers */
119 bool has_gsc_headers;
120
121 /*
122 * The firmware build process will generate a version header file with
123 * major and minor version defined. The versions are built into CSS
124 * header of firmware. The xe kernel driver set the minimal firmware
125 * version required per platform.
126 */
127
128 /** @versions: FW versions wanted and found */
129 struct {
130 /** @versions.wanted: firmware version wanted by platform */
131 struct xe_uc_fw_version wanted;
132 /**
133 * @versions.wanted_type: type of firmware version wanted
134 * (release vs compatibility)
135 */
136 enum xe_uc_fw_version_types wanted_type;
137 /** @versions.found: fw versions found in firmware blob */
138 struct xe_uc_fw_version found[XE_UC_FW_VER_TYPE_COUNT];
139 } versions;
140
141 /** @rsa_size: RSA size */
142 u32 rsa_size;
143 /** @ucode_size: micro kernel size */
144 u32 ucode_size;
145 /** @css_offset: offset within the blob at which the CSS is located */
146 u32 css_offset;
147
148 /** @private_data_size: size of private data found in uC css header */
149 u32 private_data_size;
150
151 /** @build_type: Firmware build type (see CSS_UKERNEL_INFO_BUILDTYPE for definitions) */
152 u32 build_type;
153};
154
155#endif
156

source code of linux/drivers/gpu/drm/xe/xe_uc_fw_types.h