1/* $NetBSD: nouveau_engine_copy_nvc0.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $ */
2
3/*
4 * Copyright 2012 Red Hat Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Ben Skeggs
25 */
26
27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_copy_nvc0.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $");
29
30#include <engine/falcon.h>
31#include <engine/fifo.h>
32#include <engine/copy.h>
33
34#include <core/class.h>
35#include <core/enum.h>
36#include <core/class.h>
37#include <core/enum.h>
38
39#include "fuc/nvc0.fuc.h"
40
41struct nvc0_copy_priv {
42 struct nouveau_falcon base;
43};
44
45/*******************************************************************************
46 * Copy object classes
47 ******************************************************************************/
48
49static struct nouveau_oclass
50nvc0_copy0_sclass[] = {
51 { 0x90b5, &nouveau_object_ofuncs },
52 {},
53};
54
55static struct nouveau_oclass
56nvc0_copy1_sclass[] = {
57 { 0x90b8, &nouveau_object_ofuncs },
58 {},
59};
60
61/*******************************************************************************
62 * PCOPY context
63 ******************************************************************************/
64
65static struct nouveau_ofuncs
66nvc0_copy_context_ofuncs = {
67 .ctor = _nouveau_falcon_context_ctor,
68 .dtor = _nouveau_falcon_context_dtor,
69 .init = _nouveau_falcon_context_init,
70 .fini = _nouveau_falcon_context_fini,
71 .rd32 = _nouveau_falcon_context_rd32,
72 .wr32 = _nouveau_falcon_context_wr32,
73};
74
75static struct nouveau_oclass
76nvc0_copy0_cclass = {
77 .handle = NV_ENGCTX(COPY0, 0xc0),
78 .ofuncs = &nvc0_copy_context_ofuncs,
79};
80
81static struct nouveau_oclass
82nvc0_copy1_cclass = {
83 .handle = NV_ENGCTX(COPY1, 0xc0),
84 .ofuncs = &nvc0_copy_context_ofuncs,
85};
86
87/*******************************************************************************
88 * PCOPY engine/subdev functions
89 ******************************************************************************/
90
91static int
92nvc0_copy_init(struct nouveau_object *object)
93{
94 struct nvc0_copy_priv *priv = (void *)object;
95 int ret;
96
97 ret = nouveau_falcon_init(&priv->base);
98 if (ret)
99 return ret;
100
101 nv_wo32(priv, 0x084, nv_engidx(object) - NVDEV_ENGINE_COPY0);
102 return 0;
103}
104
105static int
106nvc0_copy0_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
107 struct nouveau_oclass *oclass, void *data, u32 size,
108 struct nouveau_object **pobject)
109{
110 struct nvc0_copy_priv *priv;
111 int ret;
112
113 ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, true,
114 "PCE0", "copy0", &priv);
115 *pobject = nv_object(priv);
116 if (ret)
117 return ret;
118
119 nv_subdev(priv)->unit = 0x00000040;
120 nv_subdev(priv)->intr = nva3_copy_intr;
121 nv_engine(priv)->cclass = &nvc0_copy0_cclass;
122 nv_engine(priv)->sclass = nvc0_copy0_sclass;
123 nv_falcon(priv)->code.data = nvc0_pcopy_code;
124 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
125 nv_falcon(priv)->data.data = nvc0_pcopy_data;
126 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
127 return 0;
128}
129
130static int
131nvc0_copy1_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
132 struct nouveau_oclass *oclass, void *data, u32 size,
133 struct nouveau_object **pobject)
134{
135 struct nvc0_copy_priv *priv;
136 int ret;
137
138 ret = nouveau_falcon_create(parent, engine, oclass, 0x105000, true,
139 "PCE1", "copy1", &priv);
140 *pobject = nv_object(priv);
141 if (ret)
142 return ret;
143
144 nv_subdev(priv)->unit = 0x00000080;
145 nv_subdev(priv)->intr = nva3_copy_intr;
146 nv_engine(priv)->cclass = &nvc0_copy1_cclass;
147 nv_engine(priv)->sclass = nvc0_copy1_sclass;
148 nv_falcon(priv)->code.data = nvc0_pcopy_code;
149 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
150 nv_falcon(priv)->data.data = nvc0_pcopy_data;
151 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
152 return 0;
153}
154
155struct nouveau_oclass
156nvc0_copy0_oclass = {
157 .handle = NV_ENGINE(COPY0, 0xc0),
158 .ofuncs = &(struct nouveau_ofuncs) {
159 .ctor = nvc0_copy0_ctor,
160 .dtor = _nouveau_falcon_dtor,
161 .init = nvc0_copy_init,
162 .fini = _nouveau_falcon_fini,
163 .rd32 = _nouveau_falcon_rd32,
164 .wr32 = _nouveau_falcon_wr32,
165 },
166};
167
168struct nouveau_oclass
169nvc0_copy1_oclass = {
170 .handle = NV_ENGINE(COPY1, 0xc0),
171 .ofuncs = &(struct nouveau_ofuncs) {
172 .ctor = nvc0_copy1_ctor,
173 .dtor = _nouveau_falcon_dtor,
174 .init = nvc0_copy_init,
175 .fini = _nouveau_falcon_fini,
176 .rd32 = _nouveau_falcon_rd32,
177 .wr32 = _nouveau_falcon_wr32,
178 },
179};
180