ctxgk20a.c 2.9 KB
Newer Older
1
/*
2
 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
22

23
#include "ctxgf100.h"
24 25 26 27 28
#include "gk20a.h"

#include <subdev/mc.h>

static void
B
Ben Skeggs 已提交
29
gk20a_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
30
{
B
Ben Skeggs 已提交
31
	struct gf100_grctx_oclass *oclass = (void *)nv_engine(gr)->cclass;
32 33 34
	int idle_timeout_save;
	int i;

B
Ben Skeggs 已提交
35
	gf100_gr_mmio(gr, gr->fuc_sw_ctx);
36

B
Ben Skeggs 已提交
37
	gf100_gr_wait_idle(gr);
38

B
Ben Skeggs 已提交
39 40
	idle_timeout_save = nv_rd32(gr, 0x404154);
	nv_wr32(gr, 0x404154, 0x00000000);
41 42 43

	oclass->attrib(info);

B
Ben Skeggs 已提交
44
	oclass->unkn(gr);
45

B
Ben Skeggs 已提交
46 47 48 49
	gf100_grctx_generate_tpcid(gr);
	gf100_grctx_generate_r406028(gr);
	gk104_grctx_generate_r418bb8(gr);
	gf100_grctx_generate_r406800(gr);
50 51

	for (i = 0; i < 8; i++)
B
Ben Skeggs 已提交
52
		nv_wr32(gr, 0x4064d0 + (i * 0x04), 0x00000000);
53

B
Ben Skeggs 已提交
54
	nv_wr32(gr, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
55

B
Ben Skeggs 已提交
56
	gk104_grctx_generate_rop_active_fbps(gr);
57

B
Ben Skeggs 已提交
58
	nv_mask(gr, 0x5044b0, 0x8000000, 0x8000000);
59

B
Ben Skeggs 已提交
60
	gf100_gr_wait_idle(gr);
61

B
Ben Skeggs 已提交
62 63
	nv_wr32(gr, 0x404154, idle_timeout_save);
	gf100_gr_wait_idle(gr);
64

B
Ben Skeggs 已提交
65 66
	gf100_gr_mthd(gr, gr->fuc_method);
	gf100_gr_wait_idle(gr);
67

B
Ben Skeggs 已提交
68
	gf100_gr_icmd(gr, gr->fuc_bundle);
69 70 71
	oclass->pagepool(info);
	oclass->bundle(info);
}
72

73 74
struct nvkm_oclass *
gk20a_grctx_oclass = &(struct gf100_grctx_oclass) {
75
	.base.handle = NV_ENGCTX(GR, 0xea),
76 77 78 79 80 81 82
	.base.ofuncs = &(struct nvkm_ofuncs) {
		.ctor = gf100_gr_context_ctor,
		.dtor = gf100_gr_context_dtor,
		.init = _nvkm_gr_context_init,
		.fini = _nvkm_gr_context_fini,
		.rd32 = _nvkm_gr_context_rd32,
		.wr32 = _nvkm_gr_context_wr32,
83
	},
84
	.main  = gk20a_grctx_generate_main,
85 86
	.unkn  = gk104_grctx_generate_unkn,
	.bundle = gk104_grctx_generate_bundle,
87 88 89
	.bundle_size = 0x1800,
	.bundle_min_gpm_fifo_depth = 0x62,
	.bundle_token_limit = 0x100,
90
	.pagepool = gk104_grctx_generate_pagepool,
91
	.pagepool_size = 0x8000,
92
	.attrib = gf117_grctx_generate_attrib,
93 94 95 96
	.attrib_nr_max = 0x240,
	.attrib_nr = 0x240,
	.alpha_nr_max = 0x648 + (0x648 / 2),
	.alpha_nr = 0x648,
97
}.base;