drivers/misc/hi6421v600-irq.c
Source file repositories/reference/linux-study-clean/drivers/misc/hi6421v600-irq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/hi6421v600-irq.c- Extension
.c- Size
- 7570 bytes
- Lines
- 303
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/bitops.hlinux/interrupt.hlinux/irq.hlinux/module.hlinux/platform_device.hlinux/slab.hlinux/irqdomain.hlinux/regmap.h
Detected Declarations
struct hi6421v600_irqenum hi6421v600_irq_listfunction hi6421v600_irq_handlerfunction for_each_set_bitfunction hi6421v600_irq_maskfunction hi6421v600_irq_unmaskfunction hi6421v600_irq_mapfunction hi6421v600_irq_initfunction hi6421v600_irq_probe
Annotated Snippet
struct hi6421v600_irq {
struct device *dev;
struct irq_domain *domain;
int irq;
unsigned int *irqs;
struct regmap *regmap;
/* Protect IRQ mask changes */
spinlock_t lock;
};
enum hi6421v600_irq_list {
OTMP = 0,
VBUS_CONNECT,
VBUS_DISCONNECT,
ALARMON_R,
HOLD_6S,
HOLD_1S,
POWERKEY_UP,
POWERKEY_DOWN,
OCP_SCP_R,
COUL_R,
SIM0_HPD_R,
SIM0_HPD_F,
SIM1_HPD_R,
SIM1_HPD_F,
PMIC_IRQ_LIST_MAX
};
#define HISI_IRQ_BANK_SIZE 2
/*
* IRQ number for the power key button and mask for both UP and DOWN IRQs
*/
#define HISI_POWERKEY_IRQ_NUM 0
#define HISI_IRQ_POWERKEY_UP_DOWN (BIT(POWERKEY_DOWN) | BIT(POWERKEY_UP))
/*
* Registers for IRQ address and IRQ mask bits
*
* Please notice that we need to regmap a larger region, as other
* registers are used by the irqs.
* See drivers/irq/hi6421-irq.c.
*/
#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202
#define SOC_PMIC_IRQ0_ADDR 0x0212
/*
* The IRQs are mapped as:
*
* ====================== ============= ============ =====
* IRQ MASK REGISTER IRQ REGISTER BIT
* ====================== ============= ============ =====
* OTMP 0x0202 0x212 bit 0
* VBUS_CONNECT 0x0202 0x212 bit 1
* VBUS_DISCONNECT 0x0202 0x212 bit 2
* ALARMON_R 0x0202 0x212 bit 3
* HOLD_6S 0x0202 0x212 bit 4
* HOLD_1S 0x0202 0x212 bit 5
* POWERKEY_UP 0x0202 0x212 bit 6
* POWERKEY_DOWN 0x0202 0x212 bit 7
*
* OCP_SCP_R 0x0203 0x213 bit 0
* COUL_R 0x0203 0x213 bit 1
* SIM0_HPD_R 0x0203 0x213 bit 2
* SIM0_HPD_F 0x0203 0x213 bit 3
* SIM1_HPD_R 0x0203 0x213 bit 4
* SIM1_HPD_F 0x0203 0x213 bit 5
* ====================== ============= ============ =====
*
* Each mask register contains 8 bits. The ancillary macros below
* convert a number from 0 to 14 into a register address and a bit mask
*/
#define HISI_IRQ_MASK_REG(irq_data) (SOC_PMIC_IRQ_MASK_0_ADDR + \
(irqd_to_hwirq(irq_data) / BITS_PER_BYTE))
#define HISI_IRQ_MASK_BIT(irq_data) BIT(irqd_to_hwirq(irq_data) & (BITS_PER_BYTE - 1))
#define HISI_8BITS_MASK 0xff
static irqreturn_t hi6421v600_irq_handler(int irq, void *__priv)
{
struct hi6421v600_irq *priv = __priv;
unsigned long pending;
unsigned int in;
int i, offset;
for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) {
regmap_read(priv->regmap, SOC_PMIC_IRQ0_ADDR + i, &in);
/* Mark pending IRQs as handled */
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/irqdomain.h`, `linux/regmap.h`.
- Detected declarations: `struct hi6421v600_irq`, `enum hi6421v600_irq_list`, `function hi6421v600_irq_handler`, `function for_each_set_bit`, `function hi6421v600_irq_mask`, `function hi6421v600_irq_unmask`, `function hi6421v600_irq_map`, `function hi6421v600_irq_init`, `function hi6421v600_irq_probe`.
- Atlas domain: Driver Families / drivers/misc.
- 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.