2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include "fuc/hubnve0.fuc.h"
27 #include "fuc/gpcnve0.fuc.h"
29 /*******************************************************************************
30 * Graphics object classes
31 ******************************************************************************/
33 static struct nouveau_oclass
34 nve0_graph_sclass
[] = {
35 { 0x902d, &nouveau_object_ofuncs
},
36 { 0xa040, &nouveau_object_ofuncs
},
37 { 0xa097, &nouveau_object_ofuncs
},
38 { 0xa0c0, &nouveau_object_ofuncs
},
42 /*******************************************************************************
44 ******************************************************************************/
46 static struct nouveau_oclass
48 .handle
= NV_ENGCTX(GR
, 0xe0),
49 .ofuncs
= &(struct nouveau_ofuncs
) {
50 .ctor
= nvc0_graph_context_ctor
,
51 .dtor
= nvc0_graph_context_dtor
,
52 .init
= _nouveau_graph_context_init
,
53 .fini
= _nouveau_graph_context_fini
,
54 .rd32
= _nouveau_graph_context_rd32
,
55 .wr32
= _nouveau_graph_context_wr32
,
59 /*******************************************************************************
60 * PGRAPH engine/subdev functions
61 ******************************************************************************/
64 nve0_graph_ctxctl_isr(struct nvc0_graph_priv
*priv
)
66 u32 ustat
= nv_rd32(priv
, 0x409c18);
68 if (ustat
& 0x00000001)
69 nv_error(priv
, "CTXCTRL ucode error\n");
70 if (ustat
& 0x00080000)
71 nv_error(priv
, "CTXCTRL watchdog timeout\n");
72 if (ustat
& ~0x00080001)
73 nv_error(priv
, "CTXCTRL 0x%08x\n", ustat
);
75 nvc0_graph_ctxctl_debug(priv
);
76 nv_wr32(priv
, 0x409c20, ustat
);
79 static const struct nouveau_enum nve0_mp_warp_error
[] = {
81 { 0x01, "STACK_MISMATCH" },
82 { 0x05, "MISALIGNED_PC" },
83 { 0x08, "MISALIGNED_GPR" },
84 { 0x09, "INVALID_OPCODE" },
85 { 0x0d, "GPR_OUT_OF_BOUNDS" },
86 { 0x0e, "MEM_OUT_OF_BOUNDS" },
87 { 0x0f, "UNALIGNED_MEM_ACCESS" },
88 { 0x11, "INVALID_PARAM" },
92 static const struct nouveau_enum nve0_mp_global_error
[] = {
93 { 2, "MULTIPLE_WARP_ERRORS" },
94 { 3, "OUT_OF_STACK_SPACE" },
98 static const struct nouveau_enum nve0_gpc_rop_error
[] = {
99 { 1, "RT_PITCH_OVERRUN" },
100 { 4, "RT_WIDTH_OVERRUN" },
101 { 5, "RT_HEIGHT_OVERRUN" },
102 { 7, "ZETA_STORAGE_TYPE_MISMATCH" },
103 { 8, "RT_STORAGE_TYPE_MISMATCH" },
104 { 10, "RT_LINEAR_MISMATCH" },
108 static const struct nouveau_enum nve0_sked_error
[] = {
109 { 7, "CONSTANT_BUFFER_SIZE" },
110 { 9, "LOCAL_MEMORY_SIZE_POS" },
111 { 10, "LOCAL_MEMORY_SIZE_NEG" },
112 { 11, "WARP_CSTACK_SIZE" },
113 { 12, "TOTAL_TEMP_SIZE" },
114 { 13, "REGISTER_COUNT" },
115 { 18, "TOTAL_THREADS" },
116 { 20, "PROGRAM_OFFSET" },
117 { 21, "SHARED_MEMORY_SIZE" },
118 { 25, "SHARED_CONFIG_TOO_SMALL" },
119 { 26, "TOTAL_REGISTER_COUNT" },
124 nve0_graph_mp_trap(struct nvc0_graph_priv
*priv
, int gpc
, int tp
)
127 u32 werr
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x648));
128 u32 gerr
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x650));
130 nv_error(priv
, "GPC%i/TP%i/MP trap:", gpc
, tp
);
132 for (i
= 0; i
<= 31; ++i
) {
133 if (!(gerr
& (1 << i
)))
136 nouveau_enum_print(nve0_mp_global_error
, i
);
140 nouveau_enum_print(nve0_mp_warp_error
, werr
& 0xffff);
144 /* disable MP trap to avoid spam */
145 nv_mask(priv
, TPC_UNIT(gpc
, tp
, 0x50c), 0x2, 0x0);
147 /* TODO: figure out how to resume after an MP trap */
151 nve0_graph_tp_trap(struct nvc0_graph_priv
*priv
, int gpc
, int tp
)
153 u32 stat
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x508));
156 u32 trap
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x224));
157 nv_error(priv
, "GPC%i/TP%i/TEX trap: %08x\n",
160 nv_wr32(priv
, TPC_UNIT(gpc
, tp
, 0x224), 0xc0000000);
165 nve0_graph_mp_trap(priv
, gpc
, tp
);
170 u32 trap
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x084));
171 nv_error(priv
, "GPC%i/TP%i/POLY trap: %08x\n",
174 nv_wr32(priv
, TPC_UNIT(gpc
, tp
, 0x084), 0xc0000000);
179 u32 trap
= nv_rd32(priv
, TPC_UNIT(gpc
, tp
, 0x48c));
180 nv_error(priv
, "GPC%i/TP%i/L1C trap: %08x\n",
183 nv_wr32(priv
, TPC_UNIT(gpc
, tp
, 0x48c), 0xc0000000);
188 nv_error(priv
, "GPC%i/TP%i: unknown stat %08x\n",
194 nve0_graph_gpc_trap(struct nvc0_graph_priv
*priv
)
196 const u32 mask
= nv_rd32(priv
, 0x400118);
199 for (gpc
= 0; gpc
< 4; ++gpc
) {
203 if (!(mask
& (1 << gpc
)))
205 stat
= nv_rd32(priv
, GPC_UNIT(gpc
, 0x2c90));
211 trap
[0] = nv_rd32(priv
, GPC_UNIT(gpc
, 0x0420));
212 trap
[1] = nv_rd32(priv
, GPC_UNIT(gpc
, 0x0434));
213 trap
[2] = nv_rd32(priv
, GPC_UNIT(gpc
, 0x0438));
214 trap
[3] = nv_rd32(priv
, GPC_UNIT(gpc
, 0x043c));
216 nv_error(priv
, "GPC%i/PROP trap:", gpc
);
217 for (i
= 0; i
<= 29; ++i
) {
218 if (!(trap
[0] & (1 << i
)))
221 nouveau_enum_print(nve0_gpc_rop_error
, i
);
225 nv_error(priv
, "x = %u, y = %u, "
226 "format = %x, storage type = %x\n",
229 (trap
[2] >> 8) & 0x3f,
232 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0420), 0xc0000000);
237 u32 trap
= nv_rd32(priv
, GPC_UNIT(gpc
, 0x0900));
238 nv_error(priv
, "GPC%i/ZCULL trap: %08x\n", gpc
,
240 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0900), 0xc0000000);
245 u32 trap
= nv_rd32(priv
, GPC_UNIT(gpc
, 0x1028));
246 nv_error(priv
, "GPC%i/CCACHE trap: %08x\n", gpc
,
248 nv_wr32(priv
, GPC_UNIT(gpc
, 0x1028), 0xc0000000);
253 u32 trap
= nv_rd32(priv
, GPC_UNIT(gpc
, 0x0824));
254 nv_error(priv
, "GPC%i/ESETUP trap %08x\n", gpc
,
256 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0824), 0xc0000000);
260 for (tp
= 0; tp
< 8; ++tp
) {
261 if (stat
& (1 << (16 + tp
)))
262 nve0_graph_tp_trap(priv
, gpc
, tp
);
267 nv_error(priv
, "GPC%i: unknown stat %08x\n",
275 nve0_graph_trap_isr(struct nvc0_graph_priv
*priv
, int chid
, u64 inst
,
276 struct nouveau_object
*engctx
)
278 u32 trap
= nv_rd32(priv
, 0x400108);
282 if (trap
& 0x00000001) {
283 u32 stat
= nv_rd32(priv
, 0x404000);
284 nv_error(priv
, "DISPATCH ch %d [0x%010llx %s] 0x%08x\n",
285 chid
, inst
, nouveau_client_name(engctx
), stat
);
286 nv_wr32(priv
, 0x404000, 0xc0000000);
287 nv_wr32(priv
, 0x400108, 0x00000001);
291 if (trap
& 0x00000010) {
292 u32 stat
= nv_rd32(priv
, 0x405840);
293 nv_error(priv
, "SHADER ch %d [0x%010llx %s] 0x%08x\n",
294 chid
, inst
, nouveau_client_name(engctx
), stat
);
295 nv_wr32(priv
, 0x405840, 0xc0000000);
296 nv_wr32(priv
, 0x400108, 0x00000010);
300 if (trap
& 0x00000100) {
301 u32 stat
= nv_rd32(priv
, 0x407020);
302 nv_error(priv
, "SKED ch %d [0x%010llx %s]:",
303 chid
, inst
, nouveau_client_name(engctx
));
305 for (i
= 0; i
<= 29; ++i
) {
306 if (!(stat
& (1 << i
)))
309 nouveau_enum_print(nve0_sked_error
, i
);
313 if (stat
& 0x3fffffff)
314 nv_wr32(priv
, 0x407020, 0x40000000);
315 nv_wr32(priv
, 0x400108, 0x00000100);
319 if (trap
& 0x01000000) {
320 nv_error(priv
, "GPC ch %d [0x%010llx %s]:\n",
321 chid
, inst
, nouveau_client_name(engctx
));
322 nve0_graph_gpc_trap(priv
);
326 if (trap
& 0x02000000) {
327 for (rop
= 0; rop
< priv
->rop_nr
; rop
++) {
328 u32 statz
= nv_rd32(priv
, ROP_UNIT(rop
, 0x070));
329 u32 statc
= nv_rd32(priv
, ROP_UNIT(rop
, 0x144));
331 "ROP%d ch %d [0x%010llx %s] 0x%08x 0x%08x\n",
332 rop
, chid
, inst
, nouveau_client_name(engctx
),
334 nv_wr32(priv
, ROP_UNIT(rop
, 0x070), 0xc0000000);
335 nv_wr32(priv
, ROP_UNIT(rop
, 0x144), 0xc0000000);
337 nv_wr32(priv
, 0x400108, 0x02000000);
342 nv_error(priv
, "TRAP ch %d [0x%010llx %s] 0x%08x\n",
343 chid
, inst
, nouveau_client_name(engctx
), trap
);
344 nv_wr32(priv
, 0x400108, trap
);
349 nve0_graph_intr(struct nouveau_subdev
*subdev
)
351 struct nouveau_fifo
*pfifo
= nouveau_fifo(subdev
);
352 struct nouveau_engine
*engine
= nv_engine(subdev
);
353 struct nouveau_object
*engctx
;
354 struct nouveau_handle
*handle
;
355 struct nvc0_graph_priv
*priv
= (void *)subdev
;
356 u64 inst
= nv_rd32(priv
, 0x409b00) & 0x0fffffff;
357 u32 stat
= nv_rd32(priv
, 0x400100);
358 u32 addr
= nv_rd32(priv
, 0x400704);
359 u32 mthd
= (addr
& 0x00003ffc);
360 u32 subc
= (addr
& 0x00070000) >> 16;
361 u32 data
= nv_rd32(priv
, 0x400708);
362 u32 code
= nv_rd32(priv
, 0x400110);
363 u32
class = nv_rd32(priv
, 0x404200 + (subc
* 4));
366 engctx
= nouveau_engctx_get(engine
, inst
);
367 chid
= pfifo
->chid(pfifo
, engctx
);
369 if (stat
& 0x00000010) {
370 handle
= nouveau_handle_get_class(engctx
, class);
371 if (!handle
|| nv_call(handle
->object
, mthd
, data
)) {
373 "ILLEGAL_MTHD ch %d [0x%010llx %s] subc %d class 0x%04x mthd 0x%04x data 0x%08x\n",
374 chid
, inst
, nouveau_client_name(engctx
), subc
,
377 nouveau_handle_put(handle
);
378 nv_wr32(priv
, 0x400100, 0x00000010);
382 if (stat
& 0x00000020) {
384 "ILLEGAL_CLASS ch %d [0x%010llx %s] subc %d class 0x%04x mthd 0x%04x data 0x%08x\n",
385 chid
, inst
, nouveau_client_name(engctx
), subc
, class,
387 nv_wr32(priv
, 0x400100, 0x00000020);
391 if (stat
& 0x00100000) {
392 nv_error(priv
, "DATA_ERROR [");
393 nouveau_enum_print(nv50_data_error_names
, code
);
394 pr_cont("] ch %d [0x%010llx %s] subc %d class 0x%04x mthd 0x%04x data 0x%08x\n",
395 chid
, inst
, nouveau_client_name(engctx
), subc
, class,
397 nv_wr32(priv
, 0x400100, 0x00100000);
401 if (stat
& 0x00200000) {
402 nve0_graph_trap_isr(priv
, chid
, inst
, engctx
);
403 nv_wr32(priv
, 0x400100, 0x00200000);
407 if (stat
& 0x00080000) {
408 nve0_graph_ctxctl_isr(priv
);
409 nv_wr32(priv
, 0x400100, 0x00080000);
414 nv_error(priv
, "unknown stat 0x%08x\n", stat
);
415 nv_wr32(priv
, 0x400100, stat
);
418 nv_wr32(priv
, 0x400500, 0x00010001);
419 nouveau_engctx_put(engctx
);
423 nve0_graph_ctor(struct nouveau_object
*parent
, struct nouveau_object
*engine
,
424 struct nouveau_oclass
*oclass
, void *data
, u32 size
,
425 struct nouveau_object
**pobject
)
427 struct nouveau_device
*device
= nv_device(parent
);
428 struct nvc0_graph_priv
*priv
;
431 ret
= nouveau_graph_create(parent
, engine
, oclass
, true, &priv
);
432 *pobject
= nv_object(priv
);
436 nv_subdev(priv
)->unit
= 0x18001000;
437 nv_subdev(priv
)->intr
= nve0_graph_intr
;
438 nv_engine(priv
)->cclass
= &nve0_graph_cclass
;
439 nv_engine(priv
)->sclass
= nve0_graph_sclass
;
441 priv
->base
.units
= nvc0_graph_units
;
443 if (nouveau_boolopt(device
->cfgopt
, "NvGrUseFW", false)) {
444 nv_info(priv
, "using external firmware\n");
445 if (nvc0_graph_ctor_fw(priv
, "fuc409c", &priv
->fuc409c
) ||
446 nvc0_graph_ctor_fw(priv
, "fuc409d", &priv
->fuc409d
) ||
447 nvc0_graph_ctor_fw(priv
, "fuc41ac", &priv
->fuc41ac
) ||
448 nvc0_graph_ctor_fw(priv
, "fuc41ad", &priv
->fuc41ad
))
450 priv
->firmware
= true;
453 ret
= nouveau_gpuobj_new(nv_object(priv
), NULL
, 0x1000, 256, 0,
458 ret
= nouveau_gpuobj_new(nv_object(priv
), NULL
, 0x1000, 256, 0,
463 for (i
= 0; i
< 0x1000; i
+= 4) {
464 nv_wo32(priv
->unk4188b4
, i
, 0x00000010);
465 nv_wo32(priv
->unk4188b8
, i
, 0x00000010);
468 priv
->gpc_nr
= nv_rd32(priv
, 0x409604) & 0x0000001f;
469 priv
->rop_nr
= (nv_rd32(priv
, 0x409604) & 0x001f0000) >> 16;
470 for (i
= 0; i
< priv
->gpc_nr
; i
++) {
471 priv
->tpc_nr
[i
] = nv_rd32(priv
, GPC_UNIT(i
, 0x2608));
472 priv
->tpc_total
+= priv
->tpc_nr
[i
];
475 switch (nv_device(priv
)->chipset
) {
477 if (priv
->tpc_total
== 8)
478 priv
->magic_not_rop_nr
= 3;
480 if (priv
->tpc_total
== 7)
481 priv
->magic_not_rop_nr
= 1;
485 priv
->magic_not_rop_nr
= 1;
495 nve0_graph_init_obj418880(struct nvc0_graph_priv
*priv
)
499 nv_wr32(priv
, GPC_BCAST(0x0880), 0x00000000);
500 nv_wr32(priv
, GPC_BCAST(0x08a4), 0x00000000);
501 for (i
= 0; i
< 4; i
++)
502 nv_wr32(priv
, GPC_BCAST(0x0888) + (i
* 4), 0x00000000);
503 nv_wr32(priv
, GPC_BCAST(0x08b4), priv
->unk4188b4
->addr
>> 8);
504 nv_wr32(priv
, GPC_BCAST(0x08b8), priv
->unk4188b8
->addr
>> 8);
508 nve0_graph_init_regs(struct nvc0_graph_priv
*priv
)
510 nv_wr32(priv
, 0x400080, 0x003083c2);
511 nv_wr32(priv
, 0x400088, 0x0001ffe7);
512 nv_wr32(priv
, 0x40008c, 0x00000000);
513 nv_wr32(priv
, 0x400090, 0x00000030);
514 nv_wr32(priv
, 0x40013c, 0x003901f7);
515 nv_wr32(priv
, 0x400140, 0x00000100);
516 nv_wr32(priv
, 0x400144, 0x00000000);
517 nv_wr32(priv
, 0x400148, 0x00000110);
518 nv_wr32(priv
, 0x400138, 0x00000000);
519 nv_wr32(priv
, 0x400130, 0x00000000);
520 nv_wr32(priv
, 0x400134, 0x00000000);
521 nv_wr32(priv
, 0x400124, 0x00000002);
525 nve0_graph_init_units(struct nvc0_graph_priv
*priv
)
527 nv_wr32(priv
, 0x409ffc, 0x00000000);
528 nv_wr32(priv
, 0x409c14, 0x00003e3e);
529 nv_wr32(priv
, 0x409c24, 0x000f0000);
531 nv_wr32(priv
, 0x404000, 0xc0000000);
532 nv_wr32(priv
, 0x404600, 0xc0000000);
533 nv_wr32(priv
, 0x408030, 0xc0000000);
534 nv_wr32(priv
, 0x404490, 0xc0000000);
535 nv_wr32(priv
, 0x406018, 0xc0000000);
536 nv_wr32(priv
, 0x407020, 0xc0000000);
537 nv_wr32(priv
, 0x405840, 0xc0000000);
538 nv_wr32(priv
, 0x405844, 0x00ffffff);
540 nv_mask(priv
, 0x419cc0, 0x00000008, 0x00000008);
541 nv_mask(priv
, 0x419eb4, 0x00001000, 0x00001000);
546 nve0_graph_init_gpc_0(struct nvc0_graph_priv
*priv
)
548 const u32 magicgpc918
= DIV_ROUND_UP(0x00800000, priv
->tpc_total
);
549 u32 data
[TPC_MAX
/ 8];
553 nv_wr32(priv
, GPC_UNIT(0, 0x3018), 0x00000001);
555 memset(data
, 0x00, sizeof(data
));
556 memcpy(tpcnr
, priv
->tpc_nr
, sizeof(priv
->tpc_nr
));
557 for (i
= 0, gpc
= -1; i
< priv
->tpc_total
; i
++) {
559 gpc
= (gpc
+ 1) % priv
->gpc_nr
;
560 } while (!tpcnr
[gpc
]);
561 tpc
= priv
->tpc_nr
[gpc
] - tpcnr
[gpc
]--;
563 data
[i
/ 8] |= tpc
<< ((i
% 8) * 4);
566 nv_wr32(priv
, GPC_BCAST(0x0980), data
[0]);
567 nv_wr32(priv
, GPC_BCAST(0x0984), data
[1]);
568 nv_wr32(priv
, GPC_BCAST(0x0988), data
[2]);
569 nv_wr32(priv
, GPC_BCAST(0x098c), data
[3]);
571 for (gpc
= 0; gpc
< priv
->gpc_nr
; gpc
++) {
572 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0914), priv
->magic_not_rop_nr
<< 8 |
574 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0910), 0x00040000 | priv
->tpc_total
);
575 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0918), magicgpc918
);
578 nv_wr32(priv
, GPC_BCAST(0x3fd4), magicgpc918
);
579 nv_wr32(priv
, GPC_BCAST(0x08ac), nv_rd32(priv
, 0x100800));
583 nve0_graph_init_gpc_1(struct nvc0_graph_priv
*priv
)
587 for (gpc
= 0; gpc
< priv
->gpc_nr
; gpc
++) {
588 nv_wr32(priv
, GPC_UNIT(gpc
, 0x3038), 0xc0000000);
589 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0420), 0xc0000000);
590 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0900), 0xc0000000);
591 nv_wr32(priv
, GPC_UNIT(gpc
, 0x1028), 0xc0000000);
592 nv_wr32(priv
, GPC_UNIT(gpc
, 0x0824), 0xc0000000);
593 for (tpc
= 0; tpc
< priv
->tpc_nr
[gpc
]; tpc
++) {
594 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x508), 0xffffffff);
595 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x50c), 0xffffffff);
596 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x224), 0xc0000000);
597 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x48c), 0xc0000000);
598 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x084), 0xc0000000);
599 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x644), 0x001ffffe);
600 nv_wr32(priv
, TPC_UNIT(gpc
, tpc
, 0x64c), 0x0000000f);
602 nv_wr32(priv
, GPC_UNIT(gpc
, 0x2c90), 0xffffffff);
603 nv_wr32(priv
, GPC_UNIT(gpc
, 0x2c94), 0xffffffff);
608 nve0_graph_init_rop(struct nvc0_graph_priv
*priv
)
612 for (rop
= 0; rop
< priv
->rop_nr
; rop
++) {
613 nv_wr32(priv
, ROP_UNIT(rop
, 0x144), 0xc0000000);
614 nv_wr32(priv
, ROP_UNIT(rop
, 0x070), 0xc0000000);
615 nv_wr32(priv
, ROP_UNIT(rop
, 0x204), 0xffffffff);
616 nv_wr32(priv
, ROP_UNIT(rop
, 0x208), 0xffffffff);
621 nve0_graph_init_ctxctl(struct nvc0_graph_priv
*priv
)
626 if (priv
->firmware
) {
627 /* load fuc microcode */
628 r000260
= nv_mask(priv
, 0x000260, 0x00000001, 0x00000000);
629 nvc0_graph_init_fw(priv
, 0x409000, &priv
->fuc409c
, &priv
->fuc409d
);
630 nvc0_graph_init_fw(priv
, 0x41a000, &priv
->fuc41ac
, &priv
->fuc41ad
);
631 nv_wr32(priv
, 0x000260, r000260
);
633 /* start both of them running */
634 nv_wr32(priv
, 0x409840, 0xffffffff);
635 nv_wr32(priv
, 0x41a10c, 0x00000000);
636 nv_wr32(priv
, 0x40910c, 0x00000000);
637 nv_wr32(priv
, 0x41a100, 0x00000002);
638 nv_wr32(priv
, 0x409100, 0x00000002);
639 if (!nv_wait(priv
, 0x409800, 0x00000001, 0x00000001))
640 nv_error(priv
, "0x409800 wait failed\n");
642 nv_wr32(priv
, 0x409840, 0xffffffff);
643 nv_wr32(priv
, 0x409500, 0x7fffffff);
644 nv_wr32(priv
, 0x409504, 0x00000021);
646 nv_wr32(priv
, 0x409840, 0xffffffff);
647 nv_wr32(priv
, 0x409500, 0x00000000);
648 nv_wr32(priv
, 0x409504, 0x00000010);
649 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
650 nv_error(priv
, "fuc09 req 0x10 timeout\n");
653 priv
->size
= nv_rd32(priv
, 0x409800);
655 nv_wr32(priv
, 0x409840, 0xffffffff);
656 nv_wr32(priv
, 0x409500, 0x00000000);
657 nv_wr32(priv
, 0x409504, 0x00000016);
658 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
659 nv_error(priv
, "fuc09 req 0x16 timeout\n");
663 nv_wr32(priv
, 0x409840, 0xffffffff);
664 nv_wr32(priv
, 0x409500, 0x00000000);
665 nv_wr32(priv
, 0x409504, 0x00000025);
666 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
667 nv_error(priv
, "fuc09 req 0x25 timeout\n");
671 nv_wr32(priv
, 0x409800, 0x00000000);
672 nv_wr32(priv
, 0x409500, 0x00000001);
673 nv_wr32(priv
, 0x409504, 0x00000030);
674 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
675 nv_error(priv
, "fuc09 req 0x30 timeout\n");
679 nv_wr32(priv
, 0x409810, 0xb00095c8);
680 nv_wr32(priv
, 0x409800, 0x00000000);
681 nv_wr32(priv
, 0x409500, 0x00000001);
682 nv_wr32(priv
, 0x409504, 0x00000031);
683 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
684 nv_error(priv
, "fuc09 req 0x31 timeout\n");
688 nv_wr32(priv
, 0x409810, 0x00080420);
689 nv_wr32(priv
, 0x409800, 0x00000000);
690 nv_wr32(priv
, 0x409500, 0x00000001);
691 nv_wr32(priv
, 0x409504, 0x00000032);
692 if (!nv_wait_ne(priv
, 0x409800, 0xffffffff, 0x00000000)) {
693 nv_error(priv
, "fuc09 req 0x32 timeout\n");
697 nv_wr32(priv
, 0x409614, 0x00000070);
698 nv_wr32(priv
, 0x409614, 0x00000770);
699 nv_wr32(priv
, 0x40802c, 0x00000001);
701 if (priv
->data
== NULL
) {
702 int ret
= nve0_grctx_generate(priv
);
704 nv_error(priv
, "failed to construct context\n");
712 /* load HUB microcode */
713 r000260
= nv_mask(priv
, 0x000260, 0x00000001, 0x00000000);
714 nv_wr32(priv
, 0x4091c0, 0x01000000);
715 for (i
= 0; i
< sizeof(nve0_grhub_data
) / 4; i
++)
716 nv_wr32(priv
, 0x4091c4, nve0_grhub_data
[i
]);
718 nv_wr32(priv
, 0x409180, 0x01000000);
719 for (i
= 0; i
< sizeof(nve0_grhub_code
) / 4; i
++) {
721 nv_wr32(priv
, 0x409188, i
>> 6);
722 nv_wr32(priv
, 0x409184, nve0_grhub_code
[i
]);
725 /* load GPC microcode */
726 nv_wr32(priv
, 0x41a1c0, 0x01000000);
727 for (i
= 0; i
< sizeof(nve0_grgpc_data
) / 4; i
++)
728 nv_wr32(priv
, 0x41a1c4, nve0_grgpc_data
[i
]);
730 nv_wr32(priv
, 0x41a180, 0x01000000);
731 for (i
= 0; i
< sizeof(nve0_grgpc_code
) / 4; i
++) {
733 nv_wr32(priv
, 0x41a188, i
>> 6);
734 nv_wr32(priv
, 0x41a184, nve0_grgpc_code
[i
]);
736 nv_wr32(priv
, 0x000260, r000260
);
738 /* start HUB ucode running, it'll init the GPCs */
739 nv_wr32(priv
, 0x409800, nv_device(priv
)->chipset
);
740 nv_wr32(priv
, 0x40910c, 0x00000000);
741 nv_wr32(priv
, 0x409100, 0x00000002);
742 if (!nv_wait(priv
, 0x409800, 0x80000000, 0x80000000)) {
743 nv_error(priv
, "HUB_INIT timed out\n");
744 nvc0_graph_ctxctl_debug(priv
);
748 priv
->size
= nv_rd32(priv
, 0x409804);
749 if (priv
->data
== NULL
) {
750 int ret
= nve0_grctx_generate(priv
);
752 nv_error(priv
, "failed to construct context\n");
761 nve0_graph_init(struct nouveau_object
*object
)
763 struct nvc0_graph_priv
*priv
= (void *)object
;
766 ret
= nouveau_graph_init(&priv
->base
);
770 nve0_graph_init_obj418880(priv
);
771 nve0_graph_init_regs(priv
);
772 nve0_graph_init_gpc_0(priv
);
774 nv_wr32(priv
, 0x400500, 0x00010001);
775 nv_wr32(priv
, 0x400100, 0xffffffff);
776 nv_wr32(priv
, 0x40013c, 0xffffffff);
778 nve0_graph_init_units(priv
);
779 nve0_graph_init_gpc_1(priv
);
780 nve0_graph_init_rop(priv
);
782 nv_wr32(priv
, 0x400108, 0xffffffff);
783 nv_wr32(priv
, 0x400138, 0xffffffff);
784 nv_wr32(priv
, 0x400118, 0xffffffff);
785 nv_wr32(priv
, 0x400130, 0xffffffff);
786 nv_wr32(priv
, 0x40011c, 0xffffffff);
787 nv_wr32(priv
, 0x400134, 0xffffffff);
788 nv_wr32(priv
, 0x400054, 0x34ce3464);
790 ret
= nve0_graph_init_ctxctl(priv
);
797 struct nouveau_oclass
798 nve0_graph_oclass
= {
799 .handle
= NV_ENGINE(GR
, 0xe0),
800 .ofuncs
= &(struct nouveau_ofuncs
) {
801 .ctor
= nve0_graph_ctor
,
802 .dtor
= nvc0_graph_dtor
,
803 .init
= nve0_graph_init
,
804 .fini
= _nouveau_graph_fini
,