2 * Copyright 2013 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.
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
28 /*******************************************************************************
29 * Graphics object classes
30 ******************************************************************************/
32 static struct nouveau_oclass
33 nve4_graph_sclass[] = {
34 { 0x902d, &nouveau_object_ofuncs },
35 { 0xa040, &nouveau_object_ofuncs },
36 { 0xa097, &nouveau_object_ofuncs },
37 { 0xa0c0, &nouveau_object_ofuncs },
41 /*******************************************************************************
42 * PGRAPH register lists
43 ******************************************************************************/
45 const struct nvc0_graph_init
46 nve4_graph_init_main_0[] = {
47 { 0x400080, 1, 0x04, 0x003083c2 },
48 { 0x400088, 1, 0x04, 0x0001ffe7 },
49 { 0x40008c, 1, 0x04, 0x00000000 },
50 { 0x400090, 1, 0x04, 0x00000030 },
51 { 0x40013c, 1, 0x04, 0x003901f7 },
52 { 0x400140, 1, 0x04, 0x00000100 },
53 { 0x400144, 1, 0x04, 0x00000000 },
54 { 0x400148, 1, 0x04, 0x00000110 },
55 { 0x400138, 1, 0x04, 0x00000000 },
56 { 0x400130, 2, 0x04, 0x00000000 },
57 { 0x400124, 1, 0x04, 0x00000002 },
61 static const struct nvc0_graph_init
62 nve4_graph_init_ds_0[] = {
63 { 0x405844, 1, 0x04, 0x00ffffff },
64 { 0x405850, 1, 0x04, 0x00000000 },
65 { 0x405900, 1, 0x04, 0x0000ff34 },
66 { 0x405908, 1, 0x04, 0x00000000 },
67 { 0x405928, 2, 0x04, 0x00000000 },
71 static const struct nvc0_graph_init
72 nve4_graph_init_sked_0[] = {
73 { 0x407010, 1, 0x04, 0x00000000 },
77 static const struct nvc0_graph_init
78 nve4_graph_init_cwd_0[] = {
79 { 0x405b50, 1, 0x04, 0x00000000 },
83 static const struct nvc0_graph_init
84 nve4_graph_init_gpc_unk_1[] = {
85 { 0x418d00, 1, 0x04, 0x00000000 },
86 { 0x418d28, 2, 0x04, 0x00000000 },
87 { 0x418f00, 1, 0x04, 0x00000000 },
88 { 0x418f08, 1, 0x04, 0x00000000 },
89 { 0x418f20, 2, 0x04, 0x00000000 },
90 { 0x418e00, 1, 0x04, 0x00000060 },
91 { 0x418e08, 1, 0x04, 0x00000000 },
92 { 0x418e1c, 2, 0x04, 0x00000000 },
96 static const struct nvc0_graph_init
97 nve4_graph_init_tpc_0[] = {
98 { 0x419d0c, 1, 0x04, 0x00000000 },
99 { 0x419d10, 1, 0x04, 0x00000014 },
100 { 0x419ab0, 1, 0x04, 0x00000000 },
101 { 0x419ac8, 1, 0x04, 0x00000000 },
102 { 0x419ab8, 1, 0x04, 0x000000e7 },
103 { 0x419abc, 2, 0x04, 0x00000000 },
104 { 0x419ab4, 1, 0x04, 0x00000000 },
105 { 0x41980c, 1, 0x04, 0x00000010 },
106 { 0x419844, 1, 0x04, 0x00000000 },
107 { 0x419850, 1, 0x04, 0x00000004 },
108 { 0x419854, 2, 0x04, 0x00000000 },
109 { 0x419c98, 1, 0x04, 0x00000000 },
110 { 0x419ca8, 1, 0x04, 0x00000000 },
111 { 0x419cb0, 1, 0x04, 0x01000000 },
112 { 0x419cb4, 1, 0x04, 0x00000000 },
113 { 0x419cb8, 1, 0x04, 0x00b08bea },
114 { 0x419c84, 1, 0x04, 0x00010384 },
115 { 0x419cbc, 1, 0x04, 0x28137646 },
116 { 0x419cc0, 2, 0x04, 0x00000000 },
117 { 0x419c80, 1, 0x04, 0x00020232 },
118 { 0x419c0c, 1, 0x04, 0x00000000 },
119 { 0x419e00, 1, 0x04, 0x00000000 },
120 { 0x419ea0, 1, 0x04, 0x00000000 },
121 { 0x419ee4, 1, 0x04, 0x00000000 },
122 { 0x419ea4, 1, 0x04, 0x00000100 },
123 { 0x419ea8, 1, 0x04, 0x00000000 },
124 { 0x419eb4, 4, 0x04, 0x00000000 },
125 { 0x419edc, 1, 0x04, 0x00000000 },
126 { 0x419f00, 1, 0x04, 0x00000000 },
127 { 0x419f74, 1, 0x04, 0x00000555 },
131 const struct nvc0_graph_init
132 nve4_graph_init_be_0[] = {
133 { 0x40880c, 1, 0x04, 0x00000000 },
134 { 0x408850, 1, 0x04, 0x00000004 },
135 { 0x408910, 9, 0x04, 0x00000000 },
136 { 0x408950, 1, 0x04, 0x00000000 },
137 { 0x408954, 1, 0x04, 0x0000ffff },
138 { 0x408958, 1, 0x04, 0x00000034 },
139 { 0x408984, 1, 0x04, 0x00000000 },
140 { 0x408988, 1, 0x04, 0x08040201 },
141 { 0x40898c, 1, 0x04, 0x80402010 },
145 static const struct nvc0_graph_pack
146 nve4_graph_pack_mmio[] = {
147 { nve4_graph_init_main_0 },
148 { nvc0_graph_init_fe_0 },
149 { nvc0_graph_init_pri_0 },
150 { nvc0_graph_init_rstr2d_0 },
151 { nvd9_graph_init_pd_0 },
152 { nve4_graph_init_ds_0 },
153 { nvc0_graph_init_scc_0 },
154 { nve4_graph_init_sked_0 },
155 { nve4_graph_init_cwd_0 },
156 { nvd9_graph_init_prop_0 },
157 { nvc1_graph_init_gpc_unk_0 },
158 { nvc0_graph_init_setup_0 },
159 { nvc0_graph_init_crstr_0 },
160 { nvc1_graph_init_setup_1 },
161 { nvc0_graph_init_zcull_0 },
162 { nvd9_graph_init_gpm_0 },
163 { nve4_graph_init_gpc_unk_1 },
164 { nvc0_graph_init_gcc_0 },
165 { nve4_graph_init_tpc_0 },
166 { nvd7_graph_init_ppc_0 },
167 { nve4_graph_init_be_0 },
168 { nvc0_graph_init_fe_1 },
172 /*******************************************************************************
173 * PGRAPH engine/subdev functions
174 ******************************************************************************/
177 nve4_graph_init(struct nouveau_object *object)
179 struct nvc0_graph_oclass *oclass = (void *)object->oclass;
180 struct nvc0_graph_priv *priv = (void *)object;
181 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total);
182 u32 data[TPC_MAX / 8] = {};
187 ret = nouveau_graph_init(&priv->base);
191 nv_wr32(priv, GPC_BCAST(0x0880), 0x00000000);
192 nv_wr32(priv, GPC_BCAST(0x08a4), 0x00000000);
193 nv_wr32(priv, GPC_BCAST(0x0888), 0x00000000);
194 nv_wr32(priv, GPC_BCAST(0x088c), 0x00000000);
195 nv_wr32(priv, GPC_BCAST(0x0890), 0x00000000);
196 nv_wr32(priv, GPC_BCAST(0x0894), 0x00000000);
197 nv_wr32(priv, GPC_BCAST(0x08b4), priv->unk4188b4->addr >> 8);
198 nv_wr32(priv, GPC_BCAST(0x08b8), priv->unk4188b8->addr >> 8);
200 nvc0_graph_mmio(priv, oclass->mmio);
202 nv_wr32(priv, GPC_UNIT(0, 0x3018), 0x00000001);
204 memset(data, 0x00, sizeof(data));
205 memcpy(tpcnr, priv->tpc_nr, sizeof(priv->tpc_nr));
206 for (i = 0, gpc = -1; i < priv->tpc_total; i++) {
208 gpc = (gpc + 1) % priv->gpc_nr;
209 } while (!tpcnr[gpc]);
210 tpc = priv->tpc_nr[gpc] - tpcnr[gpc]--;
212 data[i / 8] |= tpc << ((i % 8) * 4);
215 nv_wr32(priv, GPC_BCAST(0x0980), data[0]);
216 nv_wr32(priv, GPC_BCAST(0x0984), data[1]);
217 nv_wr32(priv, GPC_BCAST(0x0988), data[2]);
218 nv_wr32(priv, GPC_BCAST(0x098c), data[3]);
220 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
221 nv_wr32(priv, GPC_UNIT(gpc, 0x0914),
222 priv->magic_not_rop_nr << 8 | priv->tpc_nr[gpc]);
223 nv_wr32(priv, GPC_UNIT(gpc, 0x0910), 0x00040000 |
225 nv_wr32(priv, GPC_UNIT(gpc, 0x0918), magicgpc918);
228 nv_wr32(priv, GPC_BCAST(0x3fd4), magicgpc918);
229 nv_wr32(priv, GPC_BCAST(0x08ac), nv_rd32(priv, 0x100800));
231 nv_wr32(priv, 0x400500, 0x00010001);
233 nv_wr32(priv, 0x400100, 0xffffffff);
234 nv_wr32(priv, 0x40013c, 0xffffffff);
236 nv_wr32(priv, 0x409ffc, 0x00000000);
237 nv_wr32(priv, 0x409c14, 0x00003e3e);
238 nv_wr32(priv, 0x409c24, 0x000f0001);
239 nv_wr32(priv, 0x404000, 0xc0000000);
240 nv_wr32(priv, 0x404600, 0xc0000000);
241 nv_wr32(priv, 0x408030, 0xc0000000);
242 nv_wr32(priv, 0x404490, 0xc0000000);
243 nv_wr32(priv, 0x406018, 0xc0000000);
244 nv_wr32(priv, 0x407020, 0x40000000);
245 nv_wr32(priv, 0x405840, 0xc0000000);
246 nv_wr32(priv, 0x405844, 0x00ffffff);
247 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
248 nv_mask(priv, 0x419eb4, 0x00001000, 0x00001000);
250 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
251 nv_wr32(priv, GPC_UNIT(gpc, 0x3038), 0xc0000000);
252 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000);
253 nv_wr32(priv, GPC_UNIT(gpc, 0x0900), 0xc0000000);
254 nv_wr32(priv, GPC_UNIT(gpc, 0x1028), 0xc0000000);
255 nv_wr32(priv, GPC_UNIT(gpc, 0x0824), 0xc0000000);
256 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
257 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
258 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
259 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
260 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
261 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
262 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x644), 0x001ffffe);
263 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x64c), 0x0000000f);
265 nv_wr32(priv, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
266 nv_wr32(priv, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
269 for (rop = 0; rop < priv->rop_nr; rop++) {
270 nv_wr32(priv, ROP_UNIT(rop, 0x144), 0xc0000000);
271 nv_wr32(priv, ROP_UNIT(rop, 0x070), 0xc0000000);
272 nv_wr32(priv, ROP_UNIT(rop, 0x204), 0xffffffff);
273 nv_wr32(priv, ROP_UNIT(rop, 0x208), 0xffffffff);
276 nv_wr32(priv, 0x400108, 0xffffffff);
277 nv_wr32(priv, 0x400138, 0xffffffff);
278 nv_wr32(priv, 0x400118, 0xffffffff);
279 nv_wr32(priv, 0x400130, 0xffffffff);
280 nv_wr32(priv, 0x40011c, 0xffffffff);
281 nv_wr32(priv, 0x400134, 0xffffffff);
283 nv_wr32(priv, 0x400054, 0x34ce3464);
284 return nvc0_graph_init_ctxctl(priv);
287 #include "fuc/hubnve0.fuc.h"
289 static struct nvc0_graph_ucode
290 nve4_graph_fecs_ucode = {
291 .code.data = nve0_grhub_code,
292 .code.size = sizeof(nve0_grhub_code),
293 .data.data = nve0_grhub_data,
294 .data.size = sizeof(nve0_grhub_data),
297 #include "fuc/gpcnve0.fuc.h"
299 static struct nvc0_graph_ucode
300 nve4_graph_gpccs_ucode = {
301 .code.data = nve0_grgpc_code,
302 .code.size = sizeof(nve0_grgpc_code),
303 .data.data = nve0_grgpc_data,
304 .data.size = sizeof(nve0_grgpc_data),
307 struct nouveau_oclass *
308 nve4_graph_oclass = &(struct nvc0_graph_oclass) {
309 .base.handle = NV_ENGINE(GR, 0xe4),
310 .base.ofuncs = &(struct nouveau_ofuncs) {
311 .ctor = nvc0_graph_ctor,
312 .dtor = nvc0_graph_dtor,
313 .init = nve4_graph_init,
314 .fini = _nouveau_graph_fini,
316 .cclass = &nve4_grctx_oclass,
317 .sclass = nve4_graph_sclass,
318 .mmio = nve4_graph_pack_mmio,
319 .fecs.ucode = &nve4_graph_fecs_ucode,
320 .gpccs.ucode = &nve4_graph_gpccs_ucode,