linux/drivers/gpu/drm/nouveau/core/engine/copy/nvc0.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/falcon.h>
  26#include <core/class.h>
  27#include <core/enum.h>
  28
  29#include <engine/fifo.h>
  30#include <engine/copy.h>
  31
  32#include "fuc/nvc0.fuc.h"
  33
  34struct nvc0_copy_priv {
  35        struct nouveau_falcon base;
  36};
  37
  38/*******************************************************************************
  39 * Copy object classes
  40 ******************************************************************************/
  41
  42static struct nouveau_oclass
  43nvc0_copy0_sclass[] = {
  44        { 0x90b5, &nouveau_object_ofuncs },
  45        {},
  46};
  47
  48static struct nouveau_oclass
  49nvc0_copy1_sclass[] = {
  50        { 0x90b8, &nouveau_object_ofuncs },
  51        {},
  52};
  53
  54/*******************************************************************************
  55 * PCOPY context
  56 ******************************************************************************/
  57
  58static struct nouveau_ofuncs
  59nvc0_copy_context_ofuncs = {
  60        .ctor = _nouveau_falcon_context_ctor,
  61        .dtor = _nouveau_falcon_context_dtor,
  62        .init = _nouveau_falcon_context_init,
  63        .fini = _nouveau_falcon_context_fini,
  64        .rd32 = _nouveau_falcon_context_rd32,
  65        .wr32 = _nouveau_falcon_context_wr32,
  66};
  67
  68static struct nouveau_oclass
  69nvc0_copy0_cclass = {
  70        .handle = NV_ENGCTX(COPY0, 0xc0),
  71        .ofuncs = &nvc0_copy_context_ofuncs,
  72};
  73
  74static struct nouveau_oclass
  75nvc0_copy1_cclass = {
  76        .handle = NV_ENGCTX(COPY1, 0xc0),
  77        .ofuncs = &nvc0_copy_context_ofuncs,
  78};
  79
  80/*******************************************************************************
  81 * PCOPY engine/subdev functions
  82 ******************************************************************************/
  83
  84static int
  85nvc0_copy_init(struct nouveau_object *object)
  86{
  87        struct nvc0_copy_priv *priv = (void *)object;
  88        int ret;
  89
  90        ret = nouveau_falcon_init(&priv->base);
  91        if (ret)
  92                return ret;
  93
  94        nv_wo32(priv, 0x084, nv_engidx(object) - NVDEV_ENGINE_COPY0);
  95        return 0;
  96}
  97
  98static int
  99nvc0_copy0_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 100                struct nouveau_oclass *oclass, void *data, u32 size,
 101                struct nouveau_object **pobject)
 102{
 103        struct nvc0_copy_priv *priv;
 104        int ret;
 105
 106        if (nv_rd32(parent, 0x022500) & 0x00000100)
 107                return -ENODEV;
 108
 109        ret = nouveau_falcon_create(parent, engine, oclass, 0x104000, true,
 110                                    "PCE0", "copy0", &priv);
 111        *pobject = nv_object(priv);
 112        if (ret)
 113                return ret;
 114
 115        nv_subdev(priv)->unit = 0x00000040;
 116        nv_subdev(priv)->intr = nva3_copy_intr;
 117        nv_engine(priv)->cclass = &nvc0_copy0_cclass;
 118        nv_engine(priv)->sclass = nvc0_copy0_sclass;
 119        nv_falcon(priv)->code.data = nvc0_pcopy_code;
 120        nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
 121        nv_falcon(priv)->data.data = nvc0_pcopy_data;
 122        nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
 123        return 0;
 124}
 125
 126static int
 127nvc0_copy1_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 128                struct nouveau_oclass *oclass, void *data, u32 size,
 129                struct nouveau_object **pobject)
 130{
 131        struct nvc0_copy_priv *priv;
 132        int ret;
 133
 134        if (nv_rd32(parent, 0x022500) & 0x00000200)
 135                return -ENODEV;
 136
 137        ret = nouveau_falcon_create(parent, engine, oclass, 0x105000, true,
 138                                    "PCE1", "copy1", &priv);
 139        *pobject = nv_object(priv);
 140        if (ret)
 141                return ret;
 142
 143        nv_subdev(priv)->unit = 0x00000080;
 144        nv_subdev(priv)->intr = nva3_copy_intr;
 145        nv_engine(priv)->cclass = &nvc0_copy1_cclass;
 146        nv_engine(priv)->sclass = nvc0_copy1_sclass;
 147        nv_falcon(priv)->code.data = nvc0_pcopy_code;
 148        nv_falcon(priv)->code.size = sizeof(nvc0_pcopy_code);
 149        nv_falcon(priv)->data.data = nvc0_pcopy_data;
 150        nv_falcon(priv)->data.size = sizeof(nvc0_pcopy_data);
 151        return 0;
 152}
 153
 154struct nouveau_oclass
 155nvc0_copy0_oclass = {
 156        .handle = NV_ENGINE(COPY0, 0xc0),
 157        .ofuncs = &(struct nouveau_ofuncs) {
 158                .ctor = nvc0_copy0_ctor,
 159                .dtor = _nouveau_falcon_dtor,
 160                .init = nvc0_copy_init,
 161                .fini = _nouveau_falcon_fini,
 162                .rd32 = _nouveau_falcon_rd32,
 163                .wr32 = _nouveau_falcon_wr32,
 164        },
 165};
 166
 167struct nouveau_oclass
 168nvc0_copy1_oclass = {
 169        .handle = NV_ENGINE(COPY1, 0xc0),
 170        .ofuncs = &(struct nouveau_ofuncs) {
 171                .ctor = nvc0_copy1_ctor,
 172                .dtor = _nouveau_falcon_dtor,
 173                .init = nvc0_copy_init,
 174                .fini = _nouveau_falcon_fini,
 175                .rd32 = _nouveau_falcon_rd32,
 176                .wr32 = _nouveau_falcon_wr32,
 177        },
 178};
 179