blob: e58cfb9c66a3f630a27089e989838adc96c9e097 [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
43/*
44 * Interrupt controller descriptor. This is all we need
45 * to describe about the low-level hardware.
46 */
47struct hw_interrupt_type {
Ingo Molnar71d218b2006-06-29 02:24:41 -070048 const char *typename;
49 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);
Ingo Molnarc0ad90a2006-06-29 02:24:44 -070056 int (*retrigger)(unsigned int irq);
57
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070058 /* Currently used only by UML, might disappear one day.*/
59#ifdef CONFIG_IRQ_RELEASE_METHOD
Ingo Molnar71d218b2006-06-29 02:24:41 -070060 void (*release)(unsigned int irq, void *dev_id);
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070061#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070062};
63
64typedef struct hw_interrupt_type hw_irq_controller;
65
Ingo Molnar4a733ee2006-06-29 02:24:42 -070066struct proc_dir_entry;
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068/*
69 * This is the "IRQ descriptor", which contains various information
70 * about the irq, including what kind of hardware handling it has,
71 * whether it is disabled etc etc.
72 *
73 * Pad this out to 32 bytes for cache and indexing reasons.
74 */
Ingo Molnar34ffdb72006-06-29 02:24:40 -070075struct irq_desc {
Ingo Molnar71d218b2006-06-29 02:24:41 -070076 hw_irq_controller *chip;
77 void *chip_data;
78 struct irqaction *action; /* IRQ action list */
79 unsigned int status; /* IRQ status */
80 unsigned int depth; /* nested irq disables */
81 unsigned int irq_count; /* For detecting broken IRQs */
82 unsigned int irqs_unhandled;
83 spinlock_t lock;
Ingo Molnara53da522006-06-29 02:24:38 -070084#ifdef CONFIG_SMP
Ingo Molnar71d218b2006-06-29 02:24:41 -070085 cpumask_t affinity;
Ingo Molnara53da522006-06-29 02:24:38 -070086#endif
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070087#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ingo Molnarcd916d32006-06-29 02:24:42 -070088 cpumask_t pending_mask;
Ingo Molnar71d218b2006-06-29 02:24:41 -070089 unsigned int move_irq; /* need to re-target IRQ dest */
Ashok Raj54d5d422005-09-06 15:16:15 -070090#endif
Ingo Molnar4a733ee2006-06-29 02:24:42 -070091#ifdef CONFIG_PROC_FS
92 struct proc_dir_entry *dir;
93#endif
Ingo Molnar34ffdb72006-06-29 02:24:40 -070094} ____cacheline_aligned;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Ingo Molnar34ffdb72006-06-29 02:24:40 -070096extern struct irq_desc irq_desc[NR_IRQS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Ingo Molnar34ffdb72006-06-29 02:24:40 -070098/*
99 * Migration helpers for obsolete names, they will go away:
100 */
101typedef struct irq_desc irq_desc_t;
102
103/*
104 * Pick up the arch-dependent methods:
105 */
106#include <asm/hw_irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700108extern int setup_irq(unsigned int irq, struct irqaction *new);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110#ifdef CONFIG_GENERIC_HARDIRQS
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700111
Ashok Raj54d5d422005-09-06 15:16:15 -0700112#ifdef CONFIG_SMP
113static inline void set_native_irq_info(int irq, cpumask_t mask)
114{
Ingo Molnara53da522006-06-29 02:24:38 -0700115 irq_desc[irq].affinity = mask;
Ashok Raj54d5d422005-09-06 15:16:15 -0700116}
117#else
118static inline void set_native_irq_info(int irq, cpumask_t mask)
119{
120}
121#endif
122
123#ifdef CONFIG_SMP
124
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700125#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ashok Raj54d5d422005-09-06 15:16:15 -0700126
Andrew Mortonc777ac52006-03-25 03:07:36 -0800127void set_pending_irq(unsigned int irq, cpumask_t mask);
128void move_native_irq(int irq);
Ashok Raj54d5d422005-09-06 15:16:15 -0700129
130#ifdef CONFIG_PCI_MSI
131/*
132 * Wonder why these are dummies?
133 * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
134 * counter part after translating the vector to irq info. We need to perform
135 * this operation on the real irq, when we dont use vector, i.e when
136 * pci_use_vector() is false.
137 */
138static inline void move_irq(int irq)
139{
140}
141
142static inline void set_irq_info(int irq, cpumask_t mask)
143{
144}
145
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700146#else /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700147
148static inline void move_irq(int irq)
149{
150 move_native_irq(irq);
151}
152
153static inline void set_irq_info(int irq, cpumask_t mask)
154{
155 set_native_irq_info(irq, mask);
156}
Ashok Raj54d5d422005-09-06 15:16:15 -0700157
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700158#endif /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700159
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700160#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
161
162static inline void move_irq(int irq)
163{
164}
165
166static inline void move_native_irq(int irq)
167{
168}
169
170static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
171{
172}
173
Ashok Raj54d5d422005-09-06 15:16:15 -0700174static inline void set_irq_info(int irq, cpumask_t mask)
175{
176 set_native_irq_info(irq, mask);
177}
178
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700179#endif /* CONFIG_GENERIC_PENDING_IRQ */
Ashok Raj54d5d422005-09-06 15:16:15 -0700180
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700181#else /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700182
183#define move_irq(x)
184#define move_native_irq(x)
185
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700186#endif /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700187
Zhang Yanmin1b61b912006-06-23 02:04:22 -0700188#ifdef CONFIG_IRQBALANCE
189extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
190#else
191static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
192{
193}
194#endif
195
Ingo Molnar71d218b2006-06-29 02:24:41 -0700196#ifdef CONFIG_AUTO_IRQ_AFFINITY
197extern int select_smp_affinity(unsigned int irq);
198#else
199static inline int select_smp_affinity(unsigned int irq)
200{
201 return 1;
202}
203#endif
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205extern int no_irq_affinity;
206extern int noirqdebug_setup(char *str);
207
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700208extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
209 struct irqaction *action);
210/*
211 * Explicit fastcall, because i386 4KSTACKS calls it from assembly:
212 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700214
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700215extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700216 int action_ret, struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217extern int can_request_irq(unsigned int irq, unsigned long irqflags);
218
219extern void init_irq_proc(void);
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800220
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700221#endif /* CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223extern hw_irq_controller no_irq_type; /* needed in every arch ? */
224
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700225#endif /* !CONFIG_S390 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700227#endif /* _LINUX_IRQ_H */