1b8bf04e1SBen Skeggs /*
2c4d0f8f6SAlexandre Courbot * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3b8bf04e1SBen Skeggs *
4b8bf04e1SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
5b8bf04e1SBen Skeggs * copy of this software and associated documentation files (the "Software"),
6b8bf04e1SBen Skeggs * to deal in the Software without restriction, including without limitation
7b8bf04e1SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8bf04e1SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
9b8bf04e1SBen Skeggs * Software is furnished to do so, subject to the following conditions:
10b8bf04e1SBen Skeggs *
11b8bf04e1SBen Skeggs * The above copyright notice and this permission notice shall be included in
12b8bf04e1SBen Skeggs * all copies or substantial portions of the Software.
13b8bf04e1SBen Skeggs *
14b8bf04e1SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b8bf04e1SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b8bf04e1SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17b8bf04e1SBen Skeggs * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18b8bf04e1SBen Skeggs * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19b8bf04e1SBen Skeggs * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20b8bf04e1SBen Skeggs * DEALINGS IN THE SOFTWARE.
21b8bf04e1SBen Skeggs */
22c4d0f8f6SAlexandre Courbot #include "ctxgf100.h"
23c85ee6caSBen Skeggs #include "gf100.h"
24c4d0f8f6SAlexandre Courbot
25c4d0f8f6SAlexandre Courbot #include <subdev/mc.h>
26c4d0f8f6SAlexandre Courbot
27c4d0f8f6SAlexandre Courbot static void
gk20a_grctx_generate_main(struct gf100_gr_chan * chan)28*78a43c7eSBen Skeggs gk20a_grctx_generate_main(struct gf100_gr_chan *chan)
29c4d0f8f6SAlexandre Courbot {
30d05095b5SBen Skeggs struct gf100_gr *gr = chan->gr;
31276836d4SBen Skeggs struct nvkm_device *device = gr->base.engine.subdev.device;
3227f3d6cfSBen Skeggs const struct gf100_grctx_func *grctx = gr->func->grctx;
33933ad445SBen Skeggs u32 idle_timeout;
34c4d0f8f6SAlexandre Courbot int i;
35c4d0f8f6SAlexandre Courbot
360033f15bSBen Skeggs gf100_gr_mmio(gr, gr->sw_ctx);
37c4d0f8f6SAlexandre Courbot
38bfee3f3dSBen Skeggs gf100_gr_wait_idle(gr);
39c4d0f8f6SAlexandre Courbot
40933ad445SBen Skeggs idle_timeout = nvkm_mask(device, 0x404154, 0xffffffff, 0x00000000);
41c4d0f8f6SAlexandre Courbot
42*78a43c7eSBen Skeggs grctx->attrib_cb(chan, chan->attrib_cb->addr, grctx->attrib_cb_size(gr));
43*78a43c7eSBen Skeggs grctx->attrib(chan);
44c4d0f8f6SAlexandre Courbot
4527f3d6cfSBen Skeggs grctx->unkn(gr);
46c4d0f8f6SAlexandre Courbot
47fc740f54SBen Skeggs gf100_grctx_generate_floorsweep(gr);
48c4d0f8f6SAlexandre Courbot
49c4d0f8f6SAlexandre Courbot for (i = 0; i < 8; i++)
50276836d4SBen Skeggs nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
51c4d0f8f6SAlexandre Courbot
52276836d4SBen Skeggs nvkm_wr32(device, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
53c4d0f8f6SAlexandre Courbot
54cfb4f929SIlia Mirkin nvkm_mask(device, 0x5044b0, 0x08000000, 0x08000000);
55c4d0f8f6SAlexandre Courbot
56bfee3f3dSBen Skeggs gf100_gr_wait_idle(gr);
57c4d0f8f6SAlexandre Courbot
58933ad445SBen Skeggs nvkm_wr32(device, 0x404154, idle_timeout);
59bfee3f3dSBen Skeggs gf100_gr_wait_idle(gr);
60c4d0f8f6SAlexandre Courbot
610033f15bSBen Skeggs gf100_gr_mthd(gr, gr->method);
62bfee3f3dSBen Skeggs gf100_gr_wait_idle(gr);
63c4d0f8f6SAlexandre Courbot
640033f15bSBen Skeggs gf100_gr_icmd(gr, gr->bundle);
65d05095b5SBen Skeggs grctx->pagepool(chan, chan->pagepool->addr);
6695f78acdSBen Skeggs grctx->bundle(chan, chan->bundle_cb->addr, grctx->bundle_size);
67c4d0f8f6SAlexandre Courbot }
68b8bf04e1SBen Skeggs
6927f3d6cfSBen Skeggs const struct gf100_grctx_func
7027f3d6cfSBen Skeggs gk20a_grctx = {
71c4d0f8f6SAlexandre Courbot .main = gk20a_grctx_generate_main,
72e3c71eb2SBen Skeggs .unkn = gk104_grctx_generate_unkn,
73e3c71eb2SBen Skeggs .bundle = gk104_grctx_generate_bundle,
74b8bf04e1SBen Skeggs .bundle_size = 0x1800,
75b8bf04e1SBen Skeggs .bundle_min_gpm_fifo_depth = 0x62,
76b8bf04e1SBen Skeggs .bundle_token_limit = 0x100,
77e3c71eb2SBen Skeggs .pagepool = gk104_grctx_generate_pagepool,
78b8bf04e1SBen Skeggs .pagepool_size = 0x8000,
79*78a43c7eSBen Skeggs .attrib_cb_size = gf100_grctx_generate_attrib_cb_size,
80*78a43c7eSBen Skeggs .attrib_cb = gf100_grctx_generate_attrib_cb,
81e3c71eb2SBen Skeggs .attrib = gf117_grctx_generate_attrib,
82b8bf04e1SBen Skeggs .attrib_nr_max = 0x240,
83b8bf04e1SBen Skeggs .attrib_nr = 0x240,
84b8bf04e1SBen Skeggs .alpha_nr_max = 0x648 + (0x648 / 2),
85b8bf04e1SBen Skeggs .alpha_nr = 0x648,
86fc740f54SBen Skeggs .sm_id = gf100_grctx_generate_sm_id,
87fc740f54SBen Skeggs .tpc_nr = gf100_grctx_generate_tpc_nr,
88ff209c23SBen Skeggs .rop_mapping = gf117_grctx_generate_rop_mapping,
8943952c6fSBen Skeggs .alpha_beta_tables = gk104_grctx_generate_alpha_beta_tables,
9027f3d6cfSBen Skeggs };
91