drm/nouveau/sec: separate from cipher (formerly crypt)
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / copy / nve0.c
1 /*
2 * Copyright 2012 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
23 */
24
25 #include <core/os.h>
26 #include <core/enum.h>
27 #include <core/engctx.h>
28
29 #include <engine/copy.h>
30
31 struct nve0_copy_priv {
32 struct nouveau_engine base;
33 };
34
35 /*******************************************************************************
36 * Copy object classes
37 ******************************************************************************/
38
39 static struct nouveau_oclass
40 nve0_copy_sclass[] = {
41 { 0xa0b5, &nouveau_object_ofuncs },
42 {},
43 };
44
45 /*******************************************************************************
46 * PCOPY context
47 ******************************************************************************/
48
49 static struct nouveau_ofuncs
50 nve0_copy_context_ofuncs = {
51 .ctor = _nouveau_engctx_ctor,
52 .dtor = _nouveau_engctx_dtor,
53 .init = _nouveau_engctx_init,
54 .fini = _nouveau_engctx_fini,
55 .rd32 = _nouveau_engctx_rd32,
56 .wr32 = _nouveau_engctx_wr32,
57 };
58
59 static struct nouveau_oclass
60 nve0_copy_cclass = {
61 .handle = NV_ENGCTX(COPY0, 0xc0),
62 .ofuncs = &nve0_copy_context_ofuncs,
63 };
64
65 /*******************************************************************************
66 * PCOPY engine/subdev functions
67 ******************************************************************************/
68
69 static void
70 nve0_copy_intr(struct nouveau_subdev *subdev)
71 {
72 const int ce = nv_subidx(subdev) - NVDEV_ENGINE_COPY0;
73 struct nve0_copy_priv *priv = (void *)subdev;
74 u32 stat = nv_rd32(priv, 0x104908 + (ce * 0x1000));
75
76 if (stat) {
77 nv_warn(priv, "unhandled intr 0x%08x\n", stat);
78 nv_wr32(priv, 0x104908 + (ce * 0x1000), stat);
79 }
80 }
81
82 static int
83 nve0_copy0_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
84 struct nouveau_oclass *oclass, void *data, u32 size,
85 struct nouveau_object **pobject)
86 {
87 struct nve0_copy_priv *priv;
88 int ret;
89
90 ret = nouveau_engine_create(parent, engine, oclass, true,
91 "PCE0", "copy0", &priv);
92 *pobject = nv_object(priv);
93 if (ret)
94 return ret;
95
96 nv_subdev(priv)->unit = 0x00000040;
97 nv_subdev(priv)->intr = nve0_copy_intr;
98 nv_engine(priv)->cclass = &nve0_copy_cclass;
99 nv_engine(priv)->sclass = nve0_copy_sclass;
100 return 0;
101 }
102
103 static int
104 nve0_copy1_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
105 struct nouveau_oclass *oclass, void *data, u32 size,
106 struct nouveau_object **pobject)
107 {
108 struct nve0_copy_priv *priv;
109 int ret;
110
111 ret = nouveau_engine_create(parent, engine, oclass, true,
112 "PCE1", "copy1", &priv);
113 *pobject = nv_object(priv);
114 if (ret)
115 return ret;
116
117 nv_subdev(priv)->unit = 0x00000080;
118 nv_subdev(priv)->intr = nve0_copy_intr;
119 nv_engine(priv)->cclass = &nve0_copy_cclass;
120 nv_engine(priv)->sclass = nve0_copy_sclass;
121 return 0;
122 }
123
124 static int
125 nve0_copy2_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
126 struct nouveau_oclass *oclass, void *data, u32 size,
127 struct nouveau_object **pobject)
128 {
129 struct nve0_copy_priv *priv;
130 int ret;
131
132 ret = nouveau_engine_create(parent, engine, oclass, true,
133 "PCE2", "copy2", &priv);
134 *pobject = nv_object(priv);
135 if (ret)
136 return ret;
137
138 nv_subdev(priv)->unit = 0x00200000;
139 nv_subdev(priv)->intr = nve0_copy_intr;
140 nv_engine(priv)->cclass = &nve0_copy_cclass;
141 nv_engine(priv)->sclass = nve0_copy_sclass;
142 return 0;
143 }
144
145 struct nouveau_oclass
146 nve0_copy0_oclass = {
147 .handle = NV_ENGINE(COPY0, 0xe0),
148 .ofuncs = &(struct nouveau_ofuncs) {
149 .ctor = nve0_copy0_ctor,
150 .dtor = _nouveau_engine_dtor,
151 .init = _nouveau_engine_init,
152 .fini = _nouveau_engine_fini,
153 },
154 };
155
156 struct nouveau_oclass
157 nve0_copy1_oclass = {
158 .handle = NV_ENGINE(COPY1, 0xe0),
159 .ofuncs = &(struct nouveau_ofuncs) {
160 .ctor = nve0_copy1_ctor,
161 .dtor = _nouveau_engine_dtor,
162 .init = _nouveau_engine_init,
163 .fini = _nouveau_engine_fini,
164 },
165 };
166
167 struct nouveau_oclass
168 nve0_copy2_oclass = {
169 .handle = NV_ENGINE(COPY2, 0xe0),
170 .ofuncs = &(struct nouveau_ofuncs) {
171 .ctor = nve0_copy2_ctor,
172 .dtor = _nouveau_engine_dtor,
173 .init = _nouveau_engine_init,
174 .fini = _nouveau_engine_fini,
175 },
176 };
This page took 0.035411 seconds and 5 git commands to generate.