1/* $NetBSD: nouveau_engine_bsp_nv98.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, Maarten Lankhorst, Ilia Mirkin
25 */
26
27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_bsp_nv98.c,v 1.1.1.1 2014/08/06 12:36:24 riastradh Exp $");
29
30#include <engine/falcon.h>
31#include <engine/bsp.h>
32
33struct nv98_bsp_priv {
34 struct nouveau_falcon base;
35};
36
37/*******************************************************************************
38 * BSP object classes
39 ******************************************************************************/
40
41static struct nouveau_oclass
42nv98_bsp_sclass[] = {
43 { 0x88b1, &nouveau_object_ofuncs },
44 { 0x85b1, &nouveau_object_ofuncs },
45 { 0x86b1, &nouveau_object_ofuncs },
46 {},
47};
48
49/*******************************************************************************
50 * PBSP context
51 ******************************************************************************/
52
53static struct nouveau_oclass
54nv98_bsp_cclass = {
55 .handle = NV_ENGCTX(BSP, 0x98),
56 .ofuncs = &(struct nouveau_ofuncs) {
57 .ctor = _nouveau_falcon_context_ctor,
58 .dtor = _nouveau_falcon_context_dtor,
59 .init = _nouveau_falcon_context_init,
60 .fini = _nouveau_falcon_context_fini,
61 .rd32 = _nouveau_falcon_context_rd32,
62 .wr32 = _nouveau_falcon_context_wr32,
63 },
64};
65
66/*******************************************************************************
67 * PBSP engine/subdev functions
68 ******************************************************************************/
69
70static int
71nv98_bsp_init(struct nouveau_object *object)
72{
73 struct nv98_bsp_priv *priv = (void *)object;
74 int ret;
75
76 ret = nouveau_falcon_init(&priv->base);
77 if (ret)
78 return ret;
79
80 nv_wr32(priv, 0x084010, 0x0000ffd2);
81 nv_wr32(priv, 0x08401c, 0x0000fff2);
82 return 0;
83}
84
85static int
86nv98_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
87 struct nouveau_oclass *oclass, void *data, u32 size,
88 struct nouveau_object **pobject)
89{
90 struct nv98_bsp_priv *priv;
91 int ret;
92
93 ret = nouveau_falcon_create(parent, engine, oclass, 0x084000, true,
94 "PBSP", "bsp", &priv);
95 *pobject = nv_object(priv);
96 if (ret)
97 return ret;
98
99 nv_subdev(priv)->unit = 0x04008000;
100 nv_engine(priv)->cclass = &nv98_bsp_cclass;
101 nv_engine(priv)->sclass = nv98_bsp_sclass;
102 return 0;
103}
104
105struct nouveau_oclass
106nv98_bsp_oclass = {
107 .handle = NV_ENGINE(BSP, 0x98),
108 .ofuncs = &(struct nouveau_ofuncs) {
109 .ctor = nv98_bsp_ctor,
110 .dtor = _nouveau_falcon_dtor,
111 .init = nv98_bsp_init,
112 .fini = _nouveau_falcon_fini,
113 .rd32 = _nouveau_falcon_rd32,
114 .wr32 = _nouveau_falcon_wr32,
115 },
116};
117