Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2012 Nouveau Community
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: Martin Peres <martin.peres@labri.fr>
0023  *          Ben Skeggs
0024  */
0025 #include "priv.h"
0026 
0027 #include <subdev/therm.h>
0028 #include <subdev/timer.h>
0029 
0030 static int
0031 nv50_bus_hwsq_exec(struct nvkm_bus *bus, u32 *data, u32 size)
0032 {
0033     struct nvkm_device *device = bus->subdev.device;
0034     int i;
0035 
0036     nvkm_mask(device, 0x001098, 0x00000008, 0x00000000);
0037     nvkm_wr32(device, 0x001304, 0x00000000);
0038     for (i = 0; i < size; i++)
0039         nvkm_wr32(device, 0x001400 + (i * 4), data[i]);
0040     nvkm_mask(device, 0x001098, 0x00000018, 0x00000018);
0041     nvkm_wr32(device, 0x00130c, 0x00000003);
0042 
0043     if (nvkm_msec(device, 2000,
0044         if (!(nvkm_rd32(device, 0x001308) & 0x00000100))
0045             break;
0046     ) < 0)
0047         return -ETIMEDOUT;
0048 
0049     return 0;
0050 }
0051 
0052 void
0053 nv50_bus_intr(struct nvkm_bus *bus)
0054 {
0055     struct nvkm_subdev *subdev = &bus->subdev;
0056     struct nvkm_device *device = subdev->device;
0057     u32 stat = nvkm_rd32(device, 0x001100) & nvkm_rd32(device, 0x001140);
0058 
0059     if (stat & 0x00000008) {
0060         u32 addr = nvkm_rd32(device, 0x009084);
0061         u32 data = nvkm_rd32(device, 0x009088);
0062 
0063         nvkm_error_ratelimited(subdev, "MMIO %s of %08x FAULT at %06x\n",
0064                        (addr & 0x00000002) ? "write" : "read", data,
0065                        (addr & 0x00fffffc));
0066 
0067         stat &= ~0x00000008;
0068         nvkm_wr32(device, 0x001100, 0x00000008);
0069     }
0070 
0071     if (stat & 0x00010000) {
0072         struct nvkm_therm *therm = device->therm;
0073         if (therm)
0074             nvkm_subdev_intr(&therm->subdev);
0075         stat &= ~0x00010000;
0076         nvkm_wr32(device, 0x001100, 0x00010000);
0077     }
0078 
0079     if (stat) {
0080         nvkm_error(subdev, "intr %08x\n", stat);
0081         nvkm_mask(device, 0x001140, stat, 0);
0082     }
0083 }
0084 
0085 void
0086 nv50_bus_init(struct nvkm_bus *bus)
0087 {
0088     struct nvkm_device *device = bus->subdev.device;
0089     nvkm_wr32(device, 0x001100, 0xffffffff);
0090     nvkm_wr32(device, 0x001140, 0x00010008);
0091 }
0092 
0093 static const struct nvkm_bus_func
0094 nv50_bus = {
0095     .init = nv50_bus_init,
0096     .intr = nv50_bus_intr,
0097     .hwsq_exec = nv50_bus_hwsq_exec,
0098     .hwsq_size = 64,
0099 };
0100 
0101 int
0102 nv50_bus_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0103          struct nvkm_bus **pbus)
0104 {
0105     return nvkm_bus_new_(&nv50_bus, device, type, inst, pbus);
0106 }