drivers/gpu/drm/nouveau/nvkm/subdev/volt/gpio.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gpio.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gpio.c
Extension
.c
Size
2844 bytes
Lines
99
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (volt->vid_mask & (1 << i)) {
			int ret = nvkm_gpio_get(gpio, 0, tags[i], 0xff);
			if (ret < 0)
				return ret;
			vid |= ret << i;
		}
	}

	return vid;
}

int
nvkm_voltgpio_set(struct nvkm_volt *volt, u8 vid)
{
	struct nvkm_gpio *gpio = volt->subdev.device->gpio;
	int i;

	for (i = 0; i < ARRAY_SIZE(tags); i++, vid >>= 1) {
		if (volt->vid_mask & (1 << i)) {
			int ret = nvkm_gpio_set(gpio, 0, tags[i], 0xff, vid & 1);
			if (ret < 0)
				return ret;
		}
	}

	return 0;
}

int
nvkm_voltgpio_init(struct nvkm_volt *volt)
{
	struct nvkm_subdev *subdev = &volt->subdev;
	struct nvkm_gpio *gpio = subdev->device->gpio;
	struct dcb_gpio_func func;
	int i;

	/* check we have gpio function info for each vid bit.  on some
	 * boards (ie. nvs295) the vid mask has more bits than there
	 * are valid gpio functions... from traces, nvidia appear to
	 * just touch the existing ones, so let's mask off the invalid
	 * bits and continue with life
	 */
	for (i = 0; i < ARRAY_SIZE(tags); i++) {
		if (volt->vid_mask & (1 << i)) {
			int ret = nvkm_gpio_find(gpio, 0, tags[i], 0xff, &func);
			if (ret) {
				if (ret != -ENOENT)
					return ret;
				nvkm_debug(subdev, "VID bit %d has no GPIO\n", i);
				volt->vid_mask &= ~(1 << i);
			}
		}
	}

	return 0;
}

Annotation

Implementation Notes