drivers/gpio/gpio-ixp4xx.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-ixp4xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-ixp4xx.c- Extension
.c- Size
- 9576 bytes
- Lines
- 354
- 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/bitops.hlinux/gpio/driver.hlinux/gpio/generic.hlinux/io.hlinux/irq.hlinux/irqdomain.hlinux/irqchip.hlinux/of_irq.hlinux/platform_device.hlinux/property.h
Detected Declarations
struct ixp4xx_gpiofunction ixp4xx_gpio_irq_ackfunction ixp4xx_gpio_mask_irqfunction ixp4xx_gpio_irq_unmaskfunction ixp4xx_gpio_irq_set_typefunction scoped_guardfunction ixp4xx_gpio_child_to_parent_hwirqfunction ixp4xx_gpio_probe
Annotated Snippet
struct ixp4xx_gpio {
struct gpio_generic_chip chip;
struct device *dev;
void __iomem *base;
unsigned long long irq_edge;
};
static void ixp4xx_gpio_irq_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ixp4xx_gpio *g = gpiochip_get_data(gc);
__raw_writel(BIT(d->hwirq), g->base + IXP4XX_REG_GPIS);
}
static void ixp4xx_gpio_mask_irq(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
irq_chip_mask_parent(d);
gpiochip_disable_irq(gc, d->hwirq);
}
static void ixp4xx_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ixp4xx_gpio *g = gpiochip_get_data(gc);
/* ACK when unmasking if not edge-triggered */
if (!(g->irq_edge & BIT(d->hwirq)))
ixp4xx_gpio_irq_ack(d);
gpiochip_enable_irq(gc, d->hwirq);
irq_chip_unmask_parent(d);
}
static int ixp4xx_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ixp4xx_gpio *g = gpiochip_get_data(gc);
int line = d->hwirq;
u32 int_style;
u32 int_reg;
u32 val;
switch (type) {
case IRQ_TYPE_EDGE_BOTH:
irq_set_handler_locked(d, handle_edge_irq);
int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL;
g->irq_edge |= BIT(d->hwirq);
break;
case IRQ_TYPE_EDGE_RISING:
irq_set_handler_locked(d, handle_edge_irq);
int_style = IXP4XX_GPIO_STYLE_RISING_EDGE;
g->irq_edge |= BIT(d->hwirq);
break;
case IRQ_TYPE_EDGE_FALLING:
irq_set_handler_locked(d, handle_edge_irq);
int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE;
g->irq_edge |= BIT(d->hwirq);
break;
case IRQ_TYPE_LEVEL_HIGH:
irq_set_handler_locked(d, handle_level_irq);
int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH;
g->irq_edge &= ~BIT(d->hwirq);
break;
case IRQ_TYPE_LEVEL_LOW:
irq_set_handler_locked(d, handle_level_irq);
int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW;
g->irq_edge &= ~BIT(d->hwirq);
break;
default:
return -EINVAL;
}
if (line >= 8) {
/* pins 8-15 */
line -= 8;
int_reg = IXP4XX_REG_GPIT2;
} else {
/* pins 0-7 */
int_reg = IXP4XX_REG_GPIT1;
}
scoped_guard(gpio_generic_lock_irqsave, &g->chip) {
/* Clear the style for the appropriate pin */
val = __raw_readl(g->base + int_reg);
val &= ~(IXP4XX_GPIO_STYLE_MASK << (line * IXP4XX_GPIO_STYLE_SIZE));
__raw_writel(val, g->base + int_reg);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/gpio/driver.h`, `linux/gpio/generic.h`, `linux/io.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/irqchip.h`, `linux/of_irq.h`.
- Detected declarations: `struct ixp4xx_gpio`, `function ixp4xx_gpio_irq_ack`, `function ixp4xx_gpio_mask_irq`, `function ixp4xx_gpio_irq_unmask`, `function ixp4xx_gpio_irq_set_type`, `function scoped_guard`, `function ixp4xx_gpio_child_to_parent_hwirq`, `function ixp4xx_gpio_probe`.
- 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.