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