Merge branch 'master' into upstream
[linux-2.6-block.git] / include / linux / irq.h
CommitLineData
1da177e4
LT
1#ifndef __irq_h
2#define __irq_h
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
347a8dc3 14#if !defined(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>
20
21#include <asm/irq.h>
22#include <asm/ptrace.h>
23
24/*
25 * IRQ line status.
26 */
27#define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */
28#define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */
29#define IRQ_PENDING 4 /* IRQ pending - replay on enable */
30#define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */
31#define IRQ_AUTODETECT 16 /* IRQ is being autodetected */
32#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
33#define IRQ_LEVEL 64 /* IRQ level triggered */
34#define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */
f26fdd59
KW
35#if defined(ARCH_HAS_IRQ_PER_CPU)
36# define IRQ_PER_CPU 256 /* IRQ is per CPU */
37# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
38#else
39# define CHECK_IRQ_PER_CPU(var) 0
40#endif
1da177e4
LT
41
42/*
43 * Interrupt controller descriptor. This is all we need
44 * to describe about the low-level hardware.
45 */
46struct hw_interrupt_type {
47 const char * typename;
48 unsigned int (*startup)(unsigned int irq);
49 void (*shutdown)(unsigned int irq);
50 void (*enable)(unsigned int irq);
51 void (*disable)(unsigned int irq);
52 void (*ack)(unsigned int irq);
53 void (*end)(unsigned int irq);
54 void (*set_affinity)(unsigned int irq, cpumask_t dest);
b77d6adc
PBG
55 /* Currently used only by UML, might disappear one day.*/
56#ifdef CONFIG_IRQ_RELEASE_METHOD
dbce706e 57 void (*release)(unsigned int irq, void *dev_id);
b77d6adc 58#endif
1da177e4
LT
59};
60
61typedef struct hw_interrupt_type hw_irq_controller;
62
63/*
64 * This is the "IRQ descriptor", which contains various information
65 * about the irq, including what kind of hardware handling it has,
66 * whether it is disabled etc etc.
67 *
68 * Pad this out to 32 bytes for cache and indexing reasons.
69 */
70typedef struct irq_desc {
71 hw_irq_controller *handler;
72 void *handler_data;
73 struct irqaction *action; /* IRQ action list */
74 unsigned int status; /* IRQ status */
75 unsigned int depth; /* nested irq disables */
76 unsigned int irq_count; /* For detecting broken interrupts */
77 unsigned int irqs_unhandled;
78 spinlock_t lock;
54d5d424
AR
79#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
80 unsigned int move_irq; /* Flag need to re-target intr dest*/
81#endif
1da177e4
LT
82} ____cacheline_aligned irq_desc_t;
83
84extern irq_desc_t irq_desc [NR_IRQS];
85
54d5d424
AR
86/* Return a pointer to the irq descriptor for IRQ. */
87static inline irq_desc_t *
88irq_descp (int irq)
89{
90 return irq_desc + irq;
91}
92
1da177e4
LT
93#include <asm/hw_irq.h> /* the arch dependent stuff */
94
95extern int setup_irq(unsigned int irq, struct irqaction * new);
96
97#ifdef CONFIG_GENERIC_HARDIRQS
98extern cpumask_t irq_affinity[NR_IRQS];
54d5d424
AR
99
100#ifdef CONFIG_SMP
101static inline void set_native_irq_info(int irq, cpumask_t mask)
102{
103 irq_affinity[irq] = mask;
104}
105#else
106static inline void set_native_irq_info(int irq, cpumask_t mask)
107{
108}
109#endif
110
111#ifdef CONFIG_SMP
112
113#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
114extern cpumask_t pending_irq_cpumask[NR_IRQS];
115
c777ac55
AM
116void set_pending_irq(unsigned int irq, cpumask_t mask);
117void move_native_irq(int irq);
54d5d424
AR
118
119#ifdef CONFIG_PCI_MSI
120/*
121 * Wonder why these are dummies?
122 * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
123 * counter part after translating the vector to irq info. We need to perform
124 * this operation on the real irq, when we dont use vector, i.e when
125 * pci_use_vector() is false.
126 */
127static inline void move_irq(int irq)
128{
129}
130
131static inline void set_irq_info(int irq, cpumask_t mask)
132{
133}
134
135#else // CONFIG_PCI_MSI
136
137static inline void move_irq(int irq)
138{
139 move_native_irq(irq);
140}
141
142static inline void set_irq_info(int irq, cpumask_t mask)
143{
144 set_native_irq_info(irq, mask);
145}
146#endif // CONFIG_PCI_MSI
147
148#else // CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE
149
150#define move_irq(x)
151#define move_native_irq(x)
152#define set_pending_irq(x,y)
153static inline void set_irq_info(int irq, cpumask_t mask)
154{
155 set_native_irq_info(irq, mask);
156}
157
158#endif // CONFIG_GENERIC_PENDING_IRQ
159
160#else // CONFIG_SMP
161
162#define move_irq(x)
163#define move_native_irq(x)
164
165#endif // CONFIG_SMP
166
1da177e4
LT
167extern int no_irq_affinity;
168extern int noirqdebug_setup(char *str);
169
170extern fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
200803df 171 struct irqaction *action);
1da177e4 172extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
200803df
AC
173extern void note_interrupt(unsigned int irq, irq_desc_t *desc,
174 int action_ret, struct pt_regs *regs);
1da177e4
LT
175extern int can_request_irq(unsigned int irq, unsigned long irqflags);
176
177extern void init_irq_proc(void);
eee45269
IK
178
179#ifdef CONFIG_AUTO_IRQ_AFFINITY
180extern int select_smp_affinity(unsigned int irq);
181#else
182static inline int
183select_smp_affinity(unsigned int irq)
184{
185 return 1;
186}
187#endif
188
1da177e4
LT
189#endif
190
191extern hw_irq_controller no_irq_type; /* needed in every arch ? */
192
193#endif
194
195#endif /* __irq_h */