1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include <subdev/ibus.h>
23#include <subdev/timer.h>
24
25static void
26gk20a_ibus_init_ibus_ring(struct nvkm_subdev *ibus)
27{
28 struct nvkm_device *device = ibus->device;
29 nvkm_mask(device, 0x137250, 0x3f, 0);
30
31 nvkm_mask(device, 0x000200, 0x20, 0);
32 udelay(20);
33 nvkm_mask(device, 0x000200, 0x20, 0x20);
34
35 nvkm_wr32(device, 0x12004c, 0x4);
36 nvkm_wr32(device, 0x122204, 0x2);
37 nvkm_rd32(device, 0x122204);
38
39
40
41
42
43 nvkm_wr32(device, 0x122354, 0x800);
44 nvkm_wr32(device, 0x128328, 0x800);
45 nvkm_wr32(device, 0x124320, 0x800);
46}
47
48static void
49gk20a_ibus_intr(struct nvkm_subdev *ibus)
50{
51 struct nvkm_device *device = ibus->device;
52 u32 status0 = nvkm_rd32(device, 0x120058);
53
54 if (status0 & 0x7) {
55 nvkm_debug(ibus, "resetting ibus ring\n");
56 gk20a_ibus_init_ibus_ring(ibus);
57 }
58
59
60 nvkm_mask(device, 0x12004c, 0x2, 0x2);
61 nvkm_msec(device, 2000,
62 if (!(nvkm_rd32(device, 0x12004c) & 0x0000003f))
63 break;
64 );
65}
66
67static int
68gk20a_ibus_init(struct nvkm_subdev *ibus)
69{
70 gk20a_ibus_init_ibus_ring(ibus);
71 return 0;
72}
73
74static const struct nvkm_subdev_func
75gk20a_ibus = {
76 .init = gk20a_ibus_init,
77 .intr = gk20a_ibus_intr,
78};
79
80int
81gk20a_ibus_new(struct nvkm_device *device, int index,
82 struct nvkm_subdev **pibus)
83{
84 struct nvkm_subdev *ibus;
85 if (!(ibus = *pibus = kzalloc(sizeof(*ibus), GFP_KERNEL)))
86 return -ENOMEM;
87 nvkm_subdev_ctor(&gk20a_ibus, device, index, ibus);
88 return 0;
89}
90