summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.h406
1 files changed, 406 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
new file mode 100644
index 00000000..7eb2923a
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
@@ -0,0 +1,406 @@
1/*
2 * GK20A Graphics Engine
3 *
4 * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef __GR_GK20A_H__
19#define __GR_GK20A_H__
20
21#include <linux/slab.h>
22
23#include "gr_ctx_gk20a.h"
24
25#define GR_IDLE_CHECK_DEFAULT 100 /* usec */
26#define GR_IDLE_CHECK_MAX 5000 /* usec */
27
28#define INVALID_SCREEN_TILE_ROW_OFFSET 0xFFFFFFFF
29#define INVALID_MAX_WAYS 0xFFFFFFFF
30
31#define GK20A_FECS_UCODE_IMAGE "fecs.bin"
32#define GK20A_GPCCS_UCODE_IMAGE "gpccs.bin"
33
34enum /* global_ctx_buffer */ {
35 CIRCULAR = 0,
36 PAGEPOOL = 1,
37 ATTRIBUTE = 2,
38 CIRCULAR_VPR = 3,
39 PAGEPOOL_VPR = 4,
40 ATTRIBUTE_VPR = 5,
41 GOLDEN_CTX = 6,
42 PRIV_ACCESS_MAP = 7,
43 NR_GLOBAL_CTX_BUF = 8
44};
45
46/* either ATTRIBUTE or ATTRIBUTE_VPR maps to ATTRIBUTE_VA */
47enum /*global_ctx_buffer_va */ {
48 CIRCULAR_VA = 0,
49 PAGEPOOL_VA = 1,
50 ATTRIBUTE_VA = 2,
51 GOLDEN_CTX_VA = 3,
52 PRIV_ACCESS_MAP_VA = 4,
53 NR_GLOBAL_CTX_BUF_VA = 5
54};
55
56enum {
57 WAIT_UCODE_LOOP,
58 WAIT_UCODE_TIMEOUT,
59 WAIT_UCODE_ERROR,
60 WAIT_UCODE_OK
61};
62
63enum {
64 GR_IS_UCODE_OP_EQUAL,
65 GR_IS_UCODE_OP_NOT_EQUAL,
66 GR_IS_UCODE_OP_AND,
67 GR_IS_UCODE_OP_LESSER,
68 GR_IS_UCODE_OP_LESSER_EQUAL,
69 GR_IS_UCODE_OP_SKIP
70};
71
72enum {
73 eUcodeHandshakeInitComplete = 1,
74 eUcodeHandshakeMethodFinished
75};
76
77enum {
78 ELCG_RUN, /* clk always run, i.e. disable elcg */
79 ELCG_STOP, /* clk is stopped */
80 ELCG_AUTO /* clk will run when non-idle, standard elcg mode */
81};
82
83enum {
84 BLCG_RUN, /* clk always run, i.e. disable blcg */
85 BLCG_AUTO /* clk will run when non-idle, standard blcg mode */
86};
87
88#ifndef GR_GO_IDLE_BUNDLE
89#define GR_GO_IDLE_BUNDLE 0x0000e100 /* --V-B */
90#endif
91
92struct gr_channel_map_tlb_entry {
93 u32 curr_ctx;
94 u32 hw_chid;
95};
96
97struct gr_zcull_gk20a {
98 u32 aliquot_width;
99 u32 aliquot_height;
100 u32 aliquot_size;
101 u32 total_aliquots;
102
103 u32 width_align_pixels;
104 u32 height_align_pixels;
105 u32 pixel_squares_by_aliquots;
106};
107
108struct gr_zcull_info {
109 u32 width_align_pixels;
110 u32 height_align_pixels;
111 u32 pixel_squares_by_aliquots;
112 u32 aliquot_total;
113 u32 region_byte_multiplier;
114 u32 region_header_size;
115 u32 subregion_header_size;
116 u32 subregion_width_align_pixels;
117 u32 subregion_height_align_pixels;
118 u32 subregion_count;
119};
120
121#define GK20A_ZBC_COLOR_VALUE_SIZE 4 /* RGBA */
122
123#define GK20A_STARTOF_ZBC_TABLE 1 /* index zero reserved to indicate "not ZBCd" */
124#define GK20A_SIZEOF_ZBC_TABLE 16 /* match ltcs_ltss_dstg_zbc_index_address width (4) */
125#define GK20A_ZBC_TABLE_SIZE (16 - 1)
126
127#define GK20A_ZBC_TYPE_INVALID 0
128#define GK20A_ZBC_TYPE_COLOR 1
129#define GK20A_ZBC_TYPE_DEPTH 2
130
131struct zbc_color_table {
132 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
133 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
134 u32 format;
135 u32 ref_cnt;
136};
137
138struct zbc_depth_table {
139 u32 depth;
140 u32 format;
141 u32 ref_cnt;
142};
143
144struct zbc_entry {
145 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
146 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
147 u32 depth;
148 u32 type; /* color or depth */
149 u32 format;
150};
151
152struct zbc_query_params {
153 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
154 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
155 u32 depth;
156 u32 ref_cnt;
157 u32 format;
158 u32 type; /* color or depth */
159 u32 index_size; /* [out] size, [in] index */
160};
161
162struct gr_gk20a {
163 struct gk20a *g;
164 struct {
165 bool dynamic;
166
167 u32 buffer_size;
168 u32 buffer_total_size;
169
170 bool golden_image_initialized;
171 u32 golden_image_size;
172 u32 *local_golden_image;
173
174 u32 zcull_ctxsw_image_size;
175
176 u32 buffer_header_size;
177
178 u32 priv_access_map_size;
179
180 struct gr_ucode_gk20a ucode;
181
182 struct av_list_gk20a sw_bundle_init;
183 struct av_list_gk20a sw_method_init;
184 struct aiv_list_gk20a sw_ctx_load;
185 struct av_list_gk20a sw_non_ctx_load;
186 struct {
187 struct aiv_list_gk20a sys;
188 struct aiv_list_gk20a gpc;
189 struct aiv_list_gk20a tpc;
190 struct aiv_list_gk20a zcull_gpc;
191 struct aiv_list_gk20a ppc;
192 struct aiv_list_gk20a pm_sys;
193 struct aiv_list_gk20a pm_gpc;
194 struct aiv_list_gk20a pm_tpc;
195 } ctxsw_regs;
196 int regs_base_index;
197 bool valid;
198 } ctx_vars;
199
200 struct mutex ctx_mutex; /* protect golden ctx init */
201 struct mutex fecs_mutex; /* protect fecs method */
202
203#define GR_NETLIST_DYNAMIC -1
204#define GR_NETLIST_STATIC_A 'A'
205 int netlist;
206
207 int initialized;
208 u32 num_fbps;
209
210 u32 max_gpc_count;
211 u32 max_fbps_count;
212 u32 max_tpc_per_gpc_count;
213 u32 max_zcull_per_gpc_count;
214 u32 max_tpc_count;
215
216 u32 sys_count;
217 u32 gpc_count;
218 u32 pe_count_per_gpc;
219 u32 ppc_count;
220 u32 *gpc_ppc_count;
221 u32 tpc_count;
222 u32 *gpc_tpc_count;
223 u32 zcb_count;
224 u32 *gpc_zcb_count;
225 u32 *pes_tpc_count[2];
226 u32 *pes_tpc_mask[2];
227 u32 *gpc_skip_mask;
228
229 u32 bundle_cb_default_size;
230 u32 min_gpm_fifo_depth;
231 u32 bundle_cb_token_limit;
232 u32 attrib_cb_default_size;
233 u32 attrib_cb_size;
234 u32 alpha_cb_default_size;
235 u32 alpha_cb_size;
236 u32 timeslice_mode;
237
238 struct gr_ctx_buffer_desc global_ctx_buffer[NR_GLOBAL_CTX_BUF];
239
240 struct mmu_desc mmu_wr_mem;
241 u32 mmu_wr_mem_size;
242 struct mmu_desc mmu_rd_mem;
243 u32 mmu_rd_mem_size;
244
245 u8 *map_tiles;
246 u32 map_tile_count;
247 u32 map_row_offset;
248
249#define COMP_TAG_LINE_SIZE_SHIFT (17) /* one tag covers 128K */
250#define COMP_TAG_LINE_SIZE (1 << COMP_TAG_LINE_SIZE_SHIFT)
251
252 u32 max_comptag_mem; /* max memory size (MB) for comptag */
253 struct compbit_store_desc compbit_store;
254 struct gk20a_allocator comp_tags;
255
256 struct gr_zcull_gk20a zcull;
257
258 struct zbc_color_table zbc_col_tbl[GK20A_ZBC_TABLE_SIZE];
259 struct zbc_depth_table zbc_dep_tbl[GK20A_ZBC_TABLE_SIZE];
260
261 s32 max_default_color_index;
262 s32 max_default_depth_index;
263
264 s32 max_used_color_index;
265 s32 max_used_depth_index;
266
267 u32 status_disable_mask;
268
269#define GR_CHANNEL_MAP_TLB_SIZE 2 /* must of power of 2 */
270 struct gr_channel_map_tlb_entry chid_tlb[GR_CHANNEL_MAP_TLB_SIZE];
271 u32 channel_tlb_flush_index;
272 spinlock_t ch_tlb_lock;
273
274 void (*remove_support)(struct gr_gk20a *gr);
275 bool sw_ready;
276 bool skip_ucode_init;
277};
278
279void gk20a_fecs_dump_falcon_stats(struct gk20a *g);
280
281struct gk20a_ctxsw_ucode_segment {
282 u32 offset;
283 u32 size;
284};
285
286struct gk20a_ctxsw_ucode_segments {
287 u32 boot_entry;
288 u32 boot_imem_offset;
289 struct gk20a_ctxsw_ucode_segment boot;
290 struct gk20a_ctxsw_ucode_segment code;
291 struct gk20a_ctxsw_ucode_segment data;
292};
293
294struct gk20a_ctxsw_ucode_info {
295 u64 *p_va;
296 struct inst_desc inst_blk_desc;
297 struct surface_mem_desc surface_desc;
298 u64 ucode_gpuva;
299 struct gk20a_ctxsw_ucode_segments fecs;
300 struct gk20a_ctxsw_ucode_segments gpccs;
301};
302
303struct gk20a_ctxsw_bootloader_desc {
304 u32 start_offset;
305 u32 size;
306 u32 imem_offset;
307 u32 entry_point;
308};
309
310struct gpu_ops;
311void gk20a_init_gr(struct gpu_ops *gops);
312int gk20a_init_gr_support(struct gk20a *g);
313void gk20a_gr_reset(struct gk20a *g);
314
315int gk20a_init_gr_channel(struct channel_gk20a *ch_gk20a);
316
317int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr);
318
319struct nvhost_alloc_obj_ctx_args;
320struct nvhost_free_obj_ctx_args;
321
322int gk20a_alloc_obj_ctx(struct channel_gk20a *c,
323 struct nvhost_alloc_obj_ctx_args *args);
324int gk20a_free_obj_ctx(struct channel_gk20a *c,
325 struct nvhost_free_obj_ctx_args *args);
326void gk20a_free_channel_ctx(struct channel_gk20a *c);
327
328int gk20a_gr_isr(struct gk20a *g);
329int gk20a_gr_nonstall_isr(struct gk20a *g);
330
331/* zcull */
332u32 gr_gk20a_get_ctxsw_zcull_size(struct gk20a *g, struct gr_gk20a *gr);
333int gr_gk20a_bind_ctxsw_zcull(struct gk20a *g, struct gr_gk20a *gr,
334 struct channel_gk20a *c, u64 zcull_va, u32 mode);
335int gr_gk20a_get_zcull_info(struct gk20a *g, struct gr_gk20a *gr,
336 struct gr_zcull_info *zcull_params);
337/* zbc */
338int gr_gk20a_add_zbc(struct gk20a *g, struct gr_gk20a *gr,
339 struct zbc_entry *zbc_val);
340int gr_gk20a_query_zbc(struct gk20a *g, struct gr_gk20a *gr,
341 struct zbc_query_params *query_params);
342int gk20a_gr_zbc_set_table(struct gk20a *g, struct gr_gk20a *gr,
343 struct zbc_entry *zbc_val);
344int gr_gk20a_clear_zbc_table(struct gk20a *g, struct gr_gk20a *gr);
345int gr_gk20a_load_zbc_default_table(struct gk20a *g, struct gr_gk20a *gr);
346
347/* pmu */
348int gr_gk20a_fecs_get_reglist_img_size(struct gk20a *g, u32 *size);
349int gr_gk20a_fecs_set_reglist_bind_inst(struct gk20a *g, phys_addr_t addr);
350int gr_gk20a_fecs_set_reglist_virual_addr(struct gk20a *g, u64 pmu_va);
351
352void gr_gk20a_init_elcg_mode(struct gk20a *g, u32 mode, u32 engine);
353void gr_gk20a_init_blcg_mode(struct gk20a *g, u32 mode, u32 engine);
354
355/* sm */
356bool gk20a_gr_sm_debugger_attached(struct gk20a *g);
357
358#define gr_gk20a_elpg_protected_call(g, func) \
359 ({ \
360 int err; \
361 if (support_gk20a_pmu()) \
362 gk20a_pmu_disable_elpg(g); \
363 err = func; \
364 if (support_gk20a_pmu()) \
365 gk20a_pmu_enable_elpg(g); \
366 err; \
367 })
368
369int gk20a_gr_suspend(struct gk20a *g);
370
371struct nvhost_dbg_gpu_reg_op;
372int gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch,
373 struct nvhost_dbg_gpu_reg_op *ctx_ops, u32 num_ops,
374 u32 num_ctx_wr_ops, u32 num_ctx_rd_ops);
375int gr_gk20a_get_ctx_buffer_offsets(struct gk20a *g,
376 u32 addr,
377 u32 max_offsets,
378 u32 *offsets, u32 *offset_addrs,
379 u32 *num_offsets,
380 bool is_quad, u32 quad);
381int gr_gk20a_update_smpc_ctxsw_mode(struct gk20a *g,
382 struct channel_gk20a *c,
383 bool enable_smpc_ctxsw);
384
385struct channel_ctx_gk20a;
386int gr_gk20a_ctx_patch_write(struct gk20a *g, struct channel_ctx_gk20a *ch_ctx,
387 u32 addr, u32 data, bool patch);
388int gr_gk20a_ctx_patch_write_begin(struct gk20a *g,
389 struct channel_ctx_gk20a *ch_ctx);
390int gr_gk20a_ctx_patch_write_end(struct gk20a *g,
391 struct channel_ctx_gk20a *ch_ctx);
392void gr_gk20a_commit_global_pagepool(struct gk20a *g,
393 struct channel_ctx_gk20a *ch_ctx,
394 u64 addr, u32 size, bool patch);
395void gk20a_gr_set_shader_exceptions(struct gk20a *g, u32 data);
396void gr_gk20a_enable_hww_exceptions(struct gk20a *g);
397void gr_gk20a_get_sm_dsm_perf_regs(struct gk20a *g,
398 u32 *num_sm_dsm_perf_regs,
399 u32 **sm_dsm_perf_regs,
400 u32 *perf_register_stride);
401void gr_gk20a_get_sm_dsm_perf_ctrl_regs(struct gk20a *g,
402 u32 *num_sm_dsm_perf_regs,
403 u32 **sm_dsm_perf_regs,
404 u32 *perf_register_stride);
405int gr_gk20a_setup_rop_mapping(struct gk20a *g, struct gr_gk20a *gr);
406#endif /*__GR_GK20A_H__*/