drivers/irqchip/irq-ls1x.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-ls1x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-ls1x.c- Extension
.c- Size
- 4805 bytes
- Lines
- 194
- Domain
- Driver Families
- Bucket
- drivers/irqchip
- 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/errno.hlinux/init.hlinux/types.hlinux/interrupt.hlinux/ioport.hlinux/irqchip.hlinux/of_address.hlinux/of_irq.hlinux/io.hlinux/irqchip/chained_irq.h
Detected Declarations
struct ls1x_intc_privfunction ls1x_chained_handle_irqfunction ls_intc_set_bitfunction ls_intc_set_typefunction ls1x_intc_of_init
Annotated Snippet
struct ls1x_intc_priv {
struct irq_domain *domain;
void __iomem *intc_base;
};
static void ls1x_chained_handle_irq(struct irq_desc *desc)
{
struct ls1x_intc_priv *priv = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc);
u32 pending;
chained_irq_enter(chip, desc);
pending = readl(priv->intc_base + LS_REG_INTC_STATUS) &
readl(priv->intc_base + LS_REG_INTC_EN);
if (!pending)
spurious_interrupt();
while (pending) {
int bit = __ffs(pending);
generic_handle_domain_irq(priv->domain, bit);
pending &= ~BIT(bit);
}
chained_irq_exit(chip, desc);
}
static void ls_intc_set_bit(struct irq_chip_generic *gc,
unsigned int offset,
u32 mask, bool set)
{
if (set)
writel(readl(gc->reg_base + offset) | mask,
gc->reg_base + offset);
else
writel(readl(gc->reg_base + offset) & ~mask,
gc->reg_base + offset);
}
static int ls_intc_set_type(struct irq_data *data, unsigned int type)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);
u32 mask = data->mask;
switch (type) {
case IRQ_TYPE_LEVEL_HIGH:
ls_intc_set_bit(gc, LS_REG_INTC_EDGE, mask, false);
ls_intc_set_bit(gc, LS_REG_INTC_POL, mask, true);
break;
case IRQ_TYPE_LEVEL_LOW:
ls_intc_set_bit(gc, LS_REG_INTC_EDGE, mask, false);
ls_intc_set_bit(gc, LS_REG_INTC_POL, mask, false);
break;
case IRQ_TYPE_EDGE_RISING:
ls_intc_set_bit(gc, LS_REG_INTC_EDGE, mask, true);
ls_intc_set_bit(gc, LS_REG_INTC_POL, mask, true);
break;
case IRQ_TYPE_EDGE_FALLING:
ls_intc_set_bit(gc, LS_REG_INTC_EDGE, mask, true);
ls_intc_set_bit(gc, LS_REG_INTC_POL, mask, false);
break;
default:
return -EINVAL;
}
irqd_set_trigger_type(data, type);
return irq_setup_alt_chip(data, type);
}
static int __init ls1x_intc_of_init(struct device_node *node,
struct device_node *parent)
{
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
struct ls1x_intc_priv *priv;
int parent_irq, err = 0;
priv = kzalloc_obj(*priv);
if (!priv)
return -ENOMEM;
priv->intc_base = of_iomap(node, 0);
if (!priv->intc_base) {
err = -ENODEV;
goto out_free_priv;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/init.h`, `linux/types.h`, `linux/interrupt.h`, `linux/ioport.h`, `linux/irqchip.h`, `linux/of_address.h`, `linux/of_irq.h`.
- Detected declarations: `struct ls1x_intc_priv`, `function ls1x_chained_handle_irq`, `function ls_intc_set_bit`, `function ls_intc_set_type`, `function ls1x_intc_of_init`.
- Atlas domain: Driver Families / drivers/irqchip.
- 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.