drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c- Extension
.c- Size
- 5895 bytes
- Lines
- 238
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
priv.hcore/option.h
Detected Declarations
function filesfunction nvkm_gpio_sensefunction nvkm_gpio_resetfunction nvkm_gpio_findfunction nvkm_gpio_setfunction nvkm_gpio_getfunction nvkm_gpio_intr_finifunction nvkm_gpio_intr_initfunction nvkm_gpio_intrfunction nvkm_gpio_finifunction nvkm_gpio_initfunction nvkm_gpio_dtorfunction nvkm_gpio_new_
Annotated Snippet
if (tag == DCB_GPIO_TVDAC0) {
*func = (struct dcb_gpio_func) {
.func = DCB_GPIO_TVDAC0,
.line = device->quirk->tv_gpio,
.log[0] = 0,
.log[1] = 1,
};
return 0;
}
}
return -ENOENT;
}
int
nvkm_gpio_set(struct nvkm_gpio *gpio, int idx, u8 tag, u8 line, int state)
{
struct dcb_gpio_func func;
int ret;
ret = nvkm_gpio_find(gpio, idx, tag, line, &func);
if (ret == 0) {
int dir = !!(func.log[state] & 0x02);
int out = !!(func.log[state] & 0x01);
ret = nvkm_gpio_drive(gpio, idx, func.line, dir, out);
}
return ret;
}
int
nvkm_gpio_get(struct nvkm_gpio *gpio, int idx, u8 tag, u8 line)
{
struct dcb_gpio_func func;
int ret;
ret = nvkm_gpio_find(gpio, idx, tag, line, &func);
if (ret == 0) {
ret = nvkm_gpio_sense(gpio, idx, func.line);
if (ret >= 0)
ret = (ret == (func.log[1] & 1));
}
return ret;
}
static void
nvkm_gpio_intr_fini(struct nvkm_event *event, int type, int index)
{
struct nvkm_gpio *gpio = container_of(event, typeof(*gpio), event);
gpio->func->intr_mask(gpio, type, 1 << index, 0);
}
static void
nvkm_gpio_intr_init(struct nvkm_event *event, int type, int index)
{
struct nvkm_gpio *gpio = container_of(event, typeof(*gpio), event);
gpio->func->intr_mask(gpio, type, 1 << index, 1 << index);
}
static const struct nvkm_event_func
nvkm_gpio_intr_func = {
.init = nvkm_gpio_intr_init,
.fini = nvkm_gpio_intr_fini,
};
static void
nvkm_gpio_intr(struct nvkm_subdev *subdev)
{
struct nvkm_gpio *gpio = nvkm_gpio(subdev);
u32 hi, lo, i;
gpio->func->intr_stat(gpio, &hi, &lo);
for (i = 0; (hi | lo) && i < gpio->func->lines; i++) {
u32 mask = (NVKM_GPIO_HI * !!(hi & (1 << i))) |
(NVKM_GPIO_LO * !!(lo & (1 << i)));
nvkm_event_ntfy(&gpio->event, i, mask);
}
}
static int
nvkm_gpio_fini(struct nvkm_subdev *subdev, enum nvkm_suspend_state suspend)
{
struct nvkm_gpio *gpio = nvkm_gpio(subdev);
u32 mask = (1ULL << gpio->func->lines) - 1;
gpio->func->intr_mask(gpio, NVKM_GPIO_TOGGLED, mask, 0);
gpio->func->intr_stat(gpio, &mask, &mask);
return 0;
Annotation
- Immediate include surface: `priv.h`, `core/option.h`.
- Detected declarations: `function files`, `function nvkm_gpio_sense`, `function nvkm_gpio_reset`, `function nvkm_gpio_find`, `function nvkm_gpio_set`, `function nvkm_gpio_get`, `function nvkm_gpio_intr_fini`, `function nvkm_gpio_intr_init`, `function nvkm_gpio_intr`, `function nvkm_gpio_fini`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.