18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2018 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 248c2ecf20Sopenharmony_ci#ifndef _DISCOVERY_H_ 258c2ecf20Sopenharmony_ci#define _DISCOVERY_H_ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define PSP_HEADER_SIZE 256 288c2ecf20Sopenharmony_ci#define BINARY_SIGNATURE 0x28211407 298c2ecf20Sopenharmony_ci#define DISCOVERY_TABLE_SIGNATURE 0x53445049 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_citypedef enum 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci IP_DISCOVERY = 0, 348c2ecf20Sopenharmony_ci GC, 358c2ecf20Sopenharmony_ci HARVEST_INFO, 368c2ecf20Sopenharmony_ci TABLE_4, 378c2ecf20Sopenharmony_ci RESERVED_1, 388c2ecf20Sopenharmony_ci RESERVED_2, 398c2ecf20Sopenharmony_ci TOTAL_TABLES = 6 408c2ecf20Sopenharmony_ci} table; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#pragma pack(1) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_citypedef struct table_info 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci uint16_t offset; /* Byte offset */ 478c2ecf20Sopenharmony_ci uint16_t checksum; /* Byte sum of the table */ 488c2ecf20Sopenharmony_ci uint16_t size; /* Table size */ 498c2ecf20Sopenharmony_ci uint16_t padding; 508c2ecf20Sopenharmony_ci} table_info; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_citypedef struct binary_header 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci /* psp structure should go at the top of this structure */ 558c2ecf20Sopenharmony_ci uint32_t binary_signature; /* 0x7, 0x14, 0x21, 0x28 */ 568c2ecf20Sopenharmony_ci uint16_t version_major; 578c2ecf20Sopenharmony_ci uint16_t version_minor; 588c2ecf20Sopenharmony_ci uint16_t binary_checksum; /* Byte sum of the binary after this field */ 598c2ecf20Sopenharmony_ci uint16_t binary_size; /* Binary Size*/ 608c2ecf20Sopenharmony_ci table_info table_list[TOTAL_TABLES]; 618c2ecf20Sopenharmony_ci} binary_header; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_citypedef struct die_info 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci uint16_t die_id; 668c2ecf20Sopenharmony_ci uint16_t die_offset; /* Points to the corresponding die_header structure */ 678c2ecf20Sopenharmony_ci} die_info; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_citypedef struct ip_discovery_header 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci uint32_t signature; /* Table Signature */ 738c2ecf20Sopenharmony_ci uint16_t version; /* Table Version */ 748c2ecf20Sopenharmony_ci uint16_t size; /* Table Size */ 758c2ecf20Sopenharmony_ci uint32_t id; /* Table ID */ 768c2ecf20Sopenharmony_ci uint16_t num_dies; /* Number of Dies */ 778c2ecf20Sopenharmony_ci die_info die_info[16]; /* list die information for up to 16 dies */ 788c2ecf20Sopenharmony_ci uint16_t padding[1]; /* padding */ 798c2ecf20Sopenharmony_ci} ip_discovery_header; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_citypedef struct ip 828c2ecf20Sopenharmony_ci{ 838c2ecf20Sopenharmony_ci uint16_t hw_id; /* Hardware ID */ 848c2ecf20Sopenharmony_ci uint8_t number_instance; /* instance of the IP */ 858c2ecf20Sopenharmony_ci uint8_t num_base_address; /* Number of Base Addresses */ 868c2ecf20Sopenharmony_ci uint8_t major; /* HCID Major */ 878c2ecf20Sopenharmony_ci uint8_t minor; /* HCID Minor */ 888c2ecf20Sopenharmony_ci uint8_t revision; /* HCID Revision */ 898c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN) 908c2ecf20Sopenharmony_ci uint8_t reserved : 4; /* Placeholder field */ 918c2ecf20Sopenharmony_ci uint8_t harvest : 4; /* Harvest */ 928c2ecf20Sopenharmony_ci#else 938c2ecf20Sopenharmony_ci uint8_t harvest : 4; /* Harvest */ 948c2ecf20Sopenharmony_ci uint8_t reserved : 4; /* Placeholder field */ 958c2ecf20Sopenharmony_ci#endif 968c2ecf20Sopenharmony_ci uint32_t base_address[1]; /* variable number of Addresses */ 978c2ecf20Sopenharmony_ci} ip; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_citypedef struct die_header 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci uint16_t die_id; 1028c2ecf20Sopenharmony_ci uint16_t num_ips; 1038c2ecf20Sopenharmony_ci} die_header; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_citypedef struct ip_structure 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci ip_discovery_header* header; 1088c2ecf20Sopenharmony_ci struct die 1098c2ecf20Sopenharmony_ci { 1108c2ecf20Sopenharmony_ci die_header *die_header; 1118c2ecf20Sopenharmony_ci ip *ip_list; 1128c2ecf20Sopenharmony_ci } die; 1138c2ecf20Sopenharmony_ci} ip_structure; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct gpu_info_header { 1168c2ecf20Sopenharmony_ci uint32_t table_id; /* table ID */ 1178c2ecf20Sopenharmony_ci uint16_t version_major; /* table version */ 1188c2ecf20Sopenharmony_ci uint16_t version_minor; /* table version */ 1198c2ecf20Sopenharmony_ci uint32_t size; /* size of the entire header+data in bytes */ 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct gc_info_v1_0 { 1238c2ecf20Sopenharmony_ci struct gpu_info_header header; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci uint32_t gc_num_se; 1268c2ecf20Sopenharmony_ci uint32_t gc_num_wgp0_per_sa; 1278c2ecf20Sopenharmony_ci uint32_t gc_num_wgp1_per_sa; 1288c2ecf20Sopenharmony_ci uint32_t gc_num_rb_per_se; 1298c2ecf20Sopenharmony_ci uint32_t gc_num_gl2c; 1308c2ecf20Sopenharmony_ci uint32_t gc_num_gprs; 1318c2ecf20Sopenharmony_ci uint32_t gc_num_max_gs_thds; 1328c2ecf20Sopenharmony_ci uint32_t gc_gs_table_depth; 1338c2ecf20Sopenharmony_ci uint32_t gc_gsprim_buff_depth; 1348c2ecf20Sopenharmony_ci uint32_t gc_parameter_cache_depth; 1358c2ecf20Sopenharmony_ci uint32_t gc_double_offchip_lds_buffer; 1368c2ecf20Sopenharmony_ci uint32_t gc_wave_size; 1378c2ecf20Sopenharmony_ci uint32_t gc_max_waves_per_simd; 1388c2ecf20Sopenharmony_ci uint32_t gc_max_scratch_slots_per_cu; 1398c2ecf20Sopenharmony_ci uint32_t gc_lds_size; 1408c2ecf20Sopenharmony_ci uint32_t gc_num_sc_per_se; 1418c2ecf20Sopenharmony_ci uint32_t gc_num_sa_per_se; 1428c2ecf20Sopenharmony_ci uint32_t gc_num_packer_per_sc; 1438c2ecf20Sopenharmony_ci uint32_t gc_num_gl2a; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct gc_info_v1_1 { 1478c2ecf20Sopenharmony_ci struct gpu_info_header header; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci uint32_t gc_num_se; 1508c2ecf20Sopenharmony_ci uint32_t gc_num_wgp0_per_sa; 1518c2ecf20Sopenharmony_ci uint32_t gc_num_wgp1_per_sa; 1528c2ecf20Sopenharmony_ci uint32_t gc_num_rb_per_se; 1538c2ecf20Sopenharmony_ci uint32_t gc_num_gl2c; 1548c2ecf20Sopenharmony_ci uint32_t gc_num_gprs; 1558c2ecf20Sopenharmony_ci uint32_t gc_num_max_gs_thds; 1568c2ecf20Sopenharmony_ci uint32_t gc_gs_table_depth; 1578c2ecf20Sopenharmony_ci uint32_t gc_gsprim_buff_depth; 1588c2ecf20Sopenharmony_ci uint32_t gc_parameter_cache_depth; 1598c2ecf20Sopenharmony_ci uint32_t gc_double_offchip_lds_buffer; 1608c2ecf20Sopenharmony_ci uint32_t gc_wave_size; 1618c2ecf20Sopenharmony_ci uint32_t gc_max_waves_per_simd; 1628c2ecf20Sopenharmony_ci uint32_t gc_max_scratch_slots_per_cu; 1638c2ecf20Sopenharmony_ci uint32_t gc_lds_size; 1648c2ecf20Sopenharmony_ci uint32_t gc_num_sc_per_se; 1658c2ecf20Sopenharmony_ci uint32_t gc_num_sa_per_se; 1668c2ecf20Sopenharmony_ci uint32_t gc_num_packer_per_sc; 1678c2ecf20Sopenharmony_ci uint32_t gc_num_gl2a; 1688c2ecf20Sopenharmony_ci uint32_t gc_num_tcp_per_sa; 1698c2ecf20Sopenharmony_ci uint32_t gc_num_sdp_interface; 1708c2ecf20Sopenharmony_ci uint32_t gc_num_tcps; 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistruct gc_info_v2_0 { 1748c2ecf20Sopenharmony_ci struct gpu_info_header header; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci uint32_t gc_num_se; 1778c2ecf20Sopenharmony_ci uint32_t gc_num_cu_per_sh; 1788c2ecf20Sopenharmony_ci uint32_t gc_num_sh_per_se; 1798c2ecf20Sopenharmony_ci uint32_t gc_num_rb_per_se; 1808c2ecf20Sopenharmony_ci uint32_t gc_num_tccs; 1818c2ecf20Sopenharmony_ci uint32_t gc_num_gprs; 1828c2ecf20Sopenharmony_ci uint32_t gc_num_max_gs_thds; 1838c2ecf20Sopenharmony_ci uint32_t gc_gs_table_depth; 1848c2ecf20Sopenharmony_ci uint32_t gc_gsprim_buff_depth; 1858c2ecf20Sopenharmony_ci uint32_t gc_parameter_cache_depth; 1868c2ecf20Sopenharmony_ci uint32_t gc_double_offchip_lds_buffer; 1878c2ecf20Sopenharmony_ci uint32_t gc_wave_size; 1888c2ecf20Sopenharmony_ci uint32_t gc_max_waves_per_simd; 1898c2ecf20Sopenharmony_ci uint32_t gc_max_scratch_slots_per_cu; 1908c2ecf20Sopenharmony_ci uint32_t gc_lds_size; 1918c2ecf20Sopenharmony_ci uint32_t gc_num_sc_per_se; 1928c2ecf20Sopenharmony_ci uint32_t gc_num_packer_per_sc; 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_citypedef struct harvest_info_header { 1968c2ecf20Sopenharmony_ci uint32_t signature; /* Table Signature */ 1978c2ecf20Sopenharmony_ci uint32_t version; /* Table Version */ 1988c2ecf20Sopenharmony_ci} harvest_info_header; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_citypedef struct harvest_info { 2018c2ecf20Sopenharmony_ci uint16_t hw_id; /* Hardware ID */ 2028c2ecf20Sopenharmony_ci uint8_t number_instance; /* Instance of the IP */ 2038c2ecf20Sopenharmony_ci uint8_t reserved; /* Reserved for alignment */ 2048c2ecf20Sopenharmony_ci} harvest_info; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_citypedef struct harvest_table { 2078c2ecf20Sopenharmony_ci harvest_info_header header; 2088c2ecf20Sopenharmony_ci harvest_info list[32]; 2098c2ecf20Sopenharmony_ci} harvest_table; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#pragma pack() 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#endif 214