drm/nouveau/fifo: convert to new-style nvkm_engine
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / gr / nv30.c
1 #include "nv20.h"
2 #include "regs.h"
3
4 #include <core/gpuobj.h>
5 #include <engine/fifo.h>
6 #include <engine/fifo/chan.h>
7 #include <subdev/fb.h>
8
9 /*******************************************************************************
10 * PGRAPH context
11 ******************************************************************************/
12
13 static const struct nvkm_object_func
14 nv30_gr_chan = {
15 .dtor = nv20_gr_chan_dtor,
16 .init = nv20_gr_chan_init,
17 .fini = nv20_gr_chan_fini,
18 };
19
20 static int
21 nv30_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch,
22 const struct nvkm_oclass *oclass, struct nvkm_object **pobject)
23 {
24 struct nv20_gr *gr = nv20_gr(base);
25 struct nv20_gr_chan *chan;
26 int ret, i;
27
28 if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
29 return -ENOMEM;
30 nvkm_object_ctor(&nv30_gr_chan, oclass, &chan->object);
31 chan->gr = gr;
32 chan->chid = fifoch->chid;
33 *pobject = &chan->object;
34
35 ret = nvkm_memory_new(gr->base.engine.subdev.device,
36 NVKM_MEM_TARGET_INST, 0x5f48, 16, true,
37 &chan->inst);
38 if (ret)
39 return ret;
40
41 nvkm_kmap(chan->inst);
42 nvkm_wo32(chan->inst, 0x0028, 0x00000001 | (chan->chid << 24));
43 nvkm_wo32(chan->inst, 0x0410, 0x00000101);
44 nvkm_wo32(chan->inst, 0x0424, 0x00000111);
45 nvkm_wo32(chan->inst, 0x0428, 0x00000060);
46 nvkm_wo32(chan->inst, 0x0444, 0x00000080);
47 nvkm_wo32(chan->inst, 0x0448, 0xffff0000);
48 nvkm_wo32(chan->inst, 0x044c, 0x00000001);
49 nvkm_wo32(chan->inst, 0x0460, 0x44400000);
50 nvkm_wo32(chan->inst, 0x048c, 0xffff0000);
51 for (i = 0x04e0; i < 0x04e8; i += 4)
52 nvkm_wo32(chan->inst, i, 0x0fff0000);
53 nvkm_wo32(chan->inst, 0x04ec, 0x00011100);
54 for (i = 0x0508; i < 0x0548; i += 4)
55 nvkm_wo32(chan->inst, i, 0x07ff0000);
56 nvkm_wo32(chan->inst, 0x0550, 0x4b7fffff);
57 nvkm_wo32(chan->inst, 0x058c, 0x00000080);
58 nvkm_wo32(chan->inst, 0x0590, 0x30201000);
59 nvkm_wo32(chan->inst, 0x0594, 0x70605040);
60 nvkm_wo32(chan->inst, 0x0598, 0xb8a89888);
61 nvkm_wo32(chan->inst, 0x059c, 0xf8e8d8c8);
62 nvkm_wo32(chan->inst, 0x05b0, 0xb0000000);
63 for (i = 0x0600; i < 0x0640; i += 4)
64 nvkm_wo32(chan->inst, i, 0x00010588);
65 for (i = 0x0640; i < 0x0680; i += 4)
66 nvkm_wo32(chan->inst, i, 0x00030303);
67 for (i = 0x06c0; i < 0x0700; i += 4)
68 nvkm_wo32(chan->inst, i, 0x0008aae4);
69 for (i = 0x0700; i < 0x0740; i += 4)
70 nvkm_wo32(chan->inst, i, 0x01012000);
71 for (i = 0x0740; i < 0x0780; i += 4)
72 nvkm_wo32(chan->inst, i, 0x00080008);
73 nvkm_wo32(chan->inst, 0x085c, 0x00040000);
74 nvkm_wo32(chan->inst, 0x0860, 0x00010000);
75 for (i = 0x0864; i < 0x0874; i += 4)
76 nvkm_wo32(chan->inst, i, 0x00040004);
77 for (i = 0x1f18; i <= 0x3088 ; i += 16) {
78 nvkm_wo32(chan->inst, i + 0, 0x10700ff9);
79 nvkm_wo32(chan->inst, i + 1, 0x0436086c);
80 nvkm_wo32(chan->inst, i + 2, 0x000c001b);
81 }
82 for (i = 0x30b8; i < 0x30c8; i += 4)
83 nvkm_wo32(chan->inst, i, 0x0000ffff);
84 nvkm_wo32(chan->inst, 0x344c, 0x3f800000);
85 nvkm_wo32(chan->inst, 0x3808, 0x3f800000);
86 nvkm_wo32(chan->inst, 0x381c, 0x3f800000);
87 nvkm_wo32(chan->inst, 0x3848, 0x40000000);
88 nvkm_wo32(chan->inst, 0x384c, 0x3f800000);
89 nvkm_wo32(chan->inst, 0x3850, 0x3f000000);
90 nvkm_wo32(chan->inst, 0x3858, 0x40000000);
91 nvkm_wo32(chan->inst, 0x385c, 0x3f800000);
92 nvkm_wo32(chan->inst, 0x3864, 0xbf800000);
93 nvkm_wo32(chan->inst, 0x386c, 0xbf800000);
94 nvkm_done(chan->inst);
95 return 0;
96 }
97
98 /*******************************************************************************
99 * PGRAPH engine/subdev functions
100 ******************************************************************************/
101
102 static const struct nvkm_gr_func
103 nv30_gr = {
104 .chan_new = nv30_gr_chan_new,
105 .sclass = {
106 { -1, -1, 0x0012, &nv04_gr_object }, /* beta1 */
107 { -1, -1, 0x0019, &nv04_gr_object }, /* clip */
108 { -1, -1, 0x0030, &nv04_gr_object }, /* null */
109 { -1, -1, 0x0039, &nv04_gr_object }, /* m2mf */
110 { -1, -1, 0x0043, &nv04_gr_object }, /* rop */
111 { -1, -1, 0x0044, &nv04_gr_object }, /* patt */
112 { -1, -1, 0x004a, &nv04_gr_object }, /* gdi */
113 { -1, -1, 0x0062, &nv04_gr_object }, /* surf2d */
114 { -1, -1, 0x0072, &nv04_gr_object }, /* beta4 */
115 { -1, -1, 0x0089, &nv04_gr_object }, /* sifm */
116 { -1, -1, 0x008a, &nv04_gr_object }, /* ifc */
117 { -1, -1, 0x009f, &nv04_gr_object }, /* imageblit */
118 { -1, -1, 0x0362, &nv04_gr_object }, /* surf2d (nv30) */
119 { -1, -1, 0x0389, &nv04_gr_object }, /* sifm (nv30) */
120 { -1, -1, 0x038a, &nv04_gr_object }, /* ifc (nv30) */
121 { -1, -1, 0x039e, &nv04_gr_object }, /* swzsurf (nv30) */
122 { -1, -1, 0x0397, &nv04_gr_object }, /* rankine */
123 {}
124 }
125 };
126
127 static int
128 nv30_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
129 struct nvkm_oclass *oclass, void *data, u32 size,
130 struct nvkm_object **pobject)
131 {
132 struct nvkm_device *device = (void *)parent;
133 struct nv20_gr *gr;
134 int ret;
135
136 ret = nvkm_gr_create(parent, engine, oclass, true, &gr);
137 *pobject = nv_object(gr);
138 if (ret)
139 return ret;
140
141 gr->base.func = &nv30_gr;
142
143 ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, 32 * 4, 16, true,
144 &gr->ctxtab);
145 if (ret)
146 return ret;
147
148 nv_subdev(gr)->unit = 0x00001000;
149 nv_subdev(gr)->intr = nv20_gr_intr;
150 nv_engine(gr)->tile_prog = nv20_gr_tile_prog;
151 return 0;
152 }
153
154 int
155 nv30_gr_init(struct nvkm_object *object)
156 {
157 struct nvkm_engine *engine = nv_engine(object);
158 struct nv20_gr *gr = (void *)engine;
159 struct nvkm_device *device = gr->base.engine.subdev.device;
160 struct nvkm_fb *fb = device->fb;
161 int ret, i;
162
163 ret = nvkm_gr_init(&gr->base);
164 if (ret)
165 return ret;
166
167 nvkm_wr32(device, NV20_PGRAPH_CHANNEL_CTX_TABLE,
168 nvkm_memory_addr(gr->ctxtab) >> 4);
169
170 nvkm_wr32(device, NV03_PGRAPH_INTR , 0xFFFFFFFF);
171 nvkm_wr32(device, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
172
173 nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
174 nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x00000000);
175 nvkm_wr32(device, NV04_PGRAPH_DEBUG_1, 0x401287c0);
176 nvkm_wr32(device, 0x400890, 0x01b463ff);
177 nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0xf2de0475);
178 nvkm_wr32(device, NV10_PGRAPH_DEBUG_4, 0x00008000);
179 nvkm_wr32(device, NV04_PGRAPH_LIMIT_VIOL_PIX, 0xf04bdff6);
180 nvkm_wr32(device, 0x400B80, 0x1003d888);
181 nvkm_wr32(device, 0x400B84, 0x0c000000);
182 nvkm_wr32(device, 0x400098, 0x00000000);
183 nvkm_wr32(device, 0x40009C, 0x0005ad00);
184 nvkm_wr32(device, 0x400B88, 0x62ff00ff); /* suspiciously like PGRAPH_DEBUG_2 */
185 nvkm_wr32(device, 0x4000a0, 0x00000000);
186 nvkm_wr32(device, 0x4000a4, 0x00000008);
187 nvkm_wr32(device, 0x4008a8, 0xb784a400);
188 nvkm_wr32(device, 0x400ba0, 0x002f8685);
189 nvkm_wr32(device, 0x400ba4, 0x00231f3f);
190 nvkm_wr32(device, 0x4008a4, 0x40000020);
191
192 if (nv_device(gr)->chipset == 0x34) {
193 nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0004);
194 nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00200201);
195 nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0008);
196 nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000008);
197 nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
198 nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000032);
199 nvkm_wr32(device, NV10_PGRAPH_RDI_INDEX, 0x00E00004);
200 nvkm_wr32(device, NV10_PGRAPH_RDI_DATA , 0x00000002);
201 }
202
203 nvkm_wr32(device, 0x4000c0, 0x00000016);
204
205 /* Turn all the tiling regions off. */
206 for (i = 0; i < fb->tile.regions; i++)
207 engine->tile_prog(engine, i);
208
209 nvkm_wr32(device, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
210 nvkm_wr32(device, NV10_PGRAPH_STATE , 0xFFFFFFFF);
211 nvkm_wr32(device, 0x0040075c , 0x00000001);
212
213 /* begin RAM config */
214 /* vramsz = pci_resource_len(gr->dev->pdev, 1) - 1; */
215 nvkm_wr32(device, 0x4009A4, nvkm_rd32(device, 0x100200));
216 nvkm_wr32(device, 0x4009A8, nvkm_rd32(device, 0x100204));
217 if (nv_device(gr)->chipset != 0x34) {
218 nvkm_wr32(device, 0x400750, 0x00EA0000);
219 nvkm_wr32(device, 0x400754, nvkm_rd32(device, 0x100200));
220 nvkm_wr32(device, 0x400750, 0x00EA0004);
221 nvkm_wr32(device, 0x400754, nvkm_rd32(device, 0x100204));
222 }
223 return 0;
224 }
225
226 struct nvkm_oclass
227 nv30_gr_oclass = {
228 .handle = NV_ENGINE(GR, 0x30),
229 .ofuncs = &(struct nvkm_ofuncs) {
230 .ctor = nv30_gr_ctor,
231 .dtor = nv20_gr_dtor,
232 .init = nv30_gr_init,
233 .fini = _nvkm_gr_fini,
234 },
235 };
This page took 0.036985 seconds and 5 git commands to generate.