1/*
2 * Copyright 2010 Red Hat Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#ifndef __NVC0_GRAPH_H__
26#define __NVC0_GRAPH_H__
27
28#include <core/client.h>
29#include <core/handle.h>
30#include <core/gpuobj.h>
31#include <core/option.h>
32
33#include <subdev/fb.h>
34#include <subdev/vm.h>
35#include <subdev/bar.h>
36#include <subdev/timer.h>
37
38#include <engine/fifo.h>
39#include <engine/graph.h>
40
41#define GPC_MAX 32
42#define TPC_MAX (GPC_MAX * 8)
43
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 PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
49#define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
50
51struct nvc0_graph_data {
52 u32 size;
53 u32 align;
54 u32 access;
55};
56
57struct nvc0_graph_mmio {
58 u32 addr;
59 u32 data;
60 u32 shift;
61 u32 buffer;
62};
63
64struct nvc0_graph_fuc {
65 u32 *data;
66 u32 size;
67};
68
69struct nvc0_graph_priv {
70 struct nouveau_graph base;
71
72 struct nvc0_graph_fuc fuc409c;
73 struct nvc0_graph_fuc fuc409d;
74 struct nvc0_graph_fuc fuc41ac;
75 struct nvc0_graph_fuc fuc41ad;
76 bool firmware;
77
78 u8 rop_nr;
79 u8 gpc_nr;
80 u8 tpc_nr[GPC_MAX];
81 u8 tpc_total;
82
83 struct nouveau_gpuobj *unk4188b4;
84 struct nouveau_gpuobj *unk4188b8;
85
86 struct nvc0_graph_data mmio_data[4];
87 struct nvc0_graph_mmio mmio_list[4096/8];
88 u32 size;
89 u32 *data;
90
91 u8 magic_not_rop_nr;
92};
93
94struct nvc0_graph_chan {
95 struct nouveau_graph_chan base;
96
97 struct nouveau_gpuobj *mmio;
98 struct nouveau_vma mmio_vma;
99 int mmio_nr;
100 struct {
101 struct nouveau_gpuobj *mem;
102 struct nouveau_vma vma;
103 } data[4];
104};
105
106int nvc0_graph_context_ctor(struct nouveau_object *, struct nouveau_object *,
107 struct nouveau_oclass *, void *, u32,
108 struct nouveau_object **);
109void nvc0_graph_context_dtor(struct nouveau_object *);
110
111void nvc0_graph_ctxctl_debug(struct nvc0_graph_priv *);
112
113u64 nvc0_graph_units(struct nouveau_graph *);
114int nvc0_graph_ctor(struct nouveau_object *, struct nouveau_object *,
115 struct nouveau_oclass *, void *data, u32 size,
116 struct nouveau_object **);
117void nvc0_graph_dtor(struct nouveau_object *);
118int nvc0_graph_init(struct nouveau_object *);
119int nve4_graph_fini(struct nouveau_object *, bool);
120int nve4_graph_init(struct nouveau_object *);
121
122extern struct nouveau_oclass nvc0_graph_sclass[];
123
124extern struct nouveau_oclass nvc8_graph_sclass[];
125
126struct nvc0_graph_init {
127 u32 addr;
128 u8 count;
129 u8 pitch;
130 u32 data;
131};
132
133struct nvc0_graph_pack {
134 const struct nvc0_graph_init *init;
135 u32 type;
136};
137
138#define pack_for_each_init(init, pack, head) \
139 for (pack = head; pack && pack->init; pack++) \
140 for (init = pack->init; init && init->count; init++)
141
142struct nvc0_graph_ucode {
143 struct nvc0_graph_fuc code;
144 struct nvc0_graph_fuc data;
145};
146
147extern struct nvc0_graph_ucode nvc0_graph_fecs_ucode;
148extern struct nvc0_graph_ucode nvc0_graph_gpccs_ucode;
149
150struct nvc0_graph_oclass {
151 struct nouveau_oclass base;
152 struct nouveau_oclass **cclass;
153 struct nouveau_oclass *sclass;
154 const struct nvc0_graph_pack *mmio;
155 struct {
156 struct nvc0_graph_ucode *ucode;
157 } fecs;
158 struct {
159 struct nvc0_graph_ucode *ucode;
160 } gpccs;
161};
162
163void nvc0_graph_mmio(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
164void nvc0_graph_icmd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
165void nvc0_graph_mthd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *);
166int nvc0_graph_init_ctxctl(struct nvc0_graph_priv *);
167
168/* register init value lists */
169
170extern const struct nvc0_graph_init nvc0_graph_init_main_0[];
171extern const struct nvc0_graph_init nvc0_graph_init_fe_0[];
172extern const struct nvc0_graph_init nvc0_graph_init_pri_0[];
173extern const struct nvc0_graph_init nvc0_graph_init_rstr2d_0[];
174extern const struct nvc0_graph_init nvc0_graph_init_pd_0[];
175extern const struct nvc0_graph_init nvc0_graph_init_ds_0[];
176extern const struct nvc0_graph_init nvc0_graph_init_scc_0[];
177extern const struct nvc0_graph_init nvc0_graph_init_prop_0[];
178extern const struct nvc0_graph_init nvc0_graph_init_gpc_unk_0[];
179extern const struct nvc0_graph_init nvc0_graph_init_setup_0[];
180extern const struct nvc0_graph_init nvc0_graph_init_crstr_0[];
181extern const struct nvc0_graph_init nvc0_graph_init_setup_1[];
182extern const struct nvc0_graph_init nvc0_graph_init_zcull_0[];
183extern const struct nvc0_graph_init nvc0_graph_init_gpm_0[];
184extern const struct nvc0_graph_init nvc0_graph_init_gpc_unk_1[];
185extern const struct nvc0_graph_init nvc0_graph_init_gcc_0[];
186extern const struct nvc0_graph_init nvc0_graph_init_tpccs_0[];
187extern const struct nvc0_graph_init nvc0_graph_init_tex_0[];
188extern const struct nvc0_graph_init nvc0_graph_init_pe_0[];
189extern const struct nvc0_graph_init nvc0_graph_init_l1c_0[];
190extern const struct nvc0_graph_init nvc0_graph_init_wwdx_0[];
191extern const struct nvc0_graph_init nvc0_graph_init_tpccs_1[];
192extern const struct nvc0_graph_init nvc0_graph_init_mpc_0[];
193extern const struct nvc0_graph_init nvc0_graph_init_be_0[];
194extern const struct nvc0_graph_init nvc0_graph_init_fe_1[];
195extern const struct nvc0_graph_init nvc0_graph_init_pe_1[];
196
197extern const struct nvc0_graph_init nvc4_graph_init_ds_0[];
198extern const struct nvc0_graph_init nvc4_graph_init_tex_0[];
199extern const struct nvc0_graph_init nvc4_graph_init_sm_0[];
200
201extern const struct nvc0_graph_init nvc1_graph_init_gpc_unk_0[];
202extern const struct nvc0_graph_init nvc1_graph_init_setup_1[];
203
204extern const struct nvc0_graph_init nvd9_graph_init_pd_0[];
205extern const struct nvc0_graph_init nvd9_graph_init_ds_0[];
206extern const struct nvc0_graph_init nvd9_graph_init_prop_0[];
207extern const struct nvc0_graph_init nvd9_graph_init_gpm_0[];
208extern const struct nvc0_graph_init nvd9_graph_init_gpc_unk_1[];
209extern const struct nvc0_graph_init nvd9_graph_init_tex_0[];
210extern const struct nvc0_graph_init nvd9_graph_init_sm_0[];
211extern const struct nvc0_graph_init nvd9_graph_init_fe_1[];
212
213extern const struct nvc0_graph_init nvd7_graph_init_pes_0[];
214extern const struct nvc0_graph_init nvd7_graph_init_wwdx_0[];
215extern const struct nvc0_graph_init nvd7_graph_init_cbm_0[];
216
217extern const struct nvc0_graph_init nve4_graph_init_main_0[];
218extern const struct nvc0_graph_init nve4_graph_init_tpccs_0[];
219extern const struct nvc0_graph_init nve4_graph_init_pe_0[];
220extern const struct nvc0_graph_init nve4_graph_init_be_0[];
221extern const struct nvc0_graph_pack nve4_graph_pack_mmio[];
222
223extern const struct nvc0_graph_init nvf0_graph_init_fe_0[];
224extern const struct nvc0_graph_init nvf0_graph_init_sked_0[];
225extern const struct nvc0_graph_init nvf0_graph_init_cwd_0[];
226extern const struct nvc0_graph_init nvf0_graph_init_gpc_unk_1[];
227extern const struct nvc0_graph_init nvf0_graph_init_sm_0[];
228
229extern const struct nvc0_graph_init nv108_graph_init_gpc_unk_0[];
230
231
232#endif
233