1 /* $NetBSD: nouveau_nvkm_engine_ce_gf100.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $ */
2
3 /*
4 * Copyright 2012 Red Hat Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Ben Skeggs
25 */
26 #include <sys/cdefs.h>
27 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_ce_gf100.c,v 1.3 2021/12/18 23:45:34 riastradh Exp $");
28
29 #include "priv.h"
30 #include "fuc/gf100.fuc3.h"
31
32 #include <nvif/class.h>
33
34 static void
gf100_ce_init(struct nvkm_falcon * ce)35 gf100_ce_init(struct nvkm_falcon *ce)
36 {
37 struct nvkm_device *device = ce->engine.subdev.device;
38 const int index = ce->engine.subdev.index - NVKM_ENGINE_CE0;
39 nvkm_wr32(device, ce->addr + 0x084, index);
40 }
41
42 static const struct nvkm_falcon_func
43 gf100_ce0 = {
44 .code.data = gf100_ce_code,
45 .code.size = sizeof(gf100_ce_code),
46 .data.data = gf100_ce_data,
47 .data.size = sizeof(gf100_ce_data),
48 .init = gf100_ce_init,
49 .intr = gt215_ce_intr,
50 .sclass = {
51 { -1, -1, FERMI_DMA },
52 {}
53 }
54 };
55
56 static const struct nvkm_falcon_func
57 gf100_ce1 = {
58 .code.data = gf100_ce_code,
59 .code.size = sizeof(gf100_ce_code),
60 .data.data = gf100_ce_data,
61 .data.size = sizeof(gf100_ce_data),
62 .init = gf100_ce_init,
63 .intr = gt215_ce_intr,
64 .sclass = {
65 { -1, -1, FERMI_DECOMPRESS },
66 {}
67 }
68 };
69
70 int
gf100_ce_new(struct nvkm_device * device,int index,struct nvkm_engine ** pengine)71 gf100_ce_new(struct nvkm_device *device, int index,
72 struct nvkm_engine **pengine)
73 {
74 if (index == NVKM_ENGINE_CE0) {
75 return nvkm_falcon_new_(&gf100_ce0, device, index, true,
76 0x104000, pengine);
77 } else
78 if (index == NVKM_ENGINE_CE1) {
79 return nvkm_falcon_new_(&gf100_ce1, device, index, true,
80 0x105000, pengine);
81 }
82 return -ENODEV;
83 }
84