xref: /openbmc/linux/arch/x86/include/asm/hw_irq.h (revision a27dca64)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_HW_IRQ_H
3 #define _ASM_X86_HW_IRQ_H
4 
5 /*
6  * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
7  *
8  * moved some of the old arch/i386/kernel/irq.h to here. VY
9  *
10  * IRQ/IPI changes taken from work by Thomas Radke
11  * <tomsoft@informatik.tu-chemnitz.de>
12  *
13  * hacked by Andi Kleen for x86-64.
14  * unified by tglx
15  */
16 
17 #include <asm/irq_vectors.h>
18 
19 #define IRQ_MATRIX_BITS		NR_VECTORS
20 
21 #ifndef __ASSEMBLY__
22 
23 #include <linux/percpu.h>
24 #include <linux/profile.h>
25 #include <linux/smp.h>
26 
27 #include <linux/atomic.h>
28 #include <asm/irq.h>
29 #include <asm/sections.h>
30 
31 #ifdef	CONFIG_X86_LOCAL_APIC
32 struct irq_data;
33 struct pci_dev;
34 struct msi_desc;
35 
36 enum irq_alloc_type {
37 	X86_IRQ_ALLOC_TYPE_IOAPIC = 1,
38 	X86_IRQ_ALLOC_TYPE_HPET,
39 	X86_IRQ_ALLOC_TYPE_PCI_MSI,
40 	X86_IRQ_ALLOC_TYPE_PCI_MSIX,
41 	X86_IRQ_ALLOC_TYPE_DMAR,
42 	X86_IRQ_ALLOC_TYPE_UV,
43 	X86_IRQ_ALLOC_TYPE_IOAPIC_GET_PARENT,
44 	X86_IRQ_ALLOC_TYPE_HPET_GET_PARENT,
45 };
46 
47 struct ioapic_alloc_info {
48 	int				pin;
49 	int				node;
50 	u32				is_level	: 1;
51 	u32				active_low	: 1;
52 	u32				valid		: 1;
53 	struct IO_APIC_route_entry	*entry;
54 };
55 
56 struct uv_alloc_info {
57 	int		limit;
58 	int		blade;
59 	unsigned long	offset;
60 	char		*name;
61 
62 };
63 
64 /**
65  * irq_alloc_info - X86 specific interrupt allocation info
66  * @type:	X86 specific allocation type
67  * @flags:	Flags for allocation tweaks
68  * @devid:	Device ID for allocations
69  * @hwirq:	Associated hw interrupt number in the domain
70  * @mask:	CPU mask for vector allocation
71  * @desc:	Pointer to msi descriptor
72  * @data:	Allocation specific data
73  *
74  * @ioapic:	IOAPIC specific allocation data
75  * @uv:		UV specific allocation data
76 */
77 struct irq_alloc_info {
78 	enum irq_alloc_type	type;
79 	u32			flags;
80 	u32			devid;
81 	irq_hw_number_t		hwirq;
82 	const struct cpumask	*mask;
83 	struct msi_desc		*desc;
84 	void			*data;
85 
86 	union {
87 		struct ioapic_alloc_info	ioapic;
88 		struct uv_alloc_info		uv;
89 	};
90 };
91 
92 struct irq_cfg {
93 	unsigned int		dest_apicid;
94 	unsigned int		vector;
95 };
96 
97 extern struct irq_cfg *irq_cfg(unsigned int irq);
98 extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);
99 extern void lock_vector_lock(void);
100 extern void unlock_vector_lock(void);
101 #ifdef CONFIG_SMP
102 extern void send_cleanup_vector(struct irq_cfg *);
103 extern void irq_complete_move(struct irq_cfg *cfg);
104 #else
105 static inline void send_cleanup_vector(struct irq_cfg *c) { }
106 static inline void irq_complete_move(struct irq_cfg *c) { }
107 #endif
108 
109 extern void apic_ack_edge(struct irq_data *data);
110 #else	/*  CONFIG_X86_LOCAL_APIC */
111 static inline void lock_vector_lock(void) {}
112 static inline void unlock_vector_lock(void) {}
113 #endif	/* CONFIG_X86_LOCAL_APIC */
114 
115 /* Statistics */
116 extern atomic_t irq_err_count;
117 extern atomic_t irq_mis_count;
118 
119 extern void elcr_set_level_irq(unsigned int irq);
120 
121 extern char irq_entries_start[];
122 #ifdef CONFIG_TRACING
123 #define trace_irq_entries_start irq_entries_start
124 #endif
125 
126 extern char spurious_entries_start[];
127 
128 #define VECTOR_UNUSED		NULL
129 #define VECTOR_SHUTDOWN		((void *)-1L)
130 #define VECTOR_RETRIGGERED	((void *)-2L)
131 
132 typedef struct irq_desc* vector_irq_t[NR_VECTORS];
133 DECLARE_PER_CPU(vector_irq_t, vector_irq);
134 
135 #endif /* !ASSEMBLY_ */
136 
137 #endif /* _ASM_X86_HW_IRQ_H */
138