1 #include <core/os.h> 2 #include <core/engctx.h> 3 #include <core/enum.h> 4 5 #include <subdev/timer.h> 6 #include <subdev/fb.h> 7 8 #include <engine/gr.h> 9 10 #include "nv20.h" 11 #include "regs.h" 12 13 /******************************************************************************* 14 * PGRAPH context 15 ******************************************************************************/ 16 17 static int 18 nv2a_gr_context_ctor(struct nouveau_object *parent, 19 struct nouveau_object *engine, 20 struct nouveau_oclass *oclass, void *data, u32 size, 21 struct nouveau_object **pobject) 22 { 23 struct nv20_gr_chan *chan; 24 int ret, i; 25 26 ret = nouveau_gr_context_create(parent, engine, oclass, NULL, 0x36b0, 27 16, NVOBJ_FLAG_ZERO_ALLOC, &chan); 28 *pobject = nv_object(chan); 29 if (ret) 30 return ret; 31 32 chan->chid = nouveau_fifo_chan(parent)->chid; 33 34 nv_wo32(chan, 0x0000, 0x00000001 | (chan->chid << 24)); 35 nv_wo32(chan, 0x033c, 0xffff0000); 36 nv_wo32(chan, 0x03a0, 0x0fff0000); 37 nv_wo32(chan, 0x03a4, 0x0fff0000); 38 nv_wo32(chan, 0x047c, 0x00000101); 39 nv_wo32(chan, 0x0490, 0x00000111); 40 nv_wo32(chan, 0x04a8, 0x44400000); 41 for (i = 0x04d4; i <= 0x04e0; i += 4) 42 nv_wo32(chan, i, 0x00030303); 43 for (i = 0x04f4; i <= 0x0500; i += 4) 44 nv_wo32(chan, i, 0x00080000); 45 for (i = 0x050c; i <= 0x0518; i += 4) 46 nv_wo32(chan, i, 0x01012000); 47 for (i = 0x051c; i <= 0x0528; i += 4) 48 nv_wo32(chan, i, 0x000105b8); 49 for (i = 0x052c; i <= 0x0538; i += 4) 50 nv_wo32(chan, i, 0x00080008); 51 for (i = 0x055c; i <= 0x0598; i += 4) 52 nv_wo32(chan, i, 0x07ff0000); 53 nv_wo32(chan, 0x05a4, 0x4b7fffff); 54 nv_wo32(chan, 0x05fc, 0x00000001); 55 nv_wo32(chan, 0x0604, 0x00004000); 56 nv_wo32(chan, 0x0610, 0x00000001); 57 nv_wo32(chan, 0x0618, 0x00040000); 58 nv_wo32(chan, 0x061c, 0x00010000); 59 for (i = 0x1a9c; i <= 0x22fc; i += 16) { /*XXX: check!! */ 60 nv_wo32(chan, (i + 0), 0x10700ff9); 61 nv_wo32(chan, (i + 4), 0x0436086c); 62 nv_wo32(chan, (i + 8), 0x000c001b); 63 } 64 nv_wo32(chan, 0x269c, 0x3f800000); 65 nv_wo32(chan, 0x26b0, 0x3f800000); 66 nv_wo32(chan, 0x26dc, 0x40000000); 67 nv_wo32(chan, 0x26e0, 0x3f800000); 68 nv_wo32(chan, 0x26e4, 0x3f000000); 69 nv_wo32(chan, 0x26ec, 0x40000000); 70 nv_wo32(chan, 0x26f0, 0x3f800000); 71 nv_wo32(chan, 0x26f8, 0xbf800000); 72 nv_wo32(chan, 0x2700, 0xbf800000); 73 nv_wo32(chan, 0x3024, 0x000fe000); 74 nv_wo32(chan, 0x30a0, 0x000003f8); 75 nv_wo32(chan, 0x33fc, 0x002fe000); 76 for (i = 0x341c; i <= 0x3438; i += 4) 77 nv_wo32(chan, i, 0x001c527c); 78 return 0; 79 } 80 81 static struct nouveau_oclass 82 nv2a_gr_cclass = { 83 .handle = NV_ENGCTX(GR, 0x2a), 84 .ofuncs = &(struct nouveau_ofuncs) { 85 .ctor = nv2a_gr_context_ctor, 86 .dtor = _nouveau_gr_context_dtor, 87 .init = nv20_gr_context_init, 88 .fini = nv20_gr_context_fini, 89 .rd32 = _nouveau_gr_context_rd32, 90 .wr32 = _nouveau_gr_context_wr32, 91 }, 92 }; 93 94 /******************************************************************************* 95 * PGRAPH engine/subdev functions 96 ******************************************************************************/ 97 98 static int 99 nv2a_gr_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 100 struct nouveau_oclass *oclass, void *data, u32 size, 101 struct nouveau_object **pobject) 102 { 103 struct nv20_gr_priv *priv; 104 int ret; 105 106 ret = nouveau_gr_create(parent, engine, oclass, true, &priv); 107 *pobject = nv_object(priv); 108 if (ret) 109 return ret; 110 111 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 32 * 4, 16, 112 NVOBJ_FLAG_ZERO_ALLOC, &priv->ctxtab); 113 if (ret) 114 return ret; 115 116 nv_subdev(priv)->unit = 0x00001000; 117 nv_subdev(priv)->intr = nv20_gr_intr; 118 nv_engine(priv)->cclass = &nv2a_gr_cclass; 119 nv_engine(priv)->sclass = nv25_gr_sclass; 120 nv_engine(priv)->tile_prog = nv20_gr_tile_prog; 121 return 0; 122 } 123 124 struct nouveau_oclass 125 nv2a_gr_oclass = { 126 .handle = NV_ENGINE(GR, 0x2a), 127 .ofuncs = &(struct nouveau_ofuncs) { 128 .ctor = nv2a_gr_ctor, 129 .dtor = nv20_gr_dtor, 130 .init = nv20_gr_init, 131 .fini = _nouveau_gr_fini, 132 }, 133 }; 134