]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
81bdf658b5cddd2df71adffaf9a69da146d4a13e
[linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / gr / gf100.h
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 #ifndef __GF100_GR_H__
25 #define __GF100_GR_H__
26 #define gf100_gr(p) container_of((p), struct gf100_gr, base)
27 #include "priv.h"
28
29 #include <core/gpuobj.h>
30 #include <subdev/ltc.h>
31 #include <subdev/mmu.h>
32 #include <engine/falcon.h>
33
34 #define GPC_MAX 32
35 #define TPC_MAX_PER_GPC 8
36 #define TPC_MAX (GPC_MAX * TPC_MAX_PER_GPC)
37
38 #define ROP_BCAST(r)      (0x408800 + (r))
39 #define ROP_UNIT(u, r)    (0x410000 + (u) * 0x400 + (r))
40 #define GPC_BCAST(r)      (0x418000 + (r))
41 #define GPC_UNIT(t, r)    (0x500000 + (t) * 0x8000 + (r))
42 #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r))
43 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r))
44
45 struct gf100_gr_data {
46         u32 size;
47         u32 align;
48         bool priv;
49 };
50
51 struct gf100_gr_mmio {
52         u32 addr;
53         u32 data;
54         u32 shift;
55         int buffer;
56 };
57
58 struct gf100_gr_fuc {
59         u32 *data;
60         u32  size;
61 };
62
63 struct gf100_gr_zbc_color {
64         u32 format;
65         u32 ds[4];
66         u32 l2[4];
67 };
68
69 struct gf100_gr_zbc_depth {
70         u32 format;
71         u32 ds;
72         u32 l2;
73 };
74
75 struct gf100_gr_zbc_stencil {
76         u32 format;
77         u32 ds;
78         u32 l2;
79 };
80
81 struct gf100_gr {
82         const struct gf100_gr_func *func;
83         struct nvkm_gr base;
84
85         struct nvkm_falcon *fecs;
86         struct nvkm_falcon *gpccs;
87         struct gf100_gr_fuc fuc409c;
88         struct gf100_gr_fuc fuc409d;
89         struct gf100_gr_fuc fuc41ac;
90         struct gf100_gr_fuc fuc41ad;
91         bool firmware;
92
93         /*
94          * Used if the register packs are loaded from NVIDIA fw instead of
95          * using hardcoded arrays. To be allocated with vzalloc().
96          */
97         struct gf100_gr_pack *fuc_sw_nonctx;
98         struct gf100_gr_pack *fuc_sw_ctx;
99         struct gf100_gr_pack *fuc_bundle;
100         struct gf100_gr_pack *fuc_method;
101
102         struct gf100_gr_zbc_color zbc_color[NVKM_LTC_MAX_ZBC_CNT];
103         struct gf100_gr_zbc_depth zbc_depth[NVKM_LTC_MAX_ZBC_CNT];
104         struct gf100_gr_zbc_stencil zbc_stencil[NVKM_LTC_MAX_ZBC_CNT];
105
106         u8 rop_nr;
107         u8 gpc_nr;
108         u8 tpc_nr[GPC_MAX];
109         u8 tpc_max;
110         u8 tpc_total;
111         u8 ppc_nr[GPC_MAX];
112         u8 ppc_mask[GPC_MAX];
113         u8 ppc_tpc_mask[GPC_MAX][4];
114         u8 ppc_tpc_nr[GPC_MAX][4];
115         u8 ppc_tpc_min;
116         u8 ppc_tpc_max;
117
118         u8 screen_tile_row_offset;
119         u8 tile[TPC_MAX];
120
121         struct {
122                 u8 gpc;
123                 u8 tpc;
124         } sm[TPC_MAX];
125         u8 sm_nr;
126
127         struct gf100_gr_data mmio_data[4];
128         struct gf100_gr_mmio mmio_list[4096/8];
129         u32  size;
130         u32 *data;
131         u32 size_zcull;
132 };
133
134 int gf100_gr_ctor(const struct gf100_gr_func *, struct nvkm_device *,
135                   int, struct gf100_gr *);
136 int gf100_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
137                   int, struct nvkm_gr **);
138 void *gf100_gr_dtor(struct nvkm_gr *);
139
140 struct gf100_gr_func_zbc {
141         void (*clear_color)(struct gf100_gr *, int zbc);
142         void (*clear_depth)(struct gf100_gr *, int zbc);
143         int (*stencil_get)(struct gf100_gr *, int format,
144                            const u32 ds, const u32 l2);
145         void (*clear_stencil)(struct gf100_gr *, int zbc);
146 };
147
148 struct gf100_gr_func {
149         void (*dtor)(struct gf100_gr *);
150         void (*oneinit_tiles)(struct gf100_gr *);
151         void (*oneinit_sm_id)(struct gf100_gr *);
152         int (*init)(struct gf100_gr *);
153         void (*init_419bd8)(struct gf100_gr *);
154         void (*init_gpc_mmu)(struct gf100_gr *);
155         void (*init_r405a14)(struct gf100_gr *);
156         void (*init_bios)(struct gf100_gr *);
157         void (*init_vsc_stream_master)(struct gf100_gr *);
158         void (*init_zcull)(struct gf100_gr *);
159         void (*init_num_active_ltcs)(struct gf100_gr *);
160         void (*init_rop_active_fbps)(struct gf100_gr *);
161         void (*init_bios_2)(struct gf100_gr *);
162         void (*init_swdx_pes_mask)(struct gf100_gr *);
163         void (*init_fecs_exceptions)(struct gf100_gr *);
164         void (*init_ds_hww_esr_2)(struct gf100_gr *);
165         void (*init_40601c)(struct gf100_gr *);
166         void (*init_sked_hww_esr)(struct gf100_gr *);
167         void (*init_419cc0)(struct gf100_gr *);
168         void (*init_419eb4)(struct gf100_gr *);
169         void (*init_419c9c)(struct gf100_gr *);
170         void (*init_ppc_exceptions)(struct gf100_gr *);
171         void (*init_tex_hww_esr)(struct gf100_gr *, int gpc, int tpc);
172         void (*init_504430)(struct gf100_gr *, int gpc, int tpc);
173         void (*init_shader_exceptions)(struct gf100_gr *, int gpc, int tpc);
174         void (*init_400054)(struct gf100_gr *);
175         void (*init_4188a4)(struct gf100_gr *);
176         void (*trap_mp)(struct gf100_gr *, int gpc, int tpc);
177         void (*set_hww_esr_report_mask)(struct gf100_gr *);
178         const struct gf100_gr_pack *mmio;
179         struct {
180                 struct gf100_gr_ucode *ucode;
181         } fecs;
182         struct {
183                 struct gf100_gr_ucode *ucode;
184         } gpccs;
185         int (*rops)(struct gf100_gr *);
186         int gpc_nr;
187         int tpc_nr;
188         int ppc_nr;
189         const struct gf100_grctx_func *grctx;
190         const struct nvkm_therm_clkgate_pack *clkgate_pack;
191         const struct gf100_gr_func_zbc *zbc;
192         struct nvkm_sclass sclass[];
193 };
194
195 int gf100_gr_rops(struct gf100_gr *);
196 void gf100_gr_oneinit_tiles(struct gf100_gr *);
197 void gf100_gr_oneinit_sm_id(struct gf100_gr *);
198 int gf100_gr_init(struct gf100_gr *);
199 void gf100_gr_init_vsc_stream_master(struct gf100_gr *);
200 void gf100_gr_init_zcull(struct gf100_gr *);
201 void gf100_gr_init_num_active_ltcs(struct gf100_gr *);
202 void gf100_gr_init_fecs_exceptions(struct gf100_gr *);
203 void gf100_gr_init_40601c(struct gf100_gr *);
204 void gf100_gr_init_419cc0(struct gf100_gr *);
205 void gf100_gr_init_419eb4(struct gf100_gr *);
206 void gf100_gr_init_tex_hww_esr(struct gf100_gr *, int, int);
207 void gf100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
208 void gf100_gr_init_400054(struct gf100_gr *);
209 extern const struct gf100_gr_func_zbc gf100_gr_zbc;
210
211 void gf117_gr_init_zcull(struct gf100_gr *);
212
213 void gk104_gr_init_vsc_stream_master(struct gf100_gr *);
214 void gk104_gr_init_rop_active_fbps(struct gf100_gr *);
215 void gk104_gr_init_ppc_exceptions(struct gf100_gr *);
216 void gk104_gr_init_sked_hww_esr(struct gf100_gr *);
217
218 void gk110_gr_init_419eb4(struct gf100_gr *);
219
220 void gm107_gr_init_504430(struct gf100_gr *, int, int);
221 void gm107_gr_init_shader_exceptions(struct gf100_gr *, int, int);
222 void gm107_gr_init_400054(struct gf100_gr *);
223
224 int gk20a_gr_init(struct gf100_gr *);
225
226 void gm200_gr_oneinit_tiles(struct gf100_gr *);
227 void gm200_gr_oneinit_sm_id(struct gf100_gr *);
228 int gm200_gr_rops(struct gf100_gr *);
229 void gm200_gr_init_num_active_ltcs(struct gf100_gr *);
230 void gm200_gr_init_ds_hww_esr_2(struct gf100_gr *);
231
232 void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
233 void gp100_gr_init_fecs_exceptions(struct gf100_gr *);
234 void gp100_gr_init_shader_exceptions(struct gf100_gr *, int, int);
235 void gp100_gr_zbc_clear_color(struct gf100_gr *, int);
236 void gp100_gr_zbc_clear_depth(struct gf100_gr *, int);
237
238 void gp102_gr_init_swdx_pes_mask(struct gf100_gr *);
239 extern const struct gf100_gr_func_zbc gp102_gr_zbc;
240
241 #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
242 #include <core/object.h>
243
244 struct gf100_gr_chan {
245         struct nvkm_object object;
246         struct gf100_gr *gr;
247         struct nvkm_vmm *vmm;
248
249         struct nvkm_memory *mmio;
250         struct nvkm_vma *mmio_vma;
251         int mmio_nr;
252
253         struct {
254                 struct nvkm_memory *mem;
255                 struct nvkm_vma *vma;
256         } data[4];
257 };
258
259 void gf100_gr_ctxctl_debug(struct gf100_gr *);
260
261 void gf100_gr_dtor_fw(struct gf100_gr_fuc *);
262 int  gf100_gr_ctor_fw(struct gf100_gr *, const char *,
263                       struct gf100_gr_fuc *);
264 u64  gf100_gr_units(struct nvkm_gr *);
265 void gf100_gr_zbc_init(struct gf100_gr *);
266
267 extern const struct nvkm_object_func gf100_fermi;
268
269 struct gf100_gr_init {
270         u32 addr;
271         u8  count;
272         u32 pitch;
273         u32 data;
274 };
275
276 struct gf100_gr_pack {
277         const struct gf100_gr_init *init;
278         u32 type;
279 };
280
281 #define pack_for_each_init(init, pack, head)                                   \
282         for (pack = head; pack && pack->init; pack++)                          \
283                   for (init = pack->init; init && init->count; init++)
284
285 struct gf100_gr_ucode {
286         struct gf100_gr_fuc code;
287         struct gf100_gr_fuc data;
288 };
289
290 extern struct gf100_gr_ucode gf100_gr_fecs_ucode;
291 extern struct gf100_gr_ucode gf100_gr_gpccs_ucode;
292
293 extern struct gf100_gr_ucode gk110_gr_fecs_ucode;
294 extern struct gf100_gr_ucode gk110_gr_gpccs_ucode;
295
296 int  gf100_gr_wait_idle(struct gf100_gr *);
297 void gf100_gr_mmio(struct gf100_gr *, const struct gf100_gr_pack *);
298 void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
299 void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
300 int  gf100_gr_init_ctxctl(struct gf100_gr *);
301
302 /* external bundles loading functions */
303 int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
304                         struct gf100_gr_pack **);
305 int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
306                          struct gf100_gr_pack **);
307 int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
308                           struct gf100_gr_pack **);
309
310 int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
311                   struct nvkm_gr **);
312
313 /* register init value lists */
314
315 extern const struct gf100_gr_init gf100_gr_init_main_0[];
316 extern const struct gf100_gr_init gf100_gr_init_fe_0[];
317 extern const struct gf100_gr_init gf100_gr_init_pri_0[];
318 extern const struct gf100_gr_init gf100_gr_init_rstr2d_0[];
319 extern const struct gf100_gr_init gf100_gr_init_pd_0[];
320 extern const struct gf100_gr_init gf100_gr_init_ds_0[];
321 extern const struct gf100_gr_init gf100_gr_init_scc_0[];
322 extern const struct gf100_gr_init gf100_gr_init_prop_0[];
323 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_0[];
324 extern const struct gf100_gr_init gf100_gr_init_setup_0[];
325 extern const struct gf100_gr_init gf100_gr_init_crstr_0[];
326 extern const struct gf100_gr_init gf100_gr_init_setup_1[];
327 extern const struct gf100_gr_init gf100_gr_init_zcull_0[];
328 extern const struct gf100_gr_init gf100_gr_init_gpm_0[];
329 extern const struct gf100_gr_init gf100_gr_init_gpc_unk_1[];
330 extern const struct gf100_gr_init gf100_gr_init_gcc_0[];
331 extern const struct gf100_gr_init gf100_gr_init_tpccs_0[];
332 extern const struct gf100_gr_init gf100_gr_init_tex_0[];
333 extern const struct gf100_gr_init gf100_gr_init_pe_0[];
334 extern const struct gf100_gr_init gf100_gr_init_l1c_0[];
335 extern const struct gf100_gr_init gf100_gr_init_wwdx_0[];
336 extern const struct gf100_gr_init gf100_gr_init_tpccs_1[];
337 extern const struct gf100_gr_init gf100_gr_init_mpc_0[];
338 extern const struct gf100_gr_init gf100_gr_init_be_0[];
339 extern const struct gf100_gr_init gf100_gr_init_fe_1[];
340 extern const struct gf100_gr_init gf100_gr_init_pe_1[];
341 void gf100_gr_init_gpc_mmu(struct gf100_gr *);
342 void gf100_gr_trap_mp(struct gf100_gr *, int, int);
343 extern const struct nvkm_bitfield gf100_mp_global_error[];
344 extern const struct nvkm_enum gf100_mp_warp_error[];
345
346 extern const struct gf100_gr_init gf104_gr_init_ds_0[];
347 extern const struct gf100_gr_init gf104_gr_init_tex_0[];
348 extern const struct gf100_gr_init gf104_gr_init_sm_0[];
349
350 extern const struct gf100_gr_init gf108_gr_init_gpc_unk_0[];
351 extern const struct gf100_gr_init gf108_gr_init_setup_1[];
352
353 extern const struct gf100_gr_init gf119_gr_init_pd_0[];
354 extern const struct gf100_gr_init gf119_gr_init_ds_0[];
355 extern const struct gf100_gr_init gf119_gr_init_prop_0[];
356 extern const struct gf100_gr_init gf119_gr_init_gpm_0[];
357 extern const struct gf100_gr_init gf119_gr_init_gpc_unk_1[];
358 extern const struct gf100_gr_init gf119_gr_init_tex_0[];
359 extern const struct gf100_gr_init gf119_gr_init_sm_0[];
360 extern const struct gf100_gr_init gf119_gr_init_fe_1[];
361
362 extern const struct gf100_gr_init gf117_gr_init_pes_0[];
363 extern const struct gf100_gr_init gf117_gr_init_wwdx_0[];
364 extern const struct gf100_gr_init gf117_gr_init_cbm_0[];
365
366 extern const struct gf100_gr_init gk104_gr_init_main_0[];
367 extern const struct gf100_gr_init gk104_gr_init_gpc_unk_2[];
368 extern const struct gf100_gr_init gk104_gr_init_tpccs_0[];
369 extern const struct gf100_gr_init gk104_gr_init_pe_0[];
370 extern const struct gf100_gr_init gk104_gr_init_be_0[];
371 extern const struct gf100_gr_pack gk104_gr_pack_mmio[];
372
373 extern const struct gf100_gr_init gk110_gr_init_fe_0[];
374 extern const struct gf100_gr_init gk110_gr_init_ds_0[];
375 extern const struct gf100_gr_init gk110_gr_init_sked_0[];
376 extern const struct gf100_gr_init gk110_gr_init_cwd_0[];
377 extern const struct gf100_gr_init gk110_gr_init_gpc_unk_1[];
378 extern const struct gf100_gr_init gk110_gr_init_tex_0[];
379 extern const struct gf100_gr_init gk110_gr_init_sm_0[];
380
381 extern const struct gf100_gr_init gk208_gr_init_gpc_unk_0[];
382
383 extern const struct gf100_gr_init gm107_gr_init_scc_0[];
384 extern const struct gf100_gr_init gm107_gr_init_prop_0[];
385 extern const struct gf100_gr_init gm107_gr_init_setup_1[];
386 extern const struct gf100_gr_init gm107_gr_init_zcull_0[];
387 extern const struct gf100_gr_init gm107_gr_init_gpc_unk_1[];
388 extern const struct gf100_gr_init gm107_gr_init_tex_0[];
389 extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
390 extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
391 extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
392 void gm107_gr_init_bios(struct gf100_gr *);
393
394 void gm200_gr_init_gpc_mmu(struct gf100_gr *);
395 #endif