2 * GK20A Graphics Engine
4 * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
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.
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
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/>.
18 #ifndef __GR_GK20A_H__
19 #define __GR_GK20A_H__
21 #include <linux/slab.h>
23 #include "gr_ctx_gk20a.h"
25 #define GR_IDLE_CHECK_DEFAULT 10 /* usec */
26 #define GR_IDLE_CHECK_MAX 200 /* usec */
28 #define INVALID_SCREEN_TILE_ROW_OFFSET 0xFFFFFFFF
29 #define INVALID_MAX_WAYS 0xFFFFFFFF
31 #define GK20A_FECS_UCODE_IMAGE "fecs.bin"
32 #define GK20A_GPCCS_UCODE_IMAGE "gpccs.bin"
34 enum /* global_ctx_buffer */ {
46 /* either ATTRIBUTE or ATTRIBUTE_VPR maps to ATTRIBUTE_VA */
47 enum /*global_ctx_buffer_va */ {
52 PRIV_ACCESS_MAP_VA = 4,
53 NR_GLOBAL_CTX_BUF_VA = 5
65 GR_IS_UCODE_OP_NOT_EQUAL,
67 GR_IS_UCODE_OP_LESSER,
68 GR_IS_UCODE_OP_LESSER_EQUAL,
73 eUcodeHandshakeInitComplete = 1,
74 eUcodeHandshakeMethodFinished
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 */
84 BLCG_RUN, /* clk always run, i.e. disable blcg */
85 BLCG_AUTO /* clk will run when non-idle, standard blcg mode */
88 #ifndef GR_GO_IDLE_BUNDLE
89 #define GR_GO_IDLE_BUNDLE 0x0000e100 /* --V-B */
92 struct gr_channel_map_tlb_entry {
97 struct gr_zcull_gk20a {
103 u32 width_align_pixels;
104 u32 height_align_pixels;
105 u32 pixel_squares_by_aliquots;
108 struct gr_zcull_info {
109 u32 width_align_pixels;
110 u32 height_align_pixels;
111 u32 pixel_squares_by_aliquots;
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;
121 #define GK20A_ZBC_COLOR_VALUE_SIZE 4 /* RGBA */
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)
127 #define GK20A_ZBC_TYPE_INVALID 0
128 #define GK20A_ZBC_TYPE_COLOR 1
129 #define GK20A_ZBC_TYPE_DEPTH 2
131 struct zbc_color_table {
132 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
133 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
138 struct zbc_depth_table {
145 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
146 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
148 u32 type; /* color or depth */
152 struct zbc_query_params {
153 u32 color_ds[GK20A_ZBC_COLOR_VALUE_SIZE];
154 u32 color_l2[GK20A_ZBC_COLOR_VALUE_SIZE];
158 u32 type; /* color or depth */
159 u32 index_size; /* [out] size, [in] index */
168 u32 buffer_total_size;
170 bool golden_image_initialized;
171 u32 golden_image_size;
172 u32 *local_golden_image;
174 u32 zcull_ctxsw_image_size;
176 u32 buffer_header_size;
178 u32 priv_access_map_size;
180 struct gr_ucode_gk20a ucode;
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;
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;
200 struct mutex ctx_mutex; /* protect golden ctx init */
201 struct mutex fecs_mutex; /* protect fecs method */
203 #define GR_NETLIST_DYNAMIC -1
204 #define GR_NETLIST_STATIC_A 'A'
207 wait_queue_head_t init_wq;
212 u32 comptags_per_cacheline;
218 u32 max_tpc_per_gpc_count;
219 u32 max_zcull_per_gpc_count;
224 u32 pe_count_per_gpc;
231 u32 *pes_tpc_count[2];
232 u32 *pes_tpc_mask[2];
235 u32 bundle_cb_default_size;
236 u32 min_gpm_fifo_depth;
237 u32 bundle_cb_token_limit;
238 u32 attrib_cb_default_size;
240 u32 alpha_cb_default_size;
244 struct gr_ctx_buffer_desc global_ctx_buffer[NR_GLOBAL_CTX_BUF];
246 struct mmu_desc mmu_wr_mem;
248 struct mmu_desc mmu_rd_mem;
255 #define COMP_TAG_LINE_SIZE_SHIFT (17) /* one tag covers 128K */
256 #define COMP_TAG_LINE_SIZE (1 << COMP_TAG_LINE_SIZE_SHIFT)
258 u32 max_comptag_mem; /* max memory size (MB) for comptag */
259 struct compbit_store_desc compbit_store;
260 struct gk20a_allocator comp_tags;
262 struct gr_zcull_gk20a zcull;
264 struct mutex zbc_lock;
265 struct zbc_color_table zbc_col_tbl[GK20A_ZBC_TABLE_SIZE];
266 struct zbc_depth_table zbc_dep_tbl[GK20A_ZBC_TABLE_SIZE];
268 s32 max_default_color_index;
269 s32 max_default_depth_index;
271 s32 max_used_color_index;
272 s32 max_used_depth_index;
274 u32 status_disable_mask;
276 #define GR_CHANNEL_MAP_TLB_SIZE 2 /* must of power of 2 */
277 struct gr_channel_map_tlb_entry chid_tlb[GR_CHANNEL_MAP_TLB_SIZE];
278 u32 channel_tlb_flush_index;
279 spinlock_t ch_tlb_lock;
281 void (*remove_support)(struct gr_gk20a *gr);
283 bool skip_ucode_init;
286 void gk20a_fecs_dump_falcon_stats(struct gk20a *g);
288 struct gk20a_ctxsw_ucode_segment {
293 struct gk20a_ctxsw_ucode_segments {
295 u32 boot_imem_offset;
296 struct gk20a_ctxsw_ucode_segment boot;
297 struct gk20a_ctxsw_ucode_segment code;
298 struct gk20a_ctxsw_ucode_segment data;
301 struct gk20a_ctxsw_ucode_info {
303 struct inst_desc inst_blk_desc;
304 struct surface_mem_desc surface_desc;
306 struct gk20a_ctxsw_ucode_segments fecs;
307 struct gk20a_ctxsw_ucode_segments gpccs;
310 struct gk20a_ctxsw_bootloader_desc {
318 void gk20a_init_gr(struct gk20a *g);
319 void gk20a_init_gr_ops(struct gpu_ops *gops);
320 int gk20a_init_gr_support(struct gk20a *g);
321 int gk20a_gr_reset(struct gk20a *g);
322 void gk20a_gr_wait_initialized(struct gk20a *g);
324 int gk20a_init_gr_channel(struct channel_gk20a *ch_gk20a);
326 int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr);
328 struct nvhost_alloc_obj_ctx_args;
329 struct nvhost_free_obj_ctx_args;
331 int gk20a_alloc_obj_ctx(struct channel_gk20a *c,
332 struct nvhost_alloc_obj_ctx_args *args);
333 int gk20a_free_obj_ctx(struct channel_gk20a *c,
334 struct nvhost_free_obj_ctx_args *args);
335 void gk20a_free_channel_ctx(struct channel_gk20a *c);
337 int gk20a_gr_isr(struct gk20a *g);
338 int gk20a_gr_nonstall_isr(struct gk20a *g);
341 u32 gr_gk20a_get_ctxsw_zcull_size(struct gk20a *g, struct gr_gk20a *gr);
342 int gr_gk20a_bind_ctxsw_zcull(struct gk20a *g, struct gr_gk20a *gr,
343 struct channel_gk20a *c, u64 zcull_va, u32 mode);
344 int gr_gk20a_get_zcull_info(struct gk20a *g, struct gr_gk20a *gr,
345 struct gr_zcull_info *zcull_params);
347 int gr_gk20a_add_zbc(struct gk20a *g, struct gr_gk20a *gr,
348 struct zbc_entry *zbc_val);
349 int gr_gk20a_query_zbc(struct gk20a *g, struct gr_gk20a *gr,
350 struct zbc_query_params *query_params);
351 int gk20a_gr_zbc_set_table(struct gk20a *g, struct gr_gk20a *gr,
352 struct zbc_entry *zbc_val);
353 int gr_gk20a_load_zbc_default_table(struct gk20a *g, struct gr_gk20a *gr);
356 int gr_gk20a_fecs_get_reglist_img_size(struct gk20a *g, u32 *size);
357 int gr_gk20a_fecs_set_reglist_bind_inst(struct gk20a *g, phys_addr_t addr);
358 int gr_gk20a_fecs_set_reglist_virtual_addr(struct gk20a *g, u64 pmu_va);
360 void gr_gk20a_init_elcg_mode(struct gk20a *g, u32 mode, u32 engine);
361 void gr_gk20a_init_blcg_mode(struct gk20a *g, u32 mode, u32 engine);
363 void gr_gk20a_pmu_save_zbc(struct gk20a *g, u32 entries);
366 bool gk20a_gr_sm_debugger_attached(struct gk20a *g);
368 #define gr_gk20a_elpg_protected_call(g, func) \
371 if (support_gk20a_pmu()) \
372 err = gk20a_pmu_disable_elpg(g); \
373 if (err) return err; \
375 if (support_gk20a_pmu()) \
376 gk20a_pmu_enable_elpg(g); \
380 int gk20a_gr_suspend(struct gk20a *g);
382 struct nvhost_dbg_gpu_reg_op;
383 int gr_gk20a_exec_ctx_ops(struct channel_gk20a *ch,
384 struct nvhost_dbg_gpu_reg_op *ctx_ops, u32 num_ops,
385 u32 num_ctx_wr_ops, u32 num_ctx_rd_ops);
386 int gr_gk20a_get_ctx_buffer_offsets(struct gk20a *g,
389 u32 *offsets, u32 *offset_addrs,
391 bool is_quad, u32 quad);
392 int gr_gk20a_update_smpc_ctxsw_mode(struct gk20a *g,
393 struct channel_gk20a *c,
394 bool enable_smpc_ctxsw);
396 struct channel_ctx_gk20a;
397 int gr_gk20a_ctx_patch_write(struct gk20a *g, struct channel_ctx_gk20a *ch_ctx,
398 u32 addr, u32 data, bool patch);
399 int gr_gk20a_ctx_patch_write_begin(struct gk20a *g,
400 struct channel_ctx_gk20a *ch_ctx);
401 int gr_gk20a_ctx_patch_write_end(struct gk20a *g,
402 struct channel_ctx_gk20a *ch_ctx);
403 void gr_gk20a_commit_global_pagepool(struct gk20a *g,
404 struct channel_ctx_gk20a *ch_ctx,
405 u64 addr, u32 size, bool patch);
406 void gk20a_gr_set_shader_exceptions(struct gk20a *g, u32 data);
407 void gr_gk20a_enable_hww_exceptions(struct gk20a *g);
408 void gr_gk20a_get_sm_dsm_perf_regs(struct gk20a *g,
409 u32 *num_sm_dsm_perf_regs,
410 u32 **sm_dsm_perf_regs,
411 u32 *perf_register_stride);
412 void gr_gk20a_get_sm_dsm_perf_ctrl_regs(struct gk20a *g,
413 u32 *num_sm_dsm_perf_regs,
414 u32 **sm_dsm_perf_regs,
415 u32 *perf_register_stride);
416 int gr_gk20a_setup_rop_mapping(struct gk20a *g, struct gr_gk20a *gr);
417 #endif /*__GR_GK20A_H__*/