1/* $NetBSD: nouveau_engine_graph_nvf0.c,v 1.1.1.1 2014/08/06 12:36:26 riastradh Exp $ */
2
3/*
4 * Copyright 2013 Red Hat Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Ben Skeggs <bskeggs@redhat.com>
25 */
26
27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_graph_nvf0.c,v 1.1.1.1 2014/08/06 12:36:26 riastradh Exp $");
29
30#include "nvc0.h"
31#include "ctxnvc0.h"
32
33/*******************************************************************************
34 * Graphics object classes
35 ******************************************************************************/
36
37static struct nouveau_oclass
38nvf0_graph_sclass[] = {
39 { 0x902d, &nouveau_object_ofuncs },
40 { 0xa140, &nouveau_object_ofuncs },
41 { 0xa197, &nouveau_object_ofuncs },
42 { 0xa1c0, &nouveau_object_ofuncs },
43 {}
44};
45
46/*******************************************************************************
47 * PGRAPH register lists
48 ******************************************************************************/
49
50const struct nvc0_graph_init
51nvf0_graph_init_fe_0[] = {
52 { 0x40415c, 1, 0x04, 0x00000000 },
53 { 0x404170, 1, 0x04, 0x00000000 },
54 { 0x4041b4, 1, 0x04, 0x00000000 },
55 {}
56};
57
58static const struct nvc0_graph_init
59nvf0_graph_init_ds_0[] = {
60 { 0x405844, 1, 0x04, 0x00ffffff },
61 { 0x405850, 1, 0x04, 0x00000000 },
62 { 0x405900, 1, 0x04, 0x0000ff00 },
63 { 0x405908, 1, 0x04, 0x00000000 },
64 { 0x405928, 2, 0x04, 0x00000000 },
65 {}
66};
67
68const struct nvc0_graph_init
69nvf0_graph_init_sked_0[] = {
70 { 0x407010, 1, 0x04, 0x00000000 },
71 { 0x407040, 1, 0x04, 0x80440424 },
72 { 0x407048, 1, 0x04, 0x0000000a },
73 {}
74};
75
76const struct nvc0_graph_init
77nvf0_graph_init_cwd_0[] = {
78 { 0x405b44, 1, 0x04, 0x00000000 },
79 { 0x405b50, 1, 0x04, 0x00000000 },
80 {}
81};
82
83const struct nvc0_graph_init
84nvf0_graph_init_gpc_unk_1[] = {
85 { 0x418d00, 1, 0x04, 0x00000000 },
86 { 0x418d28, 2, 0x04, 0x00000000 },
87 { 0x418f00, 1, 0x04, 0x00000400 },
88 { 0x418f08, 1, 0x04, 0x00000000 },
89 { 0x418f20, 2, 0x04, 0x00000000 },
90 { 0x418e00, 1, 0x04, 0x00000000 },
91 { 0x418e08, 1, 0x04, 0x00000000 },
92 { 0x418e1c, 2, 0x04, 0x00000000 },
93 {}
94};
95
96static const struct nvc0_graph_init
97nvf0_graph_init_tex_0[] = {
98 { 0x419ab0, 1, 0x04, 0x00000000 },
99 { 0x419ac8, 1, 0x04, 0x00000000 },
100 { 0x419ab8, 1, 0x04, 0x000000e7 },
101 { 0x419aec, 1, 0x04, 0x00000000 },
102 { 0x419abc, 2, 0x04, 0x00000000 },
103 { 0x419ab4, 1, 0x04, 0x00000000 },
104 { 0x419aa8, 2, 0x04, 0x00000000 },
105 {}
106};
107
108static const struct nvc0_graph_init
109nvf0_graph_init_l1c_0[] = {
110 { 0x419c98, 1, 0x04, 0x00000000 },
111 { 0x419ca8, 1, 0x04, 0x00000000 },
112 { 0x419cb0, 1, 0x04, 0x01000000 },
113 { 0x419cb4, 1, 0x04, 0x00000000 },
114 { 0x419cb8, 1, 0x04, 0x00b08bea },
115 { 0x419c84, 1, 0x04, 0x00010384 },
116 { 0x419cbc, 1, 0x04, 0x281b3646 },
117 { 0x419cc0, 2, 0x04, 0x00000000 },
118 { 0x419c80, 1, 0x04, 0x00020230 },
119 { 0x419ccc, 2, 0x04, 0x00000000 },
120 {}
121};
122
123const struct nvc0_graph_init
124nvf0_graph_init_sm_0[] = {
125 { 0x419e00, 1, 0x04, 0x00000080 },
126 { 0x419ea0, 1, 0x04, 0x00000000 },
127 { 0x419ee4, 1, 0x04, 0x00000000 },
128 { 0x419ea4, 1, 0x04, 0x00000100 },
129 { 0x419ea8, 1, 0x04, 0x00000000 },
130 { 0x419eb4, 1, 0x04, 0x00000000 },
131 { 0x419ebc, 2, 0x04, 0x00000000 },
132 { 0x419edc, 1, 0x04, 0x00000000 },
133 { 0x419f00, 1, 0x04, 0x00000000 },
134 { 0x419ed0, 1, 0x04, 0x00003234 },
135 { 0x419f74, 1, 0x04, 0x00015555 },
136 { 0x419f80, 4, 0x04, 0x00000000 },
137 {}
138};
139
140static const struct nvc0_graph_pack
141nvf0_graph_pack_mmio[] = {
142 { nve4_graph_init_main_0 },
143 { nvf0_graph_init_fe_0 },
144 { nvc0_graph_init_pri_0 },
145 { nvc0_graph_init_rstr2d_0 },
146 { nvd9_graph_init_pd_0 },
147 { nvf0_graph_init_ds_0 },
148 { nvc0_graph_init_scc_0 },
149 { nvf0_graph_init_sked_0 },
150 { nvf0_graph_init_cwd_0 },
151 { nvd9_graph_init_prop_0 },
152 { nvc1_graph_init_gpc_unk_0 },
153 { nvc0_graph_init_setup_0 },
154 { nvc0_graph_init_crstr_0 },
155 { nvc1_graph_init_setup_1 },
156 { nvc0_graph_init_zcull_0 },
157 { nvd9_graph_init_gpm_0 },
158 { nvf0_graph_init_gpc_unk_1 },
159 { nvc0_graph_init_gcc_0 },
160 { nve4_graph_init_tpccs_0 },
161 { nvf0_graph_init_tex_0 },
162 { nve4_graph_init_pe_0 },
163 { nvf0_graph_init_l1c_0 },
164 { nvc0_graph_init_mpc_0 },
165 { nvf0_graph_init_sm_0 },
166 { nvd7_graph_init_pes_0 },
167 { nvd7_graph_init_wwdx_0 },
168 { nvd7_graph_init_cbm_0 },
169 { nve4_graph_init_be_0 },
170 { nvc0_graph_init_fe_1 },
171 {}
172};
173
174/*******************************************************************************
175 * PGRAPH engine/subdev functions
176 ******************************************************************************/
177
178static int
179nvf0_graph_fini(struct nouveau_object *object, bool suspend)
180{
181 struct nvc0_graph_priv *priv = (void *)object;
182 static const struct {
183 u32 addr;
184 u32 data;
185 } magic[] = {
186 { 0x020520, 0xfffffffc },
187 { 0x020524, 0xfffffffe },
188 { 0x020524, 0xfffffffc },
189 { 0x020524, 0xfffffff8 },
190 { 0x020524, 0xffffffe0 },
191 { 0x020530, 0xfffffffe },
192 { 0x02052c, 0xfffffffa },
193 { 0x02052c, 0xfffffff0 },
194 { 0x02052c, 0xffffffc0 },
195 { 0x02052c, 0xffffff00 },
196 { 0x02052c, 0xfffffc00 },
197 { 0x02052c, 0xfffcfc00 },
198 { 0x02052c, 0xfff0fc00 },
199 { 0x02052c, 0xff80fc00 },
200 { 0x020528, 0xfffffffe },
201 { 0x020528, 0xfffffffc },
202 };
203 int i;
204
205 nv_mask(priv, 0x000200, 0x08001000, 0x00000000);
206 nv_mask(priv, 0x0206b4, 0x00000000, 0x00000000);
207 for (i = 0; i < ARRAY_SIZE(magic); i++) {
208 nv_wr32(priv, magic[i].addr, magic[i].data);
209 nv_wait(priv, magic[i].addr, 0x80000000, 0x00000000);
210 }
211
212 return nouveau_graph_fini(&priv->base, suspend);
213}
214
215#include "fuc/hubnvf0.fuc.h"
216
217static struct nvc0_graph_ucode
218nvf0_graph_fecs_ucode = {
219 .code.data = nvf0_grhub_code,
220 .code.size = sizeof(nvf0_grhub_code),
221 .data.data = nvf0_grhub_data,
222 .data.size = sizeof(nvf0_grhub_data),
223};
224
225#include "fuc/gpcnvf0.fuc.h"
226
227static struct nvc0_graph_ucode
228nvf0_graph_gpccs_ucode = {
229 .code.data = nvf0_grgpc_code,
230 .code.size = sizeof(nvf0_grgpc_code),
231 .data.data = nvf0_grgpc_data,
232 .data.size = sizeof(nvf0_grgpc_data),
233};
234
235struct nouveau_oclass *
236nvf0_graph_oclass = &(struct nvc0_graph_oclass) {
237 .base.handle = NV_ENGINE(GR, 0xf0),
238 .base.ofuncs = &(struct nouveau_ofuncs) {
239 .ctor = nvc0_graph_ctor,
240 .dtor = nvc0_graph_dtor,
241 .init = nve4_graph_init,
242 .fini = nvf0_graph_fini,
243 },
244 .cclass = &nvf0_grctx_oclass,
245 .sclass = nvf0_graph_sclass,
246 .mmio = nvf0_graph_pack_mmio,
247 .fecs.ucode = &nvf0_graph_fecs_ucode,
248 .gpccs.ucode = &nvf0_graph_gpccs_ucode,
249}.base;
250