Home | History | Annotate | Line # | Download | only in radeon
      1  1.2  riastrad /*	$NetBSD: radeon_ucode.h,v 1.3 2021/12/18 23:45:43 riastradh Exp $	*/
      2  1.2  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2012 Advanced Micro Devices, Inc.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  *
     24  1.1  riastrad  */
     25  1.1  riastrad #ifndef __RADEON_UCODE_H__
     26  1.1  riastrad #define __RADEON_UCODE_H__
     27  1.1  riastrad 
     28  1.1  riastrad /* CP */
     29  1.1  riastrad #define R600_PFP_UCODE_SIZE          576
     30  1.1  riastrad #define R600_PM4_UCODE_SIZE          1792
     31  1.1  riastrad #define R700_PFP_UCODE_SIZE          848
     32  1.1  riastrad #define R700_PM4_UCODE_SIZE          1360
     33  1.1  riastrad #define EVERGREEN_PFP_UCODE_SIZE     1120
     34  1.1  riastrad #define EVERGREEN_PM4_UCODE_SIZE     1376
     35  1.1  riastrad #define CAYMAN_PFP_UCODE_SIZE        2176
     36  1.1  riastrad #define CAYMAN_PM4_UCODE_SIZE        2176
     37  1.1  riastrad #define SI_PFP_UCODE_SIZE            2144
     38  1.1  riastrad #define SI_PM4_UCODE_SIZE            2144
     39  1.1  riastrad #define SI_CE_UCODE_SIZE             2144
     40  1.1  riastrad #define CIK_PFP_UCODE_SIZE           2144
     41  1.1  riastrad #define CIK_ME_UCODE_SIZE            2144
     42  1.1  riastrad #define CIK_CE_UCODE_SIZE            2144
     43  1.1  riastrad 
     44  1.1  riastrad /* MEC */
     45  1.1  riastrad #define CIK_MEC_UCODE_SIZE           4192
     46  1.1  riastrad 
     47  1.1  riastrad /* RLC */
     48  1.1  riastrad #define R600_RLC_UCODE_SIZE          768
     49  1.1  riastrad #define R700_RLC_UCODE_SIZE          1024
     50  1.1  riastrad #define EVERGREEN_RLC_UCODE_SIZE     768
     51  1.1  riastrad #define CAYMAN_RLC_UCODE_SIZE        1024
     52  1.1  riastrad #define ARUBA_RLC_UCODE_SIZE         1536
     53  1.1  riastrad #define SI_RLC_UCODE_SIZE            2048
     54  1.1  riastrad #define BONAIRE_RLC_UCODE_SIZE       2048
     55  1.1  riastrad #define KB_RLC_UCODE_SIZE            2560
     56  1.1  riastrad #define KV_RLC_UCODE_SIZE            2560
     57  1.1  riastrad #define ML_RLC_UCODE_SIZE            2560
     58  1.1  riastrad 
     59  1.1  riastrad /* MC */
     60  1.1  riastrad #define BTC_MC_UCODE_SIZE            6024
     61  1.1  riastrad #define CAYMAN_MC_UCODE_SIZE         6037
     62  1.1  riastrad #define SI_MC_UCODE_SIZE             7769
     63  1.1  riastrad #define TAHITI_MC_UCODE_SIZE         7808
     64  1.1  riastrad #define PITCAIRN_MC_UCODE_SIZE       7775
     65  1.1  riastrad #define VERDE_MC_UCODE_SIZE          7875
     66  1.1  riastrad #define OLAND_MC_UCODE_SIZE          7863
     67  1.1  riastrad #define BONAIRE_MC_UCODE_SIZE        7866
     68  1.1  riastrad #define BONAIRE_MC2_UCODE_SIZE       7948
     69  1.1  riastrad #define HAWAII_MC_UCODE_SIZE         7933
     70  1.1  riastrad #define HAWAII_MC2_UCODE_SIZE        8091
     71  1.1  riastrad 
     72  1.1  riastrad /* SDMA */
     73  1.1  riastrad #define CIK_SDMA_UCODE_SIZE          1050
     74  1.1  riastrad #define CIK_SDMA_UCODE_VERSION       64
     75  1.1  riastrad 
     76  1.1  riastrad /* SMC */
     77  1.1  riastrad #define RV770_SMC_UCODE_START        0x0100
     78  1.1  riastrad #define RV770_SMC_UCODE_SIZE         0x410d
     79  1.1  riastrad #define RV770_SMC_INT_VECTOR_START   0xffc0
     80  1.1  riastrad #define RV770_SMC_INT_VECTOR_SIZE    0x0040
     81  1.1  riastrad 
     82  1.1  riastrad #define RV730_SMC_UCODE_START        0x0100
     83  1.1  riastrad #define RV730_SMC_UCODE_SIZE         0x412c
     84  1.1  riastrad #define RV730_SMC_INT_VECTOR_START   0xffc0
     85  1.1  riastrad #define RV730_SMC_INT_VECTOR_SIZE    0x0040
     86  1.1  riastrad 
     87  1.1  riastrad #define RV710_SMC_UCODE_START        0x0100
     88  1.1  riastrad #define RV710_SMC_UCODE_SIZE         0x3f1f
     89  1.1  riastrad #define RV710_SMC_INT_VECTOR_START   0xffc0
     90  1.1  riastrad #define RV710_SMC_INT_VECTOR_SIZE    0x0040
     91  1.1  riastrad 
     92  1.1  riastrad #define RV740_SMC_UCODE_START        0x0100
     93  1.1  riastrad #define RV740_SMC_UCODE_SIZE         0x41c5
     94  1.1  riastrad #define RV740_SMC_INT_VECTOR_START   0xffc0
     95  1.1  riastrad #define RV740_SMC_INT_VECTOR_SIZE    0x0040
     96  1.1  riastrad 
     97  1.1  riastrad #define CEDAR_SMC_UCODE_START        0x0100
     98  1.1  riastrad #define CEDAR_SMC_UCODE_SIZE         0x5d50
     99  1.1  riastrad #define CEDAR_SMC_INT_VECTOR_START   0xffc0
    100  1.1  riastrad #define CEDAR_SMC_INT_VECTOR_SIZE    0x0040
    101  1.1  riastrad 
    102  1.1  riastrad #define REDWOOD_SMC_UCODE_START      0x0100
    103  1.1  riastrad #define REDWOOD_SMC_UCODE_SIZE       0x5f0a
    104  1.1  riastrad #define REDWOOD_SMC_INT_VECTOR_START 0xffc0
    105  1.1  riastrad #define REDWOOD_SMC_INT_VECTOR_SIZE  0x0040
    106  1.1  riastrad 
    107  1.1  riastrad #define JUNIPER_SMC_UCODE_START      0x0100
    108  1.1  riastrad #define JUNIPER_SMC_UCODE_SIZE       0x5f1f
    109  1.1  riastrad #define JUNIPER_SMC_INT_VECTOR_START 0xffc0
    110  1.1  riastrad #define JUNIPER_SMC_INT_VECTOR_SIZE  0x0040
    111  1.1  riastrad 
    112  1.1  riastrad #define CYPRESS_SMC_UCODE_START      0x0100
    113  1.1  riastrad #define CYPRESS_SMC_UCODE_SIZE       0x61f7
    114  1.1  riastrad #define CYPRESS_SMC_INT_VECTOR_START 0xffc0
    115  1.1  riastrad #define CYPRESS_SMC_INT_VECTOR_SIZE  0x0040
    116  1.1  riastrad 
    117  1.1  riastrad #define BARTS_SMC_UCODE_START        0x0100
    118  1.1  riastrad #define BARTS_SMC_UCODE_SIZE         0x6107
    119  1.1  riastrad #define BARTS_SMC_INT_VECTOR_START   0xffc0
    120  1.1  riastrad #define BARTS_SMC_INT_VECTOR_SIZE    0x0040
    121  1.1  riastrad 
    122  1.1  riastrad #define TURKS_SMC_UCODE_START        0x0100
    123  1.1  riastrad #define TURKS_SMC_UCODE_SIZE         0x605b
    124  1.1  riastrad #define TURKS_SMC_INT_VECTOR_START   0xffc0
    125  1.1  riastrad #define TURKS_SMC_INT_VECTOR_SIZE    0x0040
    126  1.1  riastrad 
    127  1.1  riastrad #define CAICOS_SMC_UCODE_START       0x0100
    128  1.1  riastrad #define CAICOS_SMC_UCODE_SIZE        0x5fbd
    129  1.1  riastrad #define CAICOS_SMC_INT_VECTOR_START  0xffc0
    130  1.1  riastrad #define CAICOS_SMC_INT_VECTOR_SIZE   0x0040
    131  1.1  riastrad 
    132  1.1  riastrad #define CAYMAN_SMC_UCODE_START       0x0100
    133  1.1  riastrad #define CAYMAN_SMC_UCODE_SIZE        0x79ec
    134  1.1  riastrad #define CAYMAN_SMC_INT_VECTOR_START  0xffc0
    135  1.1  riastrad #define CAYMAN_SMC_INT_VECTOR_SIZE   0x0040
    136  1.1  riastrad 
    137  1.1  riastrad #define TAHITI_SMC_UCODE_START       0x10000
    138  1.1  riastrad #define TAHITI_SMC_UCODE_SIZE        0xf458
    139  1.1  riastrad 
    140  1.1  riastrad #define PITCAIRN_SMC_UCODE_START     0x10000
    141  1.1  riastrad #define PITCAIRN_SMC_UCODE_SIZE      0xe9f4
    142  1.1  riastrad 
    143  1.1  riastrad #define VERDE_SMC_UCODE_START        0x10000
    144  1.1  riastrad #define VERDE_SMC_UCODE_SIZE         0xebe4
    145  1.1  riastrad 
    146  1.1  riastrad #define OLAND_SMC_UCODE_START        0x10000
    147  1.1  riastrad #define OLAND_SMC_UCODE_SIZE         0xe7b4
    148  1.1  riastrad 
    149  1.1  riastrad #define HAINAN_SMC_UCODE_START       0x10000
    150  1.1  riastrad #define HAINAN_SMC_UCODE_SIZE        0xe67C
    151  1.1  riastrad 
    152  1.1  riastrad #define BONAIRE_SMC_UCODE_START      0x20000
    153  1.1  riastrad #define BONAIRE_SMC_UCODE_SIZE       0x1FDEC
    154  1.1  riastrad 
    155  1.1  riastrad #define HAWAII_SMC_UCODE_START       0x20000
    156  1.1  riastrad #define HAWAII_SMC_UCODE_SIZE        0x1FDEC
    157  1.1  riastrad 
    158  1.2  riastrad struct common_firmware_header {
    159  1.2  riastrad 	uint32_t size_bytes; /* size of the entire header+image(s) in bytes */
    160  1.2  riastrad 	uint32_t header_size_bytes; /* size of just the header in bytes */
    161  1.2  riastrad 	uint16_t header_version_major; /* header version */
    162  1.2  riastrad 	uint16_t header_version_minor; /* header version */
    163  1.2  riastrad 	uint16_t ip_version_major; /* IP version */
    164  1.2  riastrad 	uint16_t ip_version_minor; /* IP version */
    165  1.2  riastrad 	uint32_t ucode_version;
    166  1.2  riastrad 	uint32_t ucode_size_bytes; /* size of ucode in bytes */
    167  1.2  riastrad 	uint32_t ucode_array_offset_bytes; /* payload offset from the start of the header */
    168  1.2  riastrad 	uint32_t crc32;  /* crc32 checksum of the payload */
    169  1.2  riastrad };
    170  1.2  riastrad 
    171  1.2  riastrad /* version_major=1, version_minor=0 */
    172  1.2  riastrad struct mc_firmware_header_v1_0 {
    173  1.2  riastrad 	struct common_firmware_header header;
    174  1.2  riastrad 	uint32_t io_debug_size_bytes; /* size of debug array in dwords */
    175  1.2  riastrad 	uint32_t io_debug_array_offset_bytes; /* payload offset from the start of the header */
    176  1.2  riastrad };
    177  1.2  riastrad 
    178  1.2  riastrad /* version_major=1, version_minor=0 */
    179  1.2  riastrad struct smc_firmware_header_v1_0 {
    180  1.2  riastrad 	struct common_firmware_header header;
    181  1.2  riastrad 	uint32_t ucode_start_addr;
    182  1.2  riastrad };
    183  1.2  riastrad 
    184  1.2  riastrad /* version_major=1, version_minor=0 */
    185  1.2  riastrad struct gfx_firmware_header_v1_0 {
    186  1.2  riastrad 	struct common_firmware_header header;
    187  1.2  riastrad 	uint32_t ucode_feature_version;
    188  1.2  riastrad 	uint32_t jt_offset; /* jt location */
    189  1.2  riastrad 	uint32_t jt_size;  /* size of jt */
    190  1.2  riastrad };
    191  1.2  riastrad 
    192  1.2  riastrad /* version_major=1, version_minor=0 */
    193  1.2  riastrad struct rlc_firmware_header_v1_0 {
    194  1.2  riastrad 	struct common_firmware_header header;
    195  1.2  riastrad 	uint32_t ucode_feature_version;
    196  1.2  riastrad 	uint32_t save_and_restore_offset;
    197  1.2  riastrad 	uint32_t clear_state_descriptor_offset;
    198  1.2  riastrad 	uint32_t avail_scratch_ram_locations;
    199  1.2  riastrad 	uint32_t master_pkt_description_offset;
    200  1.2  riastrad };
    201  1.2  riastrad 
    202  1.2  riastrad /* version_major=1, version_minor=0 */
    203  1.2  riastrad struct sdma_firmware_header_v1_0 {
    204  1.2  riastrad 	struct common_firmware_header header;
    205  1.2  riastrad 	uint32_t ucode_feature_version;
    206  1.2  riastrad 	uint32_t ucode_change_version;
    207  1.2  riastrad 	uint32_t jt_offset; /* jt location */
    208  1.2  riastrad 	uint32_t jt_size; /* size of jt */
    209  1.2  riastrad };
    210  1.2  riastrad 
    211  1.2  riastrad /* header is fixed size */
    212  1.2  riastrad union radeon_firmware_header {
    213  1.2  riastrad 	struct common_firmware_header common;
    214  1.2  riastrad 	struct mc_firmware_header_v1_0 mc;
    215  1.2  riastrad 	struct smc_firmware_header_v1_0 smc;
    216  1.2  riastrad 	struct gfx_firmware_header_v1_0 gfx;
    217  1.2  riastrad 	struct rlc_firmware_header_v1_0 rlc;
    218  1.2  riastrad 	struct sdma_firmware_header_v1_0 sdma;
    219  1.2  riastrad 	uint8_t raw[0x100];
    220  1.2  riastrad };
    221  1.2  riastrad 
    222  1.2  riastrad void radeon_ucode_print_mc_hdr(const struct common_firmware_header *hdr);
    223  1.2  riastrad void radeon_ucode_print_smc_hdr(const struct common_firmware_header *hdr);
    224  1.2  riastrad void radeon_ucode_print_gfx_hdr(const struct common_firmware_header *hdr);
    225  1.2  riastrad void radeon_ucode_print_rlc_hdr(const struct common_firmware_header *hdr);
    226  1.2  riastrad void radeon_ucode_print_sdma_hdr(const struct common_firmware_header *hdr);
    227  1.2  riastrad int radeon_ucode_validate(const struct firmware *fw);
    228  1.2  riastrad 
    229  1.1  riastrad #endif
    230