xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/ce/gt215.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1bd6c5cabSBen Skeggs /*
2bd6c5cabSBen Skeggs  * Copyright 2012 Red Hat Inc.
3bd6c5cabSBen Skeggs  *
4bd6c5cabSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5bd6c5cabSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6bd6c5cabSBen Skeggs  * to deal in the Software without restriction, including without limitation
7bd6c5cabSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bd6c5cabSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9bd6c5cabSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10bd6c5cabSBen Skeggs  *
11bd6c5cabSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12bd6c5cabSBen Skeggs  * all copies or substantial portions of the Software.
13bd6c5cabSBen Skeggs  *
14bd6c5cabSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bd6c5cabSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bd6c5cabSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bd6c5cabSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18bd6c5cabSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19bd6c5cabSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20bd6c5cabSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21bd6c5cabSBen Skeggs  *
22bd6c5cabSBen Skeggs  * Authors: Ben Skeggs
23bd6c5cabSBen Skeggs  */
24e5b31ca6SBen Skeggs #include "priv.h"
25bd6c5cabSBen Skeggs #include "fuc/gt215.fuc3.h"
26bd6c5cabSBen Skeggs 
27bd6c5cabSBen Skeggs #include <core/client.h>
28bd6c5cabSBen Skeggs #include <core/enum.h>
2913de7f46SBen Skeggs #include <core/gpuobj.h>
30e5b31ca6SBen Skeggs #include <engine/fifo.h>
31bd6c5cabSBen Skeggs 
329d498e0fSBen Skeggs #include <nvif/class.h>
33bd6c5cabSBen Skeggs 
34bd6c5cabSBen Skeggs static const struct nvkm_enum
35bd6c5cabSBen Skeggs gt215_ce_isr_error_name[] = {
36bd6c5cabSBen Skeggs 	{ 0x0001, "ILLEGAL_MTHD" },
37bd6c5cabSBen Skeggs 	{ 0x0002, "INVALID_ENUM" },
38bd6c5cabSBen Skeggs 	{ 0x0003, "INVALID_BITFIELD" },
39bd6c5cabSBen Skeggs 	{}
40bd6c5cabSBen Skeggs };
41bd6c5cabSBen Skeggs 
42bd6c5cabSBen Skeggs void
gt215_ce_intr(struct nvkm_falcon * ce,struct nvkm_chan * chan)43*c358f538SBen Skeggs gt215_ce_intr(struct nvkm_falcon *ce, struct nvkm_chan *chan)
44bd6c5cabSBen Skeggs {
45a83d8872SBen Skeggs 	struct nvkm_subdev *subdev = &ce->engine.subdev;
46a83d8872SBen Skeggs 	struct nvkm_device *device = subdev->device;
47608a29c2SBen Skeggs 	const u32 base = subdev->inst * 0x1000;
4863902181SBen Skeggs 	u32 ssta = nvkm_rd32(device, 0x104040 + base) & 0x0000ffff;
4963902181SBen Skeggs 	u32 addr = nvkm_rd32(device, 0x104040 + base) >> 16;
50bd6c5cabSBen Skeggs 	u32 mthd = (addr & 0x07ff) << 2;
51bd6c5cabSBen Skeggs 	u32 subc = (addr & 0x3800) >> 11;
5263902181SBen Skeggs 	u32 data = nvkm_rd32(device, 0x104044 + base);
53a83d8872SBen Skeggs 	const struct nvkm_enum *en =
54a83d8872SBen Skeggs 		nvkm_enum_find(gt215_ce_isr_error_name, ssta);
55bd6c5cabSBen Skeggs 
56a83d8872SBen Skeggs 	nvkm_error(subdev, "DISPATCH_ERROR %04x [%s] ch %d [%010llx %s] "
57a83d8872SBen Skeggs 			   "subc %d mthd %04x data %08x\n", ssta,
58*c358f538SBen Skeggs 		   en ? en->name : "", chan ? chan->id : -1,
598f0649b5SBen Skeggs 		   chan ? chan->inst->addr : 0,
60*c358f538SBen Skeggs 		   chan ? chan->name : "unknown",
61a83d8872SBen Skeggs 		   subc, mthd, data);
62bd6c5cabSBen Skeggs }
63bd6c5cabSBen Skeggs 
64a83d8872SBen Skeggs static const struct nvkm_falcon_func
6553e60da4SBen Skeggs gt215_ce = {
6653e60da4SBen Skeggs 	.code.data = gt215_ce_code,
6753e60da4SBen Skeggs 	.code.size = sizeof(gt215_ce_code),
6853e60da4SBen Skeggs 	.data.data = gt215_ce_data,
6953e60da4SBen Skeggs 	.data.size = sizeof(gt215_ce_data),
70a83d8872SBen Skeggs 	.intr = gt215_ce_intr,
719d498e0fSBen Skeggs 	.sclass = {
729d498e0fSBen Skeggs 		{ -1, -1, GT212_DMA },
739d498e0fSBen Skeggs 		{}
749d498e0fSBen Skeggs 	}
75a83d8872SBen Skeggs };
76bd6c5cabSBen Skeggs 
7753e60da4SBen Skeggs int
gt215_ce_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_engine ** pengine)7850551b15SBen Skeggs gt215_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
7953e60da4SBen Skeggs 	     struct nvkm_engine **pengine)
80bd6c5cabSBen Skeggs {
8193f43ed8SBen Skeggs 	return nvkm_falcon_new_(&gt215_ce, device, type, -1,
8253e60da4SBen Skeggs 				(device->chipset != 0xaf), 0x104000, pengine);
83bd6c5cabSBen Skeggs }
84