1*41ec0267Sriastradh /* $NetBSD: amdgpu_ucode.h,v 1.3 2021/12/18 23:44:58 riastradh Exp $ */ 2efa246c0Sriastradh 3efa246c0Sriastradh /* 4efa246c0Sriastradh * Copyright 2012 Advanced Micro Devices, Inc. 5efa246c0Sriastradh * 6efa246c0Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 7efa246c0Sriastradh * copy of this software and associated documentation files (the "Software"), 8efa246c0Sriastradh * to deal in the Software without restriction, including without limitation 9efa246c0Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10efa246c0Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 11efa246c0Sriastradh * Software is furnished to do so, subject to the following conditions: 12efa246c0Sriastradh * 13efa246c0Sriastradh * The above copyright notice and this permission notice shall be included in 14efa246c0Sriastradh * all copies or substantial portions of the Software. 15efa246c0Sriastradh * 16efa246c0Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17efa246c0Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18efa246c0Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19efa246c0Sriastradh * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20efa246c0Sriastradh * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21efa246c0Sriastradh * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22efa246c0Sriastradh * OTHER DEALINGS IN THE SOFTWARE. 23efa246c0Sriastradh * 24efa246c0Sriastradh */ 25efa246c0Sriastradh #ifndef __AMDGPU_UCODE_H__ 26efa246c0Sriastradh #define __AMDGPU_UCODE_H__ 27efa246c0Sriastradh 28*41ec0267Sriastradh #include "amdgpu_socbb.h" 29*41ec0267Sriastradh 30efa246c0Sriastradh struct common_firmware_header { 31efa246c0Sriastradh uint32_t size_bytes; /* size of the entire header+image(s) in bytes */ 32efa246c0Sriastradh uint32_t header_size_bytes; /* size of just the header in bytes */ 33efa246c0Sriastradh uint16_t header_version_major; /* header version */ 34efa246c0Sriastradh uint16_t header_version_minor; /* header version */ 35efa246c0Sriastradh uint16_t ip_version_major; /* IP version */ 36efa246c0Sriastradh uint16_t ip_version_minor; /* IP version */ 37efa246c0Sriastradh uint32_t ucode_version; 38efa246c0Sriastradh uint32_t ucode_size_bytes; /* size of ucode in bytes */ 39efa246c0Sriastradh uint32_t ucode_array_offset_bytes; /* payload offset from the start of the header */ 40efa246c0Sriastradh uint32_t crc32; /* crc32 checksum of the payload */ 41efa246c0Sriastradh }; 42efa246c0Sriastradh 43efa246c0Sriastradh /* version_major=1, version_minor=0 */ 44efa246c0Sriastradh struct mc_firmware_header_v1_0 { 45efa246c0Sriastradh struct common_firmware_header header; 46efa246c0Sriastradh uint32_t io_debug_size_bytes; /* size of debug array in dwords */ 47efa246c0Sriastradh uint32_t io_debug_array_offset_bytes; /* payload offset from the start of the header */ 48efa246c0Sriastradh }; 49efa246c0Sriastradh 50efa246c0Sriastradh /* version_major=1, version_minor=0 */ 51efa246c0Sriastradh struct smc_firmware_header_v1_0 { 52efa246c0Sriastradh struct common_firmware_header header; 53efa246c0Sriastradh uint32_t ucode_start_addr; 54efa246c0Sriastradh }; 55efa246c0Sriastradh 56*41ec0267Sriastradh /* version_major=2, version_minor=0 */ 57*41ec0267Sriastradh struct smc_firmware_header_v2_0 { 58*41ec0267Sriastradh struct smc_firmware_header_v1_0 v1_0; 59*41ec0267Sriastradh uint32_t ppt_offset_bytes; /* soft pptable offset */ 60*41ec0267Sriastradh uint32_t ppt_size_bytes; /* soft pptable size */ 61*41ec0267Sriastradh }; 62*41ec0267Sriastradh 63*41ec0267Sriastradh struct smc_soft_pptable_entry { 64*41ec0267Sriastradh uint32_t id; 65*41ec0267Sriastradh uint32_t ppt_offset_bytes; 66*41ec0267Sriastradh uint32_t ppt_size_bytes; 67*41ec0267Sriastradh }; 68*41ec0267Sriastradh 69*41ec0267Sriastradh /* version_major=2, version_minor=1 */ 70*41ec0267Sriastradh struct smc_firmware_header_v2_1 { 71*41ec0267Sriastradh struct smc_firmware_header_v1_0 v1_0; 72*41ec0267Sriastradh uint32_t pptable_count; 73*41ec0267Sriastradh uint32_t pptable_entry_offset; 74*41ec0267Sriastradh }; 75*41ec0267Sriastradh 76*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 77*41ec0267Sriastradh struct psp_firmware_header_v1_0 { 78*41ec0267Sriastradh struct common_firmware_header header; 79*41ec0267Sriastradh uint32_t ucode_feature_version; 80*41ec0267Sriastradh uint32_t sos_offset_bytes; 81*41ec0267Sriastradh uint32_t sos_size_bytes; 82*41ec0267Sriastradh }; 83*41ec0267Sriastradh 84*41ec0267Sriastradh /* version_major=1, version_minor=1 */ 85*41ec0267Sriastradh struct psp_firmware_header_v1_1 { 86*41ec0267Sriastradh struct psp_firmware_header_v1_0 v1_0; 87*41ec0267Sriastradh uint32_t toc_header_version; 88*41ec0267Sriastradh uint32_t toc_offset_bytes; 89*41ec0267Sriastradh uint32_t toc_size_bytes; 90*41ec0267Sriastradh uint32_t kdb_header_version; 91*41ec0267Sriastradh uint32_t kdb_offset_bytes; 92*41ec0267Sriastradh uint32_t kdb_size_bytes; 93*41ec0267Sriastradh }; 94*41ec0267Sriastradh 95*41ec0267Sriastradh /* version_major=1, version_minor=2 */ 96*41ec0267Sriastradh struct psp_firmware_header_v1_2 { 97*41ec0267Sriastradh struct psp_firmware_header_v1_0 v1_0; 98*41ec0267Sriastradh uint32_t reserve[3]; 99*41ec0267Sriastradh uint32_t kdb_header_version; 100*41ec0267Sriastradh uint32_t kdb_offset_bytes; 101*41ec0267Sriastradh uint32_t kdb_size_bytes; 102*41ec0267Sriastradh }; 103*41ec0267Sriastradh 104*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 105*41ec0267Sriastradh struct ta_firmware_header_v1_0 { 106*41ec0267Sriastradh struct common_firmware_header header; 107*41ec0267Sriastradh uint32_t ta_xgmi_ucode_version; 108*41ec0267Sriastradh uint32_t ta_xgmi_offset_bytes; 109*41ec0267Sriastradh uint32_t ta_xgmi_size_bytes; 110*41ec0267Sriastradh uint32_t ta_ras_ucode_version; 111*41ec0267Sriastradh uint32_t ta_ras_offset_bytes; 112*41ec0267Sriastradh uint32_t ta_ras_size_bytes; 113*41ec0267Sriastradh uint32_t ta_hdcp_ucode_version; 114*41ec0267Sriastradh uint32_t ta_hdcp_offset_bytes; 115*41ec0267Sriastradh uint32_t ta_hdcp_size_bytes; 116*41ec0267Sriastradh uint32_t ta_dtm_ucode_version; 117*41ec0267Sriastradh uint32_t ta_dtm_offset_bytes; 118*41ec0267Sriastradh uint32_t ta_dtm_size_bytes; 119*41ec0267Sriastradh }; 120*41ec0267Sriastradh 121efa246c0Sriastradh /* version_major=1, version_minor=0 */ 122efa246c0Sriastradh struct gfx_firmware_header_v1_0 { 123efa246c0Sriastradh struct common_firmware_header header; 124efa246c0Sriastradh uint32_t ucode_feature_version; 125efa246c0Sriastradh uint32_t jt_offset; /* jt location */ 126efa246c0Sriastradh uint32_t jt_size; /* size of jt */ 127efa246c0Sriastradh }; 128efa246c0Sriastradh 129efa246c0Sriastradh /* version_major=1, version_minor=0 */ 130*41ec0267Sriastradh struct mes_firmware_header_v1_0 { 131*41ec0267Sriastradh struct common_firmware_header header; 132*41ec0267Sriastradh uint32_t mes_ucode_version; 133*41ec0267Sriastradh uint32_t mes_ucode_size_bytes; 134*41ec0267Sriastradh uint32_t mes_ucode_offset_bytes; 135*41ec0267Sriastradh uint32_t mes_ucode_data_version; 136*41ec0267Sriastradh uint32_t mes_ucode_data_size_bytes; 137*41ec0267Sriastradh uint32_t mes_ucode_data_offset_bytes; 138*41ec0267Sriastradh uint32_t mes_uc_start_addr_lo; 139*41ec0267Sriastradh uint32_t mes_uc_start_addr_hi; 140*41ec0267Sriastradh uint32_t mes_data_start_addr_lo; 141*41ec0267Sriastradh uint32_t mes_data_start_addr_hi; 142*41ec0267Sriastradh }; 143*41ec0267Sriastradh 144*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 145efa246c0Sriastradh struct rlc_firmware_header_v1_0 { 146efa246c0Sriastradh struct common_firmware_header header; 147efa246c0Sriastradh uint32_t ucode_feature_version; 148efa246c0Sriastradh uint32_t save_and_restore_offset; 149efa246c0Sriastradh uint32_t clear_state_descriptor_offset; 150efa246c0Sriastradh uint32_t avail_scratch_ram_locations; 151efa246c0Sriastradh uint32_t master_pkt_description_offset; 152efa246c0Sriastradh }; 153efa246c0Sriastradh 154efa246c0Sriastradh /* version_major=2, version_minor=0 */ 155efa246c0Sriastradh struct rlc_firmware_header_v2_0 { 156efa246c0Sriastradh struct common_firmware_header header; 157efa246c0Sriastradh uint32_t ucode_feature_version; 158efa246c0Sriastradh uint32_t jt_offset; /* jt location */ 159efa246c0Sriastradh uint32_t jt_size; /* size of jt */ 160efa246c0Sriastradh uint32_t save_and_restore_offset; 161efa246c0Sriastradh uint32_t clear_state_descriptor_offset; 162efa246c0Sriastradh uint32_t avail_scratch_ram_locations; 163efa246c0Sriastradh uint32_t reg_restore_list_size; 164efa246c0Sriastradh uint32_t reg_list_format_start; 165efa246c0Sriastradh uint32_t reg_list_format_separate_start; 166efa246c0Sriastradh uint32_t starting_offsets_start; 167efa246c0Sriastradh uint32_t reg_list_format_size_bytes; /* size of reg list format array in bytes */ 168efa246c0Sriastradh uint32_t reg_list_format_array_offset_bytes; /* payload offset from the start of the header */ 169efa246c0Sriastradh uint32_t reg_list_size_bytes; /* size of reg list array in bytes */ 170efa246c0Sriastradh uint32_t reg_list_array_offset_bytes; /* payload offset from the start of the header */ 171efa246c0Sriastradh uint32_t reg_list_format_separate_size_bytes; /* size of reg list format array in bytes */ 172efa246c0Sriastradh uint32_t reg_list_format_separate_array_offset_bytes; /* payload offset from the start of the header */ 173efa246c0Sriastradh uint32_t reg_list_separate_size_bytes; /* size of reg list array in bytes */ 174efa246c0Sriastradh uint32_t reg_list_separate_array_offset_bytes; /* payload offset from the start of the header */ 175efa246c0Sriastradh }; 176efa246c0Sriastradh 177*41ec0267Sriastradh /* version_major=2, version_minor=1 */ 178*41ec0267Sriastradh struct rlc_firmware_header_v2_1 { 179*41ec0267Sriastradh struct rlc_firmware_header_v2_0 v2_0; 180*41ec0267Sriastradh uint32_t reg_list_format_direct_reg_list_length; /* length of direct reg list format array */ 181*41ec0267Sriastradh uint32_t save_restore_list_cntl_ucode_ver; 182*41ec0267Sriastradh uint32_t save_restore_list_cntl_feature_ver; 183*41ec0267Sriastradh uint32_t save_restore_list_cntl_size_bytes; 184*41ec0267Sriastradh uint32_t save_restore_list_cntl_offset_bytes; 185*41ec0267Sriastradh uint32_t save_restore_list_gpm_ucode_ver; 186*41ec0267Sriastradh uint32_t save_restore_list_gpm_feature_ver; 187*41ec0267Sriastradh uint32_t save_restore_list_gpm_size_bytes; 188*41ec0267Sriastradh uint32_t save_restore_list_gpm_offset_bytes; 189*41ec0267Sriastradh uint32_t save_restore_list_srm_ucode_ver; 190*41ec0267Sriastradh uint32_t save_restore_list_srm_feature_ver; 191*41ec0267Sriastradh uint32_t save_restore_list_srm_size_bytes; 192*41ec0267Sriastradh uint32_t save_restore_list_srm_offset_bytes; 193*41ec0267Sriastradh }; 194*41ec0267Sriastradh 195efa246c0Sriastradh /* version_major=1, version_minor=0 */ 196efa246c0Sriastradh struct sdma_firmware_header_v1_0 { 197efa246c0Sriastradh struct common_firmware_header header; 198efa246c0Sriastradh uint32_t ucode_feature_version; 199efa246c0Sriastradh uint32_t ucode_change_version; 200efa246c0Sriastradh uint32_t jt_offset; /* jt location */ 201efa246c0Sriastradh uint32_t jt_size; /* size of jt */ 202efa246c0Sriastradh }; 203efa246c0Sriastradh 204efa246c0Sriastradh /* version_major=1, version_minor=1 */ 205efa246c0Sriastradh struct sdma_firmware_header_v1_1 { 206efa246c0Sriastradh struct sdma_firmware_header_v1_0 v1_0; 207efa246c0Sriastradh uint32_t digest_size; 208efa246c0Sriastradh }; 209efa246c0Sriastradh 210*41ec0267Sriastradh /* gpu info payload */ 211*41ec0267Sriastradh struct gpu_info_firmware_v1_0 { 212*41ec0267Sriastradh uint32_t gc_num_se; 213*41ec0267Sriastradh uint32_t gc_num_cu_per_sh; 214*41ec0267Sriastradh uint32_t gc_num_sh_per_se; 215*41ec0267Sriastradh uint32_t gc_num_rb_per_se; 216*41ec0267Sriastradh uint32_t gc_num_tccs; 217*41ec0267Sriastradh uint32_t gc_num_gprs; 218*41ec0267Sriastradh uint32_t gc_num_max_gs_thds; 219*41ec0267Sriastradh uint32_t gc_gs_table_depth; 220*41ec0267Sriastradh uint32_t gc_gsprim_buff_depth; 221*41ec0267Sriastradh uint32_t gc_parameter_cache_depth; 222*41ec0267Sriastradh uint32_t gc_double_offchip_lds_buffer; 223*41ec0267Sriastradh uint32_t gc_wave_size; 224*41ec0267Sriastradh uint32_t gc_max_waves_per_simd; 225*41ec0267Sriastradh uint32_t gc_max_scratch_slots_per_cu; 226*41ec0267Sriastradh uint32_t gc_lds_size; 227*41ec0267Sriastradh }; 228*41ec0267Sriastradh 229*41ec0267Sriastradh struct gpu_info_firmware_v1_1 { 230*41ec0267Sriastradh struct gpu_info_firmware_v1_0 v1_0; 231*41ec0267Sriastradh uint32_t num_sc_per_sh; 232*41ec0267Sriastradh uint32_t num_packer_per_sc; 233*41ec0267Sriastradh }; 234*41ec0267Sriastradh 235*41ec0267Sriastradh /* gpu info payload 236*41ec0267Sriastradh * version_major=1, version_minor=1 */ 237*41ec0267Sriastradh struct gpu_info_firmware_v1_2 { 238*41ec0267Sriastradh struct gpu_info_firmware_v1_1 v1_1; 239*41ec0267Sriastradh struct gpu_info_soc_bounding_box_v1_0 soc_bounding_box; 240*41ec0267Sriastradh }; 241*41ec0267Sriastradh 242*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 243*41ec0267Sriastradh struct gpu_info_firmware_header_v1_0 { 244*41ec0267Sriastradh struct common_firmware_header header; 245*41ec0267Sriastradh uint16_t version_major; /* version */ 246*41ec0267Sriastradh uint16_t version_minor; /* version */ 247*41ec0267Sriastradh }; 248*41ec0267Sriastradh 249*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 250*41ec0267Sriastradh struct dmcu_firmware_header_v1_0 { 251*41ec0267Sriastradh struct common_firmware_header header; 252*41ec0267Sriastradh uint32_t intv_offset_bytes; /* interrupt vectors offset from end of header, in bytes */ 253*41ec0267Sriastradh uint32_t intv_size_bytes; /* size of interrupt vectors, in bytes */ 254*41ec0267Sriastradh }; 255*41ec0267Sriastradh 256*41ec0267Sriastradh /* version_major=1, version_minor=0 */ 257*41ec0267Sriastradh struct dmcub_firmware_header_v1_0 { 258*41ec0267Sriastradh struct common_firmware_header header; 259*41ec0267Sriastradh uint32_t inst_const_bytes; /* size of instruction region, in bytes */ 260*41ec0267Sriastradh uint32_t bss_data_bytes; /* size of bss/data region, in bytes */ 261*41ec0267Sriastradh }; 262*41ec0267Sriastradh 263efa246c0Sriastradh /* header is fixed size */ 264efa246c0Sriastradh union amdgpu_firmware_header { 265efa246c0Sriastradh struct common_firmware_header common; 266efa246c0Sriastradh struct mc_firmware_header_v1_0 mc; 267efa246c0Sriastradh struct smc_firmware_header_v1_0 smc; 268*41ec0267Sriastradh struct smc_firmware_header_v2_0 smc_v2_0; 269*41ec0267Sriastradh struct psp_firmware_header_v1_0 psp; 270*41ec0267Sriastradh struct psp_firmware_header_v1_1 psp_v1_1; 271*41ec0267Sriastradh struct ta_firmware_header_v1_0 ta; 272efa246c0Sriastradh struct gfx_firmware_header_v1_0 gfx; 273efa246c0Sriastradh struct rlc_firmware_header_v1_0 rlc; 274efa246c0Sriastradh struct rlc_firmware_header_v2_0 rlc_v2_0; 275*41ec0267Sriastradh struct rlc_firmware_header_v2_1 rlc_v2_1; 276efa246c0Sriastradh struct sdma_firmware_header_v1_0 sdma; 277efa246c0Sriastradh struct sdma_firmware_header_v1_1 sdma_v1_1; 278*41ec0267Sriastradh struct gpu_info_firmware_header_v1_0 gpu_info; 279*41ec0267Sriastradh struct dmcu_firmware_header_v1_0 dmcu; 280*41ec0267Sriastradh struct dmcub_firmware_header_v1_0 dmcub; 281efa246c0Sriastradh uint8_t raw[0x100]; 282efa246c0Sriastradh }; 283efa246c0Sriastradh 284efa246c0Sriastradh /* 285efa246c0Sriastradh * fw loading support 286efa246c0Sriastradh */ 287efa246c0Sriastradh enum AMDGPU_UCODE_ID { 288efa246c0Sriastradh AMDGPU_UCODE_ID_SDMA0 = 0, 289efa246c0Sriastradh AMDGPU_UCODE_ID_SDMA1, 290*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA2, 291*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA3, 292*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA4, 293*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA5, 294*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA6, 295*41ec0267Sriastradh AMDGPU_UCODE_ID_SDMA7, 296efa246c0Sriastradh AMDGPU_UCODE_ID_CP_CE, 297efa246c0Sriastradh AMDGPU_UCODE_ID_CP_PFP, 298efa246c0Sriastradh AMDGPU_UCODE_ID_CP_ME, 299efa246c0Sriastradh AMDGPU_UCODE_ID_CP_MEC1, 300*41ec0267Sriastradh AMDGPU_UCODE_ID_CP_MEC1_JT, 301efa246c0Sriastradh AMDGPU_UCODE_ID_CP_MEC2, 302*41ec0267Sriastradh AMDGPU_UCODE_ID_CP_MEC2_JT, 303*41ec0267Sriastradh AMDGPU_UCODE_ID_CP_MES, 304*41ec0267Sriastradh AMDGPU_UCODE_ID_CP_MES_DATA, 305*41ec0267Sriastradh AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL, 306*41ec0267Sriastradh AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM, 307*41ec0267Sriastradh AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM, 308efa246c0Sriastradh AMDGPU_UCODE_ID_RLC_G, 309*41ec0267Sriastradh AMDGPU_UCODE_ID_STORAGE, 310*41ec0267Sriastradh AMDGPU_UCODE_ID_SMC, 311*41ec0267Sriastradh AMDGPU_UCODE_ID_UVD, 312*41ec0267Sriastradh AMDGPU_UCODE_ID_UVD1, 313*41ec0267Sriastradh AMDGPU_UCODE_ID_VCE, 314*41ec0267Sriastradh AMDGPU_UCODE_ID_VCN, 315*41ec0267Sriastradh AMDGPU_UCODE_ID_VCN1, 316*41ec0267Sriastradh AMDGPU_UCODE_ID_DMCU_ERAM, 317*41ec0267Sriastradh AMDGPU_UCODE_ID_DMCU_INTV, 318*41ec0267Sriastradh AMDGPU_UCODE_ID_VCN0_RAM, 319*41ec0267Sriastradh AMDGPU_UCODE_ID_VCN1_RAM, 320*41ec0267Sriastradh AMDGPU_UCODE_ID_DMCUB, 321efa246c0Sriastradh AMDGPU_UCODE_ID_MAXIMUM, 322efa246c0Sriastradh }; 323efa246c0Sriastradh 324efa246c0Sriastradh /* engine firmware status */ 325efa246c0Sriastradh enum AMDGPU_UCODE_STATUS { 326efa246c0Sriastradh AMDGPU_UCODE_STATUS_INVALID, 327efa246c0Sriastradh AMDGPU_UCODE_STATUS_NOT_LOADED, 328efa246c0Sriastradh AMDGPU_UCODE_STATUS_LOADED, 329efa246c0Sriastradh }; 330efa246c0Sriastradh 331*41ec0267Sriastradh enum amdgpu_firmware_load_type { 332*41ec0267Sriastradh AMDGPU_FW_LOAD_DIRECT = 0, 333*41ec0267Sriastradh AMDGPU_FW_LOAD_SMU, 334*41ec0267Sriastradh AMDGPU_FW_LOAD_PSP, 335*41ec0267Sriastradh AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO, 336*41ec0267Sriastradh }; 337*41ec0267Sriastradh 338efa246c0Sriastradh /* conform to smu_ucode_xfer_cz.h */ 339efa246c0Sriastradh #define AMDGPU_SDMA0_UCODE_LOADED 0x00000001 340efa246c0Sriastradh #define AMDGPU_SDMA1_UCODE_LOADED 0x00000002 341efa246c0Sriastradh #define AMDGPU_CPCE_UCODE_LOADED 0x00000004 342efa246c0Sriastradh #define AMDGPU_CPPFP_UCODE_LOADED 0x00000008 343efa246c0Sriastradh #define AMDGPU_CPME_UCODE_LOADED 0x00000010 344efa246c0Sriastradh #define AMDGPU_CPMEC1_UCODE_LOADED 0x00000020 345efa246c0Sriastradh #define AMDGPU_CPMEC2_UCODE_LOADED 0x00000040 346efa246c0Sriastradh #define AMDGPU_CPRLC_UCODE_LOADED 0x00000100 347efa246c0Sriastradh 348efa246c0Sriastradh /* amdgpu firmware info */ 349efa246c0Sriastradh struct amdgpu_firmware_info { 350efa246c0Sriastradh /* ucode ID */ 351efa246c0Sriastradh enum AMDGPU_UCODE_ID ucode_id; 352efa246c0Sriastradh /* request_firmware */ 353efa246c0Sriastradh const struct firmware *fw; 354efa246c0Sriastradh /* starting mc address */ 355efa246c0Sriastradh uint64_t mc_addr; 356efa246c0Sriastradh /* kernel linear address */ 357efa246c0Sriastradh void *kaddr; 358*41ec0267Sriastradh /* ucode_size_bytes */ 359*41ec0267Sriastradh uint32_t ucode_size; 360*41ec0267Sriastradh /* starting tmr mc address */ 361*41ec0267Sriastradh uint32_t tmr_mc_addr_lo; 362*41ec0267Sriastradh uint32_t tmr_mc_addr_hi; 363*41ec0267Sriastradh }; 364*41ec0267Sriastradh 365*41ec0267Sriastradh struct amdgpu_firmware { 366*41ec0267Sriastradh struct amdgpu_firmware_info ucode[AMDGPU_UCODE_ID_MAXIMUM]; 367*41ec0267Sriastradh enum amdgpu_firmware_load_type load_type; 368*41ec0267Sriastradh struct amdgpu_bo *fw_buf; 369*41ec0267Sriastradh unsigned int fw_size; 370*41ec0267Sriastradh unsigned int max_ucodes; 371*41ec0267Sriastradh /* firmwares are loaded by psp instead of smu from vega10 */ 372*41ec0267Sriastradh const struct amdgpu_psp_funcs *funcs; 373*41ec0267Sriastradh struct amdgpu_bo *rbuf; 374*41ec0267Sriastradh struct mutex mutex; 375*41ec0267Sriastradh 376*41ec0267Sriastradh /* gpu info firmware data pointer */ 377*41ec0267Sriastradh const struct firmware *gpu_info_fw; 378*41ec0267Sriastradh 379*41ec0267Sriastradh void *fw_buf_ptr; 380*41ec0267Sriastradh uint64_t fw_buf_mc; 381efa246c0Sriastradh }; 382efa246c0Sriastradh 383efa246c0Sriastradh void amdgpu_ucode_print_mc_hdr(const struct common_firmware_header *hdr); 384efa246c0Sriastradh void amdgpu_ucode_print_smc_hdr(const struct common_firmware_header *hdr); 385efa246c0Sriastradh void amdgpu_ucode_print_gfx_hdr(const struct common_firmware_header *hdr); 386efa246c0Sriastradh void amdgpu_ucode_print_rlc_hdr(const struct common_firmware_header *hdr); 387efa246c0Sriastradh void amdgpu_ucode_print_sdma_hdr(const struct common_firmware_header *hdr); 388*41ec0267Sriastradh void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header *hdr); 389*41ec0267Sriastradh void amdgpu_ucode_print_gpu_info_hdr(const struct common_firmware_header *hdr); 390efa246c0Sriastradh int amdgpu_ucode_validate(const struct firmware *fw); 391efa246c0Sriastradh bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr, 392efa246c0Sriastradh uint16_t hdr_major, uint16_t hdr_minor); 393*41ec0267Sriastradh 394efa246c0Sriastradh int amdgpu_ucode_init_bo(struct amdgpu_device *adev); 395*41ec0267Sriastradh int amdgpu_ucode_create_bo(struct amdgpu_device *adev); 396*41ec0267Sriastradh int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev); 397*41ec0267Sriastradh void amdgpu_ucode_free_bo(struct amdgpu_device *adev); 398*41ec0267Sriastradh void amdgpu_ucode_sysfs_fini(struct amdgpu_device *adev); 399*41ec0267Sriastradh 400*41ec0267Sriastradh enum amdgpu_firmware_load_type 401*41ec0267Sriastradh amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type); 402efa246c0Sriastradh 403efa246c0Sriastradh #endif 404