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