1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2018 Etnaviv Project
4  */
5 
6 #include "etnaviv_gpu.h"
7 
8 static const struct etnaviv_chip_identity etnaviv_chip_identities[] = {
9 	{
10 		.model = 0x400,
11 		.revision = 0x4652,
12 		.product_id = 0x70001,
13 		.customer_id = 0x100,
14 		.eco_id = 0,
15 		.stream_count = 4,
16 		.register_max = 64,
17 		.thread_count = 128,
18 		.shader_core_count = 1,
19 		.nn_core_count = 0,
20 		.vertex_cache_size = 8,
21 		.vertex_output_buffer_size = 1024,
22 		.pixel_pipes = 1,
23 		.instruction_count = 256,
24 		.num_constants = 320,
25 		.buffer_size = 0,
26 		.varyings_count = 8,
27 		.features = 0xa0e9e004,
28 		.minor_features0 = 0xe1299fff,
29 		.minor_features1 = 0xbe13b219,
30 		.minor_features2 = 0xce110010,
31 		.minor_features3 = 0x8000001,
32 		.minor_features4 = 0x20102,
33 		.minor_features5 = 0x120000,
34 		.minor_features6 = 0x0,
35 		.minor_features7 = 0x0,
36 		.minor_features8 = 0x0,
37 		.minor_features9 = 0x0,
38 		.minor_features10 = 0x0,
39 		.minor_features11 = 0x0,
40 	},
41 	{
42 		.model = 0x7000,
43 		.revision = 0x6202,
44 		.product_id = 0x70003,
45 		.customer_id = 0,
46 		.eco_id = 0,
47 		.stream_count = 8,
48 		.register_max = 64,
49 		.thread_count = 512,
50 		.shader_core_count = 2,
51 		.nn_core_count = 0,
52 		.vertex_cache_size = 16,
53 		.vertex_output_buffer_size = 1024,
54 		.pixel_pipes = 1,
55 		.instruction_count = 512,
56 		.num_constants = 320,
57 		.buffer_size = 0,
58 		.varyings_count = 16,
59 		.features = 0xe0287cad,
60 		.minor_features0 = 0xc1489eff,
61 		.minor_features1 = 0xfefbfad9,
62 		.minor_features2 = 0xeb9d4fbf,
63 		.minor_features3 = 0xedfffced,
64 		.minor_features4 = 0xdb0dafc7,
65 		.minor_features5 = 0x3b5ac333,
66 		.minor_features6 = 0xfccee201,
67 		.minor_features7 = 0x03fffa6f,
68 		.minor_features8 = 0x00e10ef0,
69 		.minor_features9 = 0x0088003c,
70 		.minor_features10 = 0x00004040,
71 		.minor_features11 = 0x00000024,
72 	},
73 	{
74 		.model = 0x7000,
75 		.revision = 0x6203,
76 		.product_id = 0x70003,
77 		.customer_id = 0x4,
78 		.eco_id = 0,
79 		.stream_count = 16,
80 		.register_max = 64,
81 		.thread_count = 512,
82 		.shader_core_count = 2,
83 		.nn_core_count = 0,
84 		.vertex_cache_size = 16,
85 		.vertex_output_buffer_size = 1024,
86 		.pixel_pipes = 1,
87 		.instruction_count = 512,
88 		.num_constants = 320,
89 		.buffer_size = 0,
90 		.varyings_count = 16,
91 		.features = 0xe0287c8d,
92 		.minor_features0 = 0xc1589eff,
93 		.minor_features1 = 0xfefbfad9,
94 		.minor_features2 = 0xeb9d4fbf,
95 		.minor_features3 = 0xedfffced,
96 		.minor_features4 = 0xdb0dafc7,
97 		.minor_features5 = 0x3b5ac333,
98 		.minor_features6 = 0xfcce6000,
99 		.minor_features7 = 0xfffbfa6f,
100 		.minor_features8 = 0x00e10ef3,
101 		.minor_features9 = 0x00c8003c,
102 		.minor_features10 = 0x00004040,
103 		.minor_features11 = 0x00000024,
104 	},
105 	{
106 		.model = 0x7000,
107 		.revision = 0x6204,
108 		.product_id = ~0U,
109 		.customer_id = ~0U,
110 		.eco_id = 0,
111 		.stream_count = 16,
112 		.register_max = 64,
113 		.thread_count = 512,
114 		.shader_core_count = 2,
115 		.vertex_cache_size = 16,
116 		.vertex_output_buffer_size = 1024,
117 		.pixel_pipes = 1,
118 		.instruction_count = 512,
119 		.num_constants = 320,
120 		.buffer_size = 0,
121 		.varyings_count = 16,
122 		.features = 0xe0287c8d,
123 		.minor_features0 = 0xc1589eff,
124 		.minor_features1 = 0xfefbfad9,
125 		.minor_features2 = 0xeb9d4fbf,
126 		.minor_features3 = 0xedfffced,
127 		.minor_features4 = 0xdb0dafc7,
128 		.minor_features5 = 0x3b5ac333,
129 		.minor_features6 = 0xfcce6000,
130 		.minor_features7 = 0xfffbfa6f,
131 		.minor_features8 = 0x00e10ef3,
132 		.minor_features9 = 0x04c8003c,
133 		.minor_features10 = 0x00004060,
134 		.minor_features11 = 0x00000024,
135 	},
136 	{
137 		.model = 0x7000,
138 		.revision = 0x6214,
139 		.product_id = ~0U,
140 		.customer_id = ~0U,
141 		.eco_id = ~0U,
142 		.stream_count = 16,
143 		.register_max = 64,
144 		.thread_count = 1024,
145 		.shader_core_count = 4,
146 		.nn_core_count = 0,
147 		.vertex_cache_size = 16,
148 		.vertex_output_buffer_size = 1024,
149 		.pixel_pipes = 2,
150 		.instruction_count = 512,
151 		.num_constants = 320,
152 		.buffer_size = 0,
153 		.varyings_count = 16,
154 		.features = 0xe0287cad,
155 		.minor_features0 = 0xc1799eff,
156 		.minor_features1 = 0xfefbfad9,
157 		.minor_features2 = 0xeb9d4fbf,
158 		.minor_features3 = 0xedfffced,
159 		.minor_features4 = 0xdb0dafc7,
160 		.minor_features5 = 0xbb5ac333,
161 		.minor_features6 = 0xfc8ee200,
162 		.minor_features7 = 0x03fbfa6f,
163 		.minor_features8 = 0x00ef0ef0,
164 		.minor_features9 = 0x0edbf03c,
165 		.minor_features10 = 0x90044250,
166 		.minor_features11 = 0x00000024,
167 	},
168 	{
169 		.model = 0x8000,
170 		.revision = 0x7120,
171 		.product_id = 0x45080009,
172 		.customer_id = 0x88,
173 		.eco_id = 0,
174 		.stream_count = 8,
175 		.register_max = 64,
176 		.thread_count = 256,
177 		.shader_core_count = 1,
178 		.nn_core_count = 8,
179 		.vertex_cache_size = 16,
180 		.vertex_output_buffer_size = 1024,
181 		.pixel_pipes = 1,
182 		.instruction_count = 512,
183 		.num_constants = 320,
184 		.buffer_size = 0,
185 		.varyings_count = 16,
186 		.features = 0xe0287cac,
187 		.minor_features0 = 0xc1799eff,
188 		.minor_features1 = 0xfefbfadb,
189 		.minor_features2 = 0xeb9d6fbf,
190 		.minor_features3 = 0xedfffced,
191 		.minor_features4 = 0xd30dafc7,
192 		.minor_features5 = 0x7b5ac333,
193 		.minor_features6 = 0xfc8ee200,
194 		.minor_features7 = 0x03fffa6f,
195 		.minor_features8 = 0x00fe0ef0,
196 		.minor_features9 = 0x0088003c,
197 		.minor_features10 = 0x108048c0,
198 		.minor_features11 = 0x00000010,
199 	},
200 };
201 
202 bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu)
203 {
204 	struct etnaviv_chip_identity *ident = &gpu->identity;
205 	int i;
206 
207 	for (i = 0; i < ARRAY_SIZE(etnaviv_chip_identities); i++) {
208 		if (etnaviv_chip_identities[i].model == ident->model &&
209 		    etnaviv_chip_identities[i].revision == ident->revision &&
210 		    (etnaviv_chip_identities[i].product_id == ident->product_id ||
211 			 etnaviv_chip_identities[i].product_id == ~0U) &&
212 		    (etnaviv_chip_identities[i].customer_id == ident->customer_id ||
213 			 etnaviv_chip_identities[i].customer_id == ~0U) &&
214 		    (etnaviv_chip_identities[i].eco_id == ident->eco_id ||
215 			 etnaviv_chip_identities[i].eco_id == ~0U)) {
216 			memcpy(ident, &etnaviv_chip_identities[i],
217 			       sizeof(*ident));
218 			return true;
219 		}
220 	}
221 
222 	return false;
223 }
224