drivers/gpio/gpio-novalake-events.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-novalake-events.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-novalake-events.c- Extension
.c- Size
- 8938 bytes
- Lines
- 324
- Domain
- Driver Families
- Bucket
- drivers/gpio
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/acpi.hlinux/bitops.hlinux/cleanup.hlinux/device.hlinux/errno.hlinux/gfp_types.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/irq.hlinux/module.hlinux/platform_device.hlinux/spinlock.hlinux/types.hlinux/uuid.hlinux/gpio/driver.h
Detected Declarations
struct nvl_gpiofunction nvl_gpio_getfunction nvl_gpio_irq_set_typefunction nvl_gpio_irq_mask_unmaskfunction nvl_gpio_irq_unmaskfunction nvl_gpio_irq_maskfunction nvl_gpio_irq_ackfunction nvl_gpio_irqfunction scoped_guardfunction for_each_set_bitfunction nvl_acpi_enable_gpe_modefunction nvl_gpio_probe
Annotated Snippet
struct nvl_gpio {
struct gpio_chip gc;
void __iomem *reg_base;
raw_spinlock_t lock;
size_t blk_size;
};
static void __iomem *nvl_gpio_get_byte_addr(struct nvl_gpio *priv,
unsigned int reg_offset,
unsigned long gpio)
{
return priv->reg_base + reg_offset + gpio;
}
static int nvl_gpio_get(struct gpio_chip *gc, unsigned int gpio)
{
struct nvl_gpio *priv = gpiochip_get_data(gc);
unsigned int byte_idx = gpio / BITS_PER_BYTE;
unsigned int bit_idx = gpio % BITS_PER_BYTE;
void __iomem *addr;
u8 reg;
addr = nvl_gpio_get_byte_addr(priv, GPE_STS_REG_OFFSET, byte_idx);
guard(raw_spinlock_irqsave)(&priv->lock);
reg = ioread8(addr);
return !!(reg & BIT(bit_idx));
}
static const struct gpio_chip nvl_gpio_chip = {
.owner = THIS_MODULE,
.get = nvl_gpio_get,
};
static int nvl_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
if (type & IRQ_TYPE_EDGE_BOTH)
irq_set_handler_locked(d, handle_edge_irq);
else if (type & IRQ_TYPE_LEVEL_MASK)
irq_set_handler_locked(d, handle_level_irq);
return 0;
}
static void nvl_gpio_irq_mask_unmask(struct gpio_chip *gc, unsigned long hwirq,
bool mask)
{
struct nvl_gpio *priv = gpiochip_get_data(gc);
unsigned int byte_idx = hwirq / BITS_PER_BYTE;
unsigned int bit_idx = hwirq % BITS_PER_BYTE;
void __iomem *addr;
u8 reg;
addr = nvl_gpio_get_byte_addr(priv, GPE_EN_REG_OFFSET(priv->blk_size), byte_idx);
guard(raw_spinlock_irqsave)(&priv->lock);
reg = ioread8(addr);
if (mask)
reg &= ~BIT(bit_idx);
else
reg |= BIT(bit_idx);
iowrite8(reg, addr);
}
static void nvl_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
gpiochip_enable_irq(gc, hwirq);
nvl_gpio_irq_mask_unmask(gc, hwirq, false);
}
static void nvl_gpio_irq_mask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
nvl_gpio_irq_mask_unmask(gc, hwirq, true);
gpiochip_disable_irq(gc, hwirq);
}
static void nvl_gpio_irq_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct nvl_gpio *priv = gpiochip_get_data(gc);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/device.h`, `linux/errno.h`, `linux/gfp_types.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct nvl_gpio`, `function nvl_gpio_get`, `function nvl_gpio_irq_set_type`, `function nvl_gpio_irq_mask_unmask`, `function nvl_gpio_irq_unmask`, `function nvl_gpio_irq_mask`, `function nvl_gpio_irq_ack`, `function nvl_gpio_irq`, `function scoped_guard`, `function for_each_set_bit`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.