2 * Copyright 2021 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
24 #include <nvif/class.h>
27 tu102_vfn_intr_reset(struct nvkm_intr *intr, int leaf, u32 mask)
29 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
31 nvkm_wr32(vfn->subdev.device, vfn->addr.priv + 0x1000 + (leaf * 4), mask);
35 tu102_vfn_intr_allow(struct nvkm_intr *intr, int leaf, u32 mask)
37 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
39 nvkm_wr32(vfn->subdev.device, vfn->addr.priv + 0x1200 + (leaf * 4), mask);
43 tu102_vfn_intr_block(struct nvkm_intr *intr, int leaf, u32 mask)
45 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
47 nvkm_wr32(vfn->subdev.device, vfn->addr.priv + 0x1400 + (leaf * 4), mask);
51 tu102_vfn_intr_rearm(struct nvkm_intr *intr)
53 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
55 nvkm_wr32(vfn->subdev.device, vfn->addr.priv + 0x1608, 0x0000000f);
59 tu102_vfn_intr_unarm(struct nvkm_intr *intr)
61 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
63 nvkm_wr32(vfn->subdev.device, vfn->addr.priv + 0x1610, 0x0000000f);
67 tu102_vfn_intr_pending(struct nvkm_intr *intr)
69 struct nvkm_vfn *vfn = container_of(intr, typeof(*vfn), intr);
70 struct nvkm_device *device = vfn->subdev.device;
71 u32 intr_top = nvkm_rd32(device, vfn->addr.priv + 0x1600);
72 int pending = 0, leaf;
74 for (leaf = 0; leaf < 8; leaf++) {
75 if (intr_top & BIT(leaf / 2)) {
76 intr->stat[leaf] = nvkm_rd32(device, vfn->addr.priv + 0x1000 + (leaf * 4));
87 const struct nvkm_intr_func
89 .pending = tu102_vfn_intr_pending,
90 .unarm = tu102_vfn_intr_unarm,
91 .rearm = tu102_vfn_intr_rearm,
92 .block = tu102_vfn_intr_block,
93 .allow = tu102_vfn_intr_allow,
94 .reset = tu102_vfn_intr_reset,
97 static const struct nvkm_vfn_func
99 .intr = &tu102_vfn_intr,
100 .user = { 0x030000, 0x010000, { -1, -1, TURING_USERMODE_A } },
104 tu102_vfn_new(struct nvkm_device *device,
105 enum nvkm_subdev_type type, int inst, struct nvkm_vfn **pvfn)
107 return nvkm_vfn_new_(&tu102_vfn, device, type, inst, 0xb80000, pvfn);