discovery.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * Copyright 2018 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 _DISCOVERY_H_
  24. #define _DISCOVERY_H_
  25. #define PSP_HEADER_SIZE 256
  26. #define BINARY_SIGNATURE 0x28211407
  27. #define DISCOVERY_TABLE_SIGNATURE 0x53445049
  28. #define GC_TABLE_ID 0x4347
  29. #define HARVEST_TABLE_SIGNATURE 0x56524148
  30. #define VCN_INFO_TABLE_ID 0x004E4356
  31. #define MALL_INFO_TABLE_ID 0x4C4C414D
  32. #define NPS_INFO_TABLE_ID 0x0053504E
  33. typedef enum {
  34. IP_DISCOVERY = 0,
  35. GC,
  36. HARVEST_INFO,
  37. VCN_INFO,
  38. MALL_INFO,
  39. NPS_INFO,
  40. TOTAL_TABLES = 6
  41. } table;
  42. #pragma pack(1)
  43. typedef struct table_info
  44. {
  45. uint16_t offset; /* Byte offset */
  46. uint16_t checksum; /* Byte sum of the table */
  47. uint16_t size; /* Table size */
  48. uint16_t padding;
  49. } table_info;
  50. typedef struct binary_header
  51. {
  52. /* psp structure should go at the top of this structure */
  53. uint32_t binary_signature; /* 0x7, 0x14, 0x21, 0x28 */
  54. uint16_t version_major;
  55. uint16_t version_minor;
  56. uint16_t binary_checksum; /* Byte sum of the binary after this field */
  57. uint16_t binary_size; /* Binary Size*/
  58. table_info table_list[TOTAL_TABLES];
  59. } binary_header;
  60. typedef struct die_info
  61. {
  62. uint16_t die_id;
  63. uint16_t die_offset; /* Points to the corresponding die_header structure */
  64. } die_info;
  65. typedef struct ip_discovery_header
  66. {
  67. uint32_t signature; /* Table Signature */
  68. uint16_t version; /* Table Version */
  69. uint16_t size; /* Table Size */
  70. uint32_t id; /* Table ID */
  71. uint16_t num_dies; /* Number of Dies */
  72. die_info die_info[16]; /* list die information for up to 16 dies */
  73. union {
  74. uint16_t padding[1]; /* version <= 3 */
  75. struct { /* version == 4 */
  76. uint8_t base_addr_64_bit : 1; /* ip structures are using 64 bit base address */
  77. uint8_t reserved : 7;
  78. uint8_t reserved2;
  79. };
  80. };
  81. } ip_discovery_header;
  82. typedef struct ip
  83. {
  84. uint16_t hw_id; /* Hardware ID */
  85. uint8_t number_instance; /* instance of the IP */
  86. uint8_t num_base_address; /* Number of Base Addresses */
  87. uint8_t major; /* HCID Major */
  88. uint8_t minor; /* HCID Minor */
  89. uint8_t revision; /* HCID Revision */
  90. #if defined(__BIG_ENDIAN)
  91. uint8_t reserved : 4; /* Placeholder field */
  92. uint8_t harvest : 4; /* Harvest */
  93. #else
  94. uint8_t harvest : 4; /* Harvest */
  95. uint8_t reserved : 4; /* Placeholder field */
  96. #endif
  97. uint32_t base_address[]; /* variable number of Addresses */
  98. } ip;
  99. typedef struct ip_v3
  100. {
  101. uint16_t hw_id; /* Hardware ID */
  102. uint8_t instance_number; /* Instance number for the IP */
  103. uint8_t num_base_address; /* Number of base addresses*/
  104. uint8_t major; /* Hardware ID.major version */
  105. uint8_t minor; /* Hardware ID.minor version */
  106. uint8_t revision; /* Hardware ID.revision version */
  107. #if defined(__BIG_ENDIAN)
  108. uint8_t variant : 4; /* HW variant */
  109. uint8_t sub_revision : 4; /* HCID Sub-Revision */
  110. #else
  111. uint8_t sub_revision : 4; /* HCID Sub-Revision */
  112. uint8_t variant : 4; /* HW variant */
  113. #endif
  114. uint32_t base_address[]; /* Base Address list. Corresponds to the num_base_address field*/
  115. } ip_v3;
  116. typedef struct ip_v4 {
  117. uint16_t hw_id; /* Hardware ID */
  118. uint8_t instance_number; /* Instance number for the IP */
  119. uint8_t num_base_address; /* Number of base addresses*/
  120. uint8_t major; /* Hardware ID.major version */
  121. uint8_t minor; /* Hardware ID.minor version */
  122. uint8_t revision; /* Hardware ID.revision version */
  123. #if defined(LITTLEENDIAN_CPU)
  124. uint8_t sub_revision : 4; /* HCID Sub-Revision */
  125. uint8_t variant : 4; /* HW variant */
  126. #elif defined(BIGENDIAN_CPU)
  127. uint8_t variant : 4; /* HW variant */
  128. uint8_t sub_revision : 4; /* HCID Sub-Revision */
  129. #endif
  130. union {
  131. DECLARE_FLEX_ARRAY(uint32_t, base_address); /* 32-bit Base Address list. Corresponds to the num_base_address field*/
  132. DECLARE_FLEX_ARRAY(uint64_t, base_address_64); /* 64-bit Base Address list. Corresponds to the num_base_address field*/
  133. } __packed;
  134. } ip_v4;
  135. typedef struct die_header
  136. {
  137. uint16_t die_id;
  138. uint16_t num_ips;
  139. } die_header;
  140. typedef struct ip_structure
  141. {
  142. ip_discovery_header* header;
  143. struct die
  144. {
  145. die_header *die_header;
  146. union
  147. {
  148. ip *ip_list;
  149. ip_v3 *ip_v3_list;
  150. ip_v4 *ip_v4_list;
  151. }; /* IP list. Variable size*/
  152. } die;
  153. } ip_structure;
  154. struct gpu_info_header {
  155. uint32_t table_id; /* table ID */
  156. uint16_t version_major; /* table version */
  157. uint16_t version_minor; /* table version */
  158. uint32_t size; /* size of the entire header+data in bytes */
  159. };
  160. struct gc_info_v1_0 {
  161. struct gpu_info_header header;
  162. uint32_t gc_num_se;
  163. uint32_t gc_num_wgp0_per_sa;
  164. uint32_t gc_num_wgp1_per_sa;
  165. uint32_t gc_num_rb_per_se;
  166. uint32_t gc_num_gl2c;
  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. uint32_t gc_num_sc_per_se;
  178. uint32_t gc_num_sa_per_se;
  179. uint32_t gc_num_packer_per_sc;
  180. uint32_t gc_num_gl2a;
  181. };
  182. struct gc_info_v1_1 {
  183. struct gpu_info_header header;
  184. uint32_t gc_num_se;
  185. uint32_t gc_num_wgp0_per_sa;
  186. uint32_t gc_num_wgp1_per_sa;
  187. uint32_t gc_num_rb_per_se;
  188. uint32_t gc_num_gl2c;
  189. uint32_t gc_num_gprs;
  190. uint32_t gc_num_max_gs_thds;
  191. uint32_t gc_gs_table_depth;
  192. uint32_t gc_gsprim_buff_depth;
  193. uint32_t gc_parameter_cache_depth;
  194. uint32_t gc_double_offchip_lds_buffer;
  195. uint32_t gc_wave_size;
  196. uint32_t gc_max_waves_per_simd;
  197. uint32_t gc_max_scratch_slots_per_cu;
  198. uint32_t gc_lds_size;
  199. uint32_t gc_num_sc_per_se;
  200. uint32_t gc_num_sa_per_se;
  201. uint32_t gc_num_packer_per_sc;
  202. uint32_t gc_num_gl2a;
  203. uint32_t gc_num_tcp_per_sa;
  204. uint32_t gc_num_sdp_interface;
  205. uint32_t gc_num_tcps;
  206. };
  207. struct gc_info_v1_2 {
  208. struct gpu_info_header header;
  209. uint32_t gc_num_se;
  210. uint32_t gc_num_wgp0_per_sa;
  211. uint32_t gc_num_wgp1_per_sa;
  212. uint32_t gc_num_rb_per_se;
  213. uint32_t gc_num_gl2c;
  214. uint32_t gc_num_gprs;
  215. uint32_t gc_num_max_gs_thds;
  216. uint32_t gc_gs_table_depth;
  217. uint32_t gc_gsprim_buff_depth;
  218. uint32_t gc_parameter_cache_depth;
  219. uint32_t gc_double_offchip_lds_buffer;
  220. uint32_t gc_wave_size;
  221. uint32_t gc_max_waves_per_simd;
  222. uint32_t gc_max_scratch_slots_per_cu;
  223. uint32_t gc_lds_size;
  224. uint32_t gc_num_sc_per_se;
  225. uint32_t gc_num_sa_per_se;
  226. uint32_t gc_num_packer_per_sc;
  227. uint32_t gc_num_gl2a;
  228. uint32_t gc_num_tcp_per_sa;
  229. uint32_t gc_num_sdp_interface;
  230. uint32_t gc_num_tcps;
  231. uint32_t gc_num_tcp_per_wpg;
  232. uint32_t gc_tcp_l1_size;
  233. uint32_t gc_num_sqc_per_wgp;
  234. uint32_t gc_l1_instruction_cache_size_per_sqc;
  235. uint32_t gc_l1_data_cache_size_per_sqc;
  236. uint32_t gc_gl1c_per_sa;
  237. uint32_t gc_gl1c_size_per_instance;
  238. uint32_t gc_gl2c_per_gpu;
  239. };
  240. struct gc_info_v1_3 {
  241. struct gpu_info_header header;
  242. uint32_t gc_num_se;
  243. uint32_t gc_num_wgp0_per_sa;
  244. uint32_t gc_num_wgp1_per_sa;
  245. uint32_t gc_num_rb_per_se;
  246. uint32_t gc_num_gl2c;
  247. uint32_t gc_num_gprs;
  248. uint32_t gc_num_max_gs_thds;
  249. uint32_t gc_gs_table_depth;
  250. uint32_t gc_gsprim_buff_depth;
  251. uint32_t gc_parameter_cache_depth;
  252. uint32_t gc_double_offchip_lds_buffer;
  253. uint32_t gc_wave_size;
  254. uint32_t gc_max_waves_per_simd;
  255. uint32_t gc_max_scratch_slots_per_cu;
  256. uint32_t gc_lds_size;
  257. uint32_t gc_num_sc_per_se;
  258. uint32_t gc_num_sa_per_se;
  259. uint32_t gc_num_packer_per_sc;
  260. uint32_t gc_num_gl2a;
  261. uint32_t gc_num_tcp_per_sa;
  262. uint32_t gc_num_sdp_interface;
  263. uint32_t gc_num_tcps;
  264. uint32_t gc_num_tcp_per_wpg;
  265. uint32_t gc_tcp_l1_size;
  266. uint32_t gc_num_sqc_per_wgp;
  267. uint32_t gc_l1_instruction_cache_size_per_sqc;
  268. uint32_t gc_l1_data_cache_size_per_sqc;
  269. uint32_t gc_gl1c_per_sa;
  270. uint32_t gc_gl1c_size_per_instance;
  271. uint32_t gc_gl2c_per_gpu;
  272. uint32_t gc_tcp_size_per_cu;
  273. uint32_t gc_tcp_cache_line_size;
  274. uint32_t gc_instruction_cache_size_per_sqc;
  275. uint32_t gc_instruction_cache_line_size;
  276. uint32_t gc_scalar_data_cache_size_per_sqc;
  277. uint32_t gc_scalar_data_cache_line_size;
  278. uint32_t gc_tcc_size;
  279. uint32_t gc_tcc_cache_line_size;
  280. };
  281. struct gc_info_v2_0 {
  282. struct gpu_info_header header;
  283. uint32_t gc_num_se;
  284. uint32_t gc_num_cu_per_sh;
  285. uint32_t gc_num_sh_per_se;
  286. uint32_t gc_num_rb_per_se;
  287. uint32_t gc_num_tccs;
  288. uint32_t gc_num_gprs;
  289. uint32_t gc_num_max_gs_thds;
  290. uint32_t gc_gs_table_depth;
  291. uint32_t gc_gsprim_buff_depth;
  292. uint32_t gc_parameter_cache_depth;
  293. uint32_t gc_double_offchip_lds_buffer;
  294. uint32_t gc_wave_size;
  295. uint32_t gc_max_waves_per_simd;
  296. uint32_t gc_max_scratch_slots_per_cu;
  297. uint32_t gc_lds_size;
  298. uint32_t gc_num_sc_per_se;
  299. uint32_t gc_num_packer_per_sc;
  300. };
  301. struct gc_info_v2_1 {
  302. struct gpu_info_header header;
  303. uint32_t gc_num_se;
  304. uint32_t gc_num_cu_per_sh;
  305. uint32_t gc_num_sh_per_se;
  306. uint32_t gc_num_rb_per_se;
  307. uint32_t gc_num_tccs;
  308. uint32_t gc_num_gprs;
  309. uint32_t gc_num_max_gs_thds;
  310. uint32_t gc_gs_table_depth;
  311. uint32_t gc_gsprim_buff_depth;
  312. uint32_t gc_parameter_cache_depth;
  313. uint32_t gc_double_offchip_lds_buffer;
  314. uint32_t gc_wave_size;
  315. uint32_t gc_max_waves_per_simd;
  316. uint32_t gc_max_scratch_slots_per_cu;
  317. uint32_t gc_lds_size;
  318. uint32_t gc_num_sc_per_se;
  319. uint32_t gc_num_packer_per_sc;
  320. /* new for v2_1 */
  321. uint32_t gc_num_tcp_per_sh;
  322. uint32_t gc_tcp_size_per_cu;
  323. uint32_t gc_num_sdp_interface;
  324. uint32_t gc_num_cu_per_sqc;
  325. uint32_t gc_instruction_cache_size_per_sqc;
  326. uint32_t gc_scalar_data_cache_size_per_sqc;
  327. uint32_t gc_tcc_size;
  328. };
  329. typedef struct harvest_info_header {
  330. uint32_t signature; /* Table Signature */
  331. uint32_t version; /* Table Version */
  332. } harvest_info_header;
  333. typedef struct harvest_info {
  334. uint16_t hw_id; /* Hardware ID */
  335. uint8_t number_instance; /* Instance of the IP */
  336. uint8_t reserved; /* Reserved for alignment */
  337. } harvest_info;
  338. typedef struct harvest_table {
  339. harvest_info_header header;
  340. harvest_info list[32];
  341. } harvest_table;
  342. struct mall_info_header {
  343. uint32_t table_id; /* table ID */
  344. uint16_t version_major; /* table version */
  345. uint16_t version_minor; /* table version */
  346. uint32_t size_bytes; /* size of the entire header+data in bytes */
  347. };
  348. struct mall_info_v1_0 {
  349. struct mall_info_header header;
  350. uint32_t mall_size_per_m;
  351. uint32_t m_s_present;
  352. uint32_t m_half_use;
  353. uint32_t m_mall_config;
  354. uint32_t reserved[5];
  355. };
  356. struct mall_info_v2_0 {
  357. struct mall_info_header header;
  358. uint32_t mall_size_per_umc;
  359. uint32_t reserved[8];
  360. };
  361. #define VCN_INFO_TABLE_MAX_NUM_INSTANCES 4
  362. struct vcn_info_header {
  363. uint32_t table_id; /* table ID */
  364. uint16_t version_major; /* table version */
  365. uint16_t version_minor; /* table version */
  366. uint32_t size_bytes; /* size of the entire header+data in bytes */
  367. };
  368. struct vcn_instance_info_v1_0
  369. {
  370. uint32_t instance_num; /* VCN IP instance number. 0 - VCN0; 1 - VCN1 etc*/
  371. union _fuse_data {
  372. struct {
  373. uint32_t av1_disabled : 1;
  374. uint32_t vp9_disabled : 1;
  375. uint32_t hevc_disabled : 1;
  376. uint32_t h264_disabled : 1;
  377. uint32_t reserved : 28;
  378. } bits;
  379. uint32_t all_bits;
  380. } fuse_data;
  381. uint32_t reserved[2];
  382. };
  383. struct vcn_info_v1_0 {
  384. struct vcn_info_header header;
  385. uint32_t num_of_instances; /* number of entries used in instance_info below*/
  386. struct vcn_instance_info_v1_0 instance_info[VCN_INFO_TABLE_MAX_NUM_INSTANCES];
  387. uint32_t reserved[4];
  388. };
  389. #define NPS_INFO_TABLE_MAX_NUM_INSTANCES 12
  390. struct nps_info_header {
  391. uint32_t table_id; /* table ID */
  392. uint16_t version_major; /* table version */
  393. uint16_t version_minor; /* table version */
  394. uint32_t size_bytes; /* size of the entire header+data in bytes = 0x000000D4 (212) */
  395. };
  396. struct nps_instance_info_v1_0 {
  397. uint64_t base_address;
  398. uint64_t limit_address;
  399. };
  400. struct nps_info_v1_0 {
  401. struct nps_info_header header;
  402. uint32_t nps_type;
  403. uint32_t count;
  404. struct nps_instance_info_v1_0
  405. instance_info[NPS_INFO_TABLE_MAX_NUM_INSTANCES];
  406. };
  407. #pragma pack()
  408. #endif