]> Git Repo - linux.git/blob - drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
drm/amdgpu: bump smc firmware header version to v2 (v2)
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_ucode.h
1 /*
2  * Copyright 2012 Advanced Micro Devices, Inc.
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 shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 #ifndef __AMDGPU_UCODE_H__
24 #define __AMDGPU_UCODE_H__
25
26 struct common_firmware_header {
27         uint32_t size_bytes; /* size of the entire header+image(s) in bytes */
28         uint32_t header_size_bytes; /* size of just the header in bytes */
29         uint16_t header_version_major; /* header version */
30         uint16_t header_version_minor; /* header version */
31         uint16_t ip_version_major; /* IP version */
32         uint16_t ip_version_minor; /* IP version */
33         uint32_t ucode_version;
34         uint32_t ucode_size_bytes; /* size of ucode in bytes */
35         uint32_t ucode_array_offset_bytes; /* payload offset from the start of the header */
36         uint32_t crc32;  /* crc32 checksum of the payload */
37 };
38
39 /* version_major=1, version_minor=0 */
40 struct mc_firmware_header_v1_0 {
41         struct common_firmware_header header;
42         uint32_t io_debug_size_bytes; /* size of debug array in dwords */
43         uint32_t io_debug_array_offset_bytes; /* payload offset from the start of the header */
44 };
45
46 /* version_major=1, version_minor=0 */
47 struct smc_firmware_header_v1_0 {
48         struct common_firmware_header header;
49         uint32_t ucode_start_addr;
50 };
51
52 /* version_major=2, version_minor=0 */
53 struct smc_firmware_header_v2_0 {
54         struct smc_firmware_header_v1_0 v1_0;
55         uint32_t ppt_offset_bytes; /* soft pptable offset */
56         uint32_t ppt_size_bytes; /* soft pptable size */
57 };
58
59 /* version_major=1, version_minor=0 */
60 struct psp_firmware_header_v1_0 {
61         struct common_firmware_header header;
62         uint32_t ucode_feature_version;
63         uint32_t sos_offset_bytes;
64         uint32_t sos_size_bytes;
65 };
66
67 /* version_major=1, version_minor=1 */
68 struct psp_firmware_header_v1_1 {
69         struct psp_firmware_header_v1_0 v1_0;
70         uint32_t toc_header_version;
71         uint32_t toc_offset_bytes;
72         uint32_t toc_size_bytes;
73 };
74
75 /* version_major=1, version_minor=0 */
76 struct ta_firmware_header_v1_0 {
77         struct common_firmware_header header;
78         uint32_t ta_xgmi_ucode_version;
79         uint32_t ta_xgmi_offset_bytes;
80         uint32_t ta_xgmi_size_bytes;
81         uint32_t ta_ras_ucode_version;
82         uint32_t ta_ras_offset_bytes;
83         uint32_t ta_ras_size_bytes;
84 };
85
86 /* version_major=1, version_minor=0 */
87 struct gfx_firmware_header_v1_0 {
88         struct common_firmware_header header;
89         uint32_t ucode_feature_version;
90         uint32_t jt_offset; /* jt location */
91         uint32_t jt_size;  /* size of jt */
92 };
93
94 /* version_major=1, version_minor=0 */
95 struct rlc_firmware_header_v1_0 {
96         struct common_firmware_header header;
97         uint32_t ucode_feature_version;
98         uint32_t save_and_restore_offset;
99         uint32_t clear_state_descriptor_offset;
100         uint32_t avail_scratch_ram_locations;
101         uint32_t master_pkt_description_offset;
102 };
103
104 /* version_major=2, version_minor=0 */
105 struct rlc_firmware_header_v2_0 {
106         struct common_firmware_header header;
107         uint32_t ucode_feature_version;
108         uint32_t jt_offset; /* jt location */
109         uint32_t jt_size;  /* size of jt */
110         uint32_t save_and_restore_offset;
111         uint32_t clear_state_descriptor_offset;
112         uint32_t avail_scratch_ram_locations;
113         uint32_t reg_restore_list_size;
114         uint32_t reg_list_format_start;
115         uint32_t reg_list_format_separate_start;
116         uint32_t starting_offsets_start;
117         uint32_t reg_list_format_size_bytes; /* size of reg list format array in bytes */
118         uint32_t reg_list_format_array_offset_bytes; /* payload offset from the start of the header */
119         uint32_t reg_list_size_bytes; /* size of reg list array in bytes */
120         uint32_t reg_list_array_offset_bytes; /* payload offset from the start of the header */
121         uint32_t reg_list_format_separate_size_bytes; /* size of reg list format array in bytes */
122         uint32_t reg_list_format_separate_array_offset_bytes; /* payload offset from the start of the header */
123         uint32_t reg_list_separate_size_bytes; /* size of reg list array in bytes */
124         uint32_t reg_list_separate_array_offset_bytes; /* payload offset from the start of the header */
125 };
126
127 /* version_major=2, version_minor=1 */
128 struct rlc_firmware_header_v2_1 {
129         struct rlc_firmware_header_v2_0 v2_0;
130         uint32_t reg_list_format_direct_reg_list_length; /* length of direct reg list format array */
131         uint32_t save_restore_list_cntl_ucode_ver;
132         uint32_t save_restore_list_cntl_feature_ver;
133         uint32_t save_restore_list_cntl_size_bytes;
134         uint32_t save_restore_list_cntl_offset_bytes;
135         uint32_t save_restore_list_gpm_ucode_ver;
136         uint32_t save_restore_list_gpm_feature_ver;
137         uint32_t save_restore_list_gpm_size_bytes;
138         uint32_t save_restore_list_gpm_offset_bytes;
139         uint32_t save_restore_list_srm_ucode_ver;
140         uint32_t save_restore_list_srm_feature_ver;
141         uint32_t save_restore_list_srm_size_bytes;
142         uint32_t save_restore_list_srm_offset_bytes;
143 };
144
145 /* version_major=1, version_minor=0 */
146 struct sdma_firmware_header_v1_0 {
147         struct common_firmware_header header;
148         uint32_t ucode_feature_version;
149         uint32_t ucode_change_version;
150         uint32_t jt_offset; /* jt location */
151         uint32_t jt_size; /* size of jt */
152 };
153
154 /* version_major=1, version_minor=1 */
155 struct sdma_firmware_header_v1_1 {
156         struct sdma_firmware_header_v1_0 v1_0;
157         uint32_t digest_size;
158 };
159
160 /* gpu info payload */
161 struct gpu_info_firmware_v1_0 {
162         uint32_t gc_num_se;
163         uint32_t gc_num_cu_per_sh;
164         uint32_t gc_num_sh_per_se;
165         uint32_t gc_num_rb_per_se;
166         uint32_t gc_num_tccs;
167         uint32_t gc_num_gprs;
168         uint32_t gc_num_max_gs_thds;
169         uint32_t gc_gs_table_depth;
170         uint32_t gc_gsprim_buff_depth;
171         uint32_t gc_parameter_cache_depth;
172         uint32_t gc_double_offchip_lds_buffer;
173         uint32_t gc_wave_size;
174         uint32_t gc_max_waves_per_simd;
175         uint32_t gc_max_scratch_slots_per_cu;
176         uint32_t gc_lds_size;
177 };
178
179 struct gpu_info_firmware_v1_1 {
180         struct gpu_info_firmware_v1_0 v1_0;
181         uint32_t num_sc_per_sh;
182         uint32_t num_packer_per_sc;
183 };
184
185 /* version_major=1, version_minor=0 */
186 struct gpu_info_firmware_header_v1_0 {
187         struct common_firmware_header header;
188         uint16_t version_major; /* version */
189         uint16_t version_minor; /* version */
190 };
191
192 /* version_major=1, version_minor=0 */
193 struct dmcu_firmware_header_v1_0 {
194         struct common_firmware_header header;
195         uint32_t intv_offset_bytes; /* interrupt vectors offset from end of header, in bytes */
196         uint32_t intv_size_bytes;  /* size of interrupt vectors, in bytes */
197 };
198
199 /* header is fixed size */
200 union amdgpu_firmware_header {
201         struct common_firmware_header common;
202         struct mc_firmware_header_v1_0 mc;
203         struct smc_firmware_header_v1_0 smc;
204         struct smc_firmware_header_v2_0 smc_v2_0;
205         struct psp_firmware_header_v1_0 psp;
206         struct psp_firmware_header_v1_1 psp_v1_1;
207         struct ta_firmware_header_v1_0 ta;
208         struct gfx_firmware_header_v1_0 gfx;
209         struct rlc_firmware_header_v1_0 rlc;
210         struct rlc_firmware_header_v2_0 rlc_v2_0;
211         struct rlc_firmware_header_v2_1 rlc_v2_1;
212         struct sdma_firmware_header_v1_0 sdma;
213         struct sdma_firmware_header_v1_1 sdma_v1_1;
214         struct gpu_info_firmware_header_v1_0 gpu_info;
215         struct dmcu_firmware_header_v1_0 dmcu;
216         uint8_t raw[0x100];
217 };
218
219 /*
220  * fw loading support
221  */
222 enum AMDGPU_UCODE_ID {
223         AMDGPU_UCODE_ID_SDMA0 = 0,
224         AMDGPU_UCODE_ID_SDMA1,
225         AMDGPU_UCODE_ID_CP_CE,
226         AMDGPU_UCODE_ID_CP_PFP,
227         AMDGPU_UCODE_ID_CP_ME,
228         AMDGPU_UCODE_ID_CP_MEC1,
229         AMDGPU_UCODE_ID_CP_MEC1_JT,
230         AMDGPU_UCODE_ID_CP_MEC2,
231         AMDGPU_UCODE_ID_CP_MEC2_JT,
232         AMDGPU_UCODE_ID_RLC_G,
233         AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL,
234         AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM,
235         AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM,
236         AMDGPU_UCODE_ID_STORAGE,
237         AMDGPU_UCODE_ID_SMC,
238         AMDGPU_UCODE_ID_UVD,
239         AMDGPU_UCODE_ID_UVD1,
240         AMDGPU_UCODE_ID_VCE,
241         AMDGPU_UCODE_ID_VCN,
242         AMDGPU_UCODE_ID_DMCU_ERAM,
243         AMDGPU_UCODE_ID_DMCU_INTV,
244         AMDGPU_UCODE_ID_MAXIMUM,
245 };
246
247 /* engine firmware status */
248 enum AMDGPU_UCODE_STATUS {
249         AMDGPU_UCODE_STATUS_INVALID,
250         AMDGPU_UCODE_STATUS_NOT_LOADED,
251         AMDGPU_UCODE_STATUS_LOADED,
252 };
253
254 enum amdgpu_firmware_load_type {
255         AMDGPU_FW_LOAD_DIRECT = 0,
256         AMDGPU_FW_LOAD_SMU,
257         AMDGPU_FW_LOAD_PSP,
258         AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO,
259 };
260
261 /* conform to smu_ucode_xfer_cz.h */
262 #define AMDGPU_SDMA0_UCODE_LOADED       0x00000001
263 #define AMDGPU_SDMA1_UCODE_LOADED       0x00000002
264 #define AMDGPU_CPCE_UCODE_LOADED        0x00000004
265 #define AMDGPU_CPPFP_UCODE_LOADED       0x00000008
266 #define AMDGPU_CPME_UCODE_LOADED        0x00000010
267 #define AMDGPU_CPMEC1_UCODE_LOADED      0x00000020
268 #define AMDGPU_CPMEC2_UCODE_LOADED      0x00000040
269 #define AMDGPU_CPRLC_UCODE_LOADED       0x00000100
270
271 /* amdgpu firmware info */
272 struct amdgpu_firmware_info {
273         /* ucode ID */
274         enum AMDGPU_UCODE_ID ucode_id;
275         /* request_firmware */
276         const struct firmware *fw;
277         /* starting mc address */
278         uint64_t mc_addr;
279         /* kernel linear address */
280         void *kaddr;
281         /* ucode_size_bytes */
282         uint32_t ucode_size;
283         /* starting tmr mc address */
284         uint32_t tmr_mc_addr_lo;
285         uint32_t tmr_mc_addr_hi;
286 };
287
288 struct amdgpu_firmware {
289         struct amdgpu_firmware_info ucode[AMDGPU_UCODE_ID_MAXIMUM];
290         enum amdgpu_firmware_load_type load_type;
291         struct amdgpu_bo *fw_buf;
292         unsigned int fw_size;
293         unsigned int max_ucodes;
294         /* firmwares are loaded by psp instead of smu from vega10 */
295         const struct amdgpu_psp_funcs *funcs;
296         struct amdgpu_bo *rbuf;
297         struct mutex mutex;
298
299         /* gpu info firmware data pointer */
300         const struct firmware *gpu_info_fw;
301
302         void *fw_buf_ptr;
303         uint64_t fw_buf_mc;
304 };
305
306 void amdgpu_ucode_print_mc_hdr(const struct common_firmware_header *hdr);
307 void amdgpu_ucode_print_smc_hdr(const struct common_firmware_header *hdr);
308 void amdgpu_ucode_print_gfx_hdr(const struct common_firmware_header *hdr);
309 void amdgpu_ucode_print_rlc_hdr(const struct common_firmware_header *hdr);
310 void amdgpu_ucode_print_sdma_hdr(const struct common_firmware_header *hdr);
311 void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header *hdr);
312 void amdgpu_ucode_print_gpu_info_hdr(const struct common_firmware_header *hdr);
313 int amdgpu_ucode_validate(const struct firmware *fw);
314 bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
315                                 uint16_t hdr_major, uint16_t hdr_minor);
316
317 int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
318 int amdgpu_ucode_create_bo(struct amdgpu_device *adev);
319 int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev);
320 void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
321 void amdgpu_ucode_sysfs_fini(struct amdgpu_device *adev);
322
323 enum amdgpu_firmware_load_type
324 amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
325
326 #endif
This page took 0.052797 seconds and 4 git commands to generate.