Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2016 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs <bskeggs@redhat.com>
0023  */
0024 #include "priv.h"
0025 
0026 static int
0027 gk104_top_oneinit(struct nvkm_top *top)
0028 {
0029     struct nvkm_subdev *subdev = &top->subdev;
0030     struct nvkm_device *device = subdev->device;
0031     struct nvkm_top_device *info = NULL;
0032     u32 data, type, inst;
0033     int i;
0034 
0035     for (i = 0; i < 64; i++) {
0036         if (!info) {
0037             if (!(info = nvkm_top_device_new(top)))
0038                 return -ENOMEM;
0039             type = ~0;
0040             inst = 0;
0041         }
0042 
0043         data = nvkm_rd32(device, 0x022700 + (i * 0x04));
0044         nvkm_trace(subdev, "%02x: %08x\n", i, data);
0045         switch (data & 0x00000003) {
0046         case 0x00000000: /* NOT_VALID */
0047             continue;
0048         case 0x00000001: /* DATA */
0049             inst        = (data & 0x3c000000) >> 26;
0050             info->addr  = (data & 0x00fff000);
0051             if (data & 0x00000004)
0052                 info->fault = (data & 0x000003f8) >> 3;
0053             break;
0054         case 0x00000002: /* ENUM */
0055             if (data & 0x00000020)
0056                 info->engine  = (data & 0x3c000000) >> 26;
0057             if (data & 0x00000010)
0058                 info->runlist = (data & 0x01e00000) >> 21;
0059             if (data & 0x00000008)
0060                 info->intr    = (data & 0x000f8000) >> 15;
0061             if (data & 0x00000004)
0062                 info->reset   = (data & 0x00003e00) >> 9;
0063             break;
0064         case 0x00000003: /* ENGINE_TYPE */
0065             type = (data & 0x7ffffffc) >> 2;
0066             break;
0067         }
0068 
0069         if (data & 0x80000000)
0070             continue;
0071 
0072         /* Translate engine type to NVKM engine identifier. */
0073 #define I_(T,I) do { info->type = (T); info->inst = (I); } while(0)
0074 #define O_(T,I) do { WARN_ON(inst); I_(T, I); } while (0)
0075         switch (type) {
0076         case 0x00000000: O_(NVKM_ENGINE_GR    ,    0); break;
0077         case 0x00000001: O_(NVKM_ENGINE_CE    ,    0); break;
0078         case 0x00000002: O_(NVKM_ENGINE_CE    ,    1); break;
0079         case 0x00000003: O_(NVKM_ENGINE_CE    ,    2); break;
0080         case 0x00000008: O_(NVKM_ENGINE_MSPDEC,    0); break;
0081         case 0x00000009: O_(NVKM_ENGINE_MSPPP ,    0); break;
0082         case 0x0000000a: O_(NVKM_ENGINE_MSVLD ,    0); break;
0083         case 0x0000000b: O_(NVKM_ENGINE_MSENC ,    0); break;
0084         case 0x0000000c: O_(NVKM_ENGINE_VIC   ,    0); break;
0085         case 0x0000000d: O_(NVKM_ENGINE_SEC2  ,    0); break;
0086         case 0x0000000e: I_(NVKM_ENGINE_NVENC , inst); break;
0087         case 0x0000000f: O_(NVKM_ENGINE_NVENC ,    1); break;
0088         case 0x00000010: I_(NVKM_ENGINE_NVDEC , inst); break;
0089         case 0x00000012: I_(NVKM_SUBDEV_IOCTRL, inst); break;
0090         case 0x00000013: I_(NVKM_ENGINE_CE    , inst); break;
0091         case 0x00000014: O_(NVKM_SUBDEV_GSP   ,    0); break;
0092         case 0x00000015: O_(NVKM_ENGINE_NVJPG ,    0); break;
0093         default:
0094             break;
0095         }
0096 
0097         nvkm_debug(subdev, "%02x.%d (%8s): addr %06x fault %2d "
0098                    "engine %2d runlist %2d intr %2d "
0099                    "reset %2d\n", type, inst,
0100                info->type == NVKM_SUBDEV_NR ? "????????" : nvkm_subdev_type[info->type],
0101                info->addr, info->fault, info->engine, info->runlist,
0102                info->intr, info->reset);
0103         info = NULL;
0104     }
0105 
0106     return 0;
0107 }
0108 
0109 static const struct nvkm_top_func
0110 gk104_top = {
0111     .oneinit = gk104_top_oneinit,
0112 };
0113 
0114 int
0115 gk104_top_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0116           struct nvkm_top **ptop)
0117 {
0118     return nvkm_top_new_(&gk104_top, device, type, inst, ptop);
0119 }