]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/gpu/drm/nouveau/core/engine/copy/nvc0.c
ac3291f781f6e4c204506e02d39d8ca521cf8917
[mirror_ubuntu-jammy-kernel.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 ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, true,
109 "PCE0", "copy0", &priv);
110 *pobject = nv_object(priv);
111 if (ret)
112 return ret;
113
114 nv_subdev(priv)->unit = 0x00000040;
115 nv_subdev(priv)->intr = nva3_copy_intr;
116 nv_engine(priv)->cclass = &nvc0_copy0_cclass;
117 nv_engine(priv)->sclass = nvc0_copy0_sclass;
118 nv_falcon(priv)->code.data = nvc0_pcopy_code;
119 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
120 nv_falcon(priv)->data.data = nvc0_pcopy_data;
121 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
122 return 0;
123 }
124
125 static int
126 nvc0_copy1_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 nvc0_copy_priv *priv;
131 int ret;
132
133 ret = nouveau_falcon_create(parent, engine, oclass, 0x105000, true,
134 "PCE1", "copy1", &priv);
135 *pobject = nv_object(priv);
136 if (ret)
137 return ret;
138
139 nv_subdev(priv)->unit = 0x00000080;
140 nv_subdev(priv)->intr = nva3_copy_intr;
141 nv_engine(priv)->cclass = &nvc0_copy1_cclass;
142 nv_engine(priv)->sclass = nvc0_copy1_sclass;
143 nv_falcon(priv)->code.data = nvc0_pcopy_code;
144 nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
145 nv_falcon(priv)->data.data = nvc0_pcopy_data;
146 nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
147 return 0;
148 }
149
150 struct nouveau_oclass
151 nvc0_copy0_oclass = {
152 .handle = NV_ENGINE(COPY0, 0xc0),
153 .ofuncs = &(struct nouveau_ofuncs) {
154 .ctor = nvc0_copy0_ctor,
155 .dtor = _nouveau_falcon_dtor,
156 .init = nvc0_copy_init,
157 .fini = _nouveau_falcon_fini,
158 .rd32 = _nouveau_falcon_rd32,
159 .wr32 = _nouveau_falcon_wr32,
160 },
161 };
162
163 struct nouveau_oclass
164 nvc0_copy1_oclass = {
165 .handle = NV_ENGINE(COPY1, 0xc0),
166 .ofuncs = &(struct nouveau_ofuncs) {
167 .ctor = nvc0_copy1_ctor,
168 .dtor = _nouveau_falcon_dtor,
169 .init = nvc0_copy_init,
170 .fini = _nouveau_falcon_fini,
171 .rd32 = _nouveau_falcon_rd32,
172 .wr32 = _nouveau_falcon_wr32,
173 },
174 };