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 #include <engine/ce.h> 25 #include <engine/fifo.h> 26 #include "fuc/gt215.fuc3.h" 27 28 #include <core/client.h> 29 #include <core/enum.h> 30 31 /******************************************************************************* 32 * Copy object classes 33 ******************************************************************************/ 34 35 static struct nvkm_oclass 36 gt215_ce_sclass[] = { 37 { 0x85b5, &nvkm_object_ofuncs }, 38 {} 39 }; 40 41 /******************************************************************************* 42 * PCE context 43 ******************************************************************************/ 44 45 static struct nvkm_oclass 46 gt215_ce_cclass = { 47 .handle = NV_ENGCTX(CE0, 0xa3), 48 .ofuncs = &(struct nvkm_ofuncs) { 49 .ctor = _nvkm_falcon_context_ctor, 50 .dtor = _nvkm_falcon_context_dtor, 51 .init = _nvkm_falcon_context_init, 52 .fini = _nvkm_falcon_context_fini, 53 .rd32 = _nvkm_falcon_context_rd32, 54 .wr32 = _nvkm_falcon_context_wr32, 55 56 }, 57 }; 58 59 /******************************************************************************* 60 * PCE engine/subdev functions 61 ******************************************************************************/ 62 63 static const struct nvkm_enum 64 gt215_ce_isr_error_name[] = { 65 { 0x0001, "ILLEGAL_MTHD" }, 66 { 0x0002, "INVALID_ENUM" }, 67 { 0x0003, "INVALID_BITFIELD" }, 68 {} 69 }; 70 71 void 72 gt215_ce_intr(struct nvkm_falcon *ce, struct nvkm_fifo_chan *chan) 73 { 74 struct nvkm_subdev *subdev = &ce->engine.subdev; 75 struct nvkm_device *device = subdev->device; 76 const u32 base = (nv_subidx(subdev) - NVDEV_ENGINE_CE0) * 0x1000; 77 u32 ssta = nvkm_rd32(device, 0x104040 + base) & 0x0000ffff; 78 u32 addr = nvkm_rd32(device, 0x104040 + base) >> 16; 79 u32 mthd = (addr & 0x07ff) << 2; 80 u32 subc = (addr & 0x3800) >> 11; 81 u32 data = nvkm_rd32(device, 0x104044 + base); 82 const struct nvkm_enum *en = 83 nvkm_enum_find(gt215_ce_isr_error_name, ssta); 84 85 nvkm_error(subdev, "DISPATCH_ERROR %04x [%s] ch %d [%010llx %s] " 86 "subc %d mthd %04x data %08x\n", ssta, 87 en ? en->name : "", chan ? chan->chid : -1, 88 chan ? chan->inst : 0, nvkm_client_name(chan), 89 subc, mthd, data); 90 } 91 92 static const struct nvkm_falcon_func 93 gt215_ce_func = { 94 .intr = gt215_ce_intr, 95 }; 96 97 static int 98 gt215_ce_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 99 struct nvkm_oclass *oclass, void *data, u32 size, 100 struct nvkm_object **pobject) 101 { 102 bool enable = (nv_device(parent)->chipset != 0xaf); 103 struct nvkm_falcon *ce; 104 int ret; 105 106 ret = nvkm_falcon_create(>215_ce_func, parent, engine, oclass, 107 0x104000, enable, "PCE0", "ce0", &ce); 108 *pobject = nv_object(ce); 109 if (ret) 110 return ret; 111 112 nv_subdev(ce)->unit = 0x00802000; 113 nv_engine(ce)->cclass = >215_ce_cclass; 114 nv_engine(ce)->sclass = gt215_ce_sclass; 115 nv_falcon(ce)->code.data = gt215_ce_code; 116 nv_falcon(ce)->code.size = sizeof(gt215_ce_code); 117 nv_falcon(ce)->data.data = gt215_ce_data; 118 nv_falcon(ce)->data.size = sizeof(gt215_ce_data); 119 return 0; 120 } 121 122 struct nvkm_oclass 123 gt215_ce_oclass = { 124 .handle = NV_ENGINE(CE0, 0xa3), 125 .ofuncs = &(struct nvkm_ofuncs) { 126 .ctor = gt215_ce_ctor, 127 .dtor = _nvkm_falcon_dtor, 128 .init = _nvkm_falcon_init, 129 .fini = _nvkm_falcon_fini, 130 }, 131 }; 132