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 const struct nvc0_graph_init
97 nve4_graph_init_tpccs_0[] = {
98 { 0x419d0c, 1, 0x04, 0x00000000 },
99 { 0x419d10, 1, 0x04, 0x00000014 },
103 const struct nvc0_graph_init
104 nve4_graph_init_pe_0[] = {
105 { 0x41980c, 1, 0x04, 0x00000010 },
106 { 0x419844, 1, 0x04, 0x00000000 },
107 { 0x419850, 1, 0x04, 0x00000004 },
108 { 0x419854, 2, 0x04, 0x00000000 },
112 static const struct nvc0_graph_init
113 nve4_graph_init_l1c_0[] = {
114 { 0x419c98, 1, 0x04, 0x00000000 },
115 { 0x419ca8, 1, 0x04, 0x00000000 },
116 { 0x419cb0, 1, 0x04, 0x01000000 },
117 { 0x419cb4, 1, 0x04, 0x00000000 },
118 { 0x419cb8, 1, 0x04, 0x00b08bea },
119 { 0x419c84, 1, 0x04, 0x00010384 },
120 { 0x419cbc, 1, 0x04, 0x28137646 },
121 { 0x419cc0, 2, 0x04, 0x00000000 },
122 { 0x419c80, 1, 0x04, 0x00020232 },
126 static const struct nvc0_graph_init
127 nve4_graph_init_sm_0[] = {
128 { 0x419e00, 1, 0x04, 0x00000000 },
129 { 0x419ea0, 1, 0x04, 0x00000000 },
130 { 0x419ee4, 1, 0x04, 0x00000000 },
131 { 0x419ea4, 1, 0x04, 0x00000100 },
132 { 0x419ea8, 1, 0x04, 0x00000000 },
133 { 0x419eb4, 4, 0x04, 0x00000000 },
134 { 0x419edc, 1, 0x04, 0x00000000 },
135 { 0x419f00, 1, 0x04, 0x00000000 },
136 { 0x419f74, 1, 0x04, 0x00000555 },
140 const struct nvc0_graph_init
141 nve4_graph_init_be_0[] = {
142 { 0x40880c, 1, 0x04, 0x00000000 },
143 { 0x408850, 1, 0x04, 0x00000004 },
144 { 0x408910, 9, 0x04, 0x00000000 },
145 { 0x408950, 1, 0x04, 0x00000000 },
146 { 0x408954, 1, 0x04, 0x0000ffff },
147 { 0x408958, 1, 0x04, 0x00000034 },
148 { 0x408984, 1, 0x04, 0x00000000 },
149 { 0x408988, 1, 0x04, 0x08040201 },
150 { 0x40898c, 1, 0x04, 0x80402010 },
154 static const struct nvc0_graph_pack
155 nve4_graph_pack_mmio[] = {
156 { nve4_graph_init_main_0 },
157 { nvc0_graph_init_fe_0 },
158 { nvc0_graph_init_pri_0 },
159 { nvc0_graph_init_rstr2d_0 },
160 { nvd9_graph_init_pd_0 },
161 { nve4_graph_init_ds_0 },
162 { nvc0_graph_init_scc_0 },
163 { nve4_graph_init_sked_0 },
164 { nve4_graph_init_cwd_0 },
165 { nvd9_graph_init_prop_0 },
166 { nvc1_graph_init_gpc_unk_0 },
167 { nvc0_graph_init_setup_0 },
168 { nvc0_graph_init_crstr_0 },
169 { nvc1_graph_init_setup_1 },
170 { nvc0_graph_init_zcull_0 },
171 { nvd9_graph_init_gpm_0 },
172 { nve4_graph_init_gpc_unk_1 },
173 { nvc0_graph_init_gcc_0 },
174 { nve4_graph_init_tpccs_0 },
175 { nvd9_graph_init_tex_0 },
176 { nve4_graph_init_pe_0 },
177 { nve4_graph_init_l1c_0 },
178 { nvc0_graph_init_mpc_0 },
179 { nve4_graph_init_sm_0 },
180 { nvd7_graph_init_ppc_0 },
181 { nve4_graph_init_be_0 },
182 { nvc0_graph_init_fe_1 },
186 /*******************************************************************************
187 * PGRAPH engine/subdev functions
188 ******************************************************************************/
191 nve4_graph_init(struct nouveau_object *object)
193 struct nvc0_graph_oclass *oclass = (void *)object->oclass;
194 struct nvc0_graph_priv *priv = (void *)object;
195 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total);
196 u32 data[TPC_MAX / 8] = {};
201 ret = nouveau_graph_init(&priv->base);
205 nv_wr32(priv, GPC_BCAST(0x0880), 0x00000000);
206 nv_wr32(priv, GPC_BCAST(0x08a4), 0x00000000);
207 nv_wr32(priv, GPC_BCAST(0x0888), 0x00000000);
208 nv_wr32(priv, GPC_BCAST(0x088c), 0x00000000);
209 nv_wr32(priv, GPC_BCAST(0x0890), 0x00000000);
210 nv_wr32(priv, GPC_BCAST(0x0894), 0x00000000);
211 nv_wr32(priv, GPC_BCAST(0x08b4), priv->unk4188b4->addr >> 8);
212 nv_wr32(priv, GPC_BCAST(0x08b8), priv->unk4188b8->addr >> 8);
214 nvc0_graph_mmio(priv, oclass->mmio);
216 nv_wr32(priv, GPC_UNIT(0, 0x3018), 0x00000001);
218 memset(data, 0x00, sizeof(data));
219 memcpy(tpcnr, priv->tpc_nr, sizeof(priv->tpc_nr));
220 for (i = 0, gpc = -1; i < priv->tpc_total; i++) {
222 gpc = (gpc + 1) % priv->gpc_nr;
223 } while (!tpcnr[gpc]);
224 tpc = priv->tpc_nr[gpc] - tpcnr[gpc]--;
226 data[i / 8] |= tpc << ((i % 8) * 4);
229 nv_wr32(priv, GPC_BCAST(0x0980), data[0]);
230 nv_wr32(priv, GPC_BCAST(0x0984), data[1]);
231 nv_wr32(priv, GPC_BCAST(0x0988), data[2]);
232 nv_wr32(priv, GPC_BCAST(0x098c), data[3]);
234 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
235 nv_wr32(priv, GPC_UNIT(gpc, 0x0914),
236 priv->magic_not_rop_nr << 8 | priv->tpc_nr[gpc]);
237 nv_wr32(priv, GPC_UNIT(gpc, 0x0910), 0x00040000 |
239 nv_wr32(priv, GPC_UNIT(gpc, 0x0918), magicgpc918);
242 nv_wr32(priv, GPC_BCAST(0x3fd4), magicgpc918);
243 nv_wr32(priv, GPC_BCAST(0x08ac), nv_rd32(priv, 0x100800));
245 nv_wr32(priv, 0x400500, 0x00010001);
247 nv_wr32(priv, 0x400100, 0xffffffff);
248 nv_wr32(priv, 0x40013c, 0xffffffff);
250 nv_wr32(priv, 0x409ffc, 0x00000000);
251 nv_wr32(priv, 0x409c14, 0x00003e3e);
252 nv_wr32(priv, 0x409c24, 0x000f0001);
253 nv_wr32(priv, 0x404000, 0xc0000000);
254 nv_wr32(priv, 0x404600, 0xc0000000);
255 nv_wr32(priv, 0x408030, 0xc0000000);
256 nv_wr32(priv, 0x404490, 0xc0000000);
257 nv_wr32(priv, 0x406018, 0xc0000000);
258 nv_wr32(priv, 0x407020, 0x40000000);
259 nv_wr32(priv, 0x405840, 0xc0000000);
260 nv_wr32(priv, 0x405844, 0x00ffffff);
261 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
262 nv_mask(priv, 0x419eb4, 0x00001000, 0x00001000);
264 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
265 nv_wr32(priv, GPC_UNIT(gpc, 0x3038), 0xc0000000);
266 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000);
267 nv_wr32(priv, GPC_UNIT(gpc, 0x0900), 0xc0000000);
268 nv_wr32(priv, GPC_UNIT(gpc, 0x1028), 0xc0000000);
269 nv_wr32(priv, GPC_UNIT(gpc, 0x0824), 0xc0000000);
270 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
271 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
272 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
273 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
274 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
275 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
276 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x644), 0x001ffffe);
277 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x64c), 0x0000000f);
279 nv_wr32(priv, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
280 nv_wr32(priv, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
283 for (rop = 0; rop < priv->rop_nr; rop++) {
284 nv_wr32(priv, ROP_UNIT(rop, 0x144), 0xc0000000);
285 nv_wr32(priv, ROP_UNIT(rop, 0x070), 0xc0000000);
286 nv_wr32(priv, ROP_UNIT(rop, 0x204), 0xffffffff);
287 nv_wr32(priv, ROP_UNIT(rop, 0x208), 0xffffffff);
290 nv_wr32(priv, 0x400108, 0xffffffff);
291 nv_wr32(priv, 0x400138, 0xffffffff);
292 nv_wr32(priv, 0x400118, 0xffffffff);
293 nv_wr32(priv, 0x400130, 0xffffffff);
294 nv_wr32(priv, 0x40011c, 0xffffffff);
295 nv_wr32(priv, 0x400134, 0xffffffff);
297 nv_wr32(priv, 0x400054, 0x34ce3464);
298 return nvc0_graph_init_ctxctl(priv);
301 #include "fuc/hubnve0.fuc.h"
303 static struct nvc0_graph_ucode
304 nve4_graph_fecs_ucode = {
305 .code.data = nve0_grhub_code,
306 .code.size = sizeof(nve0_grhub_code),
307 .data.data = nve0_grhub_data,
308 .data.size = sizeof(nve0_grhub_data),
311 #include "fuc/gpcnve0.fuc.h"
313 static struct nvc0_graph_ucode
314 nve4_graph_gpccs_ucode = {
315 .code.data = nve0_grgpc_code,
316 .code.size = sizeof(nve0_grgpc_code),
317 .data.data = nve0_grgpc_data,
318 .data.size = sizeof(nve0_grgpc_data),
321 struct nouveau_oclass *
322 nve4_graph_oclass = &(struct nvc0_graph_oclass) {
323 .base.handle = NV_ENGINE(GR, 0xe4),
324 .base.ofuncs = &(struct nouveau_ofuncs) {
325 .ctor = nvc0_graph_ctor,
326 .dtor = nvc0_graph_dtor,
327 .init = nve4_graph_init,
328 .fini = _nouveau_graph_fini,
330 .cclass = &nve4_grctx_oclass,
331 .sclass = nve4_graph_sclass,
332 .mmio = nve4_graph_pack_mmio,
333 .fecs.ucode = &nve4_graph_fecs_ucode,
334 .gpccs.ucode = &nve4_graph_gpccs_ucode,