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