linux/drivers/gpu/drm/nouveau/core/engine/ppp/nv98.c
<<
>>
Prefs
   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
  23 */
  24
  25#include <core/os.h>
  26#include <core/class.h>
  27#include <core/engctx.h>
  28
  29#include <engine/ppp.h>
  30
  31struct nv98_ppp_priv {
  32        struct nouveau_ppp base;
  33};
  34
  35struct nv98_ppp_chan {
  36        struct nouveau_ppp_chan base;
  37};
  38
  39/*******************************************************************************
  40 * PPP object classes
  41 ******************************************************************************/
  42
  43static struct nouveau_oclass
  44nv98_ppp_sclass[] = {
  45        {},
  46};
  47
  48/*******************************************************************************
  49 * PPPP context
  50 ******************************************************************************/
  51
  52static int
  53nv98_ppp_context_ctor(struct nouveau_object *parent,
  54                      struct nouveau_object *engine,
  55                      struct nouveau_oclass *oclass, void *data, u32 size,
  56                      struct nouveau_object **pobject)
  57{
  58        struct nv98_ppp_chan *priv;
  59        int ret;
  60
  61        ret = nouveau_ppp_context_create(parent, engine, oclass, NULL,
  62                                         0, 0, 0, &priv);
  63        *pobject = nv_object(priv);
  64        if (ret)
  65                return ret;
  66
  67        return 0;
  68}
  69
  70static void
  71nv98_ppp_context_dtor(struct nouveau_object *object)
  72{
  73        struct nv98_ppp_chan *priv = (void *)object;
  74        nouveau_ppp_context_destroy(&priv->base);
  75}
  76
  77static int
  78nv98_ppp_context_init(struct nouveau_object *object)
  79{
  80        struct nv98_ppp_chan *priv = (void *)object;
  81        int ret;
  82
  83        ret = nouveau_ppp_context_init(&priv->base);
  84        if (ret)
  85                return ret;
  86
  87        return 0;
  88}
  89
  90static int
  91nv98_ppp_context_fini(struct nouveau_object *object, bool suspend)
  92{
  93        struct nv98_ppp_chan *priv = (void *)object;
  94        return nouveau_ppp_context_fini(&priv->base, suspend);
  95}
  96
  97static struct nouveau_oclass
  98nv98_ppp_cclass = {
  99        .handle = NV_ENGCTX(PPP, 0x98),
 100        .ofuncs = &(struct nouveau_ofuncs) {
 101                .ctor = nv98_ppp_context_ctor,
 102                .dtor = nv98_ppp_context_dtor,
 103                .init = nv98_ppp_context_init,
 104                .fini = nv98_ppp_context_fini,
 105                .rd32 = _nouveau_ppp_context_rd32,
 106                .wr32 = _nouveau_ppp_context_wr32,
 107        },
 108};
 109
 110/*******************************************************************************
 111 * PPPP engine/subdev functions
 112 ******************************************************************************/
 113
 114static void
 115nv98_ppp_intr(struct nouveau_subdev *subdev)
 116{
 117}
 118
 119static int
 120nv98_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 121              struct nouveau_oclass *oclass, void *data, u32 size,
 122              struct nouveau_object **pobject)
 123{
 124        struct nv98_ppp_priv *priv;
 125        int ret;
 126
 127        ret = nouveau_ppp_create(parent, engine, oclass, &priv);
 128        *pobject = nv_object(priv);
 129        if (ret)
 130                return ret;
 131
 132        nv_subdev(priv)->unit = 0x00400002;
 133        nv_subdev(priv)->intr = nv98_ppp_intr;
 134        nv_engine(priv)->cclass = &nv98_ppp_cclass;
 135        nv_engine(priv)->sclass = nv98_ppp_sclass;
 136        return 0;
 137}
 138
 139static void
 140nv98_ppp_dtor(struct nouveau_object *object)
 141{
 142        struct nv98_ppp_priv *priv = (void *)object;
 143        nouveau_ppp_destroy(&priv->base);
 144}
 145
 146static int
 147nv98_ppp_init(struct nouveau_object *object)
 148{
 149        struct nv98_ppp_priv *priv = (void *)object;
 150        int ret;
 151
 152        ret = nouveau_ppp_init(&priv->base);
 153        if (ret)
 154                return ret;
 155
 156        return 0;
 157}
 158
 159static int
 160nv98_ppp_fini(struct nouveau_object *object, bool suspend)
 161{
 162        struct nv98_ppp_priv *priv = (void *)object;
 163        return nouveau_ppp_fini(&priv->base, suspend);
 164}
 165
 166struct nouveau_oclass
 167nv98_ppp_oclass = {
 168        .handle = NV_ENGINE(PPP, 0x98),
 169        .ofuncs = &(struct nouveau_ofuncs) {
 170                .ctor = nv98_ppp_ctor,
 171                .dtor = nv98_ppp_dtor,
 172                .init = nv98_ppp_init,
 173                .fini = nv98_ppp_fini,
 174        },
 175};
 176