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, Ilia Mirkin
23  */
24 #include <engine/vp.h>
25 #include <engine/xtensa.h>
26 
27 #include <core/engctx.h>
28 
29 /*******************************************************************************
30  * VP object classes
31  ******************************************************************************/
32 
33 static struct nvkm_oclass
34 g84_vp_sclass[] = {
35 	{ 0x7476, &nvkm_object_ofuncs },
36 	{},
37 };
38 
39 /*******************************************************************************
40  * PVP context
41  ******************************************************************************/
42 
43 static struct nvkm_oclass
44 g84_vp_cclass = {
45 	.handle = NV_ENGCTX(VP, 0x84),
46 	.ofuncs = &(struct nvkm_ofuncs) {
47 		.ctor = _nvkm_xtensa_engctx_ctor,
48 		.dtor = _nvkm_engctx_dtor,
49 		.init = _nvkm_engctx_init,
50 		.fini = _nvkm_engctx_fini,
51 		.rd32 = _nvkm_engctx_rd32,
52 		.wr32 = _nvkm_engctx_wr32,
53 	},
54 };
55 
56 /*******************************************************************************
57  * PVP engine/subdev functions
58  ******************************************************************************/
59 
60 static int
61 g84_vp_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
62 	    struct nvkm_oclass *oclass, void *data, u32 size,
63 	    struct nvkm_object **pobject)
64 {
65 	struct nvkm_xtensa *vp;
66 	int ret;
67 
68 	ret = nvkm_xtensa_create(parent, engine, oclass, 0xf000, true,
69 				 "PVP", "vp", &vp);
70 	*pobject = nv_object(vp);
71 	if (ret)
72 		return ret;
73 
74 	nv_subdev(vp)->unit = 0x01020000;
75 	nv_engine(vp)->cclass = &g84_vp_cclass;
76 	nv_engine(vp)->sclass = g84_vp_sclass;
77 	vp->fifo_val = 0x111;
78 	vp->unkd28 = 0x9c544;
79 	return 0;
80 }
81 
82 struct nvkm_oclass
83 g84_vp_oclass = {
84 	.handle = NV_ENGINE(VP, 0x84),
85 	.ofuncs = &(struct nvkm_ofuncs) {
86 		.ctor = g84_vp_ctor,
87 		.dtor = _nvkm_xtensa_dtor,
88 		.init = _nvkm_xtensa_init,
89 		.fini = _nvkm_xtensa_fini,
90 		.rd32 = _nvkm_xtensa_rd32,
91 		.wr32 = _nvkm_xtensa_wr32,
92 	},
93 };
94