Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2012 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
0023  */
0024 #include "priv.h"
0025 #include <subdev/timer.h>
0026 
0027 static void
0028 gf100_privring_intr_hub(struct nvkm_subdev *privring, int i)
0029 {
0030     struct nvkm_device *device = privring->device;
0031     u32 addr = nvkm_rd32(device, 0x122120 + (i * 0x0400));
0032     u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
0033     u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
0034     nvkm_debug(privring, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
0035 }
0036 
0037 static void
0038 gf100_privring_intr_rop(struct nvkm_subdev *privring, int i)
0039 {
0040     struct nvkm_device *device = privring->device;
0041     u32 addr = nvkm_rd32(device, 0x124120 + (i * 0x0400));
0042     u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
0043     u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
0044     nvkm_debug(privring, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
0045 }
0046 
0047 static void
0048 gf100_privring_intr_gpc(struct nvkm_subdev *privring, int i)
0049 {
0050     struct nvkm_device *device = privring->device;
0051     u32 addr = nvkm_rd32(device, 0x128120 + (i * 0x0400));
0052     u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
0053     u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
0054     nvkm_debug(privring, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
0055 }
0056 
0057 void
0058 gf100_privring_intr(struct nvkm_subdev *privring)
0059 {
0060     struct nvkm_device *device = privring->device;
0061     u32 intr0 = nvkm_rd32(device, 0x121c58);
0062     u32 intr1 = nvkm_rd32(device, 0x121c5c);
0063     u32 hubnr = nvkm_rd32(device, 0x121c70);
0064     u32 ropnr = nvkm_rd32(device, 0x121c74);
0065     u32 gpcnr = nvkm_rd32(device, 0x121c78);
0066     u32 i;
0067 
0068     for (i = 0; (intr0 & 0x0000ff00) && i < hubnr; i++) {
0069         u32 stat = 0x00000100 << i;
0070         if (intr0 & stat) {
0071             gf100_privring_intr_hub(privring, i);
0072             intr0 &= ~stat;
0073         }
0074     }
0075 
0076     for (i = 0; (intr0 & 0xffff0000) && i < ropnr; i++) {
0077         u32 stat = 0x00010000 << i;
0078         if (intr0 & stat) {
0079             gf100_privring_intr_rop(privring, i);
0080             intr0 &= ~stat;
0081         }
0082     }
0083 
0084     for (i = 0; intr1 && i < gpcnr; i++) {
0085         u32 stat = 0x00000001 << i;
0086         if (intr1 & stat) {
0087             gf100_privring_intr_gpc(privring, i);
0088             intr1 &= ~stat;
0089         }
0090     }
0091 
0092     nvkm_mask(device, 0x121c4c, 0x0000003f, 0x00000002);
0093     nvkm_msec(device, 2000,
0094         if (!(nvkm_rd32(device, 0x121c4c) & 0x0000003f))
0095             break;
0096     );
0097 }
0098 
0099 static int
0100 gf100_privring_init(struct nvkm_subdev *privring)
0101 {
0102     struct nvkm_device *device = privring->device;
0103     nvkm_mask(device, 0x122310, 0x0003ffff, 0x00000800);
0104     nvkm_wr32(device, 0x12232c, 0x00100064);
0105     nvkm_wr32(device, 0x122330, 0x00100064);
0106     nvkm_wr32(device, 0x122334, 0x00100064);
0107     nvkm_mask(device, 0x122348, 0x0003ffff, 0x00000100);
0108     return 0;
0109 }
0110 
0111 static const struct nvkm_subdev_func
0112 gf100_privring = {
0113     .init = gf100_privring_init,
0114     .intr = gf100_privring_intr,
0115 };
0116 
0117 int
0118 gf100_privring_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0119            struct nvkm_subdev **pprivring)
0120 {
0121     return nvkm_subdev_new_(&gf100_privring, device, type, inst, pprivring);
0122 }