0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
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 }