blob: 1df49ec7f8204b55912c703e224c7b3d31f623f8 [file] [log] [blame]
Ingo Molnar06fcb0c2006-06-29 02:24:40 -07001#ifndef _LINUX_IRQ_H
2#define _LINUX_IRQ_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
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
Adrian Bunk23f9b312005-12-21 02:27:50 +010012#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070014#ifndef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#include <linux/linkage.h>
17#include <linux/cache.h>
18#include <linux/spinlock.h>
19#include <linux/cpumask.h>
Jan Beulich908dcec2006-06-23 02:06:00 -070020#include <linux/irqreturn.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
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 */
Ingo Molnar0d7012a2006-06-29 02:24:43 -070036#ifdef CONFIG_IRQ_PER_CPU
Karsten Wiesef26fdd52005-09-06 15:17:25 -070037# 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Thomas Gleixner3418d722006-06-29 02:24:49 -070043#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */
Thomas Gleixner6550c772006-06-29 02:24:49 -070044#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */
Ingo Molnar8fee5c32006-06-29 02:24:45 -070045/**
46 * struct hw_interrupt_type - hardware interrupt type descriptor
47 *
48 * @name: name for /proc/interrupts
49 * @startup: start up the interrupt (defaults to ->enable if NULL)
50 * @shutdown: shut down the interrupt (defaults to ->disable if NULL)
51 * @enable: enable the interrupt (defaults to chip->unmask if NULL)
52 * @disable: disable the interrupt (defaults to chip->mask if NULL)
53 * @handle_irq: irq flow handler called from the arch IRQ glue code
54 * @ack: start of a new interrupt
55 * @mask: mask an interrupt source
56 * @mask_ack: ack and mask an interrupt source
57 * @unmask: unmask an interrupt source
58 * @hold: same interrupt while the handler is running
59 * @end: end of interrupt
60 * @set_affinity: set the CPU affinity on SMP machines
61 * @retrigger: resend an IRQ to the CPU
62 * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
63 * @set_wake: enable/disable power-management wake-on of an IRQ
64 *
65 * @release: release function solely used by UML
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 */
67struct hw_interrupt_type {
Ingo Molnar71d218b2006-06-29 02:24:41 -070068 const char *typename;
69 unsigned int (*startup)(unsigned int irq);
70 void (*shutdown)(unsigned int irq);
71 void (*enable)(unsigned int irq);
72 void (*disable)(unsigned int irq);
73 void (*ack)(unsigned int irq);
74 void (*end)(unsigned int irq);
75 void (*set_affinity)(unsigned int irq, cpumask_t dest);
Ingo Molnarc0ad90a2006-06-29 02:24:44 -070076 int (*retrigger)(unsigned int irq);
77
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070078 /* Currently used only by UML, might disappear one day.*/
79#ifdef CONFIG_IRQ_RELEASE_METHOD
Ingo Molnar71d218b2006-06-29 02:24:41 -070080 void (*release)(unsigned int irq, void *dev_id);
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070081#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
84typedef struct hw_interrupt_type hw_irq_controller;
85
Ingo Molnar4a733ee2006-06-29 02:24:42 -070086struct proc_dir_entry;
87
Ingo Molnar8fee5c32006-06-29 02:24:45 -070088/**
89 * struct irq_desc - interrupt descriptor
90 *
91 * @handler: interrupt type dependent handler functions
92 * @handler_data: data for the type handlers
93 * @action: the irq action chain
94 * @status: status information
95 * @depth: disable-depth, for nested irq_disable() calls
96 * @irq_count: stats field to detect stalled irqs
97 * @irqs_unhandled: stats field for spurious unhandled interrupts
98 * @lock: locking for SMP
99 * @affinity: IRQ affinity on SMP
100 * @pending_mask: pending rebalanced interrupts
101 * @move_irq: need to re-target IRQ destination
102 * @dir: /proc/irq/ procfs entry
103 * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 *
105 * Pad this out to 32 bytes for cache and indexing reasons.
106 */
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700107struct irq_desc {
Ingo Molnar71d218b2006-06-29 02:24:41 -0700108 hw_irq_controller *chip;
109 void *chip_data;
110 struct irqaction *action; /* IRQ action list */
111 unsigned int status; /* IRQ status */
112 unsigned int depth; /* nested irq disables */
113 unsigned int irq_count; /* For detecting broken IRQs */
114 unsigned int irqs_unhandled;
115 spinlock_t lock;
Ingo Molnara53da522006-06-29 02:24:38 -0700116#ifdef CONFIG_SMP
Ingo Molnar71d218b2006-06-29 02:24:41 -0700117 cpumask_t affinity;
Ingo Molnara53da522006-06-29 02:24:38 -0700118#endif
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700119#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ingo Molnarcd916d32006-06-29 02:24:42 -0700120 cpumask_t pending_mask;
Ingo Molnar71d218b2006-06-29 02:24:41 -0700121 unsigned int move_irq; /* need to re-target IRQ dest */
Ashok Raj54d5d422005-09-06 15:16:15 -0700122#endif
Ingo Molnar4a733ee2006-06-29 02:24:42 -0700123#ifdef CONFIG_PROC_FS
124 struct proc_dir_entry *dir;
125#endif
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700126} ____cacheline_aligned;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700128extern struct irq_desc irq_desc[NR_IRQS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700130/*
131 * Migration helpers for obsolete names, they will go away:
132 */
133typedef struct irq_desc irq_desc_t;
134
135/*
136 * Pick up the arch-dependent methods:
137 */
138#include <asm/hw_irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700140extern int setup_irq(unsigned int irq, struct irqaction *new);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142#ifdef CONFIG_GENERIC_HARDIRQS
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700143
Ashok Raj54d5d422005-09-06 15:16:15 -0700144#ifdef CONFIG_SMP
145static inline void set_native_irq_info(int irq, cpumask_t mask)
146{
Ingo Molnara53da522006-06-29 02:24:38 -0700147 irq_desc[irq].affinity = mask;
Ashok Raj54d5d422005-09-06 15:16:15 -0700148}
149#else
150static inline void set_native_irq_info(int irq, cpumask_t mask)
151{
152}
153#endif
154
155#ifdef CONFIG_SMP
156
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700157#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ashok Raj54d5d422005-09-06 15:16:15 -0700158
Andrew Mortonc777ac52006-03-25 03:07:36 -0800159void set_pending_irq(unsigned int irq, cpumask_t mask);
160void move_native_irq(int irq);
Ashok Raj54d5d422005-09-06 15:16:15 -0700161
162#ifdef CONFIG_PCI_MSI
163/*
164 * Wonder why these are dummies?
165 * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
166 * counter part after translating the vector to irq info. We need to perform
167 * this operation on the real irq, when we dont use vector, i.e when
168 * pci_use_vector() is false.
169 */
170static inline void move_irq(int irq)
171{
172}
173
174static inline void set_irq_info(int irq, cpumask_t mask)
175{
176}
177
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700178#else /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700179
180static inline void move_irq(int irq)
181{
182 move_native_irq(irq);
183}
184
185static inline void set_irq_info(int irq, cpumask_t mask)
186{
187 set_native_irq_info(irq, mask);
188}
Ashok Raj54d5d422005-09-06 15:16:15 -0700189
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700190#endif /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700191
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700192#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
193
194static inline void move_irq(int irq)
195{
196}
197
198static inline void move_native_irq(int irq)
199{
200}
201
202static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
203{
204}
205
Ashok Raj54d5d422005-09-06 15:16:15 -0700206static inline void set_irq_info(int irq, cpumask_t mask)
207{
208 set_native_irq_info(irq, mask);
209}
210
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700211#endif /* CONFIG_GENERIC_PENDING_IRQ */
Ashok Raj54d5d422005-09-06 15:16:15 -0700212
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700213#else /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700214
215#define move_irq(x)
216#define move_native_irq(x)
217
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700218#endif /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700219
Zhang Yanmin1b61b912006-06-23 02:04:22 -0700220#ifdef CONFIG_IRQBALANCE
221extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
222#else
223static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
224{
225}
226#endif
227
Ingo Molnar71d218b2006-06-29 02:24:41 -0700228#ifdef CONFIG_AUTO_IRQ_AFFINITY
229extern int select_smp_affinity(unsigned int irq);
230#else
231static inline int select_smp_affinity(unsigned int irq)
232{
233 return 1;
234}
235#endif
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237extern int no_irq_affinity;
238extern int noirqdebug_setup(char *str);
239
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700240extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
241 struct irqaction *action);
242/*
243 * Explicit fastcall, because i386 4KSTACKS calls it from assembly:
244 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700246
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700247extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700248 int action_ret, struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249extern int can_request_irq(unsigned int irq, unsigned long irqflags);
250
Thomas Gleixnera4633ad2006-06-29 02:24:48 -0700251/* Resending of interrupts :*/
252void check_irq_resend(struct irq_desc *desc, unsigned int irq);
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254extern void init_irq_proc(void);
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800255
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700256#endif /* CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
258extern hw_irq_controller no_irq_type; /* needed in every arch ? */
259
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700260#endif /* !CONFIG_S390 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700262#endif /* _LINUX_IRQ_H */