drivers/irqchip/irq-riscv-aplic-main.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-riscv-aplic-main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-riscv-aplic-main.c- Extension
.c- Size
- 10530 bytes
- Lines
- 416
- 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.
- 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/bitfield.hlinux/irqchip/riscv-aplic.hlinux/irqchip/riscv-imsic.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/platform_device.hlinux/pm_domain.hlinux/pm_runtime.hlinux/printk.hlinux/syscore_ops.hirq-riscv-aplic-main.h
Detected Declarations
function aplic_restore_statesfunction aplic_save_statesfunction aplic_syscore_suspendfunction aplic_syscore_resumefunction aplic_syscore_initfunction aplic_pm_notifierfunction aplic_pm_removefunction aplic_pm_addfunction aplic_irq_unmaskfunction aplic_irq_maskfunction aplic_irq_set_typefunction aplic_irqdomain_translatefunction aplic_init_hw_globalfunction aplic_init_hw_irqsfunction aplic_setup_privfunction aplic_probe
Annotated Snippet
if (rc) {
dev_err(dev, "failed to get number of interrupt sources\n");
return rc;
}
/*
* Find out number of IDCs based on parent interrupts
*
* If "msi-parent" property is present then we ignore the
* APLIC IDCs which forces the APLIC driver to use MSI mode.
*/
if (!of_property_present(np, "msi-parent")) {
while (!of_irq_parse_one(np, priv->nr_idcs, &parent))
priv->nr_idcs++;
}
} else {
rc = riscv_acpi_get_gsi_info(dev->fwnode, &priv->gsi_base, &priv->acpi_aplic_id,
&priv->nr_irqs, &priv->nr_idcs);
if (rc) {
dev_err(dev, "failed to find GSI mapping\n");
return rc;
}
}
/* Setup initial state APLIC interrupts */
aplic_init_hw_irqs(priv);
return aplic_pm_add(dev, priv);
}
static int aplic_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
bool msi_mode = false;
void __iomem *regs;
int rc;
/* Map the MMIO registers */
regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(regs)) {
dev_err(dev, "failed map MMIO registers\n");
return PTR_ERR(regs);
}
/*
* If msi-parent property is present then setup APLIC MSI
* mode otherwise setup APLIC direct mode.
*/
if (is_of_node(dev->fwnode))
msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent");
else
msi_mode = imsic_acpi_get_fwnode(NULL) ? 1 : 0;
if (msi_mode)
rc = aplic_msi_setup(dev, regs);
else
rc = aplic_direct_setup(dev, regs);
if (rc) {
dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
msi_mode ? "MSI" : "direct");
return rc;
}
aplic_syscore_init();
#ifdef CONFIG_ACPI
if (!acpi_disabled)
acpi_dev_clear_dependencies(ACPI_COMPANION(dev));
#endif
return 0;
}
static const struct of_device_id aplic_match[] = {
{ .compatible = "riscv,aplic" },
{}
};
static struct platform_driver aplic_driver = {
.driver = {
.name = "riscv-aplic",
.of_match_table = aplic_match,
.acpi_match_table = ACPI_PTR(aplic_acpi_match),
},
.probe = aplic_probe,
};
builtin_platform_driver(aplic_driver);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/irqchip/riscv-aplic.h`, `linux/irqchip/riscv-imsic.h`, `linux/module.h`, `linux/of.h`, `linux/of_irq.h`, `linux/platform_device.h`.
- Detected declarations: `function aplic_restore_states`, `function aplic_save_states`, `function aplic_syscore_suspend`, `function aplic_syscore_resume`, `function aplic_syscore_init`, `function aplic_pm_notifier`, `function aplic_pm_remove`, `function aplic_pm_add`, `function aplic_irq_unmask`, `function aplic_irq_mask`.
- Atlas domain: Driver Families / drivers/irqchip.
- Implementation status: source implementation candidate.
- 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.