1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "priv.h"
25
26static void
27gk104_gpio_intr_stat(struct nvkm_gpio *gpio, u32 *hi, u32 *lo)
28{
29 struct nvkm_device *device = gpio->subdev.device;
30 u32 intr0 = nvkm_rd32(device, 0x00dc00);
31 u32 intr1 = nvkm_rd32(device, 0x00dc80);
32 u32 stat0 = nvkm_rd32(device, 0x00dc08) & intr0;
33 u32 stat1 = nvkm_rd32(device, 0x00dc88) & intr1;
34 *lo = (stat1 & 0xffff0000) | (stat0 >> 16);
35 *hi = (stat1 << 16) | (stat0 & 0x0000ffff);
36 nvkm_wr32(device, 0x00dc00, intr0);
37 nvkm_wr32(device, 0x00dc80, intr1);
38}
39
40static void
41gk104_gpio_intr_mask(struct nvkm_gpio *gpio, u32 type, u32 mask, u32 data)
42{
43 struct nvkm_device *device = gpio->subdev.device;
44 u32 inte0 = nvkm_rd32(device, 0x00dc08);
45 u32 inte1 = nvkm_rd32(device, 0x00dc88);
46 if (type & NVKM_GPIO_LO)
47 inte0 = (inte0 & ~(mask << 16)) | (data << 16);
48 if (type & NVKM_GPIO_HI)
49 inte0 = (inte0 & ~(mask & 0xffff)) | (data & 0xffff);
50 mask >>= 16;
51 data >>= 16;
52 if (type & NVKM_GPIO_LO)
53 inte1 = (inte1 & ~(mask << 16)) | (data << 16);
54 if (type & NVKM_GPIO_HI)
55 inte1 = (inte1 & ~mask) | data;
56 nvkm_wr32(device, 0x00dc08, inte0);
57 nvkm_wr32(device, 0x00dc88, inte1);
58}
59
60static const struct nvkm_gpio_func
61gk104_gpio = {
62 .lines = 32,
63 .intr_stat = gk104_gpio_intr_stat,
64 .intr_mask = gk104_gpio_intr_mask,
65 .drive = gf119_gpio_drive,
66 .sense = gf119_gpio_sense,
67 .reset = gf119_gpio_reset,
68};
69
70int
71gk104_gpio_new(struct nvkm_device *device, int index, struct nvkm_gpio **pgpio)
72{
73 return nvkm_gpio_new_(&gk104_gpio, device, index, pgpio);
74}
75