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