0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "priv.h"
0025
0026 void
0027 gf119_gpio_reset(struct nvkm_gpio *gpio, u8 match)
0028 {
0029 struct nvkm_device *device = gpio->subdev.device;
0030 struct nvkm_bios *bios = device->bios;
0031 u8 ver, len;
0032 u16 entry;
0033 int ent = -1;
0034
0035 while ((entry = dcb_gpio_entry(bios, 0, ++ent, &ver, &len))) {
0036 u32 data = nvbios_rd32(bios, entry);
0037 u8 line = (data & 0x0000003f);
0038 u8 defs = !!(data & 0x00000080);
0039 u8 func = (data & 0x0000ff00) >> 8;
0040 u8 unk0 = (data & 0x00ff0000) >> 16;
0041 u8 unk1 = (data & 0x1f000000) >> 24;
0042
0043 if ( func == DCB_GPIO_UNUSED ||
0044 (match != DCB_GPIO_UNUSED && match != func))
0045 continue;
0046
0047 nvkm_gpio_set(gpio, 0, func, line, defs);
0048
0049 nvkm_mask(device, 0x00d610 + (line * 4), 0xff, unk0);
0050 if (unk1--)
0051 nvkm_mask(device, 0x00d740 + (unk1 * 4), 0xff, line);
0052 }
0053 }
0054
0055 int
0056 gf119_gpio_drive(struct nvkm_gpio *gpio, int line, int dir, int out)
0057 {
0058 struct nvkm_device *device = gpio->subdev.device;
0059 u32 data = ((dir ^ 1) << 13) | (out << 12);
0060 nvkm_mask(device, 0x00d610 + (line * 4), 0x00003000, data);
0061 nvkm_mask(device, 0x00d604, 0x00000001, 0x00000001);
0062 return 0;
0063 }
0064
0065 int
0066 gf119_gpio_sense(struct nvkm_gpio *gpio, int line)
0067 {
0068 struct nvkm_device *device = gpio->subdev.device;
0069 return !!(nvkm_rd32(device, 0x00d610 + (line * 4)) & 0x00004000);
0070 }
0071
0072 static const struct nvkm_gpio_func
0073 gf119_gpio = {
0074 .lines = 32,
0075 .intr_stat = g94_gpio_intr_stat,
0076 .intr_mask = g94_gpio_intr_mask,
0077 .drive = gf119_gpio_drive,
0078 .sense = gf119_gpio_sense,
0079 .reset = gf119_gpio_reset,
0080 };
0081
0082 int
0083 gf119_gpio_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0084 struct nvkm_gpio **pgpio)
0085 {
0086 return nvkm_gpio_new_(&gf119_gpio, device, type, inst, pgpio);
0087 }