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>
25 #include <subdev/pwr.h>
30 /*******************************************************************************
31 * Graphics object classes
32 ******************************************************************************/
34 static struct nouveau_oclass
35 nve4_graph_sclass[] = {
36 { 0x902d, &nouveau_object_ofuncs },
37 { 0xa040, &nouveau_object_ofuncs },
38 { 0xa097, &nouveau_object_ofuncs },
39 { 0xa0c0, &nouveau_object_ofuncs },
43 /*******************************************************************************
44 * PGRAPH register lists
45 ******************************************************************************/
47 const struct nvc0_graph_init
48 nve4_graph_init_main_0[] = {
49 { 0x400080, 1, 0x04, 0x003083c2 },
50 { 0x400088, 1, 0x04, 0x0001ffe7 },
51 { 0x40008c, 1, 0x04, 0x00000000 },
52 { 0x400090, 1, 0x04, 0x00000030 },
53 { 0x40013c, 1, 0x04, 0x003901f7 },
54 { 0x400140, 1, 0x04, 0x00000100 },
55 { 0x400144, 1, 0x04, 0x00000000 },
56 { 0x400148, 1, 0x04, 0x00000110 },
57 { 0x400138, 1, 0x04, 0x00000000 },
58 { 0x400130, 2, 0x04, 0x00000000 },
59 { 0x400124, 1, 0x04, 0x00000002 },
63 static const struct nvc0_graph_init
64 nve4_graph_init_ds_0[] = {
65 { 0x405844, 1, 0x04, 0x00ffffff },
66 { 0x405850, 1, 0x04, 0x00000000 },
67 { 0x405900, 1, 0x04, 0x0000ff34 },
68 { 0x405908, 1, 0x04, 0x00000000 },
69 { 0x405928, 2, 0x04, 0x00000000 },
73 static const struct nvc0_graph_init
74 nve4_graph_init_sked_0[] = {
75 { 0x407010, 1, 0x04, 0x00000000 },
79 static const struct nvc0_graph_init
80 nve4_graph_init_cwd_0[] = {
81 { 0x405b50, 1, 0x04, 0x00000000 },
85 static const struct nvc0_graph_init
86 nve4_graph_init_gpc_unk_1[] = {
87 { 0x418d00, 1, 0x04, 0x00000000 },
88 { 0x418d28, 2, 0x04, 0x00000000 },
89 { 0x418f00, 1, 0x04, 0x00000000 },
90 { 0x418f08, 1, 0x04, 0x00000000 },
91 { 0x418f20, 2, 0x04, 0x00000000 },
92 { 0x418e00, 1, 0x04, 0x00000060 },
93 { 0x418e08, 1, 0x04, 0x00000000 },
94 { 0x418e1c, 2, 0x04, 0x00000000 },
98 const struct nvc0_graph_init
99 nve4_graph_init_tpccs_0[] = {
100 { 0x419d0c, 1, 0x04, 0x00000000 },
101 { 0x419d10, 1, 0x04, 0x00000014 },
105 const struct nvc0_graph_init
106 nve4_graph_init_pe_0[] = {
107 { 0x41980c, 1, 0x04, 0x00000010 },
108 { 0x419844, 1, 0x04, 0x00000000 },
109 { 0x419850, 1, 0x04, 0x00000004 },
110 { 0x419854, 2, 0x04, 0x00000000 },
114 static const struct nvc0_graph_init
115 nve4_graph_init_l1c_0[] = {
116 { 0x419c98, 1, 0x04, 0x00000000 },
117 { 0x419ca8, 1, 0x04, 0x00000000 },
118 { 0x419cb0, 1, 0x04, 0x01000000 },
119 { 0x419cb4, 1, 0x04, 0x00000000 },
120 { 0x419cb8, 1, 0x04, 0x00b08bea },
121 { 0x419c84, 1, 0x04, 0x00010384 },
122 { 0x419cbc, 1, 0x04, 0x28137646 },
123 { 0x419cc0, 2, 0x04, 0x00000000 },
124 { 0x419c80, 1, 0x04, 0x00020232 },
128 static const struct nvc0_graph_init
129 nve4_graph_init_sm_0[] = {
130 { 0x419e00, 1, 0x04, 0x00000000 },
131 { 0x419ea0, 1, 0x04, 0x00000000 },
132 { 0x419ee4, 1, 0x04, 0x00000000 },
133 { 0x419ea4, 1, 0x04, 0x00000100 },
134 { 0x419ea8, 1, 0x04, 0x00000000 },
135 { 0x419eb4, 4, 0x04, 0x00000000 },
136 { 0x419edc, 1, 0x04, 0x00000000 },
137 { 0x419f00, 1, 0x04, 0x00000000 },
138 { 0x419f74, 1, 0x04, 0x00000555 },
142 const struct nvc0_graph_init
143 nve4_graph_init_be_0[] = {
144 { 0x40880c, 1, 0x04, 0x00000000 },
145 { 0x408850, 1, 0x04, 0x00000004 },
146 { 0x408910, 9, 0x04, 0x00000000 },
147 { 0x408950, 1, 0x04, 0x00000000 },
148 { 0x408954, 1, 0x04, 0x0000ffff },
149 { 0x408958, 1, 0x04, 0x00000034 },
150 { 0x408984, 1, 0x04, 0x00000000 },
151 { 0x408988, 1, 0x04, 0x08040201 },
152 { 0x40898c, 1, 0x04, 0x80402010 },
156 const struct nvc0_graph_pack
157 nve4_graph_pack_mmio[] = {
158 { nve4_graph_init_main_0 },
159 { nvc0_graph_init_fe_0 },
160 { nvc0_graph_init_pri_0 },
161 { nvc0_graph_init_rstr2d_0 },
162 { nvd9_graph_init_pd_0 },
163 { nve4_graph_init_ds_0 },
164 { nvc0_graph_init_scc_0 },
165 { nve4_graph_init_sked_0 },
166 { nve4_graph_init_cwd_0 },
167 { nvd9_graph_init_prop_0 },
168 { nvc1_graph_init_gpc_unk_0 },
169 { nvc0_graph_init_setup_0 },
170 { nvc0_graph_init_crstr_0 },
171 { nvc1_graph_init_setup_1 },
172 { nvc0_graph_init_zcull_0 },
173 { nvd9_graph_init_gpm_0 },
174 { nve4_graph_init_gpc_unk_1 },
175 { nvc0_graph_init_gcc_0 },
176 { nve4_graph_init_tpccs_0 },
177 { nvd9_graph_init_tex_0 },
178 { nve4_graph_init_pe_0 },
179 { nve4_graph_init_l1c_0 },
180 { nvc0_graph_init_mpc_0 },
181 { nve4_graph_init_sm_0 },
182 { nvd7_graph_init_pes_0 },
183 { nvd7_graph_init_wwdx_0 },
184 { nvd7_graph_init_cbm_0 },
185 { nve4_graph_init_be_0 },
186 { nvc0_graph_init_fe_1 },
190 /*******************************************************************************
191 * PGRAPH engine/subdev functions
192 ******************************************************************************/
195 nve4_graph_init(struct nouveau_object *object)
197 struct nvc0_graph_oclass *oclass = (void *)object->oclass;
198 struct nvc0_graph_priv *priv = (void *)object;
199 struct nouveau_pwr *ppwr = nouveau_pwr(priv);
200 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total);
201 u32 data[TPC_MAX / 8] = {};
207 ppwr->pgob(ppwr, false);
209 ret = nouveau_graph_init(&priv->base);
213 nv_wr32(priv, GPC_BCAST(0x0880), 0x00000000);
214 nv_wr32(priv, GPC_BCAST(0x08a4), 0x00000000);
215 nv_wr32(priv, GPC_BCAST(0x0888), 0x00000000);
216 nv_wr32(priv, GPC_BCAST(0x088c), 0x00000000);
217 nv_wr32(priv, GPC_BCAST(0x0890), 0x00000000);
218 nv_wr32(priv, GPC_BCAST(0x0894), 0x00000000);
219 nv_wr32(priv, GPC_BCAST(0x08b4), priv->unk4188b4->addr >> 8);
220 nv_wr32(priv, GPC_BCAST(0x08b8), priv->unk4188b8->addr >> 8);
222 nvc0_graph_mmio(priv, oclass->mmio);
224 nv_wr32(priv, GPC_UNIT(0, 0x3018), 0x00000001);
226 memset(data, 0x00, sizeof(data));
227 memcpy(tpcnr, priv->tpc_nr, sizeof(priv->tpc_nr));
228 for (i = 0, gpc = -1; i < priv->tpc_total; i++) {
230 gpc = (gpc + 1) % priv->gpc_nr;
231 } while (!tpcnr[gpc]);
232 tpc = priv->tpc_nr[gpc] - tpcnr[gpc]--;
234 data[i / 8] |= tpc << ((i % 8) * 4);
237 nv_wr32(priv, GPC_BCAST(0x0980), data[0]);
238 nv_wr32(priv, GPC_BCAST(0x0984), data[1]);
239 nv_wr32(priv, GPC_BCAST(0x0988), data[2]);
240 nv_wr32(priv, GPC_BCAST(0x098c), data[3]);
242 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
243 nv_wr32(priv, GPC_UNIT(gpc, 0x0914),
244 priv->magic_not_rop_nr << 8 | priv->tpc_nr[gpc]);
245 nv_wr32(priv, GPC_UNIT(gpc, 0x0910), 0x00040000 |
247 nv_wr32(priv, GPC_UNIT(gpc, 0x0918), magicgpc918);
250 nv_wr32(priv, GPC_BCAST(0x3fd4), magicgpc918);
251 nv_wr32(priv, GPC_BCAST(0x08ac), nv_rd32(priv, 0x100800));
253 nv_wr32(priv, 0x400500, 0x00010001);
255 nv_wr32(priv, 0x400100, 0xffffffff);
256 nv_wr32(priv, 0x40013c, 0xffffffff);
258 nv_wr32(priv, 0x409ffc, 0x00000000);
259 nv_wr32(priv, 0x409c14, 0x00003e3e);
260 nv_wr32(priv, 0x409c24, 0x000f0001);
261 nv_wr32(priv, 0x404000, 0xc0000000);
262 nv_wr32(priv, 0x404600, 0xc0000000);
263 nv_wr32(priv, 0x408030, 0xc0000000);
264 nv_wr32(priv, 0x404490, 0xc0000000);
265 nv_wr32(priv, 0x406018, 0xc0000000);
266 nv_wr32(priv, 0x407020, 0x40000000);
267 nv_wr32(priv, 0x405840, 0xc0000000);
268 nv_wr32(priv, 0x405844, 0x00ffffff);
269 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
270 nv_mask(priv, 0x419eb4, 0x00001000, 0x00001000);
272 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
273 nv_wr32(priv, GPC_UNIT(gpc, 0x3038), 0xc0000000);
274 nv_wr32(priv, GPC_UNIT(gpc, 0x0420), 0xc0000000);
275 nv_wr32(priv, GPC_UNIT(gpc, 0x0900), 0xc0000000);
276 nv_wr32(priv, GPC_UNIT(gpc, 0x1028), 0xc0000000);
277 nv_wr32(priv, GPC_UNIT(gpc, 0x0824), 0xc0000000);
278 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
279 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
280 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
281 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
282 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
283 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
284 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x644), 0x001ffffe);
285 nv_wr32(priv, TPC_UNIT(gpc, tpc, 0x64c), 0x0000000f);
287 nv_wr32(priv, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
288 nv_wr32(priv, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
291 for (rop = 0; rop < priv->rop_nr; rop++) {
292 nv_wr32(priv, ROP_UNIT(rop, 0x144), 0xc0000000);
293 nv_wr32(priv, ROP_UNIT(rop, 0x070), 0xc0000000);
294 nv_wr32(priv, ROP_UNIT(rop, 0x204), 0xffffffff);
295 nv_wr32(priv, ROP_UNIT(rop, 0x208), 0xffffffff);
298 nv_wr32(priv, 0x400108, 0xffffffff);
299 nv_wr32(priv, 0x400138, 0xffffffff);
300 nv_wr32(priv, 0x400118, 0xffffffff);
301 nv_wr32(priv, 0x400130, 0xffffffff);
302 nv_wr32(priv, 0x40011c, 0xffffffff);
303 nv_wr32(priv, 0x400134, 0xffffffff);
305 nv_wr32(priv, 0x400054, 0x34ce3464);
306 return nvc0_graph_init_ctxctl(priv);
309 #include "fuc/hubnve0.fuc.h"
311 static struct nvc0_graph_ucode
312 nve4_graph_fecs_ucode = {
313 .code.data = nve0_grhub_code,
314 .code.size = sizeof(nve0_grhub_code),
315 .data.data = nve0_grhub_data,
316 .data.size = sizeof(nve0_grhub_data),
319 #include "fuc/gpcnve0.fuc.h"
321 static struct nvc0_graph_ucode
322 nve4_graph_gpccs_ucode = {
323 .code.data = nve0_grgpc_code,
324 .code.size = sizeof(nve0_grgpc_code),
325 .data.data = nve0_grgpc_data,
326 .data.size = sizeof(nve0_grgpc_data),
329 struct nouveau_oclass *
330 nve4_graph_oclass = &(struct nvc0_graph_oclass) {
331 .base.handle = NV_ENGINE(GR, 0xe4),
332 .base.ofuncs = &(struct nouveau_ofuncs) {
333 .ctor = nvc0_graph_ctor,
334 .dtor = nvc0_graph_dtor,
335 .init = nve4_graph_init,
336 .fini = _nouveau_graph_fini,
338 .cclass = &nve4_grctx_oclass,
339 .sclass = nve4_graph_sclass,
340 .mmio = nve4_graph_pack_mmio,
341 .fecs.ucode = &nve4_graph_fecs_ucode,
342 .gpccs.ucode = &nve4_graph_gpccs_ucode,