drivers/irqchip/irq-mvebu-icu.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-mvebu-icu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-mvebu-icu.c- Extension
.c- Size
- 10543 bytes
- Lines
- 370
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/interrupt.hlinux/irq.hlinux/irqchip.hlinux/irqdomain.hlinux/jump_label.hlinux/kernel.hlinux/msi.hlinux/of_irq.hlinux/of_platform.hlinux/platform_device.hlinux/irqchip/irq-msi-lib.hdt-bindings/interrupt-controller/mvebu-icu.h
Detected Declarations
struct mvebu_icu_subset_datastruct mvebu_icustruct mvebu_icu_msi_datafunction mvebu_icu_translatefunction mvebu_icu_initfunction mvebu_icu_msi_initfunction mvebu_icu_set_descfunction mvebu_icu_write_msi_msgfunction configuredfunction mvebu_icu_subset_probefunction mvebu_icu_probe
Annotated Snippet
struct mvebu_icu_subset_data {
unsigned int icu_group;
unsigned int offset_set_ah;
unsigned int offset_set_al;
unsigned int offset_clr_ah;
unsigned int offset_clr_al;
};
struct mvebu_icu {
void __iomem *base;
struct device *dev;
};
struct mvebu_icu_msi_data {
struct mvebu_icu *icu;
atomic_t initialized;
const struct mvebu_icu_subset_data *subset_data;
};
static DEFINE_STATIC_KEY_FALSE(legacy_bindings);
static int mvebu_icu_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
unsigned long *hwirq, unsigned int *type)
{
unsigned int param_count = static_branch_unlikely(&legacy_bindings) ? 3 : 2;
struct msi_domain_info *info = d->host_data;
struct mvebu_icu_msi_data *msi_data = info->chip_data;
struct mvebu_icu *icu = msi_data->icu;
/* Check the count of the parameters in dt */
if (WARN_ON(fwspec->param_count != param_count)) {
dev_err(icu->dev, "wrong ICU parameter count %d\n",
fwspec->param_count);
return -EINVAL;
}
if (static_branch_unlikely(&legacy_bindings)) {
*hwirq = fwspec->param[1];
*type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK;
if (fwspec->param[0] != ICU_GRP_NSR) {
dev_err(icu->dev, "wrong ICU group type %x\n",
fwspec->param[0]);
return -EINVAL;
}
} else {
*hwirq = fwspec->param[0];
*type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK;
/*
* The ICU receives level interrupts. While the NSR are also
* level interrupts, SEI are edge interrupts. Force the type
* here in this case. Please note that this makes the interrupt
* handling unreliable.
*/
if (msi_data->subset_data->icu_group == ICU_GRP_SEI)
*type = IRQ_TYPE_EDGE_RISING;
}
if (*hwirq >= ICU_MAX_IRQS) {
dev_err(icu->dev, "invalid interrupt number %ld\n", *hwirq);
return -EINVAL;
}
return 0;
}
static void mvebu_icu_init(struct mvebu_icu *icu,
struct mvebu_icu_msi_data *msi_data,
struct msi_msg *msg)
{
const struct mvebu_icu_subset_data *subset = msi_data->subset_data;
if (atomic_cmpxchg(&msi_data->initialized, false, true))
return;
/* Set 'SET' ICU SPI message address in AP */
writel_relaxed(msg[0].address_hi, icu->base + subset->offset_set_ah);
writel_relaxed(msg[0].address_lo, icu->base + subset->offset_set_al);
if (subset->icu_group != ICU_GRP_NSR)
return;
/* Set 'CLEAR' ICU SPI message address in AP (level-MSI only) */
writel_relaxed(msg[1].address_hi, icu->base + subset->offset_clr_ah);
writel_relaxed(msg[1].address_lo, icu->base + subset->offset_clr_al);
}
static int mvebu_icu_msi_init(struct irq_domain *domain, struct msi_domain_info *info,
unsigned int virq, irq_hw_number_t hwirq, msi_alloc_info_t *arg)
{
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip.h`, `linux/irqdomain.h`, `linux/jump_label.h`, `linux/kernel.h`, `linux/msi.h`, `linux/of_irq.h`.
- Detected declarations: `struct mvebu_icu_subset_data`, `struct mvebu_icu`, `struct mvebu_icu_msi_data`, `function mvebu_icu_translate`, `function mvebu_icu_init`, `function mvebu_icu_msi_init`, `function mvebu_icu_set_desc`, `function mvebu_icu_write_msi_msg`, `function configured`, `function mvebu_icu_subset_probe`.
- Atlas domain: Driver Families / drivers/irqchip.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.