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