blob: 9a39756bfd31162f3891932d055b67d6c987bd72 [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
Ingo Molnar8fee5c32006-06-29 02:24:45 -070043/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 */
65struct hw_interrupt_type {
Ingo Molnar71d218b2006-06-29 02:24:41 -070066 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);
Ingo Molnarc0ad90a2006-06-29 02:24:44 -070074 int (*retrigger)(unsigned int irq);
75
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070076 /* Currently used only by UML, might disappear one day.*/
77#ifdef CONFIG_IRQ_RELEASE_METHOD
Ingo Molnar71d218b2006-06-29 02:24:41 -070078 void (*release)(unsigned int irq, void *dev_id);
Paolo 'Blaisorblade' Giarrussob77d6ad2005-06-21 17:16:24 -070079#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070080};
81
82typedef struct hw_interrupt_type hw_irq_controller;
83
Ingo Molnar4a733ee2006-06-29 02:24:42 -070084struct proc_dir_entry;
85
Ingo Molnar8fee5c32006-06-29 02:24:45 -070086/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *
103 * Pad this out to 32 bytes for cache and indexing reasons.
104 */
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700105struct irq_desc {
Ingo Molnar71d218b2006-06-29 02:24:41 -0700106 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;
Ingo Molnara53da522006-06-29 02:24:38 -0700114#ifdef CONFIG_SMP
Ingo Molnar71d218b2006-06-29 02:24:41 -0700115 cpumask_t affinity;
Ingo Molnara53da522006-06-29 02:24:38 -0700116#endif
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700117#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ingo Molnarcd916d32006-06-29 02:24:42 -0700118 cpumask_t pending_mask;
Ingo Molnar71d218b2006-06-29 02:24:41 -0700119 unsigned int move_irq; /* need to re-target IRQ dest */
Ashok Raj54d5d422005-09-06 15:16:15 -0700120#endif
Ingo Molnar4a733ee2006-06-29 02:24:42 -0700121#ifdef CONFIG_PROC_FS
122 struct proc_dir_entry *dir;
123#endif
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700124} ____cacheline_aligned;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700126extern struct irq_desc irq_desc[NR_IRQS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700128/*
129 * Migration helpers for obsolete names, they will go away:
130 */
131typedef struct irq_desc irq_desc_t;
132
133/*
134 * Pick up the arch-dependent methods:
135 */
136#include <asm/hw_irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700138extern int setup_irq(unsigned int irq, struct irqaction *new);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140#ifdef CONFIG_GENERIC_HARDIRQS
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700141
Ashok Raj54d5d422005-09-06 15:16:15 -0700142#ifdef CONFIG_SMP
143static inline void set_native_irq_info(int irq, cpumask_t mask)
144{
Ingo Molnara53da522006-06-29 02:24:38 -0700145 irq_desc[irq].affinity = mask;
Ashok Raj54d5d422005-09-06 15:16:15 -0700146}
147#else
148static inline void set_native_irq_info(int irq, cpumask_t mask)
149{
150}
151#endif
152
153#ifdef CONFIG_SMP
154
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700155#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
Ashok Raj54d5d422005-09-06 15:16:15 -0700156
Andrew Mortonc777ac52006-03-25 03:07:36 -0800157void set_pending_irq(unsigned int irq, cpumask_t mask);
158void move_native_irq(int irq);
Ashok Raj54d5d422005-09-06 15:16:15 -0700159
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 */
168static inline void move_irq(int irq)
169{
170}
171
172static inline void set_irq_info(int irq, cpumask_t mask)
173{
174}
175
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700176#else /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700177
178static inline void move_irq(int irq)
179{
180 move_native_irq(irq);
181}
182
183static inline void set_irq_info(int irq, cpumask_t mask)
184{
185 set_native_irq_info(irq, mask);
186}
Ashok Raj54d5d422005-09-06 15:16:15 -0700187
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700188#endif /* CONFIG_PCI_MSI */
Ashok Raj54d5d422005-09-06 15:16:15 -0700189
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700190#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
191
192static inline void move_irq(int irq)
193{
194}
195
196static inline void move_native_irq(int irq)
197{
198}
199
200static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
201{
202}
203
Ashok Raj54d5d422005-09-06 15:16:15 -0700204static inline void set_irq_info(int irq, cpumask_t mask)
205{
206 set_native_irq_info(irq, mask);
207}
208
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700209#endif /* CONFIG_GENERIC_PENDING_IRQ */
Ashok Raj54d5d422005-09-06 15:16:15 -0700210
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700211#else /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700212
213#define move_irq(x)
214#define move_native_irq(x)
215
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700216#endif /* CONFIG_SMP */
Ashok Raj54d5d422005-09-06 15:16:15 -0700217
Zhang Yanmin1b61b912006-06-23 02:04:22 -0700218#ifdef CONFIG_IRQBALANCE
219extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
220#else
221static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
222{
223}
224#endif
225
Ingo Molnar71d218b2006-06-29 02:24:41 -0700226#ifdef CONFIG_AUTO_IRQ_AFFINITY
227extern int select_smp_affinity(unsigned int irq);
228#else
229static inline int select_smp_affinity(unsigned int irq)
230{
231 return 1;
232}
233#endif
234
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235extern int no_irq_affinity;
236extern int noirqdebug_setup(char *str);
237
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700238extern 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700244
Ingo Molnar34ffdb72006-06-29 02:24:40 -0700245extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
Ingo Molnar2e60bbb2006-06-29 02:24:39 -0700246 int action_ret, struct pt_regs *regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247extern int can_request_irq(unsigned int irq, unsigned long irqflags);
248
Thomas Gleixnera4633adc2006-06-29 02:24:48 -0700249/* Resending of interrupts :*/
250void check_irq_resend(struct irq_desc *desc, unsigned int irq);
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252extern void init_irq_proc(void);
Ivan Kokshayskyeee45262006-01-06 00:12:21 -0800253
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700254#endif /* CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
256extern hw_irq_controller no_irq_type; /* needed in every arch ? */
257
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700258#endif /* !CONFIG_S390 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700260#endif /* _LINUX_IRQ_H */