18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef __RADEON_UCODE_H__
248c2ecf20Sopenharmony_ci#define __RADEON_UCODE_H__
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* CP */
278c2ecf20Sopenharmony_ci#define R600_PFP_UCODE_SIZE          576
288c2ecf20Sopenharmony_ci#define R600_PM4_UCODE_SIZE          1792
298c2ecf20Sopenharmony_ci#define R700_PFP_UCODE_SIZE          848
308c2ecf20Sopenharmony_ci#define R700_PM4_UCODE_SIZE          1360
318c2ecf20Sopenharmony_ci#define EVERGREEN_PFP_UCODE_SIZE     1120
328c2ecf20Sopenharmony_ci#define EVERGREEN_PM4_UCODE_SIZE     1376
338c2ecf20Sopenharmony_ci#define CAYMAN_PFP_UCODE_SIZE        2176
348c2ecf20Sopenharmony_ci#define CAYMAN_PM4_UCODE_SIZE        2176
358c2ecf20Sopenharmony_ci#define SI_PFP_UCODE_SIZE            2144
368c2ecf20Sopenharmony_ci#define SI_PM4_UCODE_SIZE            2144
378c2ecf20Sopenharmony_ci#define SI_CE_UCODE_SIZE             2144
388c2ecf20Sopenharmony_ci#define CIK_PFP_UCODE_SIZE           2144
398c2ecf20Sopenharmony_ci#define CIK_ME_UCODE_SIZE            2144
408c2ecf20Sopenharmony_ci#define CIK_CE_UCODE_SIZE            2144
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* MEC */
438c2ecf20Sopenharmony_ci#define CIK_MEC_UCODE_SIZE           4192
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* RLC */
468c2ecf20Sopenharmony_ci#define R600_RLC_UCODE_SIZE          768
478c2ecf20Sopenharmony_ci#define R700_RLC_UCODE_SIZE          1024
488c2ecf20Sopenharmony_ci#define EVERGREEN_RLC_UCODE_SIZE     768
498c2ecf20Sopenharmony_ci#define CAYMAN_RLC_UCODE_SIZE        1024
508c2ecf20Sopenharmony_ci#define ARUBA_RLC_UCODE_SIZE         1536
518c2ecf20Sopenharmony_ci#define SI_RLC_UCODE_SIZE            2048
528c2ecf20Sopenharmony_ci#define BONAIRE_RLC_UCODE_SIZE       2048
538c2ecf20Sopenharmony_ci#define KB_RLC_UCODE_SIZE            2560
548c2ecf20Sopenharmony_ci#define KV_RLC_UCODE_SIZE            2560
558c2ecf20Sopenharmony_ci#define ML_RLC_UCODE_SIZE            2560
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* MC */
588c2ecf20Sopenharmony_ci#define BTC_MC_UCODE_SIZE            6024
598c2ecf20Sopenharmony_ci#define CAYMAN_MC_UCODE_SIZE         6037
608c2ecf20Sopenharmony_ci#define SI_MC_UCODE_SIZE             7769
618c2ecf20Sopenharmony_ci#define TAHITI_MC_UCODE_SIZE         7808
628c2ecf20Sopenharmony_ci#define PITCAIRN_MC_UCODE_SIZE       7775
638c2ecf20Sopenharmony_ci#define VERDE_MC_UCODE_SIZE          7875
648c2ecf20Sopenharmony_ci#define OLAND_MC_UCODE_SIZE          7863
658c2ecf20Sopenharmony_ci#define BONAIRE_MC_UCODE_SIZE        7866
668c2ecf20Sopenharmony_ci#define BONAIRE_MC2_UCODE_SIZE       7948
678c2ecf20Sopenharmony_ci#define HAWAII_MC_UCODE_SIZE         7933
688c2ecf20Sopenharmony_ci#define HAWAII_MC2_UCODE_SIZE        8091
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* SDMA */
718c2ecf20Sopenharmony_ci#define CIK_SDMA_UCODE_SIZE          1050
728c2ecf20Sopenharmony_ci#define CIK_SDMA_UCODE_VERSION       64
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* SMC */
758c2ecf20Sopenharmony_ci#define RV770_SMC_UCODE_START        0x0100
768c2ecf20Sopenharmony_ci#define RV770_SMC_UCODE_SIZE         0x410d
778c2ecf20Sopenharmony_ci#define RV770_SMC_INT_VECTOR_START   0xffc0
788c2ecf20Sopenharmony_ci#define RV770_SMC_INT_VECTOR_SIZE    0x0040
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define RV730_SMC_UCODE_START        0x0100
818c2ecf20Sopenharmony_ci#define RV730_SMC_UCODE_SIZE         0x412c
828c2ecf20Sopenharmony_ci#define RV730_SMC_INT_VECTOR_START   0xffc0
838c2ecf20Sopenharmony_ci#define RV730_SMC_INT_VECTOR_SIZE    0x0040
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define RV710_SMC_UCODE_START        0x0100
868c2ecf20Sopenharmony_ci#define RV710_SMC_UCODE_SIZE         0x3f1f
878c2ecf20Sopenharmony_ci#define RV710_SMC_INT_VECTOR_START   0xffc0
888c2ecf20Sopenharmony_ci#define RV710_SMC_INT_VECTOR_SIZE    0x0040
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define RV740_SMC_UCODE_START        0x0100
918c2ecf20Sopenharmony_ci#define RV740_SMC_UCODE_SIZE         0x41c5
928c2ecf20Sopenharmony_ci#define RV740_SMC_INT_VECTOR_START   0xffc0
938c2ecf20Sopenharmony_ci#define RV740_SMC_INT_VECTOR_SIZE    0x0040
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define CEDAR_SMC_UCODE_START        0x0100
968c2ecf20Sopenharmony_ci#define CEDAR_SMC_UCODE_SIZE         0x5d50
978c2ecf20Sopenharmony_ci#define CEDAR_SMC_INT_VECTOR_START   0xffc0
988c2ecf20Sopenharmony_ci#define CEDAR_SMC_INT_VECTOR_SIZE    0x0040
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define REDWOOD_SMC_UCODE_START      0x0100
1018c2ecf20Sopenharmony_ci#define REDWOOD_SMC_UCODE_SIZE       0x5f0a
1028c2ecf20Sopenharmony_ci#define REDWOOD_SMC_INT_VECTOR_START 0xffc0
1038c2ecf20Sopenharmony_ci#define REDWOOD_SMC_INT_VECTOR_SIZE  0x0040
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define JUNIPER_SMC_UCODE_START      0x0100
1068c2ecf20Sopenharmony_ci#define JUNIPER_SMC_UCODE_SIZE       0x5f1f
1078c2ecf20Sopenharmony_ci#define JUNIPER_SMC_INT_VECTOR_START 0xffc0
1088c2ecf20Sopenharmony_ci#define JUNIPER_SMC_INT_VECTOR_SIZE  0x0040
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define CYPRESS_SMC_UCODE_START      0x0100
1118c2ecf20Sopenharmony_ci#define CYPRESS_SMC_UCODE_SIZE       0x61f7
1128c2ecf20Sopenharmony_ci#define CYPRESS_SMC_INT_VECTOR_START 0xffc0
1138c2ecf20Sopenharmony_ci#define CYPRESS_SMC_INT_VECTOR_SIZE  0x0040
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define BARTS_SMC_UCODE_START        0x0100
1168c2ecf20Sopenharmony_ci#define BARTS_SMC_UCODE_SIZE         0x6107
1178c2ecf20Sopenharmony_ci#define BARTS_SMC_INT_VECTOR_START   0xffc0
1188c2ecf20Sopenharmony_ci#define BARTS_SMC_INT_VECTOR_SIZE    0x0040
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define TURKS_SMC_UCODE_START        0x0100
1218c2ecf20Sopenharmony_ci#define TURKS_SMC_UCODE_SIZE         0x605b
1228c2ecf20Sopenharmony_ci#define TURKS_SMC_INT_VECTOR_START   0xffc0
1238c2ecf20Sopenharmony_ci#define TURKS_SMC_INT_VECTOR_SIZE    0x0040
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define CAICOS_SMC_UCODE_START       0x0100
1268c2ecf20Sopenharmony_ci#define CAICOS_SMC_UCODE_SIZE        0x5fbd
1278c2ecf20Sopenharmony_ci#define CAICOS_SMC_INT_VECTOR_START  0xffc0
1288c2ecf20Sopenharmony_ci#define CAICOS_SMC_INT_VECTOR_SIZE   0x0040
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define CAYMAN_SMC_UCODE_START       0x0100
1318c2ecf20Sopenharmony_ci#define CAYMAN_SMC_UCODE_SIZE        0x79ec
1328c2ecf20Sopenharmony_ci#define CAYMAN_SMC_INT_VECTOR_START  0xffc0
1338c2ecf20Sopenharmony_ci#define CAYMAN_SMC_INT_VECTOR_SIZE   0x0040
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define TAHITI_SMC_UCODE_START       0x10000
1368c2ecf20Sopenharmony_ci#define TAHITI_SMC_UCODE_SIZE        0xf458
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci#define PITCAIRN_SMC_UCODE_START     0x10000
1398c2ecf20Sopenharmony_ci#define PITCAIRN_SMC_UCODE_SIZE      0xe9f4
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#define VERDE_SMC_UCODE_START        0x10000
1428c2ecf20Sopenharmony_ci#define VERDE_SMC_UCODE_SIZE         0xebe4
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#define OLAND_SMC_UCODE_START        0x10000
1458c2ecf20Sopenharmony_ci#define OLAND_SMC_UCODE_SIZE         0xe7b4
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define HAINAN_SMC_UCODE_START       0x10000
1488c2ecf20Sopenharmony_ci#define HAINAN_SMC_UCODE_SIZE        0xe67C
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define BONAIRE_SMC_UCODE_START      0x20000
1518c2ecf20Sopenharmony_ci#define BONAIRE_SMC_UCODE_SIZE       0x1FDEC
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define HAWAII_SMC_UCODE_START       0x20000
1548c2ecf20Sopenharmony_ci#define HAWAII_SMC_UCODE_SIZE        0x1FDEC
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistruct common_firmware_header {
1578c2ecf20Sopenharmony_ci	uint32_t size_bytes; /* size of the entire header+image(s) in bytes */
1588c2ecf20Sopenharmony_ci	uint32_t header_size_bytes; /* size of just the header in bytes */
1598c2ecf20Sopenharmony_ci	uint16_t header_version_major; /* header version */
1608c2ecf20Sopenharmony_ci	uint16_t header_version_minor; /* header version */
1618c2ecf20Sopenharmony_ci	uint16_t ip_version_major; /* IP version */
1628c2ecf20Sopenharmony_ci	uint16_t ip_version_minor; /* IP version */
1638c2ecf20Sopenharmony_ci	uint32_t ucode_version;
1648c2ecf20Sopenharmony_ci	uint32_t ucode_size_bytes; /* size of ucode in bytes */
1658c2ecf20Sopenharmony_ci	uint32_t ucode_array_offset_bytes; /* payload offset from the start of the header */
1668c2ecf20Sopenharmony_ci	uint32_t crc32;  /* crc32 checksum of the payload */
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* version_major=1, version_minor=0 */
1708c2ecf20Sopenharmony_cistruct mc_firmware_header_v1_0 {
1718c2ecf20Sopenharmony_ci	struct common_firmware_header header;
1728c2ecf20Sopenharmony_ci	uint32_t io_debug_size_bytes; /* size of debug array in dwords */
1738c2ecf20Sopenharmony_ci	uint32_t io_debug_array_offset_bytes; /* payload offset from the start of the header */
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci/* version_major=1, version_minor=0 */
1778c2ecf20Sopenharmony_cistruct smc_firmware_header_v1_0 {
1788c2ecf20Sopenharmony_ci	struct common_firmware_header header;
1798c2ecf20Sopenharmony_ci	uint32_t ucode_start_addr;
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/* version_major=1, version_minor=0 */
1838c2ecf20Sopenharmony_cistruct gfx_firmware_header_v1_0 {
1848c2ecf20Sopenharmony_ci	struct common_firmware_header header;
1858c2ecf20Sopenharmony_ci	uint32_t ucode_feature_version;
1868c2ecf20Sopenharmony_ci	uint32_t jt_offset; /* jt location */
1878c2ecf20Sopenharmony_ci	uint32_t jt_size;  /* size of jt */
1888c2ecf20Sopenharmony_ci};
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci/* version_major=1, version_minor=0 */
1918c2ecf20Sopenharmony_cistruct rlc_firmware_header_v1_0 {
1928c2ecf20Sopenharmony_ci	struct common_firmware_header header;
1938c2ecf20Sopenharmony_ci	uint32_t ucode_feature_version;
1948c2ecf20Sopenharmony_ci	uint32_t save_and_restore_offset;
1958c2ecf20Sopenharmony_ci	uint32_t clear_state_descriptor_offset;
1968c2ecf20Sopenharmony_ci	uint32_t avail_scratch_ram_locations;
1978c2ecf20Sopenharmony_ci	uint32_t master_pkt_description_offset;
1988c2ecf20Sopenharmony_ci};
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* version_major=1, version_minor=0 */
2018c2ecf20Sopenharmony_cistruct sdma_firmware_header_v1_0 {
2028c2ecf20Sopenharmony_ci	struct common_firmware_header header;
2038c2ecf20Sopenharmony_ci	uint32_t ucode_feature_version;
2048c2ecf20Sopenharmony_ci	uint32_t ucode_change_version;
2058c2ecf20Sopenharmony_ci	uint32_t jt_offset; /* jt location */
2068c2ecf20Sopenharmony_ci	uint32_t jt_size; /* size of jt */
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/* header is fixed size */
2108c2ecf20Sopenharmony_ciunion radeon_firmware_header {
2118c2ecf20Sopenharmony_ci	struct common_firmware_header common;
2128c2ecf20Sopenharmony_ci	struct mc_firmware_header_v1_0 mc;
2138c2ecf20Sopenharmony_ci	struct smc_firmware_header_v1_0 smc;
2148c2ecf20Sopenharmony_ci	struct gfx_firmware_header_v1_0 gfx;
2158c2ecf20Sopenharmony_ci	struct rlc_firmware_header_v1_0 rlc;
2168c2ecf20Sopenharmony_ci	struct sdma_firmware_header_v1_0 sdma;
2178c2ecf20Sopenharmony_ci	uint8_t raw[0x100];
2188c2ecf20Sopenharmony_ci};
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_civoid radeon_ucode_print_mc_hdr(const struct common_firmware_header *hdr);
2218c2ecf20Sopenharmony_civoid radeon_ucode_print_smc_hdr(const struct common_firmware_header *hdr);
2228c2ecf20Sopenharmony_civoid radeon_ucode_print_gfx_hdr(const struct common_firmware_header *hdr);
2238c2ecf20Sopenharmony_civoid radeon_ucode_print_rlc_hdr(const struct common_firmware_header *hdr);
2248c2ecf20Sopenharmony_civoid radeon_ucode_print_sdma_hdr(const struct common_firmware_header *hdr);
2258c2ecf20Sopenharmony_ciint radeon_ucode_validate(const struct firmware *fw);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci#endif
228