drivers/irqchip/irq-loongson-htpic.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-loongson-htpic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-loongson-htpic.c- Extension
.c- Size
- 3143 bytes
- Lines
- 151
- 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/init.hlinux/of_address.hlinux/of_irq.hlinux/irqchip.hlinux/irqchip/chained_irq.hlinux/irq.hlinux/io.hlinux/syscore_ops.hasm/i8259.h
Detected Declarations
struct loongson_htpicfunction htpic_irq_dispatchfunction htpic_reg_initfunction htpic_resumefunction htpic_of_init
Annotated Snippet
struct loongson_htpic {
void __iomem *base;
struct irq_domain *domain;
};
static struct loongson_htpic *htpic;
static void htpic_irq_dispatch(struct irq_desc *desc)
{
struct loongson_htpic *priv = irq_desc_get_handler_data(desc);
struct irq_chip *chip = irq_desc_get_chip(desc);
uint32_t pending;
chained_irq_enter(chip, desc);
pending = readl(priv->base);
/* Ack all IRQs at once, otherwise IRQ flood might happen */
writel(pending, priv->base);
if (!pending)
spurious_interrupt();
while (pending) {
int bit = __ffs(pending);
if (unlikely(bit > 15)) {
spurious_interrupt();
break;
}
generic_handle_domain_irq(priv->domain, bit);
pending &= ~BIT(bit);
}
chained_irq_exit(chip, desc);
}
static void htpic_reg_init(void)
{
int i;
for (i = 0; i < HTINT_NUM_VECTORS; i++) {
/* Disable all HT Vectors */
writel(0x0, htpic->base + HTINT_EN_OFF + i * 0x4);
/* Read back to force write */
(void) readl(htpic->base + i * 0x4);
/* Ack all possible pending IRQs */
writel(GENMASK(31, 0), htpic->base + i * 0x4);
}
/* Enable 16 vectors for PIC */
writel(0xffff, htpic->base + HTINT_EN_OFF);
}
static void htpic_resume(void *data)
{
htpic_reg_init();
}
static const struct syscore_ops htpic_syscore_ops = {
.resume = htpic_resume,
};
static struct syscore htpic_syscore = {
.ops = &htpic_syscore_ops,
};
static int __init htpic_of_init(struct device_node *node, struct device_node *parent)
{
unsigned int parent_irq[4];
int i, err;
int num_parents = 0;
if (htpic) {
pr_err("loongson-htpic: Only one HTPIC is allowed in the system\n");
return -ENODEV;
}
htpic = kzalloc_obj(*htpic);
if (!htpic)
return -ENOMEM;
htpic->base = of_iomap(node, 0);
if (!htpic->base) {
err = -ENODEV;
goto out_free;
}
htpic->domain = __init_i8259_irqs(node);
if (!htpic->domain) {
pr_err("loongson-htpic: Failed to initialize i8259 IRQs\n");
err = -ENOMEM;
Annotation
- Immediate include surface: `linux/init.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/irqchip.h`, `linux/irqchip/chained_irq.h`, `linux/irq.h`, `linux/io.h`, `linux/syscore_ops.h`.
- Detected declarations: `struct loongson_htpic`, `function htpic_irq_dispatch`, `function htpic_reg_init`, `function htpic_resume`, `function htpic_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.