2 * Copyright 2015 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <engine/ce.h>
26 #include <core/engctx.h>
28 struct gm204_ce_priv {
29 struct nvkm_engine base;
32 /*******************************************************************************
34 ******************************************************************************/
36 static struct nvkm_oclass
38 { 0xb0b5, &nvkm_object_ofuncs },
42 /*******************************************************************************
44 ******************************************************************************/
46 static struct nvkm_ofuncs
47 gm204_ce_context_ofuncs = {
48 .ctor = _nvkm_engctx_ctor,
49 .dtor = _nvkm_engctx_dtor,
50 .init = _nvkm_engctx_init,
51 .fini = _nvkm_engctx_fini,
52 .rd32 = _nvkm_engctx_rd32,
53 .wr32 = _nvkm_engctx_wr32,
56 static struct nvkm_oclass
58 .handle = NV_ENGCTX(CE0, 0x24),
59 .ofuncs = &gm204_ce_context_ofuncs,
62 /*******************************************************************************
63 * PCE engine/subdev functions
64 ******************************************************************************/
67 gm204_ce_intr(struct nvkm_subdev *subdev)
69 const int ce = nv_subidx(subdev) - NVDEV_ENGINE_CE0;
70 struct gm204_ce_priv *priv = (void *)subdev;
71 u32 stat = nv_rd32(priv, 0x104908 + (ce * 0x1000));
74 nv_warn(priv, "unhandled intr 0x%08x\n", stat);
75 nv_wr32(priv, 0x104908 + (ce * 0x1000), stat);
80 gm204_ce0_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
81 struct nvkm_oclass *oclass, void *data, u32 size,
82 struct nvkm_object **pobject)
84 struct gm204_ce_priv *priv;
87 ret = nvkm_engine_create(parent, engine, oclass, true,
88 "PCE0", "ce0", &priv);
89 *pobject = nv_object(priv);
93 nv_subdev(priv)->unit = 0x00000040;
94 nv_subdev(priv)->intr = gm204_ce_intr;
95 nv_engine(priv)->cclass = &gm204_ce_cclass;
96 nv_engine(priv)->sclass = gm204_ce_sclass;
101 gm204_ce1_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
102 struct nvkm_oclass *oclass, void *data, u32 size,
103 struct nvkm_object **pobject)
105 struct gm204_ce_priv *priv;
108 ret = nvkm_engine_create(parent, engine, oclass, true,
109 "PCE1", "ce1", &priv);
110 *pobject = nv_object(priv);
114 nv_subdev(priv)->unit = 0x00000080;
115 nv_subdev(priv)->intr = gm204_ce_intr;
116 nv_engine(priv)->cclass = &gm204_ce_cclass;
117 nv_engine(priv)->sclass = gm204_ce_sclass;
122 gm204_ce2_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
123 struct nvkm_oclass *oclass, void *data, u32 size,
124 struct nvkm_object **pobject)
126 struct gm204_ce_priv *priv;
129 ret = nvkm_engine_create(parent, engine, oclass, true,
130 "PCE2", "ce2", &priv);
131 *pobject = nv_object(priv);
135 nv_subdev(priv)->unit = 0x00200000;
136 nv_subdev(priv)->intr = gm204_ce_intr;
137 nv_engine(priv)->cclass = &gm204_ce_cclass;
138 nv_engine(priv)->sclass = gm204_ce_sclass;
144 .handle = NV_ENGINE(CE0, 0x24),
145 .ofuncs = &(struct nvkm_ofuncs) {
146 .ctor = gm204_ce0_ctor,
147 .dtor = _nvkm_engine_dtor,
148 .init = _nvkm_engine_init,
149 .fini = _nvkm_engine_fini,
155 .handle = NV_ENGINE(CE1, 0x24),
156 .ofuncs = &(struct nvkm_ofuncs) {
157 .ctor = gm204_ce1_ctor,
158 .dtor = _nvkm_engine_dtor,
159 .init = _nvkm_engine_init,
160 .fini = _nvkm_engine_fini,
166 .handle = NV_ENGINE(CE2, 0x24),
167 .ofuncs = &(struct nvkm_ofuncs) {
168 .ctor = gm204_ce2_ctor,
169 .dtor = _nvkm_engine_dtor,
170 .init = _nvkm_engine_init,
171 .fini = _nvkm_engine_fini,