2 * Copyright 2010 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.
25 #ifndef __NVC0_GRAPH_H__
26 #define __NVC0_GRAPH_H__
28 #include <core/client.h>
29 #include <core/handle.h>
30 #include <core/gpuobj.h>
31 #include <core/option.h>
33 #include <subdev/fb.h>
34 #include <subdev/vm.h>
35 #include <subdev/bar.h>
36 #include <subdev/timer.h>
38 #include <engine/fifo.h>
39 #include <engine/graph.h>
42 #define TPC_MAX (GPC_MAX * 8)
44 #define ROP_BCAST(r) (0x408800 + (r))
45 #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r))
46 #define GPC_BCAST(r) (0x418000 + (r))
47 #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r))
48 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
50 struct nvc0_graph_data {
56 struct nvc0_graph_mmio {
63 struct nvc0_graph_fuc {
68 struct nvc0_graph_priv {
69 struct nouveau_graph base;
71 struct nvc0_graph_fuc fuc409c;
72 struct nvc0_graph_fuc fuc409d;
73 struct nvc0_graph_fuc fuc41ac;
74 struct nvc0_graph_fuc fuc41ad;
82 struct nouveau_gpuobj *unk4188b4;
83 struct nouveau_gpuobj *unk4188b8;
85 struct nvc0_graph_data mmio_data[4];
86 struct nvc0_graph_mmio mmio_list[4096/8];
93 struct nvc0_graph_chan {
94 struct nouveau_graph_chan base;
96 struct nouveau_gpuobj *mmio;
97 struct nouveau_vma mmio_vma;
100 struct nouveau_gpuobj *mem;
101 struct nouveau_vma vma;
105 int nvc0_grctx_generate(struct nvc0_graph_priv *);
107 int nvc0_graph_context_ctor(struct nouveau_object *, struct nouveau_object *,
108 struct nouveau_oclass *, void *, u32,
109 struct nouveau_object **);
110 void nvc0_graph_context_dtor(struct nouveau_object *);
112 void nvc0_graph_ctxctl_debug(struct nvc0_graph_priv *);
114 u64 nvc0_graph_units(struct nouveau_graph *);
115 int nvc0_graph_ctor(struct nouveau_object *, struct nouveau_object *,
116 struct nouveau_oclass *, void *data, u32 size,
117 struct nouveau_object **);
118 void nvc0_graph_dtor(struct nouveau_object *);
119 int nvc0_graph_init(struct nouveau_object *);
120 int nve4_graph_init(struct nouveau_object *);
122 extern struct nouveau_oclass nvc0_graph_sclass[];
124 extern struct nouveau_oclass nvc8_graph_sclass[];
126 struct nvc0_graph_init {
133 struct nvc0_graph_mthd {
135 struct nvc0_graph_init *init;
139 struct nvc0_graph_priv *priv;
140 struct nvc0_graph_data *data;
141 struct nvc0_graph_mmio *mmio;
147 struct nvc0_grctx_oclass {
148 struct nouveau_oclass base;
149 /* main context generation function */
150 void (*main)(struct nvc0_graph_priv *, struct nvc0_grctx *);
151 /* context-specific modify-on-first-load list generation function */
152 void (*mods)(struct nvc0_graph_priv *, struct nvc0_grctx *);
153 void (*unkn)(struct nvc0_graph_priv *);
154 /* mmio context data */
155 struct nvc0_graph_init **hub;
156 struct nvc0_graph_init **gpc;
157 /* indirect context data, generated with icmds/mthds */
158 struct nvc0_graph_init *icmd;
159 struct nvc0_graph_mthd *mthd;
162 struct nvc0_graph_ucode {
163 struct nvc0_graph_fuc code;
164 struct nvc0_graph_fuc data;
167 extern struct nvc0_graph_ucode nvc0_graph_fecs_ucode;
168 extern struct nvc0_graph_ucode nvc0_graph_gpccs_ucode;
170 struct nvc0_graph_oclass {
171 struct nouveau_oclass base;
172 struct nouveau_oclass **cclass;
173 struct nouveau_oclass *sclass;
174 struct nvc0_graph_init **mmio;
176 struct nvc0_graph_ucode *ucode;
179 struct nvc0_graph_ucode *ucode;
183 void nvc0_graph_mmio(struct nvc0_graph_priv *, struct nvc0_graph_init *);
184 void nvc0_graph_icmd(struct nvc0_graph_priv *, struct nvc0_graph_init *);
185 void nvc0_graph_mthd(struct nvc0_graph_priv *, struct nvc0_graph_mthd *);
186 int nvc0_graph_init_ctxctl(struct nvc0_graph_priv *);
188 extern struct nvc0_graph_init nvc0_graph_init_regs[];
189 extern struct nvc0_graph_init nvc0_graph_init_unk40xx[];
190 extern struct nvc0_graph_init nvc0_graph_init_unk44xx[];
191 extern struct nvc0_graph_init nvc0_graph_init_unk78xx[];
192 extern struct nvc0_graph_init nvc0_graph_init_unk60xx[];
193 extern struct nvc0_graph_init nvc0_graph_init_unk58xx[];
194 extern struct nvc0_graph_init nvc0_graph_init_unk80xx[];
195 extern struct nvc0_graph_init nvc0_graph_init_gpc[];
196 extern struct nvc0_graph_init nvc0_graph_init_unk88xx[];
197 extern struct nvc0_graph_init nvc0_graph_tpc_0[];
199 extern struct nvc0_graph_init nvc3_graph_init_unk58xx[];
201 extern struct nvc0_graph_init nvd9_graph_init_unk58xx[];
202 extern struct nvc0_graph_init nvd9_graph_init_unk64xx[];
204 extern struct nvc0_graph_init nve4_graph_init_regs[];
205 extern struct nvc0_graph_init nve4_graph_init_unk[];
206 extern struct nvc0_graph_init nve4_graph_init_unk88xx[];
208 int nvc0_grctx_generate(struct nvc0_graph_priv *);
209 void nvc0_grctx_generate_main(struct nvc0_graph_priv *, struct nvc0_grctx *);
210 void nvc0_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
211 void nvc0_grctx_generate_unkn(struct nvc0_graph_priv *);
212 void nvc0_grctx_generate_tpcid(struct nvc0_graph_priv *);
213 void nvc0_grctx_generate_r406028(struct nvc0_graph_priv *);
214 void nvc0_grctx_generate_r4060a8(struct nvc0_graph_priv *);
215 void nvc0_grctx_generate_r418bb8(struct nvc0_graph_priv *);
216 void nve4_grctx_generate_r418bb8(struct nvc0_graph_priv *);
217 void nvc0_grctx_generate_r406800(struct nvc0_graph_priv *);
219 extern struct nouveau_oclass *nvc0_grctx_oclass;
220 extern struct nvc0_graph_init *nvc0_grctx_init_hub[];
221 extern struct nvc0_graph_init nvc0_grctx_init_base[];
222 extern struct nvc0_graph_init nvc0_grctx_init_unk40xx[];
223 extern struct nvc0_graph_init nvc0_grctx_init_unk44xx[];
224 extern struct nvc0_graph_init nvc0_grctx_init_unk46xx[];
225 extern struct nvc0_graph_init nvc0_grctx_init_unk47xx[];
226 extern struct nvc0_graph_init nvc0_grctx_init_unk60xx[];
227 extern struct nvc0_graph_init nvc0_grctx_init_unk64xx[];
228 extern struct nvc0_graph_init nvc0_grctx_init_unk78xx[];
229 extern struct nvc0_graph_init nvc0_grctx_init_unk80xx[];
230 extern struct nvc0_graph_init nvc0_grctx_init_gpc_0[];
231 extern struct nvc0_graph_init nvc0_grctx_init_gpc_1[];
232 extern struct nvc0_graph_init nvc0_grctx_init_tpc[];
233 extern struct nvc0_graph_init nvc0_grctx_init_icmd[];
234 extern struct nvc0_graph_init nvd9_grctx_init_icmd[]; //
236 extern struct nvc0_graph_mthd nvc0_grctx_init_mthd[];
237 extern struct nvc0_graph_init nvc0_grctx_init_902d[];
238 extern struct nvc0_graph_init nvc0_grctx_init_9039[];
239 extern struct nvc0_graph_init nvc0_grctx_init_90c0[];
240 extern struct nvc0_graph_init nvc0_grctx_init_mthd_magic[];
242 void nvc1_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
243 void nvc1_grctx_generate_unkn(struct nvc0_graph_priv *);
244 extern struct nouveau_oclass *nvc1_grctx_oclass;
245 extern struct nvc0_graph_init nvc1_grctx_init_9097[];
247 extern struct nouveau_oclass *nvc3_grctx_oclass;
249 extern struct nouveau_oclass *nvc8_grctx_oclass;
250 extern struct nvc0_graph_init nvc8_grctx_init_9197[];
251 extern struct nvc0_graph_init nvc8_grctx_init_9297[];
253 extern struct nouveau_oclass *nvd7_grctx_oclass;
255 extern struct nouveau_oclass *nvd9_grctx_oclass;
256 extern struct nvc0_graph_init nvd9_grctx_init_rop[];
257 extern struct nvc0_graph_mthd nvd9_grctx_init_mthd[];
259 void nve4_grctx_generate_main(struct nvc0_graph_priv *, struct nvc0_grctx *);
260 void nve4_grctx_generate_unkn(struct nvc0_graph_priv *);
261 extern struct nouveau_oclass *nve4_grctx_oclass;
262 extern struct nvc0_graph_init nve4_grctx_init_unk46xx[];
263 extern struct nvc0_graph_init nve4_grctx_init_unk47xx[];
264 extern struct nvc0_graph_init nve4_grctx_init_unk58xx[];
265 extern struct nvc0_graph_init nve4_grctx_init_unk80xx[];
266 extern struct nvc0_graph_init nve4_grctx_init_unk90xx[];
268 extern struct nouveau_oclass *nvf0_grctx_oclass;
270 #define mmio_data(s,a,p) do { \
271 info->buffer[info->buffer_nr] = round_up(info->addr, (a)); \
272 info->addr = info->buffer[info->buffer_nr++] + (s); \
273 info->data->size = (s); \
274 info->data->align = (a); \
275 info->data->access = (p); \
279 #define mmio_list(r,d,s,b) do { \
280 info->mmio->addr = (r); \
281 info->mmio->data = (d); \
282 info->mmio->shift = (s); \
283 info->mmio->buffer = (b); \
285 nv_wr32(priv, (r), (d) | ((s) ? (info->buffer[(b)] >> (s)) : 0)); \