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