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/bsp.h>
25 #include <engine/xtensa.h>
26
27 #include <core/engctx.h>
28
29 /*******************************************************************************
30 * BSP object classes
31 ******************************************************************************/
32
33 static struct nvkm_oclass
34 g84_bsp_sclass[] = {
35 { 0x74b0, &nvkm_object_ofuncs },
36 {},
37 };
38
39 /*******************************************************************************
40 * BSP context
41 ******************************************************************************/
42
43 static struct nvkm_oclass
44 g84_bsp_cclass = {
45 .handle = NV_ENGCTX(BSP, 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 * BSP engine/subdev functions
58 ******************************************************************************/
59
60 static int
g84_bsp_ctor(struct nvkm_object * parent,struct nvkm_object * engine,struct nvkm_oclass * oclass,void * data,u32 size,struct nvkm_object ** pobject)61 g84_bsp_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 *priv;
66 int ret;
67
68 ret = nvkm_xtensa_create(parent, engine, oclass, 0x103000, true,
69 "PBSP", "bsp", &priv);
70 *pobject = nv_object(priv);
71 if (ret)
72 return ret;
73
74 nv_subdev(priv)->unit = 0x04008000;
75 nv_engine(priv)->cclass = &g84_bsp_cclass;
76 nv_engine(priv)->sclass = g84_bsp_sclass;
77 priv->fifo_val = 0x1111;
78 priv->unkd28 = 0x90044;
79 return 0;
80 }
81
82 struct nvkm_oclass
83 g84_bsp_oclass = {
84 .handle = NV_ENGINE(BSP, 0x84),
85 .ofuncs = &(struct nvkm_ofuncs) {
86 .ctor = g84_bsp_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