blob: 92c6854146223c85c2346aeb1bd7992e0405a19d [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 Molnar06fcb0c2006-06-29 02:24:40 -070036#ifdef ARCH_HAS_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
43/*
44 * Interrupt controller descriptor. This is all we need
45 * to describe about the low-level hardware.
46 */
47struct hw_interrupt_type {
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070048 const char *typename;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 unsigned int (*startup)(unsigned int irq);
50 void (*shutdown)(unsigned int irq);
51 void (*enable)(unsigned int irq);
52 void (*disable)(unsigned int irq);
53 void (*ack)(unsigned int irq);
54 void (*end)(unsigned int irq);
55 void (*set_affinity)(unsigned int irq, cpumask_t dest);
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070056 /* Currently used only by UML, might disappear one day.*/
57#ifdef CONFIG_IRQ_RELEASE_METHOD
Paolo 'Blaisorblade' Giarrussodbce7062005-06-21 17:16:19 -070058 void (*release)(unsigned int irq, void *dev_id);
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070059#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
62typedef struct hw_interrupt_type hw_irq_controller;
63
64/*
65 * This is the "IRQ descriptor", which contains various information
66 * about the irq, including what kind of hardware handling it has,
67 * whether it is disabled etc etc.
68 *
69 * Pad this out to 32 bytes for cache and indexing reasons.
70 */
71typedef struct irq_desc {
Ingo Molnard1bef4e2006-06-29 02:24:36 -070072 hw_irq_controller *chip;
73 void *chip_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 struct irqaction *action; /* IRQ action list */
75 unsigned int status; /* IRQ status */
76 unsigned int depth; /* nested irq disables */
77 unsigned int irq_count; /* For detecting broken interrupts */
78 unsigned int irqs_unhandled;
79 spinlock_t lock;
Ingo Molnara53da522006-06-29 02:24:38 -070080#ifdef CONFIG_SMP
81 cpumask_t affinity;
82#endif
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070083#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ashok Raj54d5d422005-09-06 15:16:15 -070084 unsigned int move_irq; /* Flag need to re-target intr dest*/
85#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070086} ____cacheline_aligned irq_desc_t;
87
88extern irq_desc_t irq_desc [NR_IRQS];
89
90#include <asm/hw_irq.h> /* the arch dependent stuff */
91
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070092extern int setup_irq(unsigned int irq, struct irqaction *new);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94#ifdef CONFIG_GENERIC_HARDIRQS
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070095
Ashok Raj54d5d422005-09-06 15:16:15 -070096#ifdef CONFIG_SMP
97static inline void set_native_irq_info(int irq, cpumask_t mask)
98{
Ingo Molnara53da522006-06-29 02:24:38 -070099 irq_desc[irq].affinity = mask;
Ashok Raj54d5d422005-09-06 15:16:15 -0700100}
101#else
102static inline void set_native_irq_info(int irq, cpumask_t mask)
103{
104}
105#endif
106
107#ifdef CONFIG_SMP
108
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700109#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ashok Raj54d5d422005-09-06 15:16:15 -0700110extern cpumask_t pending_irq_cpumask[NR_IRQS];
111
Andrew Mortonc777ac52006-03-25 03:07:36 -0800112void set_pending_irq(unsigned int irq, cpumask_t mask);
113void move_native_irq(int irq);
Ashok Raj54d5d422005-09-06 15:16:15 -0700114
115#ifdef CONFIG_PCI_MSI
116/*
117 * Wonder why these are dummies?
118 * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
119 * counter part after translating the vector to irq info. We need to perform
120 * this operation on the real irq, when we dont use vector, i.e when
121 * pci_use_vector() is false.
122 */
123static inline void move_irq(int irq)
124{
125}
126
127static inline void set_irq_info(int irq, cpumask_t mask)
128{
129}
130
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700131#else /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700132
133static inline void move_irq(int irq)
134{
135 move_native_irq(irq);
136}
137
138static inline void set_irq_info(int irq, cpumask_t mask)
139{
140 set_native_irq_info(irq, mask);
141}
Ashok Raj54d5d422005-09-06 15:16:15 -0700142
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700143#endif /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700144
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700145#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
146
147static inline void move_irq(int irq)
148{
149}
150
151static inline void move_native_irq(int irq)
152{
153}
154
155static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
156{
157}
158
Ashok Raj54d5d422005-09-06 15:16:15 -0700159static inline void set_irq_info(int irq, cpumask_t mask)
160{
161 set_native_irq_info(irq, mask);
162}
163
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700164#endif /* CONFIG_GENERIC_PENDING_IRQ */
Ashok Raj54d5d422005-09-06 15:16:15 -0700165
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700166#else /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700167
168#define move_irq(x)
169#define move_native_irq(x)
170
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700171#endif /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700172
Zhang Yanmin1b61b912006-06-23 02:04:22 -0700173#ifdef CONFIG_IRQBALANCE
174extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
175#else
176static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
177{
178}
179#endif
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181extern int no_irq_affinity;
182extern int noirqdebug_setup(char *str);
183
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700184extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
185 struct irqaction *action);
186/*
187 * Explicit fastcall, because i386 4KSTACKS calls it from assembly:
188 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700190
Alan Cox200803d2005-06-28 20:45:18 -0700191extern void note_interrupt(unsigned int irq, irq_desc_t *desc,
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700192 int action_ret, struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193extern int can_request_irq(unsigned int irq, unsigned long irqflags);
194
195extern void init_irq_proc(void);
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800196
197#ifdef CONFIG_AUTO_IRQ_AFFINITY
198extern int select_smp_affinity(unsigned int irq);
199#else
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700200static inline int select_smp_affinity(unsigned int irq)
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800201{
202 return 1;
203}
204#endif
205
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700206#endif /* CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208extern hw_irq_controller no_irq_type; /* needed in every arch ? */
209
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700210#endif /* !CONFIG_S390 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700212#endif /* _LINUX_IRQ_H */