xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/include/discovery.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: discovery.h,v 1.2 2021/12/18 23:45:08 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2018 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 
26 #ifndef _DISCOVERY_H_
27 #define _DISCOVERY_H_
28 
29 #define PSP_HEADER_SIZE                 256
30 #define BINARY_SIGNATURE                0x28211407
31 #define DISCOVERY_TABLE_SIGNATURE       0x53445049
32 
33 typedef enum
34 {
35 	IP_DISCOVERY = 0,
36 	GC,
37 	HARVEST_INFO,
38 	TABLE_4,
39 	RESERVED_1,
40 	RESERVED_2,
41 	TOTAL_TABLES = 6
42 } table;
43 
44 #pragma pack(1)
45 
46 typedef struct table_info
47 {
48 	uint16_t offset;   /* Byte offset */
49 	uint16_t checksum; /* Byte sum of the table */
50 	uint16_t size;     /* Table size */
51 	uint16_t padding;
52 } table_info;
53 
54 typedef struct binary_header
55 {
56 	/* psp structure should go at the top of this structure */
57 	uint32_t binary_signature; /* 0x7, 0x14, 0x21, 0x28 */
58 	uint16_t version_major;
59 	uint16_t version_minor;
60 	uint16_t binary_checksum;  /* Byte sum of the binary after this field */
61 	uint16_t binary_size;      /* Binary Size*/
62 	table_info table_list[TOTAL_TABLES];
63 } binary_header;
64 
65 typedef struct die_info
66 {
67 	uint16_t die_id;
68 	uint16_t die_offset; /* Points to the corresponding die_header structure */
69 } die_info;
70 
71 
72 typedef struct ip_discovery_header
73 {
74 	uint32_t signature;    /* Table Signature */
75 	uint16_t version;      /* Table Version */
76 	uint16_t size;         /* Table Size */
77 	uint32_t id;           /* Table ID */
78 	uint16_t num_dies;     /* Number of Dies */
79 	die_info die_info[16]; /* list die information for up to 16 dies */
80 	uint16_t padding[1];   /* padding */
81 } ip_discovery_header;
82 
83 typedef struct ip
84 {
85 	uint16_t hw_id;           /* Hardware ID */
86 	uint8_t number_instance;  /* instance of the IP */
87 	uint8_t num_base_address; /* Number of Base Addresses */
88 	uint8_t major;            /* HCID Major */
89 	uint8_t minor;            /* HCID Minor */
90 	uint8_t revision;         /* HCID Revision */
91 #if defined(__BIG_ENDIAN)
92 	uint8_t reserved : 4;     /* Placeholder field */
93 	uint8_t harvest : 4;      /* Harvest */
94 #else
95 	uint8_t harvest : 4;      /* Harvest */
96 	uint8_t reserved : 4;     /* Placeholder field */
97 #endif
98 	uint32_t base_address[1]; /* variable number of Addresses */
99 } ip;
100 
101 typedef struct die_header
102 {
103 	uint16_t die_id;
104 	uint16_t num_ips;
105 } die_header;
106 
107 typedef struct ip_structure
108 {
109 	ip_discovery_header* header;
110 	struct die
111 	{
112 		die_header *die_header;
113 		ip *ip_list;
114 	} die;
115 } ip_structure;
116 
117 struct gpu_info_header {
118 	uint32_t table_id;      /* table ID */
119 	uint16_t version_major; /* table version */
120 	uint16_t version_minor; /* table version */
121 	uint32_t size;          /* size of the entire header+data in bytes */
122 };
123 
124 struct gc_info_v1_0 {
125 	struct gpu_info_header header;
126 
127 	uint32_t gc_num_se;
128 	uint32_t gc_num_wgp0_per_sa;
129 	uint32_t gc_num_wgp1_per_sa;
130 	uint32_t gc_num_rb_per_se;
131 	uint32_t gc_num_gl2c;
132 	uint32_t gc_num_gprs;
133 	uint32_t gc_num_max_gs_thds;
134 	uint32_t gc_gs_table_depth;
135 	uint32_t gc_gsprim_buff_depth;
136 	uint32_t gc_parameter_cache_depth;
137 	uint32_t gc_double_offchip_lds_buffer;
138 	uint32_t gc_wave_size;
139 	uint32_t gc_max_waves_per_simd;
140 	uint32_t gc_max_scratch_slots_per_cu;
141 	uint32_t gc_lds_size;
142 	uint32_t gc_num_sc_per_se;
143 	uint32_t gc_num_sa_per_se;
144 	uint32_t gc_num_packer_per_sc;
145 	uint32_t gc_num_gl2a;
146 };
147 
148 typedef struct harvest_info_header {
149 	uint32_t signature; /* Table Signature */
150 	uint32_t version;   /* Table Version */
151 } harvest_info_header;
152 
153 typedef struct harvest_info {
154 	uint16_t hw_id;          /* Hardware ID */
155 	uint8_t number_instance; /* Instance of the IP */
156 	uint8_t reserved;        /* Reserved for alignment */
157 } harvest_info;
158 
159 typedef struct harvest_table {
160 	harvest_info_header header;
161 	harvest_info list[32];
162 } harvest_table;
163 
164 #pragma pack()
165 
166 #endif
167