drivers/irqchip/irq-sp7021-intc.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-sp7021-intc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-sp7021-intc.c- Extension
.c- Size
- 7099 bytes
- Lines
- 279
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/irq.hlinux/irqdomain.hlinux/io.hlinux/irqchip.hlinux/irqchip/chained_irq.hlinux/of_address.hlinux/of_irq.h
Detected Declarations
function sp_intc_assign_bitfunction sp_intc_ack_irqfunction sp_intc_mask_irqfunction sp_intc_unmask_irqfunction sp_intc_set_typefunction sp_intc_get_ext_irqfunction sp_intc_handle_ext_cascadedfunction sp_intc_irq_domain_mapfunction sp_intc_irq_mapfunction sp_intc_init_dt
Annotated Snippet
if (unlikely(IS_GPIO_INT(hwirq) && TEST_STATE(hwirq, _IS_ACTIVE))) { // WORKAROUND
ASSIGN_STATE(hwirq, _IS_ACTIVE, false);
sp_intc_assign_bit(hwirq, REG_INTR_POLARITY, TEST_STATE(hwirq, _IS_LOW));
} else {
generic_handle_domain_irq(sp_intc.domain, hwirq);
}
}
chained_irq_exit(chip, desc);
}
static struct irq_chip sp_intc_chip = {
.name = "sp_intc",
.irq_ack = sp_intc_ack_irq,
.irq_mask = sp_intc_mask_irq,
.irq_unmask = sp_intc_unmask_irq,
.irq_set_type = sp_intc_set_type,
};
static int sp_intc_irq_domain_map(struct irq_domain *domain,
unsigned int irq, irq_hw_number_t hwirq)
{
irq_set_chip_and_handler(irq, &sp_intc_chip, handle_level_irq);
irq_set_chip_data(irq, &sp_intc_chip);
irq_set_noprobe(irq);
return 0;
}
static const struct irq_domain_ops sp_intc_dm_ops = {
.xlate = irq_domain_xlate_twocell,
.map = sp_intc_irq_domain_map,
};
static int sp_intc_irq_map(struct device_node *node, int i)
{
unsigned int irq;
irq = irq_of_parse_and_map(node, i);
if (!irq)
return -ENOENT;
irq_set_chained_handler_and_data(irq, sp_intc_handle_ext_cascaded, (void *)(uintptr_t)i);
return 0;
}
static int __init sp_intc_init_dt(struct device_node *node, struct device_node *parent)
{
int i, ret;
sp_intc.g0 = of_iomap(node, 0);
if (!sp_intc.g0)
return -ENXIO;
sp_intc.g1 = of_iomap(node, 1);
if (!sp_intc.g1) {
ret = -ENXIO;
goto out_unmap0;
}
ret = sp_intc_irq_map(node, 0); // EXT_INT0
if (ret)
goto out_unmap1;
ret = sp_intc_irq_map(node, 1); // EXT_INT1
if (ret)
goto out_unmap1;
/* initial regs */
for (i = 0; i < SP_INTC_NR_GROUPS; i++) {
/* all mask */
writel_relaxed(0, REG_INTR_MASK + i * 4);
/* all edge */
writel_relaxed(~0, REG_INTR_TYPE + i * 4);
/* all high-active */
writel_relaxed(0, REG_INTR_POLARITY + i * 4);
/* all EXT_INT0 */
writel_relaxed(~0, REG_INTR_PRIORITY + i * 4);
/* all clear */
writel_relaxed(~0, REG_INTR_CLEAR + i * 4);
}
sp_intc.domain = irq_domain_create_linear(of_fwnode_handle(node), SP_INTC_NR_IRQS,
&sp_intc_dm_ops, &sp_intc);
if (!sp_intc.domain) {
ret = -ENOMEM;
goto out_unmap1;
}
Annotation
- Immediate include surface: `linux/irq.h`, `linux/irqdomain.h`, `linux/io.h`, `linux/irqchip.h`, `linux/irqchip/chained_irq.h`, `linux/of_address.h`, `linux/of_irq.h`.
- Detected declarations: `function sp_intc_assign_bit`, `function sp_intc_ack_irq`, `function sp_intc_mask_irq`, `function sp_intc_unmask_irq`, `function sp_intc_set_type`, `function sp_intc_get_ext_irq`, `function sp_intc_handle_ext_cascaded`, `function sp_intc_irq_domain_map`, `function sp_intc_irq_map`, `function sp_intc_init_dt`.
- 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.
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.