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/falcon.h>
26#include <core/class.h>
27#include <core/enum.h>
28
29#include <engine/fifo.h>
30#include <engine/copy.h>
31
32#include "fuc/nvc0.fuc.h"
33
34struct nvc0_copy_priv {
35 struct nouveau_falcon base;
36};
37
38
39
40
41
42static struct nouveau_oclass
43nvc0_copy0_sclass[] = {
44 { 0x90b5, &nouveau_object_ofuncs },
45 {},
46};
47
48static struct nouveau_oclass
49nvc0_copy1_sclass[] = {
50 { 0x90b8, &nouveau_object_ofuncs },
51 {},
52};
53
54
55
56
57
58static struct nouveau_ofuncs
59nvc0_copy_context_ofuncs = {
60 .ctor = _nouveau_falcon_context_ctor,
61 .dtor = _nouveau_falcon_context_dtor,
62 .init = _nouveau_falcon_context_init,
63 .fini = _nouveau_falcon_context_fini,
64 .rd32 = _nouveau_falcon_context_rd32,
65 .wr32 = _nouveau_falcon_context_wr32,
66};
67
68static struct nouveau_oclass
69nvc0_copy0_cclass = {
70 .handle = NV_ENGCTX(COPY0, 0xc0),
71 .ofuncs = &nvc0_copy_context_ofuncs,
72};
73
74static struct nouveau_oclass
75nvc0_copy1_cclass = {
76 .handle = NV_ENGCTX(COPY1, 0xc0),
77 .ofuncs = &nvc0_copy_context_ofuncs,
78};
79
80
81
82
83
84static int
85nvc0_copy_init(struct nouveau_object *object)
86{
87 struct nvc0_copy_priv *priv = (void *)object;
88 int ret;
89
90 ret = nouveau_falcon_init(&priv->base);
91 if (ret)
92 return ret;
93
94 nv_wo32(priv, 0x084, nv_engidx(object) - NVDEV_ENGINE_COPY0);
95 return 0;
96}
97
98static int
99nvc0_copy0_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
100 struct nouveau_oclass *oclass, void *data, u32 size,
101 struct nouveau_object **pobject)
102{
103 struct nvc0_copy_priv *priv;
104 int ret;
105
106 if (nv_rd32(parent, 0x022500) & 0x00000100)
107 return -ENODEV;
108
109 ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, true,
110 "PCE0", "copy0", &priv);
111 *pobject = nv_object(priv);
112 if (ret)
113 return ret;
114
115 nv_subdev(priv)->unit = 0x00000040;
116 nv_subdev(priv)->intr = nva3_copy_intr;
117 nv_engine(priv)->cclass = &nvc0_copy0_cclass;
118 nv_engine(priv)->sclass = nvc0_copy0_sclass;
119 nv_falcon(priv)->code.data = nvc0_pcopy_code;
120 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
121 nv_falcon(priv)->data.data = nvc0_pcopy_data;
122 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
123 return 0;
124}
125
126static int
127nvc0_copy1_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
128 struct nouveau_oclass *oclass, void *data, u32 size,
129 struct nouveau_object **pobject)
130{
131 struct nvc0_copy_priv *priv;
132 int ret;
133
134 if (nv_rd32(parent, 0x022500) & 0x00000200)
135 return -ENODEV;
136
137 ret = nouveau_falcon_create(parent, engine, oclass, 0x105000, true,
138 "PCE1", "copy1", &priv);
139 *pobject = nv_object(priv);
140 if (ret)
141 return ret;
142
143 nv_subdev(priv)->unit = 0x00000080;
144 nv_subdev(priv)->intr = nva3_copy_intr;
145 nv_engine(priv)->cclass = &nvc0_copy1_cclass;
146 nv_engine(priv)->sclass = nvc0_copy1_sclass;
147 nv_falcon(priv)->code.data = nvc0_pcopy_code;
148 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
149 nv_falcon(priv)->data.data = nvc0_pcopy_data;
150 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
151 return 0;
152}
153
154struct nouveau_oclass
155nvc0_copy0_oclass = {
156 .handle = NV_ENGINE(COPY0, 0xc0),
157 .ofuncs = &(struct nouveau_ofuncs) {
158 .ctor = nvc0_copy0_ctor,
159 .dtor = _nouveau_falcon_dtor,
160 .init = nvc0_copy_init,
161 .fini = _nouveau_falcon_fini,
162 .rd32 = _nouveau_falcon_rd32,
163 .wr32 = _nouveau_falcon_wr32,
164 },
165};
166
167struct nouveau_oclass
168nvc0_copy1_oclass = {
169 .handle = NV_ENGINE(COPY1, 0xc0),
170 .ofuncs = &(struct nouveau_ofuncs) {
171 .ctor = nvc0_copy1_ctor,
172 .dtor = _nouveau_falcon_dtor,
173 .init = nvc0_copy_init,
174 .fini = _nouveau_falcon_fini,
175 .rd32 = _nouveau_falcon_rd32,
176 .wr32 = _nouveau_falcon_wr32,
177 },
178};
179