drivers/gpio/gpio-ath79.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-ath79.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-ath79.c- Extension
.c- Size
- 9449 bytes
- Lines
- 349
- 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.
- 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/device.hlinux/gpio/driver.hlinux/gpio/generic.hlinux/gpio/machine.hlinux/interrupt.hlinux/irq.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.h
Detected Declarations
struct ath79_gpio_ctrlfunction ath79_gpio_readfunction ath79_gpio_writefunction ath79_gpio_update_bitsfunction ath79_gpio_irq_unmaskfunction ath79_gpio_irq_maskfunction ath79_gpio_irq_enablefunction ath79_gpio_irq_disablefunction ath79_gpio_irq_set_typefunction ath79_gpio_irq_handlerfunction scoped_guardfunction ath79_gpio_register_wifi_descriptorsfunction ath79_gpio_register_wifi_descriptorsfunction ath79_gpio_probe
Annotated Snippet
struct ath79_gpio_ctrl {
struct gpio_generic_chip chip;
void __iomem *base;
unsigned long both_edges;
};
static struct ath79_gpio_ctrl *irq_data_to_ath79_gpio(struct irq_data *data)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
struct gpio_generic_chip *gen_gc = to_gpio_generic_chip(gc);
return container_of(gen_gc, struct ath79_gpio_ctrl, chip);
}
static u32 ath79_gpio_read(struct ath79_gpio_ctrl *ctrl, unsigned reg)
{
return readl(ctrl->base + reg);
}
static void ath79_gpio_write(struct ath79_gpio_ctrl *ctrl,
unsigned reg, u32 val)
{
writel(val, ctrl->base + reg);
}
static bool ath79_gpio_update_bits(
struct ath79_gpio_ctrl *ctrl, unsigned reg, u32 mask, u32 bits)
{
u32 old_val, new_val;
old_val = ath79_gpio_read(ctrl, reg);
new_val = (old_val & ~mask) | (bits & mask);
if (new_val != old_val)
ath79_gpio_write(ctrl, reg, new_val);
return new_val != old_val;
}
static void ath79_gpio_irq_unmask(struct irq_data *data)
{
struct ath79_gpio_ctrl *ctrl = irq_data_to_ath79_gpio(data);
u32 mask = BIT(irqd_to_hwirq(data));
gpiochip_enable_irq(&ctrl->chip.gc, irqd_to_hwirq(data));
guard(gpio_generic_lock_irqsave)(&ctrl->chip);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
}
static void ath79_gpio_irq_mask(struct irq_data *data)
{
struct ath79_gpio_ctrl *ctrl = irq_data_to_ath79_gpio(data);
u32 mask = BIT(irqd_to_hwirq(data));
scoped_guard(gpio_generic_lock_irqsave, &ctrl->chip)
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0);
gpiochip_disable_irq(&ctrl->chip.gc, irqd_to_hwirq(data));
}
static void ath79_gpio_irq_enable(struct irq_data *data)
{
struct ath79_gpio_ctrl *ctrl = irq_data_to_ath79_gpio(data);
u32 mask = BIT(irqd_to_hwirq(data));
guard(gpio_generic_lock_irqsave)(&ctrl->chip);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
}
static void ath79_gpio_irq_disable(struct irq_data *data)
{
struct ath79_gpio_ctrl *ctrl = irq_data_to_ath79_gpio(data);
u32 mask = BIT(irqd_to_hwirq(data));
guard(gpio_generic_lock_irqsave)(&ctrl->chip);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0);
ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, 0);
}
static int ath79_gpio_irq_set_type(struct irq_data *data,
unsigned int flow_type)
{
struct ath79_gpio_ctrl *ctrl = irq_data_to_ath79_gpio(data);
u32 mask = BIT(irqd_to_hwirq(data));
u32 type = 0, polarity = 0;
bool disabled;
Annotation
- Immediate include surface: `linux/device.h`, `linux/gpio/driver.h`, `linux/gpio/generic.h`, `linux/gpio/machine.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct ath79_gpio_ctrl`, `function ath79_gpio_read`, `function ath79_gpio_write`, `function ath79_gpio_update_bits`, `function ath79_gpio_irq_unmask`, `function ath79_gpio_irq_mask`, `function ath79_gpio_irq_enable`, `function ath79_gpio_irq_disable`, `function ath79_gpio_irq_set_type`, `function ath79_gpio_irq_handler`.
- Atlas domain: Driver Families / drivers/gpio.
- 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.