Commit | Line | Data |
---|---|---|
fb3e9c61 BS |
1 | /* |
2 | * Copyright 2016 Red Hat Inc. | |
3 | * | |
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: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
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. | |
21 | * | |
22 | * Authors: Ben Skeggs <bskeggs@redhat.com> | |
23 | */ | |
24 | #include "priv.h" | |
25 | ||
d4c9cd34 BS |
26 | #include <subdev/gsp.h> |
27 | ||
fb3e9c61 | 28 | static int |
eec3f6df | 29 | gk104_top_parse(struct nvkm_top *top) |
fb3e9c61 BS |
30 | { |
31 | struct nvkm_subdev *subdev = &top->subdev; | |
32 | struct nvkm_device *device = subdev->device; | |
33 | struct nvkm_top_device *info = NULL; | |
51012a39 | 34 | u32 data, type, inst; |
fb3e9c61 BS |
35 | int i; |
36 | ||
37 | for (i = 0; i < 64; i++) { | |
38 | if (!info) { | |
39 | if (!(info = nvkm_top_device_new(top))) | |
40 | return -ENOMEM; | |
41 | type = ~0; | |
51012a39 | 42 | inst = 0; |
fb3e9c61 BS |
43 | } |
44 | ||
45 | data = nvkm_rd32(device, 0x022700 + (i * 0x04)); | |
46 | nvkm_trace(subdev, "%02x: %08x\n", i, data); | |
47 | switch (data & 0x00000003) { | |
48 | case 0x00000000: /* NOT_VALID */ | |
49 | continue; | |
50 | case 0x00000001: /* DATA */ | |
51012a39 | 51 | inst = (data & 0x3c000000) >> 26; |
fb3e9c61 | 52 | info->addr = (data & 0x00fff000); |
a1c771a5 BS |
53 | if (data & 0x00000004) |
54 | info->fault = (data & 0x000003f8) >> 3; | |
fb3e9c61 BS |
55 | break; |
56 | case 0x00000002: /* ENUM */ | |
57 | if (data & 0x00000020) | |
58 | info->engine = (data & 0x3c000000) >> 26; | |
59 | if (data & 0x00000010) | |
60 | info->runlist = (data & 0x01e00000) >> 21; | |
61 | if (data & 0x00000008) | |
62 | info->intr = (data & 0x000f8000) >> 15; | |
63 | if (data & 0x00000004) | |
64 | info->reset = (data & 0x00003e00) >> 9; | |
65 | break; | |
66 | case 0x00000003: /* ENGINE_TYPE */ | |
67 | type = (data & 0x7ffffffc) >> 2; | |
68 | break; | |
69 | } | |
70 | ||
71 | if (data & 0x80000000) | |
72 | continue; | |
73 | ||
74 | /* Translate engine type to NVKM engine identifier. */ | |
ba083ec7 | 75 | #define I_(T,I) do { info->type = (T); info->inst = (I); } while(0) |
5e0d3dbc | 76 | #define O_(T,I) do { WARN_ON(inst); I_(T, I); } while (0) |
fb3e9c61 | 77 | switch (type) { |
5e0d3dbc BS |
78 | case 0x00000000: O_(NVKM_ENGINE_GR , 0); break; |
79 | case 0x00000001: O_(NVKM_ENGINE_CE , 0); break; | |
80 | case 0x00000002: O_(NVKM_ENGINE_CE , 1); break; | |
81 | case 0x00000003: O_(NVKM_ENGINE_CE , 2); break; | |
82 | case 0x00000008: O_(NVKM_ENGINE_MSPDEC, 0); break; | |
83 | case 0x00000009: O_(NVKM_ENGINE_MSPPP , 0); break; | |
84 | case 0x0000000a: O_(NVKM_ENGINE_MSVLD , 0); break; | |
85 | case 0x0000000b: O_(NVKM_ENGINE_MSENC , 0); break; | |
86 | case 0x0000000c: O_(NVKM_ENGINE_VIC , 0); break; | |
87 | case 0x0000000d: O_(NVKM_ENGINE_SEC2 , 0); break; | |
88 | case 0x0000000e: I_(NVKM_ENGINE_NVENC , inst); break; | |
89 | case 0x0000000f: O_(NVKM_ENGINE_NVENC , 1); break; | |
90 | case 0x00000010: I_(NVKM_ENGINE_NVDEC , inst); break; | |
18618fc6 | 91 | case 0x00000012: I_(NVKM_SUBDEV_IOCTRL, inst); break; |
5e0d3dbc BS |
92 | case 0x00000013: I_(NVKM_ENGINE_CE , inst); break; |
93 | case 0x00000014: O_(NVKM_SUBDEV_GSP , 0); break; | |
e8669270 | 94 | case 0x00000015: I_(NVKM_ENGINE_NVJPG , inst); break; |
fb3e9c61 BS |
95 | default: |
96 | break; | |
97 | } | |
98 | ||
51012a39 BS |
99 | nvkm_debug(subdev, "%02x.%d (%8s): addr %06x fault %2d " |
100 | "engine %2d runlist %2d intr %2d " | |
101 | "reset %2d\n", type, inst, | |
5e0d3dbc | 102 | info->type == NVKM_SUBDEV_NR ? "????????" : nvkm_subdev_type[info->type], |
fb3e9c61 BS |
103 | info->addr, info->fault, info->engine, info->runlist, |
104 | info->intr, info->reset); | |
105 | info = NULL; | |
106 | } | |
107 | ||
108 | return 0; | |
109 | } | |
110 | ||
111 | static const struct nvkm_top_func | |
112 | gk104_top = { | |
eec3f6df | 113 | .parse = gk104_top_parse, |
fb3e9c61 BS |
114 | }; |
115 | ||
116 | int | |
601c2a06 BS |
117 | gk104_top_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, |
118 | struct nvkm_top **ptop) | |
fb3e9c61 | 119 | { |
d4c9cd34 BS |
120 | if (nvkm_gsp_rm(device->gsp)) |
121 | return -ENODEV; | |
122 | ||
601c2a06 | 123 | return nvkm_top_new_(&gk104_top, device, type, inst, ptop); |
fb3e9c61 | 124 | } |