1 /* $NetBSD: nouveau_nvkm_engine_gr_ctxgf100.c,v 1.3 2021/12/18 23:45:36 riastradh Exp $ */
2
3 /*
4 * Copyright 2010 Red Hat 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 * Authors: Ben Skeggs
25 */
26 #include <sys/cdefs.h>
27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_gr_ctxgf100.c,v 1.3 2021/12/18 23:45:36 riastradh Exp $");
28
29 #include "ctxgf100.h"
30
31 #include <subdev/fb.h>
32 #include <subdev/mc.h>
33 #include <subdev/timer.h>
34
35 /*******************************************************************************
36 * PGRAPH context register lists
37 ******************************************************************************/
38
39 static const struct gf100_gr_init
40 gf100_grctx_init_icmd_0[] = {
41 { 0x001000, 1, 0x01, 0x00000004 },
42 { 0x0000a9, 1, 0x01, 0x0000ffff },
43 { 0x000038, 1, 0x01, 0x0fac6881 },
44 { 0x00003d, 1, 0x01, 0x00000001 },
45 { 0x0000e8, 8, 0x01, 0x00000400 },
46 { 0x000078, 8, 0x01, 0x00000300 },
47 { 0x000050, 1, 0x01, 0x00000011 },
48 { 0x000058, 8, 0x01, 0x00000008 },
49 { 0x000208, 8, 0x01, 0x00000001 },
50 { 0x000081, 1, 0x01, 0x00000001 },
51 { 0x000085, 1, 0x01, 0x00000004 },
52 { 0x000088, 1, 0x01, 0x00000400 },
53 { 0x000090, 1, 0x01, 0x00000300 },
54 { 0x000098, 1, 0x01, 0x00001001 },
55 { 0x0000e3, 1, 0x01, 0x00000001 },
56 { 0x0000da, 1, 0x01, 0x00000001 },
57 { 0x0000f8, 1, 0x01, 0x00000003 },
58 { 0x0000fa, 1, 0x01, 0x00000001 },
59 { 0x00009f, 4, 0x01, 0x0000ffff },
60 { 0x0000b1, 1, 0x01, 0x00000001 },
61 { 0x0000b2, 40, 0x01, 0x00000000 },
62 { 0x000210, 8, 0x01, 0x00000040 },
63 { 0x000218, 8, 0x01, 0x0000c080 },
64 { 0x0000ad, 1, 0x01, 0x0000013e },
65 { 0x0000e1, 1, 0x01, 0x00000010 },
66 { 0x000290, 16, 0x01, 0x00000000 },
67 { 0x0003b0, 16, 0x01, 0x00000000 },
68 { 0x0002a0, 16, 0x01, 0x00000000 },
69 { 0x000420, 16, 0x01, 0x00000000 },
70 { 0x0002b0, 16, 0x01, 0x00000000 },
71 { 0x000430, 16, 0x01, 0x00000000 },
72 { 0x0002c0, 16, 0x01, 0x00000000 },
73 { 0x0004d0, 16, 0x01, 0x00000000 },
74 { 0x000720, 16, 0x01, 0x00000000 },
75 { 0x0008c0, 16, 0x01, 0x00000000 },
76 { 0x000890, 16, 0x01, 0x00000000 },
77 { 0x0008e0, 16, 0x01, 0x00000000 },
78 { 0x0008a0, 16, 0x01, 0x00000000 },
79 { 0x0008f0, 16, 0x01, 0x00000000 },
80 { 0x00094c, 1, 0x01, 0x000000ff },
81 { 0x00094d, 1, 0x01, 0xffffffff },
82 { 0x00094e, 1, 0x01, 0x00000002 },
83 { 0x0002ec, 1, 0x01, 0x00000001 },
84 { 0x000303, 1, 0x01, 0x00000001 },
85 { 0x0002e6, 1, 0x01, 0x00000001 },
86 { 0x000466, 1, 0x01, 0x00000052 },
87 { 0x000301, 1, 0x01, 0x3f800000 },
88 { 0x000304, 1, 0x01, 0x30201000 },
89 { 0x000305, 1, 0x01, 0x70605040 },
90 { 0x000306, 1, 0x01, 0xb8a89888 },
91 { 0x000307, 1, 0x01, 0xf8e8d8c8 },
92 { 0x00030a, 1, 0x01, 0x00ffff00 },
93 { 0x00030b, 1, 0x01, 0x0000001a },
94 { 0x00030c, 1, 0x01, 0x00000001 },
95 { 0x000318, 1, 0x01, 0x00000001 },
96 { 0x000340, 1, 0x01, 0x00000000 },
97 { 0x000375, 1, 0x01, 0x00000001 },
98 { 0x000351, 1, 0x01, 0x00000100 },
99 { 0x00037d, 1, 0x01, 0x00000006 },
100 { 0x0003a0, 1, 0x01, 0x00000002 },
101 { 0x0003aa, 1, 0x01, 0x00000001 },
102 { 0x0003a9, 1, 0x01, 0x00000001 },
103 { 0x000380, 1, 0x01, 0x00000001 },
104 { 0x000360, 1, 0x01, 0x00000040 },
105 { 0x000366, 2, 0x01, 0x00000000 },
106 { 0x000368, 1, 0x01, 0x00001fff },
107 { 0x000370, 2, 0x01, 0x00000000 },
108 { 0x000372, 1, 0x01, 0x003fffff },
109 { 0x00037a, 1, 0x01, 0x00000012 },
110 { 0x0005e0, 5, 0x01, 0x00000022 },
111 { 0x000619, 1, 0x01, 0x00000003 },
112 { 0x000811, 1, 0x01, 0x00000003 },
113 { 0x000812, 1, 0x01, 0x00000004 },
114 { 0x000813, 1, 0x01, 0x00000006 },
115 { 0x000814, 1, 0x01, 0x00000008 },
116 { 0x000815, 1, 0x01, 0x0000000b },
117 { 0x000800, 6, 0x01, 0x00000001 },
118 { 0x000632, 1, 0x01, 0x00000001 },
119 { 0x000633, 1, 0x01, 0x00000002 },
120 { 0x000634, 1, 0x01, 0x00000003 },
121 { 0x000635, 1, 0x01, 0x00000004 },
122 { 0x000654, 1, 0x01, 0x3f800000 },
123 { 0x000657, 1, 0x01, 0x3f800000 },
124 { 0x000655, 2, 0x01, 0x3f800000 },
125 { 0x0006cd, 1, 0x01, 0x3f800000 },
126 { 0x0007f5, 1, 0x01, 0x3f800000 },
127 { 0x0007dc, 1, 0x01, 0x39291909 },
128 { 0x0007dd, 1, 0x01, 0x79695949 },
129 { 0x0007de, 1, 0x01, 0xb9a99989 },
130 { 0x0007df, 1, 0x01, 0xf9e9d9c9 },
131 { 0x0007e8, 1, 0x01, 0x00003210 },
132 { 0x0007e9, 1, 0x01, 0x00007654 },
133 { 0x0007ea, 1, 0x01, 0x00000098 },
134 { 0x0007ec, 1, 0x01, 0x39291909 },
135 { 0x0007ed, 1, 0x01, 0x79695949 },
136 { 0x0007ee, 1, 0x01, 0xb9a99989 },
137 { 0x0007ef, 1, 0x01, 0xf9e9d9c9 },
138 { 0x0007f0, 1, 0x01, 0x00003210 },
139 { 0x0007f1, 1, 0x01, 0x00007654 },
140 { 0x0007f2, 1, 0x01, 0x00000098 },
141 { 0x0005a5, 1, 0x01, 0x00000001 },
142 { 0x000980, 128, 0x01, 0x00000000 },
143 { 0x000468, 1, 0x01, 0x00000004 },
144 { 0x00046c, 1, 0x01, 0x00000001 },
145 { 0x000470, 96, 0x01, 0x00000000 },
146 { 0x000510, 16, 0x01, 0x3f800000 },
147 { 0x000520, 1, 0x01, 0x000002b6 },
148 { 0x000529, 1, 0x01, 0x00000001 },
149 { 0x000530, 16, 0x01, 0xffff0000 },
150 { 0x000585, 1, 0x01, 0x0000003f },
151 { 0x000576, 1, 0x01, 0x00000003 },
152 { 0x000586, 1, 0x01, 0x00000040 },
153 { 0x000582, 2, 0x01, 0x00000080 },
154 { 0x0005c2, 1, 0x01, 0x00000001 },
155 { 0x000638, 2, 0x01, 0x00000001 },
156 { 0x00063a, 1, 0x01, 0x00000002 },
157 { 0x00063b, 2, 0x01, 0x00000001 },
158 { 0x00063d, 1, 0x01, 0x00000002 },
159 { 0x00063e, 1, 0x01, 0x00000001 },
160 { 0x0008b8, 8, 0x01, 0x00000001 },
161 { 0x000900, 8, 0x01, 0x00000001 },
162 { 0x000908, 8, 0x01, 0x00000002 },
163 { 0x000910, 16, 0x01, 0x00000001 },
164 { 0x000920, 8, 0x01, 0x00000002 },
165 { 0x000928, 8, 0x01, 0x00000001 },
166 { 0x000648, 9, 0x01, 0x00000001 },
167 { 0x000658, 1, 0x01, 0x0000000f },
168 { 0x0007ff, 1, 0x01, 0x0000000a },
169 { 0x00066a, 1, 0x01, 0x40000000 },
170 { 0x00066b, 1, 0x01, 0x10000000 },
171 { 0x00066c, 2, 0x01, 0xffff0000 },
172 { 0x0007af, 2, 0x01, 0x00000008 },
173 { 0x0007f6, 1, 0x01, 0x00000001 },
174 { 0x0006b2, 1, 0x01, 0x00000055 },
175 { 0x0007ad, 1, 0x01, 0x00000003 },
176 { 0x000937, 1, 0x01, 0x00000001 },
177 { 0x000971, 1, 0x01, 0x00000008 },
178 { 0x000972, 1, 0x01, 0x00000040 },
179 { 0x000973, 1, 0x01, 0x0000012c },
180 { 0x00097c, 1, 0x01, 0x00000040 },
181 { 0x000979, 1, 0x01, 0x00000003 },
182 { 0x000975, 1, 0x01, 0x00000020 },
183 { 0x000976, 1, 0x01, 0x00000001 },
184 { 0x000977, 1, 0x01, 0x00000020 },
185 { 0x000978, 1, 0x01, 0x00000001 },
186 { 0x000957, 1, 0x01, 0x00000003 },
187 { 0x00095e, 1, 0x01, 0x20164010 },
188 { 0x00095f, 1, 0x01, 0x00000020 },
189 { 0x000683, 1, 0x01, 0x00000006 },
190 { 0x000685, 1, 0x01, 0x003fffff },
191 { 0x000687, 1, 0x01, 0x00000c48 },
192 { 0x0006a0, 1, 0x01, 0x00000005 },
193 { 0x000840, 1, 0x01, 0x00300008 },
194 { 0x000841, 1, 0x01, 0x04000080 },
195 { 0x000842, 1, 0x01, 0x00300008 },
196 { 0x000843, 1, 0x01, 0x04000080 },
197 { 0x000818, 8, 0x01, 0x00000000 },
198 { 0x000848, 16, 0x01, 0x00000000 },
199 { 0x000738, 1, 0x01, 0x00000000 },
200 { 0x0006aa, 1, 0x01, 0x00000001 },
201 { 0x0006ab, 1, 0x01, 0x00000002 },
202 { 0x0006ac, 1, 0x01, 0x00000080 },
203 { 0x0006ad, 2, 0x01, 0x00000100 },
204 { 0x0006b1, 1, 0x01, 0x00000011 },
205 { 0x0006bb, 1, 0x01, 0x000000cf },
206 { 0x0006ce, 1, 0x01, 0x2a712488 },
207 { 0x000739, 1, 0x01, 0x4085c000 },
208 { 0x00073a, 1, 0x01, 0x00000080 },
209 { 0x000786, 1, 0x01, 0x80000100 },
210 { 0x00073c, 1, 0x01, 0x00010100 },
211 { 0x00073d, 1, 0x01, 0x02800000 },
212 { 0x000787, 1, 0x01, 0x000000cf },
213 { 0x00078c, 1, 0x01, 0x00000008 },
214 { 0x000792, 1, 0x01, 0x00000001 },
215 { 0x000794, 3, 0x01, 0x00000001 },
216 { 0x000797, 1, 0x01, 0x000000cf },
217 { 0x000836, 1, 0x01, 0x00000001 },
218 { 0x00079a, 1, 0x01, 0x00000002 },
219 { 0x000833, 1, 0x01, 0x04444480 },
220 { 0x0007a1, 1, 0x01, 0x00000001 },
221 { 0x0007a3, 3, 0x01, 0x00000001 },
222 { 0x000831, 1, 0x01, 0x00000004 },
223 { 0x00080c, 1, 0x01, 0x00000002 },
224 { 0x00080d, 2, 0x01, 0x00000100 },
225 { 0x00080f, 1, 0x01, 0x00000001 },
226 { 0x000823, 1, 0x01, 0x00000002 },
227 { 0x000824, 2, 0x01, 0x00000100 },
228 { 0x000826, 1, 0x01, 0x00000001 },
229 { 0x00095d, 1, 0x01, 0x00000001 },
230 { 0x00082b, 1, 0x01, 0x00000004 },
231 { 0x000942, 1, 0x01, 0x00010001 },
232 { 0x000943, 1, 0x01, 0x00000001 },
233 { 0x000944, 1, 0x01, 0x00000022 },
234 { 0x0007c5, 1, 0x01, 0x00010001 },
235 { 0x000834, 1, 0x01, 0x00000001 },
236 { 0x0007c7, 1, 0x01, 0x00000001 },
237 { 0x00c1b0, 8, 0x01, 0x0000000f },
238 { 0x00c1b8, 1, 0x01, 0x0fac6881 },
239 { 0x00c1b9, 1, 0x01, 0x00fac688 },
240 { 0x01e100, 1, 0x01, 0x00000001 },
241 { 0x001000, 1, 0x01, 0x00000002 },
242 { 0x0006aa, 1, 0x01, 0x00000001 },
243 { 0x0006ad, 2, 0x01, 0x00000100 },
244 { 0x0006b1, 1, 0x01, 0x00000011 },
245 { 0x00078c, 1, 0x01, 0x00000008 },
246 { 0x000792, 1, 0x01, 0x00000001 },
247 { 0x000794, 3, 0x01, 0x00000001 },
248 { 0x000797, 1, 0x01, 0x000000cf },
249 { 0x00079a, 1, 0x01, 0x00000002 },
250 { 0x000833, 1, 0x01, 0x04444480 },
251 { 0x0007a1, 1, 0x01, 0x00000001 },
252 { 0x0007a3, 3, 0x01, 0x00000001 },
253 { 0x000831, 1, 0x01, 0x00000004 },
254 { 0x01e100, 1, 0x01, 0x00000001 },
255 { 0x001000, 1, 0x01, 0x00000014 },
256 { 0x000351, 1, 0x01, 0x00000100 },
257 { 0x000957, 1, 0x01, 0x00000003 },
258 { 0x00095d, 1, 0x01, 0x00000001 },
259 { 0x00082b, 1, 0x01, 0x00000004 },
260 { 0x000942, 1, 0x01, 0x00010001 },
261 { 0x000943, 1, 0x01, 0x00000001 },
262 { 0x0007c5, 1, 0x01, 0x00010001 },
263 { 0x000834, 1, 0x01, 0x00000001 },
264 { 0x0007c7, 1, 0x01, 0x00000001 },
265 { 0x01e100, 1, 0x01, 0x00000001 },
266 { 0x001000, 1, 0x01, 0x00000001 },
267 { 0x00080c, 1, 0x01, 0x00000002 },
268 { 0x00080d, 2, 0x01, 0x00000100 },
269 { 0x00080f, 1, 0x01, 0x00000001 },
270 { 0x000823, 1, 0x01, 0x00000002 },
271 { 0x000824, 2, 0x01, 0x00000100 },
272 { 0x000826, 1, 0x01, 0x00000001 },
273 { 0x01e100, 1, 0x01, 0x00000001 },
274 {}
275 };
276
277 const struct gf100_gr_pack
278 gf100_grctx_pack_icmd[] = {
279 { gf100_grctx_init_icmd_0 },
280 {}
281 };
282
283 static const struct gf100_gr_init
284 gf100_grctx_init_9097_0[] = {
285 { 0x000800, 8, 0x40, 0x00000000 },
286 { 0x000804, 8, 0x40, 0x00000000 },
287 { 0x000808, 8, 0x40, 0x00000400 },
288 { 0x00080c, 8, 0x40, 0x00000300 },
289 { 0x000810, 1, 0x04, 0x000000cf },
290 { 0x000850, 7, 0x40, 0x00000000 },
291 { 0x000814, 8, 0x40, 0x00000040 },
292 { 0x000818, 8, 0x40, 0x00000001 },
293 { 0x00081c, 8, 0x40, 0x00000000 },
294 { 0x000820, 8, 0x40, 0x00000000 },
295 { 0x002700, 8, 0x20, 0x00000000 },
296 { 0x002704, 8, 0x20, 0x00000000 },
297 { 0x002708, 8, 0x20, 0x00000000 },
298 { 0x00270c, 8, 0x20, 0x00000000 },
299 { 0x002710, 8, 0x20, 0x00014000 },
300 { 0x002714, 8, 0x20, 0x00000040 },
301 { 0x001c00, 16, 0x10, 0x00000000 },
302 { 0x001c04, 16, 0x10, 0x00000000 },
303 { 0x001c08, 16, 0x10, 0x00000000 },
304 { 0x001c0c, 16, 0x10, 0x00000000 },
305 { 0x001d00, 16, 0x10, 0x00000000 },
306 { 0x001d04, 16, 0x10, 0x00000000 },
307 { 0x001d08, 16, 0x10, 0x00000000 },
308 { 0x001d0c, 16, 0x10, 0x00000000 },
309 { 0x001f00, 16, 0x08, 0x00000000 },
310 { 0x001f04, 16, 0x08, 0x00000000 },
311 { 0x001f80, 16, 0x08, 0x00000000 },
312 { 0x001f84, 16, 0x08, 0x00000000 },
313 { 0x002200, 5, 0x10, 0x00000022 },
314 { 0x002000, 1, 0x04, 0x00000000 },
315 { 0x002040, 1, 0x04, 0x00000011 },
316 { 0x002080, 1, 0x04, 0x00000020 },
317 { 0x0020c0, 1, 0x04, 0x00000030 },
318 { 0x002100, 1, 0x04, 0x00000040 },
319 { 0x002140, 1, 0x04, 0x00000051 },
320 { 0x00200c, 6, 0x40, 0x00000001 },
321 { 0x002010, 1, 0x04, 0x00000000 },
322 { 0x002050, 1, 0x04, 0x00000000 },
323 { 0x002090, 1, 0x04, 0x00000001 },
324 { 0x0020d0, 1, 0x04, 0x00000002 },
325 { 0x002110, 1, 0x04, 0x00000003 },
326 { 0x002150, 1, 0x04, 0x00000004 },
327 { 0x000380, 4, 0x20, 0x00000000 },
328 { 0x000384, 4, 0x20, 0x00000000 },
329 { 0x000388, 4, 0x20, 0x00000000 },
330 { 0x00038c, 4, 0x20, 0x00000000 },
331 { 0x000700, 4, 0x10, 0x00000000 },
332 { 0x000704, 4, 0x10, 0x00000000 },
333 { 0x000708, 4, 0x10, 0x00000000 },
334 { 0x002800, 128, 0x04, 0x00000000 },
335 { 0x000a00, 16, 0x20, 0x00000000 },
336 { 0x000a04, 16, 0x20, 0x00000000 },
337 { 0x000a08, 16, 0x20, 0x00000000 },
338 { 0x000a0c, 16, 0x20, 0x00000000 },
339 { 0x000a10, 16, 0x20, 0x00000000 },
340 { 0x000a14, 16, 0x20, 0x00000000 },
341 { 0x000c00, 16, 0x10, 0x00000000 },
342 { 0x000c04, 16, 0x10, 0x00000000 },
343 { 0x000c08, 16, 0x10, 0x00000000 },
344 { 0x000c0c, 16, 0x10, 0x3f800000 },
345 { 0x000d00, 8, 0x08, 0xffff0000 },
346 { 0x000d04, 8, 0x08, 0xffff0000 },
347 { 0x000e00, 16, 0x10, 0x00000000 },
348 { 0x000e04, 16, 0x10, 0xffff0000 },
349 { 0x000e08, 16, 0x10, 0xffff0000 },
350 { 0x000d40, 4, 0x08, 0x00000000 },
351 { 0x000d44, 4, 0x08, 0x00000000 },
352 { 0x001e00, 8, 0x20, 0x00000001 },
353 { 0x001e04, 8, 0x20, 0x00000001 },
354 { 0x001e08, 8, 0x20, 0x00000002 },
355 { 0x001e0c, 8, 0x20, 0x00000001 },
356 { 0x001e10, 8, 0x20, 0x00000001 },
357 { 0x001e14, 8, 0x20, 0x00000002 },
358 { 0x001e18, 8, 0x20, 0x00000001 },
359 { 0x003400, 128, 0x04, 0x00000000 },
360 { 0x00030c, 1, 0x04, 0x00000001 },
361 { 0x001944, 1, 0x04, 0x00000000 },
362 { 0x001514, 1, 0x04, 0x00000000 },
363 { 0x000d68, 1, 0x04, 0x0000ffff },
364 { 0x00121c, 1, 0x04, 0x0fac6881 },
365 { 0x000fac, 1, 0x04, 0x00000001 },
366 { 0x001538, 1, 0x04, 0x00000001 },
367 { 0x000fe0, 2, 0x04, 0x00000000 },
368 { 0x000fe8, 1, 0x04, 0x00000014 },
369 { 0x000fec, 1, 0x04, 0x00000040 },
370 { 0x000ff0, 1, 0x04, 0x00000000 },
371 { 0x00179c, 1, 0x04, 0x00000000 },
372 { 0x001228, 1, 0x04, 0x00000400 },
373 { 0x00122c, 1, 0x04, 0x00000300 },
374 { 0x001230, 1, 0x04, 0x00010001 },
375 { 0x0007f8, 1, 0x04, 0x00000000 },
376 { 0x0015b4, 1, 0x04, 0x00000001 },
377 { 0x0015cc, 1, 0x04, 0x00000000 },
378 { 0x001534, 1, 0x04, 0x00000000 },
379 { 0x000fb0, 1, 0x04, 0x00000000 },
380 { 0x0015d0, 1, 0x04, 0x00000000 },
381 { 0x00153c, 1, 0x04, 0x00000000 },
382 { 0x0016b4, 1, 0x04, 0x00000003 },
383 { 0x000fbc, 4, 0x04, 0x0000ffff },
384 { 0x000df8, 2, 0x04, 0x00000000 },
385 { 0x001948, 1, 0x04, 0x00000000 },
386 { 0x001970, 1, 0x04, 0x00000001 },
387 { 0x00161c, 1, 0x04, 0x000009f0 },
388 { 0x000dcc, 1, 0x04, 0x00000010 },
389 { 0x00163c, 1, 0x04, 0x00000000 },
390 { 0x0015e4, 1, 0x04, 0x00000000 },
391 { 0x001160, 32, 0x04, 0x25e00040 },
392 { 0x001880, 32, 0x04, 0x00000000 },
393 { 0x000f84, 2, 0x04, 0x00000000 },
394 { 0x0017c8, 2, 0x04, 0x00000000 },
395 { 0x0017d0, 1, 0x04, 0x000000ff },
396 { 0x0017d4, 1, 0x04, 0xffffffff },
397 { 0x0017d8, 1, 0x04, 0x00000002 },
398 { 0x0017dc, 1, 0x04, 0x00000000 },
399 { 0x0015f4, 2, 0x04, 0x00000000 },
400 { 0x001434, 2, 0x04, 0x00000000 },
401 { 0x000d74, 1, 0x04, 0x00000000 },
402 { 0x000dec, 1, 0x04, 0x00000001 },
403 { 0x0013a4, 1, 0x04, 0x00000000 },
404 { 0x001318, 1, 0x04, 0x00000001 },
405 { 0x001644, 1, 0x04, 0x00000000 },
406 { 0x000748, 1, 0x04, 0x00000000 },
407 { 0x000de8, 1, 0x04, 0x00000000 },
408 { 0x001648, 1, 0x04, 0x00000000 },
409 { 0x0012a4, 1, 0x04, 0x00000000 },
410 { 0x001120, 4, 0x04, 0x00000000 },
411 { 0x001118, 1, 0x04, 0x00000000 },
412 { 0x00164c, 1, 0x04, 0x00000000 },
413 { 0x001658, 1, 0x04, 0x00000000 },
414 { 0x001910, 1, 0x04, 0x00000290 },
415 { 0x001518, 1, 0x04, 0x00000000 },
416 { 0x00165c, 1, 0x04, 0x00000001 },
417 { 0x001520, 1, 0x04, 0x00000000 },
418 { 0x001604, 1, 0x04, 0x00000000 },
419 { 0x001570, 1, 0x04, 0x00000000 },
420 { 0x0013b0, 2, 0x04, 0x3f800000 },
421 { 0x00020c, 1, 0x04, 0x00000000 },
422 { 0x001670, 1, 0x04, 0x30201000 },
423 { 0x001674, 1, 0x04, 0x70605040 },
424 { 0x001678, 1, 0x04, 0xb8a89888 },
425 { 0x00167c, 1, 0x04, 0xf8e8d8c8 },
426 { 0x00166c, 1, 0x04, 0x00000000 },
427 { 0x001680, 1, 0x04, 0x00ffff00 },
428 { 0x0012d0, 1, 0x04, 0x00000003 },
429 { 0x0012d4, 1, 0x04, 0x00000002 },
430 { 0x001684, 2, 0x04, 0x00000000 },
431 { 0x000dac, 2, 0x04, 0x00001b02 },
432 { 0x000db4, 1, 0x04, 0x00000000 },
433 { 0x00168c, 1, 0x04, 0x00000000 },
434 { 0x0015bc, 1, 0x04, 0x00000000 },
435 { 0x00156c, 1, 0x04, 0x00000000 },
436 { 0x00187c, 1, 0x04, 0x00000000 },
437 { 0x001110, 1, 0x04, 0x00000001 },
438 { 0x000dc0, 3, 0x04, 0x00000000 },
439 { 0x001234, 1, 0x04, 0x00000000 },
440 { 0x001690, 1, 0x04, 0x00000000 },
441 { 0x0012ac, 1, 0x04, 0x00000001 },
442 { 0x0002c4, 1, 0x04, 0x00000000 },
443 { 0x000790, 5, 0x04, 0x00000000 },
444 { 0x00077c, 1, 0x04, 0x00000000 },
445 { 0x001000, 1, 0x04, 0x00000010 },
446 { 0x0010fc, 1, 0x04, 0x00000000 },
447 { 0x001290, 1, 0x04, 0x00000000 },
448 { 0x000218, 1, 0x04, 0x00000010 },
449 { 0x0012d8, 1, 0x04, 0x00000000 },
450 { 0x0012dc, 1, 0x04, 0x00000010 },
451 { 0x000d94, 1, 0x04, 0x00000001 },
452 { 0x00155c, 2, 0x04, 0x00000000 },
453 { 0x001564, 1, 0x04, 0x00001fff },
454 { 0x001574, 2, 0x04, 0x00000000 },
455 { 0x00157c, 1, 0x04, 0x003fffff },
456 { 0x001354, 1, 0x04, 0x00000000 },
457 { 0x001664, 1, 0x04, 0x00000000 },
458 { 0x001610, 1, 0x04, 0x00000012 },
459 { 0x001608, 2, 0x04, 0x00000000 },
460 { 0x00162c, 1, 0x04, 0x00000003 },
461 { 0x000210, 1, 0x04, 0x00000000 },
462 { 0x000320, 1, 0x04, 0x00000000 },
463 { 0x000324, 6, 0x04, 0x3f800000 },
464 { 0x000750, 1, 0x04, 0x00000000 },
465 { 0x000760, 1, 0x04, 0x39291909 },
466 { 0x000764, 1, 0x04, 0x79695949 },
467 { 0x000768, 1, 0x04, 0xb9a99989 },
468 { 0x00076c, 1, 0x04, 0xf9e9d9c9 },
469 { 0x000770, 1, 0x04, 0x30201000 },
470 { 0x000774, 1, 0x04, 0x70605040 },
471 { 0x000778, 1, 0x04, 0x00009080 },
472 { 0x000780, 1, 0x04, 0x39291909 },
473 { 0x000784, 1, 0x04, 0x79695949 },
474 { 0x000788, 1, 0x04, 0xb9a99989 },
475 { 0x00078c, 1, 0x04, 0xf9e9d9c9 },
476 { 0x0007d0, 1, 0x04, 0x30201000 },
477 { 0x0007d4, 1, 0x04, 0x70605040 },
478 { 0x0007d8, 1, 0x04, 0x00009080 },
479 { 0x00037c, 1, 0x04, 0x00000001 },
480 { 0x000740, 2, 0x04, 0x00000000 },
481 { 0x002600, 1, 0x04, 0x00000000 },
482 { 0x001918, 1, 0x04, 0x00000000 },
483 { 0x00191c, 1, 0x04, 0x00000900 },
484 { 0x001920, 1, 0x04, 0x00000405 },
485 { 0x001308, 1, 0x04, 0x00000001 },
486 { 0x001924, 1, 0x04, 0x00000000 },
487 { 0x0013ac, 1, 0x04, 0x00000000 },
488 { 0x00192c, 1, 0x04, 0x00000001 },
489 { 0x00193c, 1, 0x04, 0x00002c1c },
490 { 0x000d7c, 1, 0x04, 0x00000000 },
491 { 0x000f8c, 1, 0x04, 0x00000000 },
492 { 0x0002c0, 1, 0x04, 0x00000001 },
493 { 0x001510, 1, 0x04, 0x00000000 },
494 { 0x001940, 1, 0x04, 0x00000000 },
495 { 0x000ff4, 2, 0x04, 0x00000000 },
496 { 0x00194c, 2, 0x04, 0x00000000 },
497 { 0x001968, 1, 0x04, 0x00000000 },
498 { 0x001590, 1, 0x04, 0x0000003f },
499 { 0x0007e8, 4, 0x04, 0x00000000 },
500 { 0x00196c, 1, 0x04, 0x00000011 },
501 { 0x00197c, 1, 0x04, 0x00000000 },
502 { 0x000fcc, 2, 0x04, 0x00000000 },
503 { 0x0002d8, 1, 0x04, 0x00000040 },
504 { 0x001980, 1, 0x04, 0x00000080 },
505 { 0x001504, 1, 0x04, 0x00000080 },
506 { 0x001984, 1, 0x04, 0x00000000 },
507 { 0x000300, 1, 0x04, 0x00000001 },
508 { 0x0013a8, 1, 0x04, 0x00000000 },
509 { 0x0012ec, 1, 0x04, 0x00000000 },
510 { 0x001310, 1, 0x04, 0x00000000 },
511 { 0x001314, 1, 0x04, 0x00000001 },
512 { 0x001380, 1, 0x04, 0x00000000 },
513 { 0x001384, 4, 0x04, 0x00000001 },
514 { 0x001394, 1, 0x04, 0x00000000 },
515 { 0x00139c, 1, 0x04, 0x00000000 },
516 { 0x001398, 1, 0x04, 0x00000000 },
517 { 0x001594, 1, 0x04, 0x00000000 },
518 { 0x001598, 4, 0x04, 0x00000001 },
519 { 0x000f54, 3, 0x04, 0x00000000 },
520 { 0x0019bc, 1, 0x04, 0x00000000 },
521 { 0x000f9c, 2, 0x04, 0x00000000 },
522 { 0x0012cc, 1, 0x04, 0x00000000 },
523 { 0x0012e8, 1, 0x04, 0x00000000 },
524 { 0x00130c, 1, 0x04, 0x00000001 },
525 { 0x001360, 8, 0x04, 0x00000000 },
526 { 0x00133c, 2, 0x04, 0x00000001 },
527 { 0x001344, 1, 0x04, 0x00000002 },
528 { 0x001348, 2, 0x04, 0x00000001 },
529 { 0x001350, 1, 0x04, 0x00000002 },
530 { 0x001358, 1, 0x04, 0x00000001 },
531 { 0x0012e4, 1, 0x04, 0x00000000 },
532 { 0x00131c, 4, 0x04, 0x00000000 },
533 { 0x0019c0, 1, 0x04, 0x00000000 },
534 { 0x001140, 1, 0x04, 0x00000000 },
535 { 0x0019c4, 1, 0x04, 0x00000000 },
536 { 0x0019c8, 1, 0x04, 0x00001500 },
537 { 0x00135c, 1, 0x04, 0x00000000 },
538 { 0x000f90, 1, 0x04, 0x00000000 },
539 { 0x0019e0, 8, 0x04, 0x00000001 },
540 { 0x0019cc, 1, 0x04, 0x00000001 },
541 { 0x0015b8, 1, 0x04, 0x00000000 },
542 { 0x001a00, 1, 0x04, 0x00001111 },
543 { 0x001a04, 7, 0x04, 0x00000000 },
544 { 0x000d6c, 2, 0x04, 0xffff0000 },
545 { 0x0010f8, 1, 0x04, 0x00001010 },
546 { 0x000d80, 5, 0x04, 0x00000000 },
547 { 0x000da0, 1, 0x04, 0x00000000 },
548 { 0x001508, 1, 0x04, 0x80000000 },
549 { 0x00150c, 1, 0x04, 0x40000000 },
550 { 0x001668, 1, 0x04, 0x00000000 },
551 { 0x000318, 2, 0x04, 0x00000008 },
552 { 0x000d9c, 1, 0x04, 0x00000001 },
553 { 0x0007dc, 1, 0x04, 0x00000000 },
554 { 0x00074c, 1, 0x04, 0x00000055 },
555 { 0x001420, 1, 0x04, 0x00000003 },
556 { 0x0017bc, 2, 0x04, 0x00000000 },
557 { 0x0017c4, 1, 0x04, 0x00000001 },
558 { 0x001008, 1, 0x04, 0x00000008 },
559 { 0x00100c, 1, 0x04, 0x00000040 },
560 { 0x001010, 1, 0x04, 0x0000012c },
561 { 0x000d60, 1, 0x04, 0x00000040 },
562 { 0x00075c, 1, 0x04, 0x00000003 },
563 { 0x001018, 1, 0x04, 0x00000020 },
564 { 0x00101c, 1, 0x04, 0x00000001 },
565 { 0x001020, 1, 0x04, 0x00000020 },
566 { 0x001024, 1, 0x04, 0x00000001 },
567 { 0x001444, 3, 0x04, 0x00000000 },
568 { 0x000360, 1, 0x04, 0x20164010 },
569 { 0x000364, 1, 0x04, 0x00000020 },
570 { 0x000368, 1, 0x04, 0x00000000 },
571 { 0x000de4, 1, 0x04, 0x00000000 },
572 { 0x000204, 1, 0x04, 0x00000006 },
573 { 0x000208, 1, 0x04, 0x00000000 },
574 { 0x0002cc, 1, 0x04, 0x003fffff },
575 { 0x0002d0, 1, 0x04, 0x00000c48 },
576 { 0x001220, 1, 0x04, 0x00000005 },
577 { 0x000fdc, 1, 0x04, 0x00000000 },
578 { 0x000f98, 1, 0x04, 0x00300008 },
579 { 0x001284, 1, 0x04, 0x04000080 },
580 { 0x001450, 1, 0x04, 0x00300008 },
581 { 0x001454, 1, 0x04, 0x04000080 },
582 { 0x000214, 1, 0x04, 0x00000000 },
583 {}
584 };
585
586 const struct gf100_gr_init
587 gf100_grctx_init_902d_0[] = {
588 { 0x000200, 1, 0x04, 0x000000cf },
589 { 0x000204, 1, 0x04, 0x00000001 },
590 { 0x000208, 1, 0x04, 0x00000020 },
591 { 0x00020c, 1, 0x04, 0x00000001 },
592 { 0x000210, 1, 0x04, 0x00000000 },
593 { 0x000214, 1, 0x04, 0x00000080 },
594 { 0x000218, 2, 0x04, 0x00000100 },
595 { 0x000220, 2, 0x04, 0x00000000 },
596 { 0x000230, 1, 0x04, 0x000000cf },
597 { 0x000234, 1, 0x04, 0x00000001 },
598 { 0x000238, 1, 0x04, 0x00000020 },
599 { 0x00023c, 1, 0x04, 0x00000001 },
600 { 0x000244, 1, 0x04, 0x00000080 },
601 { 0x000248, 2, 0x04, 0x00000100 },
602 {}
603 };
604
605 const struct gf100_gr_init
606 gf100_grctx_init_9039_0[] = {
607 { 0x00030c, 3, 0x04, 0x00000000 },
608 { 0x000320, 1, 0x04, 0x00000000 },
609 { 0x000238, 2, 0x04, 0x00000000 },
610 { 0x000318, 2, 0x04, 0x00000000 },
611 {}
612 };
613
614 const struct gf100_gr_init
615 gf100_grctx_init_90c0_0[] = {
616 { 0x00270c, 8, 0x20, 0x00000000 },
617 { 0x00030c, 1, 0x04, 0x00000001 },
618 { 0x001944, 1, 0x04, 0x00000000 },
619 { 0x000758, 1, 0x04, 0x00000100 },
620 { 0x0002c4, 1, 0x04, 0x00000000 },
621 { 0x000790, 5, 0x04, 0x00000000 },
622 { 0x00077c, 1, 0x04, 0x00000000 },
623 { 0x000204, 3, 0x04, 0x00000000 },
624 { 0x000214, 1, 0x04, 0x00000000 },
625 { 0x00024c, 1, 0x04, 0x00000000 },
626 { 0x000d94, 1, 0x04, 0x00000001 },
627 { 0x001608, 2, 0x04, 0x00000000 },
628 { 0x001664, 1, 0x04, 0x00000000 },
629 {}
630 };
631
632 const struct gf100_gr_pack
633 gf100_grctx_pack_mthd[] = {
634 { gf100_grctx_init_9097_0, 0x9097 },
635 { gf100_grctx_init_902d_0, 0x902d },
636 { gf100_grctx_init_9039_0, 0x9039 },
637 { gf100_grctx_init_90c0_0, 0x90c0 },
638 {}
639 };
640
641 const struct gf100_gr_init
642 gf100_grctx_init_main_0[] = {
643 { 0x400204, 2, 0x04, 0x00000000 },
644 {}
645 };
646
647 const struct gf100_gr_init
648 gf100_grctx_init_fe_0[] = {
649 { 0x404004, 11, 0x04, 0x00000000 },
650 { 0x404044, 1, 0x04, 0x00000000 },
651 { 0x404094, 13, 0x04, 0x00000000 },
652 { 0x4040c8, 1, 0x04, 0xf0000087 },
653 { 0x4040d0, 6, 0x04, 0x00000000 },
654 { 0x4040e8, 1, 0x04, 0x00001000 },
655 { 0x4040f8, 1, 0x04, 0x00000000 },
656 { 0x404130, 2, 0x04, 0x00000000 },
657 { 0x404138, 1, 0x04, 0x20000040 },
658 { 0x404150, 1, 0x04, 0x0000002e },
659 { 0x404154, 1, 0x04, 0x00000400 },
660 { 0x404158, 1, 0x04, 0x00000200 },
661 { 0x404164, 1, 0x04, 0x00000055 },
662 { 0x404168, 1, 0x04, 0x00000000 },
663 { 0x404174, 3, 0x04, 0x00000000 },
664 { 0x404200, 8, 0x04, 0x00000000 },
665 {}
666 };
667
668 const struct gf100_gr_init
669 gf100_grctx_init_pri_0[] = {
670 { 0x404404, 14, 0x04, 0x00000000 },
671 { 0x404460, 2, 0x04, 0x00000000 },
672 { 0x404468, 1, 0x04, 0x00ffffff },
673 { 0x40446c, 1, 0x04, 0x00000000 },
674 { 0x404480, 1, 0x04, 0x00000001 },
675 { 0x404498, 1, 0x04, 0x00000001 },
676 {}
677 };
678
679 const struct gf100_gr_init
680 gf100_grctx_init_memfmt_0[] = {
681 { 0x404604, 1, 0x04, 0x00000015 },
682 { 0x404608, 1, 0x04, 0x00000000 },
683 { 0x40460c, 1, 0x04, 0x00002e00 },
684 { 0x404610, 1, 0x04, 0x00000100 },
685 { 0x404618, 8, 0x04, 0x00000000 },
686 { 0x404638, 1, 0x04, 0x00000004 },
687 { 0x40463c, 8, 0x04, 0x00000000 },
688 { 0x40465c, 1, 0x04, 0x007f0100 },
689 { 0x404660, 7, 0x04, 0x00000000 },
690 { 0x40467c, 1, 0x04, 0x00000002 },
691 { 0x404680, 8, 0x04, 0x00000000 },
692 { 0x4046a0, 1, 0x04, 0x007f0080 },
693 { 0x4046a4, 18, 0x04, 0x00000000 },
694 { 0x4046f0, 2, 0x04, 0x00000000 },
695 { 0x404700, 13, 0x04, 0x00000000 },
696 { 0x404734, 1, 0x04, 0x00000100 },
697 { 0x404738, 8, 0x04, 0x00000000 },
698 {}
699 };
700
701 static const struct gf100_gr_init
702 gf100_grctx_init_ds_0[] = {
703 { 0x405800, 1, 0x04, 0x078000bf },
704 { 0x405830, 1, 0x04, 0x02180000 },
705 { 0x405834, 2, 0x04, 0x00000000 },
706 { 0x405854, 1, 0x04, 0x00000000 },
707 { 0x405870, 4, 0x04, 0x00000001 },
708 { 0x405a00, 2, 0x04, 0x00000000 },
709 { 0x405a18, 1, 0x04, 0x00000000 },
710 {}
711 };
712
713 static const struct gf100_gr_init
714 gf100_grctx_init_pd_0[] = {
715 { 0x406020, 1, 0x04, 0x000103c1 },
716 { 0x406028, 4, 0x04, 0x00000001 },
717 { 0x4064a8, 1, 0x04, 0x00000000 },
718 { 0x4064ac, 1, 0x04, 0x00003fff },
719 { 0x4064b4, 2, 0x04, 0x00000000 },
720 {}
721 };
722
723 const struct gf100_gr_init
724 gf100_grctx_init_rstr2d_0[] = {
725 { 0x407804, 1, 0x04, 0x00000023 },
726 { 0x40780c, 1, 0x04, 0x0a418820 },
727 { 0x407810, 1, 0x04, 0x062080e6 },
728 { 0x407814, 1, 0x04, 0x020398a4 },
729 { 0x407818, 1, 0x04, 0x0e629062 },
730 { 0x40781c, 1, 0x04, 0x0a418820 },
731 { 0x407820, 1, 0x04, 0x000000e6 },
732 { 0x4078bc, 1, 0x04, 0x00000103 },
733 {}
734 };
735
736 const struct gf100_gr_init
737 gf100_grctx_init_scc_0[] = {
738 { 0x408000, 2, 0x04, 0x00000000 },
739 { 0x408008, 1, 0x04, 0x00000018 },
740 { 0x40800c, 2, 0x04, 0x00000000 },
741 { 0x408014, 1, 0x04, 0x00000069 },
742 { 0x408018, 1, 0x04, 0xe100e100 },
743 { 0x408064, 1, 0x04, 0x00000000 },
744 {}
745 };
746
747 static const struct gf100_gr_init
748 gf100_grctx_init_be_0[] = {
749 { 0x408800, 1, 0x04, 0x02802a3c },
750 { 0x408804, 1, 0x04, 0x00000040 },
751 { 0x408808, 1, 0x04, 0x0003e00d },
752 { 0x408900, 1, 0x04, 0x3080b801 },
753 { 0x408904, 1, 0x04, 0x02000001 },
754 { 0x408908, 1, 0x04, 0x00c80929 },
755 { 0x408980, 1, 0x04, 0x0000011d },
756 {}
757 };
758
759 const struct gf100_gr_pack
760 gf100_grctx_pack_hub[] = {
761 { gf100_grctx_init_main_0 },
762 { gf100_grctx_init_fe_0 },
763 { gf100_grctx_init_pri_0 },
764 { gf100_grctx_init_memfmt_0 },
765 { gf100_grctx_init_ds_0 },
766 { gf100_grctx_init_pd_0 },
767 { gf100_grctx_init_rstr2d_0 },
768 { gf100_grctx_init_scc_0 },
769 { gf100_grctx_init_be_0 },
770 {}
771 };
772
773 const struct gf100_gr_init
774 gf100_grctx_init_gpc_unk_0[] = {
775 { 0x418380, 1, 0x04, 0x00000016 },
776 {}
777 };
778
779 const struct gf100_gr_init
780 gf100_grctx_init_prop_0[] = {
781 { 0x418400, 1, 0x04, 0x38004e00 },
782 { 0x418404, 1, 0x04, 0x71e0ffff },
783 { 0x418408, 1, 0x04, 0x00000000 },
784 { 0x41840c, 1, 0x04, 0x00001008 },
785 { 0x418410, 1, 0x04, 0x0fff0fff },
786 { 0x418414, 1, 0x04, 0x00200fff },
787 { 0x418450, 6, 0x04, 0x00000000 },
788 { 0x418468, 1, 0x04, 0x00000001 },
789 { 0x41846c, 2, 0x04, 0x00000000 },
790 {}
791 };
792
793 const struct gf100_gr_init
794 gf100_grctx_init_gpc_unk_1[] = {
795 { 0x418600, 1, 0x04, 0x0000001f },
796 { 0x418684, 1, 0x04, 0x0000000f },
797 { 0x418700, 1, 0x04, 0x00000002 },
798 { 0x418704, 1, 0x04, 0x00000080 },
799 { 0x418708, 1, 0x04, 0x00000000 },
800 { 0x41870c, 1, 0x04, 0x07c80000 },
801 { 0x418710, 1, 0x04, 0x00000000 },
802 {}
803 };
804
805 static const struct gf100_gr_init
806 gf100_grctx_init_setup_0[] = {
807 { 0x418800, 1, 0x04, 0x0006860a },
808 { 0x418808, 3, 0x04, 0x00000000 },
809 { 0x418828, 1, 0x04, 0x00008442 },
810 { 0x418830, 1, 0x04, 0x00000001 },
811 { 0x4188d8, 1, 0x04, 0x00000008 },
812 { 0x4188e0, 1, 0x04, 0x01000000 },
813 { 0x4188e8, 5, 0x04, 0x00000000 },
814 { 0x4188fc, 1, 0x04, 0x00100000 },
815 {}
816 };
817
818 const struct gf100_gr_init
819 gf100_grctx_init_zcull_0[] = {
820 { 0x41891c, 1, 0x04, 0x00ff00ff },
821 { 0x418924, 1, 0x04, 0x00000000 },
822 { 0x418928, 1, 0x04, 0x00ffff00 },
823 { 0x41892c, 1, 0x04, 0x0000ff00 },
824 {}
825 };
826
827 const struct gf100_gr_init
828 gf100_grctx_init_crstr_0[] = {
829 { 0x418b00, 1, 0x04, 0x00000000 },
830 { 0x418b08, 1, 0x04, 0x0a418820 },
831 { 0x418b0c, 1, 0x04, 0x062080e6 },
832 { 0x418b10, 1, 0x04, 0x020398a4 },
833 { 0x418b14, 1, 0x04, 0x0e629062 },
834 { 0x418b18, 1, 0x04, 0x0a418820 },
835 { 0x418b1c, 1, 0x04, 0x000000e6 },
836 { 0x418bb8, 1, 0x04, 0x00000103 },
837 {}
838 };
839
840 const struct gf100_gr_init
841 gf100_grctx_init_gpm_0[] = {
842 { 0x418c08, 1, 0x04, 0x00000001 },
843 { 0x418c10, 8, 0x04, 0x00000000 },
844 { 0x418c80, 1, 0x04, 0x20200004 },
845 { 0x418c8c, 1, 0x04, 0x00000001 },
846 {}
847 };
848
849 const struct gf100_gr_init
850 gf100_grctx_init_gcc_0[] = {
851 { 0x419000, 1, 0x04, 0x00000780 },
852 { 0x419004, 2, 0x04, 0x00000000 },
853 { 0x419014, 1, 0x04, 0x00000004 },
854 {}
855 };
856
857 const struct gf100_gr_pack
858 gf100_grctx_pack_gpc_0[] = {
859 { gf100_grctx_init_gpc_unk_0 },
860 { gf100_grctx_init_prop_0 },
861 { gf100_grctx_init_gpc_unk_1 },
862 { gf100_grctx_init_setup_0 },
863 { gf100_grctx_init_zcull_0 },
864 {}
865 };
866
867 const struct gf100_gr_pack
868 gf100_grctx_pack_gpc_1[] = {
869 { gf100_grctx_init_crstr_0 },
870 { gf100_grctx_init_gpm_0 },
871 { gf100_grctx_init_gcc_0 },
872 {}
873 };
874
875 static const struct gf100_gr_init
876 gf100_grctx_init_zcullr_0[] = {
877 { 0x418a00, 3, 0x04, 0x00000000 },
878 { 0x418a0c, 1, 0x04, 0x00010000 },
879 { 0x418a10, 3, 0x04, 0x00000000 },
880 { 0x418a20, 3, 0x04, 0x00000000 },
881 { 0x418a2c, 1, 0x04, 0x00010000 },
882 { 0x418a30, 3, 0x04, 0x00000000 },
883 { 0x418a40, 3, 0x04, 0x00000000 },
884 { 0x418a4c, 1, 0x04, 0x00010000 },
885 { 0x418a50, 3, 0x04, 0x00000000 },
886 { 0x418a60, 3, 0x04, 0x00000000 },
887 { 0x418a6c, 1, 0x04, 0x00010000 },
888 { 0x418a70, 3, 0x04, 0x00000000 },
889 { 0x418a80, 3, 0x04, 0x00000000 },
890 { 0x418a8c, 1, 0x04, 0x00010000 },
891 { 0x418a90, 3, 0x04, 0x00000000 },
892 { 0x418aa0, 3, 0x04, 0x00000000 },
893 { 0x418aac, 1, 0x04, 0x00010000 },
894 { 0x418ab0, 3, 0x04, 0x00000000 },
895 { 0x418ac0, 3, 0x04, 0x00000000 },
896 { 0x418acc, 1, 0x04, 0x00010000 },
897 { 0x418ad0, 3, 0x04, 0x00000000 },
898 { 0x418ae0, 3, 0x04, 0x00000000 },
899 { 0x418aec, 1, 0x04, 0x00010000 },
900 { 0x418af0, 3, 0x04, 0x00000000 },
901 {}
902 };
903
904 const struct gf100_gr_pack
905 gf100_grctx_pack_zcull[] = {
906 { gf100_grctx_init_zcullr_0 },
907 {}
908 };
909
910 const struct gf100_gr_init
911 gf100_grctx_init_pe_0[] = {
912 { 0x419818, 1, 0x04, 0x00000000 },
913 { 0x41983c, 1, 0x04, 0x00038bc7 },
914 { 0x419848, 1, 0x04, 0x00000000 },
915 { 0x419864, 1, 0x04, 0x0000012a },
916 { 0x419888, 1, 0x04, 0x00000000 },
917 {}
918 };
919
920 static const struct gf100_gr_init
921 gf100_grctx_init_tex_0[] = {
922 { 0x419a00, 1, 0x04, 0x000001f0 },
923 { 0x419a04, 1, 0x04, 0x00000001 },
924 { 0x419a08, 1, 0x04, 0x00000023 },
925 { 0x419a0c, 1, 0x04, 0x00020000 },
926 { 0x419a10, 1, 0x04, 0x00000000 },
927 { 0x419a14, 1, 0x04, 0x00000200 },
928 {}
929 };
930
931 const struct gf100_gr_init
932 gf100_grctx_init_wwdx_0[] = {
933 { 0x419b00, 1, 0x04, 0x0a418820 },
934 { 0x419b04, 1, 0x04, 0x062080e6 },
935 { 0x419b08, 1, 0x04, 0x020398a4 },
936 { 0x419b0c, 1, 0x04, 0x0e629062 },
937 { 0x419b10, 1, 0x04, 0x0a418820 },
938 { 0x419b14, 1, 0x04, 0x000000e6 },
939 { 0x419bd0, 1, 0x04, 0x00900103 },
940 { 0x419be0, 1, 0x04, 0x00000001 },
941 { 0x419be4, 1, 0x04, 0x00000000 },
942 {}
943 };
944
945 const struct gf100_gr_init
946 gf100_grctx_init_mpc_0[] = {
947 { 0x419c00, 1, 0x04, 0x00000002 },
948 { 0x419c04, 1, 0x04, 0x00000006 },
949 { 0x419c08, 1, 0x04, 0x00000002 },
950 { 0x419c20, 1, 0x04, 0x00000000 },
951 {}
952 };
953
954 static const struct gf100_gr_init
955 gf100_grctx_init_l1c_0[] = {
956 { 0x419cb0, 1, 0x04, 0x00060048 },
957 { 0x419ce8, 1, 0x04, 0x00000000 },
958 { 0x419cf4, 1, 0x04, 0x00000183 },
959 {}
960 };
961
962 const struct gf100_gr_init
963 gf100_grctx_init_tpccs_0[] = {
964 { 0x419d20, 1, 0x04, 0x02180000 },
965 { 0x419d24, 1, 0x04, 0x00001fff },
966 {}
967 };
968
969 static const struct gf100_gr_init
970 gf100_grctx_init_sm_0[] = {
971 { 0x419e04, 3, 0x04, 0x00000000 },
972 { 0x419e10, 1, 0x04, 0x00000002 },
973 { 0x419e44, 1, 0x04, 0x001beff2 },
974 { 0x419e48, 1, 0x04, 0x00000000 },
975 { 0x419e4c, 1, 0x04, 0x0000000f },
976 { 0x419e50, 17, 0x04, 0x00000000 },
977 { 0x419e98, 1, 0x04, 0x00000000 },
978 { 0x419f50, 2, 0x04, 0x00000000 },
979 {}
980 };
981
982 const struct gf100_gr_pack
983 gf100_grctx_pack_tpc[] = {
984 { gf100_grctx_init_pe_0 },
985 { gf100_grctx_init_tex_0 },
986 { gf100_grctx_init_wwdx_0 },
987 { gf100_grctx_init_mpc_0 },
988 { gf100_grctx_init_l1c_0 },
989 { gf100_grctx_init_tpccs_0 },
990 { gf100_grctx_init_sm_0 },
991 {}
992 };
993
994 /*******************************************************************************
995 * PGRAPH context implementation
996 ******************************************************************************/
997
998 int
gf100_grctx_mmio_data(struct gf100_grctx * info,u32 size,u32 align,bool priv)999 gf100_grctx_mmio_data(struct gf100_grctx *info, u32 size, u32 align, bool priv)
1000 {
1001 if (info->data) {
1002 info->buffer[info->buffer_nr] = round_up(info->addr, align);
1003 info->addr = info->buffer[info->buffer_nr] + size;
1004 info->data->size = size;
1005 info->data->align = align;
1006 info->data->priv = priv;
1007 info->data++;
1008 return info->buffer_nr++;
1009 }
1010 return -1;
1011 }
1012
1013 void
gf100_grctx_mmio_item(struct gf100_grctx * info,u32 addr,u32 data,int shift,int buffer)1014 gf100_grctx_mmio_item(struct gf100_grctx *info, u32 addr, u32 data,
1015 int shift, int buffer)
1016 {
1017 struct nvkm_device *device = info->gr->base.engine.subdev.device;
1018 if (info->data) {
1019 if (shift >= 0) {
1020 info->mmio->addr = addr;
1021 info->mmio->data = data;
1022 info->mmio->shift = shift;
1023 info->mmio->buffer = buffer;
1024 if (buffer >= 0)
1025 data |= info->buffer[buffer] >> shift;
1026 info->mmio++;
1027 } else
1028 return;
1029 } else {
1030 if (buffer >= 0)
1031 return;
1032 }
1033
1034 nvkm_wr32(device, addr, data);
1035 }
1036
1037 void
gf100_grctx_generate_r419cb8(struct gf100_gr * gr)1038 gf100_grctx_generate_r419cb8(struct gf100_gr *gr)
1039 {
1040 struct nvkm_device *device = gr->base.engine.subdev.device;
1041 nvkm_mask(device, 0x419cb8, 0x00007c00, 0x00000000);
1042 }
1043
1044 void
gf100_grctx_generate_bundle(struct gf100_grctx * info)1045 gf100_grctx_generate_bundle(struct gf100_grctx *info)
1046 {
1047 const struct gf100_grctx_func *grctx = info->gr->func->grctx;
1048 const int s = 8;
1049 const int b = mmio_vram(info, grctx->bundle_size, (1 << s), true);
1050 mmio_refn(info, 0x408004, 0x00000000, s, b);
1051 mmio_wr32(info, 0x408008, 0x80000000 | (grctx->bundle_size >> s));
1052 mmio_refn(info, 0x418808, 0x00000000, s, b);
1053 mmio_wr32(info, 0x41880c, 0x80000000 | (grctx->bundle_size >> s));
1054 }
1055
1056 void
gf100_grctx_generate_pagepool(struct gf100_grctx * info)1057 gf100_grctx_generate_pagepool(struct gf100_grctx *info)
1058 {
1059 const struct gf100_grctx_func *grctx = info->gr->func->grctx;
1060 const int s = 8;
1061 const int b = mmio_vram(info, grctx->pagepool_size, (1 << s), true);
1062 mmio_refn(info, 0x40800c, 0x00000000, s, b);
1063 mmio_wr32(info, 0x408010, 0x80000000);
1064 mmio_refn(info, 0x419004, 0x00000000, s, b);
1065 mmio_wr32(info, 0x419008, 0x00000000);
1066 }
1067
1068 void
gf100_grctx_generate_attrib(struct gf100_grctx * info)1069 gf100_grctx_generate_attrib(struct gf100_grctx *info)
1070 {
1071 struct gf100_gr *gr = info->gr;
1072 const struct gf100_grctx_func *grctx = gr->func->grctx;
1073 const u32 attrib = grctx->attrib_nr;
1074 const u32 size = 0x20 * (grctx->attrib_nr_max + grctx->alpha_nr_max);
1075 const int s = 12;
1076 const int b = mmio_vram(info, size * gr->tpc_total, (1 << s), false);
1077 int gpc, tpc;
1078 u32 bo = 0;
1079
1080 mmio_refn(info, 0x418810, 0x80000000, s, b);
1081 mmio_refn(info, 0x419848, 0x10000000, s, b);
1082 mmio_wr32(info, 0x405830, (attrib << 16));
1083
1084 for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
1085 for (tpc = 0; tpc < gr->tpc_nr[gpc]; tpc++) {
1086 const u32 o = TPC_UNIT(gpc, tpc, 0x0520);
1087 mmio_skip(info, o, (attrib << 16) | ++bo);
1088 mmio_wr32(info, o, (attrib << 16) | --bo);
1089 bo += grctx->attrib_nr_max;
1090 }
1091 }
1092 }
1093
1094 void
gf100_grctx_generate_unkn(struct gf100_gr * gr)1095 gf100_grctx_generate_unkn(struct gf100_gr *gr)
1096 {
1097 }
1098
1099 void
gf100_grctx_generate_r4060a8(struct gf100_gr * gr)1100 gf100_grctx_generate_r4060a8(struct gf100_gr *gr)
1101 {
1102 struct nvkm_device *device = gr->base.engine.subdev.device;
1103 const u8 gpcmax = nvkm_rd32(device, 0x022430);
1104 const u8 tpcmax = nvkm_rd32(device, 0x022434) * gpcmax;
1105 int i, j, sm = 0;
1106 u32 data;
1107
1108 for (i = 0; i < DIV_ROUND_UP(tpcmax, 4); i++) {
1109 for (data = 0, j = 0; j < 4; j++) {
1110 if (sm < gr->sm_nr)
1111 data |= gr->sm[sm++].gpc << (j * 8);
1112 else
1113 data |= 0x1f << (j * 8);
1114 }
1115 nvkm_wr32(device, 0x4060a8 + (i * 4), data);
1116 }
1117 }
1118
1119 void
gf100_grctx_generate_rop_mapping(struct gf100_gr * gr)1120 gf100_grctx_generate_rop_mapping(struct gf100_gr *gr)
1121 {
1122 struct nvkm_device *device = gr->base.engine.subdev.device;
1123 u32 data[6] = {}, data2[2] = {};
1124 u8 shift, ntpcv;
1125 int i;
1126
1127 /* Pack tile map into register format. */
1128 for (i = 0; i < 32; i++)
1129 data[i / 6] |= (gr->tile[i] & 0x07) << ((i % 6) * 5);
1130
1131 /* Magic. */
1132 shift = 0;
1133 ntpcv = gr->tpc_total;
1134 while (!(ntpcv & (1 << 4))) {
1135 ntpcv <<= 1;
1136 shift++;
1137 }
1138
1139 data2[0] = (ntpcv << 16);
1140 data2[0] |= (shift << 21);
1141 data2[0] |= (((1 << (0 + 5)) % ntpcv) << 24);
1142 for (i = 1; i < 7; i++)
1143 data2[1] |= ((1 << (i + 5)) % ntpcv) << ((i - 1) * 5);
1144
1145 /* GPC_BROADCAST */
1146 nvkm_wr32(device, 0x418bb8, (gr->tpc_total << 8) |
1147 gr->screen_tile_row_offset);
1148 for (i = 0; i < 6; i++)
1149 nvkm_wr32(device, 0x418b08 + (i * 4), data[i]);
1150
1151 /* GPC_BROADCAST.TP_BROADCAST */
1152 nvkm_wr32(device, 0x419bd0, (gr->tpc_total << 8) |
1153 gr->screen_tile_row_offset | data2[0]);
1154 nvkm_wr32(device, 0x419be4, data2[1]);
1155 for (i = 0; i < 6; i++)
1156 nvkm_wr32(device, 0x419b00 + (i * 4), data[i]);
1157
1158 /* UNK78xx */
1159 nvkm_wr32(device, 0x4078bc, (gr->tpc_total << 8) |
1160 gr->screen_tile_row_offset);
1161 for (i = 0; i < 6; i++)
1162 nvkm_wr32(device, 0x40780c + (i * 4), data[i]);
1163 }
1164
1165 void
gf100_grctx_generate_max_ways_evict(struct gf100_gr * gr)1166 gf100_grctx_generate_max_ways_evict(struct gf100_gr *gr)
1167 {
1168 struct nvkm_device *device = gr->base.engine.subdev.device;
1169 u32 fbps = nvkm_rd32(device, 0x121c74);
1170 if (fbps == 1)
1171 nvkm_mask(device, 0x17e91c, 0x001f0000, 0x00090000);
1172 }
1173
1174 static const u32
1175 gf100_grctx_alpha_beta_map[17][32] = {
1176 [1] = {
1177 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1178 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1179 },
1180 [2] = {
1181 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1182 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1183 },
1184 //XXX: 3
1185 [4] = {
1186 1, 1, 1, 1, 1, 1, 1, 1,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1188 3, 3, 3, 3, 3, 3, 3, 3,
1189 },
1190 //XXX: 5
1191 //XXX: 6
1192 [7] = {
1193 1, 1, 1, 1,
1194 2, 2, 2, 2, 2, 2,
1195 3, 3, 3, 3, 3, 3,
1196 4, 4, 4, 4, 4, 4,
1197 5, 5, 5, 5, 5, 5,
1198 6, 6, 6, 6,
1199 },
1200 [8] = {
1201 1, 1, 1,
1202 2, 2, 2, 2, 2,
1203 3, 3, 3, 3, 3,
1204 4, 4, 4, 4, 4, 4,
1205 5, 5, 5, 5, 5,
1206 6, 6, 6, 6, 6,
1207 7, 7, 7,
1208 },
1209 //XXX: 9
1210 //XXX: 10
1211 [11] = {
1212 1, 1,
1213 2, 2, 2, 2,
1214 3, 3, 3,
1215 4, 4, 4, 4,
1216 5, 5, 5,
1217 6, 6, 6,
1218 7, 7, 7, 7,
1219 8, 8, 8,
1220 9, 9, 9, 9,
1221 10, 10,
1222 },
1223 //XXX: 12
1224 //XXX: 13
1225 [14] = {
1226 1, 1,
1227 2, 2,
1228 3, 3, 3,
1229 4, 4, 4,
1230 5, 5,
1231 6, 6, 6,
1232 7, 7,
1233 8, 8, 8,
1234 9, 9,
1235 10, 10, 10,
1236 11, 11, 11,
1237 12, 12,
1238 13, 13,
1239 },
1240 [15] = {
1241 1, 1,
1242 2, 2,
1243 3, 3,
1244 4, 4, 4,
1245 5, 5,
1246 6, 6, 6,
1247 7, 7,
1248 8, 8,
1249 9, 9, 9,
1250 10, 10,
1251 11, 11, 11,
1252 12, 12,
1253 13, 13,
1254 14, 14,
1255 },
1256 [16] = {
1257 1, 1,
1258 2, 2,
1259 3, 3,
1260 4, 4,
1261 5, 5,
1262 6, 6, 6,
1263 7, 7,
1264 8, 8,
1265 9, 9,
1266 10, 10, 10,
1267 11, 11,
1268 12, 12,
1269 13, 13,
1270 14, 14,
1271 15, 15,
1272 },
1273 };
1274
1275 void
gf100_grctx_generate_alpha_beta_tables(struct gf100_gr * gr)1276 gf100_grctx_generate_alpha_beta_tables(struct gf100_gr *gr)
1277 {
1278 struct nvkm_subdev *subdev = &gr->base.engine.subdev;
1279 struct nvkm_device *device = subdev->device;
1280 int i, gpc;
1281
1282 for (i = 0; i < 32; i++) {
1283 u32 atarget = gf100_grctx_alpha_beta_map[gr->tpc_total][i];
1284 u32 abits[GPC_MAX] = {}, amask = 0, bmask = 0;
1285
1286 if (!atarget) {
1287 nvkm_warn(subdev, "missing alpha/beta mapping table\n");
1288 atarget = max_t(u32, gr->tpc_total * i / 32, 1);
1289 }
1290
1291 while (atarget) {
1292 for (gpc = 0; atarget && gpc < gr->gpc_nr; gpc++) {
1293 if (abits[gpc] < gr->tpc_nr[gpc]) {
1294 abits[gpc]++;
1295 atarget--;
1296 }
1297 }
1298 }
1299
1300 for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
1301 u32 bbits = gr->tpc_nr[gpc] - abits[gpc];
1302 amask |= ((1 << abits[gpc]) - 1) << (gpc * 8);
1303 bmask |= ((1 << bbits) - 1) << abits[gpc] << (gpc * 8);
1304 }
1305
1306 nvkm_wr32(device, 0x406800 + (i * 0x20), amask);
1307 nvkm_wr32(device, 0x406c00 + (i * 0x20), bmask);
1308 }
1309 }
1310
1311 void
gf100_grctx_generate_tpc_nr(struct gf100_gr * gr,int gpc)1312 gf100_grctx_generate_tpc_nr(struct gf100_gr *gr, int gpc)
1313 {
1314 struct nvkm_device *device = gr->base.engine.subdev.device;
1315 nvkm_wr32(device, GPC_UNIT(gpc, 0x0c08), gr->tpc_nr[gpc]);
1316 nvkm_wr32(device, GPC_UNIT(gpc, 0x0c8c), gr->tpc_nr[gpc]);
1317 }
1318
1319 void
gf100_grctx_generate_sm_id(struct gf100_gr * gr,int gpc,int tpc,int sm)1320 gf100_grctx_generate_sm_id(struct gf100_gr *gr, int gpc, int tpc, int sm)
1321 {
1322 struct nvkm_device *device = gr->base.engine.subdev.device;
1323 nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x698), sm);
1324 nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x4e8), sm);
1325 nvkm_wr32(device, GPC_UNIT(gpc, 0x0c10 + tpc * 4), sm);
1326 nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x088), sm);
1327 }
1328
1329 void
gf100_grctx_generate_floorsweep(struct gf100_gr * gr)1330 gf100_grctx_generate_floorsweep(struct gf100_gr *gr)
1331 {
1332 const struct gf100_grctx_func *func = gr->func->grctx;
1333 int sm;
1334
1335 for (sm = 0; sm < gr->sm_nr; sm++) {
1336 func->sm_id(gr, gr->sm[sm].gpc, gr->sm[sm].tpc, sm);
1337 if (func->tpc_nr)
1338 func->tpc_nr(gr, gr->sm[sm].gpc);
1339 }
1340
1341 gf100_gr_init_num_tpc_per_gpc(gr, false, true);
1342 if (!func->skip_pd_num_tpc_per_gpc)
1343 gf100_gr_init_num_tpc_per_gpc(gr, true, false);
1344
1345 if (func->r4060a8)
1346 func->r4060a8(gr);
1347
1348 func->rop_mapping(gr);
1349
1350 if (func->alpha_beta_tables)
1351 func->alpha_beta_tables(gr);
1352 if (func->max_ways_evict)
1353 func->max_ways_evict(gr);
1354 if (func->dist_skip_table)
1355 func->dist_skip_table(gr);
1356 if (func->r406500)
1357 func->r406500(gr);
1358 if (func->gpc_tpc_nr)
1359 func->gpc_tpc_nr(gr);
1360 if (func->r419f78)
1361 func->r419f78(gr);
1362 if (func->tpc_mask)
1363 func->tpc_mask(gr);
1364 if (func->smid_config)
1365 func->smid_config(gr);
1366 }
1367
1368 void
gf100_grctx_generate_main(struct gf100_gr * gr,struct gf100_grctx * info)1369 gf100_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
1370 {
1371 struct nvkm_device *device = gr->base.engine.subdev.device;
1372 const struct gf100_grctx_func *grctx = gr->func->grctx;
1373 u32 idle_timeout;
1374
1375 nvkm_mc_unk260(device, 0);
1376
1377 if (!gr->sw_ctx) {
1378 gf100_gr_mmio(gr, grctx->hub);
1379 gf100_gr_mmio(gr, grctx->gpc_0);
1380 gf100_gr_mmio(gr, grctx->zcull);
1381 gf100_gr_mmio(gr, grctx->gpc_1);
1382 gf100_gr_mmio(gr, grctx->tpc);
1383 gf100_gr_mmio(gr, grctx->ppc);
1384 } else {
1385 gf100_gr_mmio(gr, gr->sw_ctx);
1386 }
1387
1388 gf100_gr_wait_idle(gr);
1389
1390 idle_timeout = nvkm_mask(device, 0x404154, 0xffffffff, 0x00000000);
1391
1392 grctx->pagepool(info);
1393 grctx->bundle(info);
1394 grctx->attrib(info);
1395 if (grctx->patch_ltc)
1396 grctx->patch_ltc(info);
1397 grctx->unkn(gr);
1398
1399 gf100_grctx_generate_floorsweep(gr);
1400
1401 gf100_gr_wait_idle(gr);
1402
1403 if (grctx->r400088) grctx->r400088(gr, false);
1404 if (gr->bundle)
1405 gf100_gr_icmd(gr, gr->bundle);
1406 else
1407 gf100_gr_icmd(gr, grctx->icmd);
1408 if (grctx->sw_veid_bundle_init)
1409 gf100_gr_icmd(gr, grctx->sw_veid_bundle_init);
1410 if (grctx->r400088) grctx->r400088(gr, true);
1411
1412 nvkm_wr32(device, 0x404154, idle_timeout);
1413
1414 if (gr->method)
1415 gf100_gr_mthd(gr, gr->method);
1416 else
1417 gf100_gr_mthd(gr, grctx->mthd);
1418 nvkm_mc_unk260(device, 1);
1419
1420 if (grctx->r419cb8)
1421 grctx->r419cb8(gr);
1422 if (grctx->r418800)
1423 grctx->r418800(gr);
1424 if (grctx->r419eb0)
1425 grctx->r419eb0(gr);
1426 if (grctx->r419e00)
1427 grctx->r419e00(gr);
1428 if (grctx->r418e94)
1429 grctx->r418e94(gr);
1430 if (grctx->r419a3c)
1431 grctx->r419a3c(gr);
1432 if (grctx->r408840)
1433 grctx->r408840(gr);
1434 if (grctx->r419c0c)
1435 grctx->r419c0c(gr);
1436 }
1437
1438 #define CB_RESERVED 0x80000
1439
1440 int
gf100_grctx_generate(struct gf100_gr * gr)1441 gf100_grctx_generate(struct gf100_gr *gr)
1442 {
1443 const struct gf100_grctx_func *grctx = gr->func->grctx;
1444 struct nvkm_subdev *subdev = &gr->base.engine.subdev;
1445 struct nvkm_device *device = subdev->device;
1446 struct nvkm_memory *inst = NULL;
1447 struct nvkm_memory *data = NULL;
1448 struct nvkm_vmm *vmm = NULL;
1449 struct nvkm_vma *ctx = NULL;
1450 struct gf100_grctx info;
1451 int ret, i;
1452 u64 addr;
1453
1454 /* NV_PGRAPH_FE_PWR_MODE_FORCE_ON. */
1455 nvkm_wr32(device, 0x404170, 0x00000012);
1456 nvkm_msec(device, 2000,
1457 if (!(nvkm_rd32(device, 0x404170) & 0x00000010))
1458 break;
1459 );
1460
1461 if (grctx->unkn88c)
1462 grctx->unkn88c(gr, true);
1463
1464 /* Reset FECS. */
1465 nvkm_wr32(device, 0x409614, 0x00000070);
1466 nvkm_usec(device, 10, NVKM_DELAY);
1467 nvkm_mask(device, 0x409614, 0x00000700, 0x00000700);
1468 nvkm_usec(device, 10, NVKM_DELAY);
1469 nvkm_rd32(device, 0x409614);
1470
1471 if (grctx->unkn88c)
1472 grctx->unkn88c(gr, false);
1473
1474 /* NV_PGRAPH_FE_PWR_MODE_AUTO. */
1475 nvkm_wr32(device, 0x404170, 0x00000010);
1476
1477 /* Init SCC RAM. */
1478 nvkm_wr32(device, 0x40802c, 0x00000001);
1479
1480 /* Allocate memory to for a "channel", which we'll use to generate
1481 * the default context values.
1482 */
1483 ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
1484 0x1000, 0x1000, true, &inst);
1485 if (ret)
1486 goto done;
1487
1488 ret = nvkm_vmm_new(device, 0, 0, NULL, 0, NULL, "grctx", &vmm);
1489 if (ret)
1490 goto done;
1491
1492 vmm->debug = subdev->debug;
1493
1494 ret = nvkm_vmm_join(vmm, inst);
1495 if (ret)
1496 goto done;
1497
1498 ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
1499 CB_RESERVED + gr->size, 0, true, &data);
1500 if (ret)
1501 goto done;
1502
1503 ret = nvkm_vmm_get(vmm, 0, nvkm_memory_size(data), &ctx);
1504 if (ret)
1505 goto done;
1506
1507 ret = nvkm_memory_map(data, 0, vmm, ctx, NULL, 0);
1508 if (ret)
1509 goto done;
1510
1511
1512 /* Setup context pointer. */
1513 nvkm_kmap(inst);
1514 nvkm_wo32(inst, 0x0210, lower_32_bits(ctx->addr + CB_RESERVED) | 4);
1515 nvkm_wo32(inst, 0x0214, upper_32_bits(ctx->addr + CB_RESERVED));
1516 nvkm_done(inst);
1517
1518 /* Setup default state for mmio list construction. */
1519 info.gr = gr;
1520 info.data = gr->mmio_data;
1521 info.mmio = gr->mmio_list;
1522 info.addr = ctx->addr;
1523 info.buffer_nr = 0;
1524
1525 /* Make channel current. */
1526 addr = nvkm_memory_addr(inst) >> 12;
1527 if (gr->firmware) {
1528 ret = gf100_gr_fecs_bind_pointer(gr, 0x80000000 | addr);
1529 if (ret)
1530 goto done;
1531
1532 nvkm_kmap(data);
1533 nvkm_wo32(data, 0x1c, 1);
1534 nvkm_wo32(data, 0x20, 0);
1535 nvkm_wo32(data, 0x28, 0);
1536 nvkm_wo32(data, 0x2c, 0);
1537 nvkm_done(data);
1538 } else {
1539 nvkm_wr32(device, 0x409840, 0x80000000);
1540 nvkm_wr32(device, 0x409500, 0x80000000 | addr);
1541 nvkm_wr32(device, 0x409504, 0x00000001);
1542 nvkm_msec(device, 2000,
1543 if (nvkm_rd32(device, 0x409800) & 0x80000000)
1544 break;
1545 );
1546 }
1547
1548 grctx->main(gr, &info);
1549
1550 /* Trigger a context unload by unsetting the "next channel valid" bit
1551 * and faking a context switch interrupt.
1552 */
1553 nvkm_mask(device, 0x409b04, 0x80000000, 0x00000000);
1554 nvkm_wr32(device, 0x409000, 0x00000100);
1555 if (nvkm_msec(device, 2000,
1556 if (!(nvkm_rd32(device, 0x409b00) & 0x80000000))
1557 break;
1558 ) < 0) {
1559 ret = -EBUSY;
1560 goto done;
1561 }
1562
1563 gr->data = kmalloc(gr->size, GFP_KERNEL);
1564 if (gr->data) {
1565 nvkm_kmap(data);
1566 for (i = 0; i < gr->size; i += 4)
1567 gr->data[i / 4] = nvkm_ro32(data, CB_RESERVED + i);
1568 nvkm_done(data);
1569 ret = 0;
1570 } else {
1571 ret = -ENOMEM;
1572 }
1573
1574 done:
1575 nvkm_vmm_put(vmm, &ctx);
1576 nvkm_memory_unref(&data);
1577 nvkm_vmm_part(vmm, inst);
1578 nvkm_vmm_unref(&vmm);
1579 nvkm_memory_unref(&inst);
1580 return ret;
1581 }
1582
1583 const struct gf100_grctx_func
1584 gf100_grctx = {
1585 .main = gf100_grctx_generate_main,
1586 .unkn = gf100_grctx_generate_unkn,
1587 .hub = gf100_grctx_pack_hub,
1588 .gpc_0 = gf100_grctx_pack_gpc_0,
1589 .gpc_1 = gf100_grctx_pack_gpc_1,
1590 .zcull = gf100_grctx_pack_zcull,
1591 .tpc = gf100_grctx_pack_tpc,
1592 .icmd = gf100_grctx_pack_icmd,
1593 .mthd = gf100_grctx_pack_mthd,
1594 .bundle = gf100_grctx_generate_bundle,
1595 .bundle_size = 0x1800,
1596 .pagepool = gf100_grctx_generate_pagepool,
1597 .pagepool_size = 0x8000,
1598 .attrib = gf100_grctx_generate_attrib,
1599 .attrib_nr_max = 0x324,
1600 .attrib_nr = 0x218,
1601 .sm_id = gf100_grctx_generate_sm_id,
1602 .tpc_nr = gf100_grctx_generate_tpc_nr,
1603 .r4060a8 = gf100_grctx_generate_r4060a8,
1604 .rop_mapping = gf100_grctx_generate_rop_mapping,
1605 .alpha_beta_tables = gf100_grctx_generate_alpha_beta_tables,
1606 .max_ways_evict = gf100_grctx_generate_max_ways_evict,
1607 .r419cb8 = gf100_grctx_generate_r419cb8,
1608 };
1609