Commit | Line | Data |
---|---|---|
06fcb0c6 IM |
1 | #ifndef _LINUX_IRQ_H |
2 | #define _LINUX_IRQ_H | |
1da177e4 LT |
3 | |
4 | /* | |
5 | * Please do not include this file in generic code. There is currently | |
6 | * no requirement for any architecture to implement anything held | |
7 | * within this file. | |
8 | * | |
9 | * Thanks. --rmk | |
10 | */ | |
11 | ||
23f9b317 | 12 | #include <linux/smp.h> |
1da177e4 | 13 | |
06fcb0c6 | 14 | #ifndef CONFIG_S390 |
1da177e4 LT |
15 | |
16 | #include <linux/linkage.h> | |
17 | #include <linux/cache.h> | |
18 | #include <linux/spinlock.h> | |
19 | #include <linux/cpumask.h> | |
908dcecd | 20 | #include <linux/irqreturn.h> |
1da177e4 LT |
21 | |
22 | #include <asm/irq.h> | |
23 | #include <asm/ptrace.h> | |
24 | ||
25 | /* | |
26 | * IRQ line status. | |
27 | */ | |
28 | #define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */ | |
29 | #define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */ | |
30 | #define IRQ_PENDING 4 /* IRQ pending - replay on enable */ | |
31 | #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */ | |
32 | #define IRQ_AUTODETECT 16 /* IRQ is being autodetected */ | |
33 | #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ | |
34 | #define IRQ_LEVEL 64 /* IRQ level triggered */ | |
35 | #define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */ | |
0d7012a9 | 36 | #ifdef CONFIG_IRQ_PER_CPU |
f26fdd59 KW |
37 | # define IRQ_PER_CPU 256 /* IRQ is per CPU */ |
38 | # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) | |
39 | #else | |
40 | # define CHECK_IRQ_PER_CPU(var) 0 | |
41 | #endif | |
1da177e4 | 42 | |
8fee5c36 IM |
43 | /** |
44 | * struct hw_interrupt_type - hardware interrupt type descriptor | |
45 | * | |
46 | * @name: name for /proc/interrupts | |
47 | * @startup: start up the interrupt (defaults to ->enable if NULL) | |
48 | * @shutdown: shut down the interrupt (defaults to ->disable if NULL) | |
49 | * @enable: enable the interrupt (defaults to chip->unmask if NULL) | |
50 | * @disable: disable the interrupt (defaults to chip->mask if NULL) | |
51 | * @handle_irq: irq flow handler called from the arch IRQ glue code | |
52 | * @ack: start of a new interrupt | |
53 | * @mask: mask an interrupt source | |
54 | * @mask_ack: ack and mask an interrupt source | |
55 | * @unmask: unmask an interrupt source | |
56 | * @hold: same interrupt while the handler is running | |
57 | * @end: end of interrupt | |
58 | * @set_affinity: set the CPU affinity on SMP machines | |
59 | * @retrigger: resend an IRQ to the CPU | |
60 | * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ | |
61 | * @set_wake: enable/disable power-management wake-on of an IRQ | |
62 | * | |
63 | * @release: release function solely used by UML | |
1da177e4 LT |
64 | */ |
65 | struct hw_interrupt_type { | |
71d218b7 IM |
66 | const char *typename; |
67 | unsigned int (*startup)(unsigned int irq); | |
68 | void (*shutdown)(unsigned int irq); | |
69 | void (*enable)(unsigned int irq); | |
70 | void (*disable)(unsigned int irq); | |
71 | void (*ack)(unsigned int irq); | |
72 | void (*end)(unsigned int irq); | |
73 | void (*set_affinity)(unsigned int irq, cpumask_t dest); | |
c0ad90a3 IM |
74 | int (*retrigger)(unsigned int irq); |
75 | ||
b77d6adc PBG |
76 | /* Currently used only by UML, might disappear one day.*/ |
77 | #ifdef CONFIG_IRQ_RELEASE_METHOD | |
71d218b7 | 78 | void (*release)(unsigned int irq, void *dev_id); |
b77d6adc | 79 | #endif |
1da177e4 LT |
80 | }; |
81 | ||
82 | typedef struct hw_interrupt_type hw_irq_controller; | |
83 | ||
4a733ee1 IM |
84 | struct proc_dir_entry; |
85 | ||
8fee5c36 IM |
86 | /** |
87 | * struct irq_desc - interrupt descriptor | |
88 | * | |
89 | * @handler: interrupt type dependent handler functions | |
90 | * @handler_data: data for the type handlers | |
91 | * @action: the irq action chain | |
92 | * @status: status information | |
93 | * @depth: disable-depth, for nested irq_disable() calls | |
94 | * @irq_count: stats field to detect stalled irqs | |
95 | * @irqs_unhandled: stats field for spurious unhandled interrupts | |
96 | * @lock: locking for SMP | |
97 | * @affinity: IRQ affinity on SMP | |
98 | * @pending_mask: pending rebalanced interrupts | |
99 | * @move_irq: need to re-target IRQ destination | |
100 | * @dir: /proc/irq/ procfs entry | |
101 | * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP | |
1da177e4 LT |
102 | * |
103 | * Pad this out to 32 bytes for cache and indexing reasons. | |
104 | */ | |
34ffdb72 | 105 | struct irq_desc { |
71d218b7 IM |
106 | hw_irq_controller *chip; |
107 | void *chip_data; | |
108 | struct irqaction *action; /* IRQ action list */ | |
109 | unsigned int status; /* IRQ status */ | |
110 | unsigned int depth; /* nested irq disables */ | |
111 | unsigned int irq_count; /* For detecting broken IRQs */ | |
112 | unsigned int irqs_unhandled; | |
113 | spinlock_t lock; | |
a53da52f | 114 | #ifdef CONFIG_SMP |
71d218b7 | 115 | cpumask_t affinity; |
a53da52f | 116 | #endif |
06fcb0c6 | 117 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
cd916d31 | 118 | cpumask_t pending_mask; |
71d218b7 | 119 | unsigned int move_irq; /* need to re-target IRQ dest */ |
54d5d424 | 120 | #endif |
4a733ee1 IM |
121 | #ifdef CONFIG_PROC_FS |
122 | struct proc_dir_entry *dir; | |
123 | #endif | |
34ffdb72 | 124 | } ____cacheline_aligned; |
1da177e4 | 125 | |
34ffdb72 | 126 | extern struct irq_desc irq_desc[NR_IRQS]; |
1da177e4 | 127 | |
34ffdb72 IM |
128 | /* |
129 | * Migration helpers for obsolete names, they will go away: | |
130 | */ | |
131 | typedef struct irq_desc irq_desc_t; | |
132 | ||
133 | /* | |
134 | * Pick up the arch-dependent methods: | |
135 | */ | |
136 | #include <asm/hw_irq.h> | |
1da177e4 | 137 | |
06fcb0c6 | 138 | extern int setup_irq(unsigned int irq, struct irqaction *new); |
1da177e4 LT |
139 | |
140 | #ifdef CONFIG_GENERIC_HARDIRQS | |
06fcb0c6 | 141 | |
54d5d424 AR |
142 | #ifdef CONFIG_SMP |
143 | static inline void set_native_irq_info(int irq, cpumask_t mask) | |
144 | { | |
a53da52f | 145 | irq_desc[irq].affinity = mask; |
54d5d424 AR |
146 | } |
147 | #else | |
148 | static inline void set_native_irq_info(int irq, cpumask_t mask) | |
149 | { | |
150 | } | |
151 | #endif | |
152 | ||
153 | #ifdef CONFIG_SMP | |
154 | ||
06fcb0c6 | 155 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
54d5d424 | 156 | |
c777ac55 AM |
157 | void set_pending_irq(unsigned int irq, cpumask_t mask); |
158 | void move_native_irq(int irq); | |
54d5d424 AR |
159 | |
160 | #ifdef CONFIG_PCI_MSI | |
161 | /* | |
162 | * Wonder why these are dummies? | |
163 | * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq() | |
164 | * counter part after translating the vector to irq info. We need to perform | |
165 | * this operation on the real irq, when we dont use vector, i.e when | |
166 | * pci_use_vector() is false. | |
167 | */ | |
168 | static inline void move_irq(int irq) | |
169 | { | |
170 | } | |
171 | ||
172 | static inline void set_irq_info(int irq, cpumask_t mask) | |
173 | { | |
174 | } | |
175 | ||
06fcb0c6 | 176 | #else /* CONFIG_PCI_MSI */ |
54d5d424 AR |
177 | |
178 | static inline void move_irq(int irq) | |
179 | { | |
180 | move_native_irq(irq); | |
181 | } | |
182 | ||
183 | static inline void set_irq_info(int irq, cpumask_t mask) | |
184 | { | |
185 | set_native_irq_info(irq, mask); | |
186 | } | |
54d5d424 | 187 | |
06fcb0c6 IM |
188 | #endif /* CONFIG_PCI_MSI */ |
189 | ||
190 | #else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */ | |
191 | ||
192 | static inline void move_irq(int irq) | |
193 | { | |
194 | } | |
195 | ||
196 | static inline void move_native_irq(int irq) | |
197 | { | |
198 | } | |
199 | ||
200 | static inline void set_pending_irq(unsigned int irq, cpumask_t mask) | |
201 | { | |
202 | } | |
54d5d424 | 203 | |
54d5d424 AR |
204 | static inline void set_irq_info(int irq, cpumask_t mask) |
205 | { | |
206 | set_native_irq_info(irq, mask); | |
207 | } | |
208 | ||
06fcb0c6 | 209 | #endif /* CONFIG_GENERIC_PENDING_IRQ */ |
54d5d424 | 210 | |
06fcb0c6 | 211 | #else /* CONFIG_SMP */ |
54d5d424 AR |
212 | |
213 | #define move_irq(x) | |
214 | #define move_native_irq(x) | |
215 | ||
06fcb0c6 | 216 | #endif /* CONFIG_SMP */ |
54d5d424 | 217 | |
1b61b910 ZY |
218 | #ifdef CONFIG_IRQBALANCE |
219 | extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); | |
220 | #else | |
221 | static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) | |
222 | { | |
223 | } | |
224 | #endif | |
225 | ||
71d218b7 IM |
226 | #ifdef CONFIG_AUTO_IRQ_AFFINITY |
227 | extern int select_smp_affinity(unsigned int irq); | |
228 | #else | |
229 | static inline int select_smp_affinity(unsigned int irq) | |
230 | { | |
231 | return 1; | |
232 | } | |
233 | #endif | |
234 | ||
1da177e4 LT |
235 | extern int no_irq_affinity; |
236 | extern int noirqdebug_setup(char *str); | |
237 | ||
2e60bbb6 IM |
238 | extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, |
239 | struct irqaction *action); | |
240 | /* | |
241 | * Explicit fastcall, because i386 4KSTACKS calls it from assembly: | |
242 | */ | |
1da177e4 | 243 | extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); |
2e60bbb6 | 244 | |
34ffdb72 | 245 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, |
2e60bbb6 | 246 | int action_ret, struct pt_regs *regs); |
1da177e4 LT |
247 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); |
248 | ||
249 | extern void init_irq_proc(void); | |
eee45269 | 250 | |
06fcb0c6 | 251 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
1da177e4 LT |
252 | |
253 | extern hw_irq_controller no_irq_type; /* needed in every arch ? */ | |
254 | ||
06fcb0c6 | 255 | #endif /* !CONFIG_S390 */ |
1da177e4 | 256 | |
06fcb0c6 | 257 | #endif /* _LINUX_IRQ_H */ |