drivers/irqchip/irq-loongson-pch-pic.c
Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-loongson-pch-pic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/irqchip/irq-loongson-pch-pic.c- Extension
.c- Size
- 11650 bytes
- Lines
- 478
- 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/kernel.hlinux/platform_device.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/syscore_ops.hirq-loongson.h
Detected Declarations
struct pch_picfunction hwirq_to_bitfunction pch_pic_bitsetfunction pch_pic_bitclrfunction pch_pic_mask_irqfunction pch_pic_unmask_irqfunction pch_pic_set_typefunction pch_pic_ack_irqfunction pch_pic_domain_translatefunction pch_pic_allocfunction pch_pic_resetfunction pch_pic_suspendfunction pch_pic_resumefunction pch_pic_initfunction pch_pic_of_initfunction find_pch_picfunction pch_lpc_parse_madtfunction acpi_cascade_irqdomain_initfunction pch_pic_acpi_init
Annotated Snippet
struct pch_pic {
void __iomem *base;
struct irq_domain *pic_domain;
u32 ht_vec_base;
raw_spinlock_t pic_lock;
u32 vec_count;
u32 gsi_base;
u32 saved_vec_en[PIC_REG_COUNT];
u32 saved_vec_pol[PIC_REG_COUNT];
u32 saved_vec_edge[PIC_REG_COUNT];
u8 table[PIC_COUNT];
int inuse;
};
static struct pch_pic *pch_pic_priv[MAX_IO_PICS];
struct fwnode_handle *pch_pic_handle[MAX_IO_PICS];
static inline u8 hwirq_to_bit(struct pch_pic *priv, int hirq)
{
return priv->table[hirq];
}
static void pch_pic_bitset(struct pch_pic *priv, int offset, int bit)
{
u32 reg;
void __iomem *addr = priv->base + offset + PIC_REG_IDX(bit) * 4;
raw_spin_lock(&priv->pic_lock);
reg = readl(addr);
reg |= BIT(PIC_REG_BIT(bit));
writel(reg, addr);
raw_spin_unlock(&priv->pic_lock);
}
static void pch_pic_bitclr(struct pch_pic *priv, int offset, int bit)
{
u32 reg;
void __iomem *addr = priv->base + offset + PIC_REG_IDX(bit) * 4;
raw_spin_lock(&priv->pic_lock);
reg = readl(addr);
reg &= ~BIT(PIC_REG_BIT(bit));
writel(reg, addr);
raw_spin_unlock(&priv->pic_lock);
}
static void pch_pic_mask_irq(struct irq_data *d)
{
struct pch_pic *priv = irq_data_get_irq_chip_data(d);
pch_pic_bitset(priv, PCH_PIC_MASK, hwirq_to_bit(priv, d->hwirq));
irq_chip_mask_parent(d);
}
static void pch_pic_unmask_irq(struct irq_data *d)
{
struct pch_pic *priv = irq_data_get_irq_chip_data(d);
int bit = hwirq_to_bit(priv, d->hwirq);
writel(BIT(PIC_REG_BIT(bit)),
priv->base + PCH_PIC_CLR + PIC_REG_IDX(bit) * 4);
irq_chip_unmask_parent(d);
pch_pic_bitclr(priv, PCH_PIC_MASK, bit);
}
static int pch_pic_set_type(struct irq_data *d, unsigned int type)
{
struct pch_pic *priv = irq_data_get_irq_chip_data(d);
int bit = hwirq_to_bit(priv, d->hwirq);
int ret = 0;
switch (type) {
case IRQ_TYPE_EDGE_RISING:
pch_pic_bitset(priv, PCH_PIC_EDGE, bit);
pch_pic_bitclr(priv, PCH_PIC_POL, bit);
irq_set_handler_locked(d, handle_edge_irq);
break;
case IRQ_TYPE_EDGE_FALLING:
pch_pic_bitset(priv, PCH_PIC_EDGE, bit);
pch_pic_bitset(priv, PCH_PIC_POL, bit);
irq_set_handler_locked(d, handle_edge_irq);
break;
case IRQ_TYPE_LEVEL_HIGH:
pch_pic_bitclr(priv, PCH_PIC_EDGE, bit);
pch_pic_bitclr(priv, PCH_PIC_POL, bit);
irq_set_handler_locked(d, handle_level_irq);
break;
case IRQ_TYPE_LEVEL_LOW:
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irq.h`, `linux/irqchip.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/platform_device.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct pch_pic`, `function hwirq_to_bit`, `function pch_pic_bitset`, `function pch_pic_bitclr`, `function pch_pic_mask_irq`, `function pch_pic_unmask_irq`, `function pch_pic_set_type`, `function pch_pic_ack_irq`, `function pch_pic_domain_translate`, `function pch_pic_alloc`.
- 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.