1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <core/client.h>
26#include <core/os.h>
27#include <core/enum.h>
28#include <core/class.h>
29#include <core/engctx.h>
30
31#include <subdev/timer.h>
32#include <subdev/fb.h>
33
34#include <engine/falcon.h>
35#include <engine/fifo.h>
36#include <engine/crypt.h>
37
38#include "fuc/nv98.fuc.h"
39
40struct nv98_crypt_priv {
41 struct nouveau_falcon base;
42};
43
44
45
46
47
48static struct nouveau_oclass
49nv98_crypt_sclass[] = {
50 { 0x88b4, &nouveau_object_ofuncs },
51 {},
52};
53
54
55
56
57
58static struct nouveau_oclass
59nv98_crypt_cclass = {
60 .handle = NV_ENGCTX(CRYPT, 0x98),
61 .ofuncs = &(struct nouveau_ofuncs) {
62 .ctor = _nouveau_falcon_context_ctor,
63 .dtor = _nouveau_falcon_context_dtor,
64 .init = _nouveau_falcon_context_init,
65 .fini = _nouveau_falcon_context_fini,
66 .rd32 = _nouveau_falcon_context_rd32,
67 .wr32 = _nouveau_falcon_context_wr32,
68 },
69};
70
71
72
73
74
75static const struct nouveau_enum nv98_crypt_isr_error_name[] = {
76 { 0x0000, "ILLEGAL_MTHD" },
77 { 0x0001, "INVALID_BITFIELD" },
78 { 0x0002, "INVALID_ENUM" },
79 { 0x0003, "QUERY" },
80 {}
81};
82
83static void
84nv98_crypt_intr(struct nouveau_subdev *subdev)
85{
86 struct nouveau_fifo *pfifo = nouveau_fifo(subdev);
87 struct nouveau_engine *engine = nv_engine(subdev);
88 struct nouveau_object *engctx;
89 struct nv98_crypt_priv *priv = (void *)subdev;
90 u32 disp = nv_rd32(priv, 0x08701c);
91 u32 stat = nv_rd32(priv, 0x087008) & disp & ~(disp >> 16);
92 u32 inst = nv_rd32(priv, 0x087050) & 0x3fffffff;
93 u32 ssta = nv_rd32(priv, 0x087040) & 0x0000ffff;
94 u32 addr = nv_rd32(priv, 0x087040) >> 16;
95 u32 mthd = (addr & 0x07ff) << 2;
96 u32 subc = (addr & 0x3800) >> 11;
97 u32 data = nv_rd32(priv, 0x087044);
98 int chid;
99
100 engctx = nouveau_engctx_get(engine, inst);
101 chid = pfifo->chid(pfifo, engctx);
102
103 if (stat & 0x00000040) {
104 nv_error(priv, "DISPATCH_ERROR [");
105 nouveau_enum_print(nv98_crypt_isr_error_name, ssta);
106 pr_cont("] ch %d [0x%010llx %s] subc %d mthd 0x%04x data 0x%08x\n",
107 chid, (u64)inst << 12, nouveau_client_name(engctx),
108 subc, mthd, data);
109 nv_wr32(priv, 0x087004, 0x00000040);
110 stat &= ~0x00000040;
111 }
112
113 if (stat) {
114 nv_error(priv, "unhandled intr 0x%08x\n", stat);
115 nv_wr32(priv, 0x087004, stat);
116 }
117
118 nouveau_engctx_put(engctx);
119}
120
121static int
122nv98_crypt_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
123 struct nouveau_oclass *oclass, void *data, u32 size,
124 struct nouveau_object **pobject)
125{
126 struct nv98_crypt_priv *priv;
127 int ret;
128
129 ret = nouveau_falcon_create(parent, engine, oclass, 0x087000, true,
130 "PCRYPT", "crypt", &priv);
131 *pobject = nv_object(priv);
132 if (ret)
133 return ret;
134
135 nv_subdev(priv)->unit = 0x00004000;
136 nv_subdev(priv)->intr = nv98_crypt_intr;
137 nv_engine(priv)->cclass = &nv98_crypt_cclass;
138 nv_engine(priv)->sclass = nv98_crypt_sclass;
139 nv_falcon(priv)->code.data = nv98_pcrypt_code;
140 nv_falcon(priv)->code.size = sizeof(nv98_pcrypt_code);
141 nv_falcon(priv)->data.data = nv98_pcrypt_data;
142 nv_falcon(priv)->data.size = sizeof(nv98_pcrypt_data);
143 return 0;
144}
145
146struct nouveau_oclass
147nv98_crypt_oclass = {
148 .handle = NV_ENGINE(CRYPT, 0x98),
149 .ofuncs = &(struct nouveau_ofuncs) {
150 .ctor = nv98_crypt_ctor,
151 .dtor = _nouveau_falcon_dtor,
152 .init = _nouveau_falcon_init,
153 .fini = _nouveau_falcon_fini,
154 .rd32 = _nouveau_falcon_rd32,
155 .wr32 = _nouveau_falcon_wr32,
156 },
157};
158