]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/nvkm/engine/gr/nv30.c
drm/nouveau/ce: rename from copy (no binary change)
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / gr / nv30.c
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  * Graphics object classes
15  ******************************************************************************/
16
17 static struct nouveau_oclass
18 nv30_gr_sclass[] = {
19         { 0x0012, &nv04_gr_ofuncs, NULL }, /* beta1 */
20         { 0x0019, &nv04_gr_ofuncs, NULL }, /* clip */
21         { 0x0030, &nv04_gr_ofuncs, NULL }, /* null */
22         { 0x0039, &nv04_gr_ofuncs, NULL }, /* m2mf */
23         { 0x0043, &nv04_gr_ofuncs, NULL }, /* rop */
24         { 0x0044, &nv04_gr_ofuncs, NULL }, /* patt */
25         { 0x004a, &nv04_gr_ofuncs, NULL }, /* gdi */
26         { 0x0062, &nv04_gr_ofuncs, NULL }, /* surf2d */
27         { 0x0072, &nv04_gr_ofuncs, NULL }, /* beta4 */
28         { 0x0089, &nv04_gr_ofuncs, NULL }, /* sifm */
29         { 0x008a, &nv04_gr_ofuncs, NULL }, /* ifc */
30         { 0x009f, &nv04_gr_ofuncs, NULL }, /* imageblit */
31         { 0x0362, &nv04_gr_ofuncs, NULL }, /* surf2d (nv30) */
32         { 0x0389, &nv04_gr_ofuncs, NULL }, /* sifm (nv30) */
33         { 0x038a, &nv04_gr_ofuncs, NULL }, /* ifc (nv30) */
34         { 0x039e, &nv04_gr_ofuncs, NULL }, /* swzsurf (nv30) */
35         { 0x0397, &nv04_gr_ofuncs, NULL }, /* rankine */
36         {},
37 };
38
39 /*******************************************************************************
40  * PGRAPH context
41  ******************************************************************************/
42
43 static int
44 nv30_gr_context_ctor(struct nouveau_object *parent,
45                         struct nouveau_object *engine,
46                         struct nouveau_oclass *oclass, void *data, u32 size,
47                         struct nouveau_object **pobject)
48 {
49         struct nv20_gr_chan *chan;
50         int ret, i;
51
52         ret = nouveau_gr_context_create(parent, engine, oclass, NULL, 0x5f48,
53                                            16, NVOBJ_FLAG_ZERO_ALLOC, &chan);
54         *pobject = nv_object(chan);
55         if (ret)
56                 return ret;
57
58         chan->chid = nouveau_fifo_chan(parent)->chid;
59
60         nv_wo32(chan, 0x0028, 0x00000001 | (chan->chid << 24));
61         nv_wo32(chan, 0x0410, 0x00000101);
62         nv_wo32(chan, 0x0424, 0x00000111);
63         nv_wo32(chan, 0x0428, 0x00000060);
64         nv_wo32(chan, 0x0444, 0x00000080);
65         nv_wo32(chan, 0x0448, 0xffff0000);
66         nv_wo32(chan, 0x044c, 0x00000001);
67         nv_wo32(chan, 0x0460, 0x44400000);
68         nv_wo32(chan, 0x048c, 0xffff0000);
69         for (i = 0x04e0; i < 0x04e8; i += 4)
70                 nv_wo32(chan, i, 0x0fff0000);
71         nv_wo32(chan, 0x04ec, 0x00011100);
72         for (i = 0x0508; i < 0x0548; i += 4)
73                 nv_wo32(chan, i, 0x07ff0000);
74         nv_wo32(chan, 0x0550, 0x4b7fffff);
75         nv_wo32(chan, 0x058c, 0x00000080);
76         nv_wo32(chan, 0x0590, 0x30201000);
77         nv_wo32(chan, 0x0594, 0x70605040);
78         nv_wo32(chan, 0x0598, 0xb8a89888);
79         nv_wo32(chan, 0x059c, 0xf8e8d8c8);
80         nv_wo32(chan, 0x05b0, 0xb0000000);
81         for (i = 0x0600; i < 0x0640; i += 4)
82                 nv_wo32(chan, i, 0x00010588);
83         for (i = 0x0640; i < 0x0680; i += 4)
84                 nv_wo32(chan, i, 0x00030303);
85         for (i = 0x06c0; i < 0x0700; i += 4)
86                 nv_wo32(chan, i, 0x0008aae4);
87         for (i = 0x0700; i < 0x0740; i += 4)
88                 nv_wo32(chan, i, 0x01012000);
89         for (i = 0x0740; i < 0x0780; i += 4)
90                 nv_wo32(chan, i, 0x00080008);
91         nv_wo32(chan, 0x085c, 0x00040000);
92         nv_wo32(chan, 0x0860, 0x00010000);
93         for (i = 0x0864; i < 0x0874; i += 4)
94                 nv_wo32(chan, i, 0x00040004);
95         for (i = 0x1f18; i <= 0x3088 ; i += 16) {
96                 nv_wo32(chan, i + 0, 0x10700ff9);
97                 nv_wo32(chan, i + 1, 0x0436086c);
98                 nv_wo32(chan, i + 2, 0x000c001b);
99         }
100         for (i = 0x30b8; i < 0x30c8; i += 4)
101                 nv_wo32(chan, i, 0x0000ffff);
102         nv_wo32(chan, 0x344c, 0x3f800000);
103         nv_wo32(chan, 0x3808, 0x3f800000);
104         nv_wo32(chan, 0x381c, 0x3f800000);
105         nv_wo32(chan, 0x3848, 0x40000000);
106         nv_wo32(chan, 0x384c, 0x3f800000);
107         nv_wo32(chan, 0x3850, 0x3f000000);
108         nv_wo32(chan, 0x3858, 0x40000000);
109         nv_wo32(chan, 0x385c, 0x3f800000);
110         nv_wo32(chan, 0x3864, 0xbf800000);
111         nv_wo32(chan, 0x386c, 0xbf800000);
112         return 0;
113 }
114
115 static struct nouveau_oclass
116 nv30_gr_cclass = {
117         .handle = NV_ENGCTX(GR, 0x30),
118         .ofuncs = &(struct nouveau_ofuncs) {
119                 .ctor = nv30_gr_context_ctor,
120                 .dtor = _nouveau_gr_context_dtor,
121                 .init = nv20_gr_context_init,
122                 .fini = nv20_gr_context_fini,
123                 .rd32 = _nouveau_gr_context_rd32,
124                 .wr32 = _nouveau_gr_context_wr32,
125         },
126 };
127
128 /*******************************************************************************
129  * PGRAPH engine/subdev functions
130  ******************************************************************************/
131
132 static int
133 nv30_gr_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
134                struct nouveau_oclass *oclass, void *data, u32 size,
135                struct nouveau_object **pobject)
136 {
137         struct nv20_gr_priv *priv;
138         int ret;
139
140         ret = nouveau_gr_create(parent, engine, oclass, true, &priv);
141         *pobject = nv_object(priv);
142         if (ret)
143                 return ret;
144
145         ret = nouveau_gpuobj_new(nv_object(priv), NULL, 32 * 4, 16,
146                                  NVOBJ_FLAG_ZERO_ALLOC, &priv->ctxtab);
147         if (ret)
148                 return ret;
149
150         nv_subdev(priv)->unit = 0x00001000;
151         nv_subdev(priv)->intr = nv20_gr_intr;
152         nv_engine(priv)->cclass = &nv30_gr_cclass;
153         nv_engine(priv)->sclass = nv30_gr_sclass;
154         nv_engine(priv)->tile_prog = nv20_gr_tile_prog;
155         return 0;
156 }
157
158 int
159 nv30_gr_init(struct nouveau_object *object)
160 {
161         struct nouveau_engine *engine = nv_engine(object);
162         struct nv20_gr_priv *priv = (void *)engine;
163         struct nouveau_fb *pfb = nouveau_fb(object);
164         int ret, i;
165
166         ret = nouveau_gr_init(&priv->base);
167         if (ret)
168                 return ret;
169
170         nv_wr32(priv, NV20_PGRAPH_CHANNEL_CTX_TABLE, priv->ctxtab->addr >> 4);
171
172         nv_wr32(priv, NV03_PGRAPH_INTR   , 0xFFFFFFFF);
173         nv_wr32(priv, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
174
175         nv_wr32(priv, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
176         nv_wr32(priv, NV04_PGRAPH_DEBUG_0, 0x00000000);
177         nv_wr32(priv, NV04_PGRAPH_DEBUG_1, 0x401287c0);
178         nv_wr32(priv, 0x400890, 0x01b463ff);
179         nv_wr32(priv, NV04_PGRAPH_DEBUG_3, 0xf2de0475);
180         nv_wr32(priv, NV10_PGRAPH_DEBUG_4, 0x00008000);
181         nv_wr32(priv, NV04_PGRAPH_LIMIT_VIOL_PIX, 0xf04bdff6);
182         nv_wr32(priv, 0x400B80, 0x1003d888);
183         nv_wr32(priv, 0x400B84, 0x0c000000);
184         nv_wr32(priv, 0x400098, 0x00000000);
185         nv_wr32(priv, 0x40009C, 0x0005ad00);
186         nv_wr32(priv, 0x400B88, 0x62ff00ff); /* suspiciously like PGRAPH_DEBUG_2 */
187         nv_wr32(priv, 0x4000a0, 0x00000000);
188         nv_wr32(priv, 0x4000a4, 0x00000008);
189         nv_wr32(priv, 0x4008a8, 0xb784a400);
190         nv_wr32(priv, 0x400ba0, 0x002f8685);
191         nv_wr32(priv, 0x400ba4, 0x00231f3f);
192         nv_wr32(priv, 0x4008a4, 0x40000020);
193
194         if (nv_device(priv)->chipset == 0x34) {
195                 nv_wr32(priv, NV10_PGRAPH_RDI_INDEX, 0x00EA0004);
196                 nv_wr32(priv, NV10_PGRAPH_RDI_DATA , 0x00200201);
197                 nv_wr32(priv, NV10_PGRAPH_RDI_INDEX, 0x00EA0008);
198                 nv_wr32(priv, NV10_PGRAPH_RDI_DATA , 0x00000008);
199                 nv_wr32(priv, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
200                 nv_wr32(priv, NV10_PGRAPH_RDI_DATA , 0x00000032);
201                 nv_wr32(priv, NV10_PGRAPH_RDI_INDEX, 0x00E00004);
202                 nv_wr32(priv, NV10_PGRAPH_RDI_DATA , 0x00000002);
203         }
204
205         nv_wr32(priv, 0x4000c0, 0x00000016);
206
207         /* Turn all the tiling regions off. */
208         for (i = 0; i < pfb->tile.regions; i++)
209                 engine->tile_prog(engine, i);
210
211         nv_wr32(priv, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
212         nv_wr32(priv, NV10_PGRAPH_STATE      , 0xFFFFFFFF);
213         nv_wr32(priv, 0x0040075c             , 0x00000001);
214
215         /* begin RAM config */
216         /* vramsz = pci_resource_len(priv->dev->pdev, 0) - 1; */
217         nv_wr32(priv, 0x4009A4, nv_rd32(priv, 0x100200));
218         nv_wr32(priv, 0x4009A8, nv_rd32(priv, 0x100204));
219         if (nv_device(priv)->chipset != 0x34) {
220                 nv_wr32(priv, 0x400750, 0x00EA0000);
221                 nv_wr32(priv, 0x400754, nv_rd32(priv, 0x100200));
222                 nv_wr32(priv, 0x400750, 0x00EA0004);
223                 nv_wr32(priv, 0x400754, nv_rd32(priv, 0x100204));
224         }
225         return 0;
226 }
227
228 struct nouveau_oclass
229 nv30_gr_oclass = {
230         .handle = NV_ENGINE(GR, 0x30),
231         .ofuncs = &(struct nouveau_ofuncs) {
232                 .ctor = nv30_gr_ctor,
233                 .dtor = nv20_gr_dtor,
234                 .init = nv30_gr_init,
235                 .fini = _nouveau_gr_fini,
236         },
237 };