drm/nouveau/core: move falcon class to engine/
[deliverable/linux.git] / drivers / gpu / drm / nouveau / core / engine / copy / nvc0.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 <engine/falcon.h>
26 #include <engine/fifo.h>
27 #include <engine/copy.h>
28
29 #include <core/class.h>
30 #include <core/enum.h>
31 #include <core/class.h>
32 #include <core/enum.h>
33
34 #include "fuc/nvc0.fuc.h"
35
36 struct nvc0_copy_priv {
37 struct nouveau_falcon base;
38 };
39
40 /*******************************************************************************
41 * Copy object classes
42 ******************************************************************************/
43
44 static struct nouveau_oclass
45 nvc0_copy0_sclass[] = {
46 { 0x90b5, &nouveau_object_ofuncs },
47 {},
48 };
49
50 static struct nouveau_oclass
51 nvc0_copy1_sclass[] = {
52 { 0x90b8, &nouveau_object_ofuncs },
53 {},
54 };
55
56 /*******************************************************************************
57 * PCOPY context
58 ******************************************************************************/
59
60 static struct nouveau_ofuncs
61 nvc0_copy_context_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 static struct nouveau_oclass
71 nvc0_copy0_cclass = {
72 .handle = NV_ENGCTX(COPY0, 0xc0),
73 .ofuncs = &nvc0_copy_context_ofuncs,
74 };
75
76 static struct nouveau_oclass
77 nvc0_copy1_cclass = {
78 .handle = NV_ENGCTX(COPY1, 0xc0),
79 .ofuncs = &nvc0_copy_context_ofuncs,
80 };
81
82 /*******************************************************************************
83 * PCOPY engine/subdev functions
84 ******************************************************************************/
85
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
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)
104 {
105 struct nvc0_copy_priv *priv;
106 int ret;
107
108 if (nv_rd32(parent, 0x022500) & 0x00000100)
109 return -ENODEV;
110
111 ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, true,
112 "PCE0", "copy0", &priv);
113 *pobject = nv_object(priv);
114 if (ret)
115 return ret;
116
117 nv_subdev(priv)->unit = 0x00000040;
118 nv_subdev(priv)->intr = nva3_copy_intr;
119 nv_engine(priv)->cclass = &nvc0_copy0_cclass;
120 nv_engine(priv)->sclass = nvc0_copy0_sclass;
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);
125 return 0;
126 }
127
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)
132 {
133 struct nvc0_copy_priv *priv;
134 int ret;
135
136 if (nv_rd32(parent, 0x022500) & 0x00000200)
137 return -ENODEV;
138
139 ret = nouveau_falcon_create(parent, engine, oclass, 0x105000, true,
140 "PCE1", "copy1", &priv);
141 *pobject = nv_object(priv);
142 if (ret)
143 return ret;
144
145 nv_subdev(priv)->unit = 0x00000080;
146 nv_subdev(priv)->intr = nva3_copy_intr;
147 nv_engine(priv)->cclass = &nvc0_copy1_cclass;
148 nv_engine(priv)->sclass = nvc0_copy1_sclass;
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);
153 return 0;
154 }
155
156 struct nouveau_oclass
157 nvc0_copy0_oclass = {
158 .handle = NV_ENGINE(COPY0, 0xc0),
159 .ofuncs = &(struct nouveau_ofuncs) {
160 .ctor = nvc0_copy0_ctor,
161 .dtor = _nouveau_falcon_dtor,
162 .init = nvc0_copy_init,
163 .fini = _nouveau_falcon_fini,
164 .rd32 = _nouveau_falcon_rd32,
165 .wr32 = _nouveau_falcon_wr32,
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,
174 .dtor = _nouveau_falcon_dtor,
175 .init = nvc0_copy_init,
176 .fini = _nouveau_falcon_fini,
177 .rd32 = _nouveau_falcon_rd32,
178 .wr32 = _nouveau_falcon_wr32,
179 },
180 };
This page took 0.048024 seconds and 5 git commands to generate.