Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_IRQ_H |
| 2 | #define _LINUX_IRQ_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Adrian Bunk | 23f9b31 | 2005-12-21 02:27:50 +0100 | [diff] [blame] | 12 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 14 | #ifndef CONFIG_S390 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #include <linux/linkage.h> |
| 17 | #include <linux/cache.h> |
| 18 | #include <linux/spinlock.h> |
| 19 | #include <linux/cpumask.h> |
Jan Beulich | 908dcec | 2006-06-23 02:06:00 -0700 | [diff] [blame] | 20 | #include <linux/irqreturn.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 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 Molnar | 0d7012a | 2006-06-29 02:24:43 -0700 | [diff] [blame] | 36 | #ifdef CONFIG_IRQ_PER_CPU |
Karsten Wiese | f26fdd5 | 2005-09-06 15:17:25 -0700 | [diff] [blame] | 37 | # 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Thomas Gleixner | 3418d72 | 2006-06-29 02:24:49 -0700 | [diff] [blame^] | 43 | #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ |
Ingo Molnar | 8fee5c3 | 2006-06-29 02:24:45 -0700 | [diff] [blame] | 44 | /** |
| 45 | * struct hw_interrupt_type - hardware interrupt type descriptor |
| 46 | * |
| 47 | * @name: name for /proc/interrupts |
| 48 | * @startup: start up the interrupt (defaults to ->enable if NULL) |
| 49 | * @shutdown: shut down the interrupt (defaults to ->disable if NULL) |
| 50 | * @enable: enable the interrupt (defaults to chip->unmask if NULL) |
| 51 | * @disable: disable the interrupt (defaults to chip->mask if NULL) |
| 52 | * @handle_irq: irq flow handler called from the arch IRQ glue code |
| 53 | * @ack: start of a new interrupt |
| 54 | * @mask: mask an interrupt source |
| 55 | * @mask_ack: ack and mask an interrupt source |
| 56 | * @unmask: unmask an interrupt source |
| 57 | * @hold: same interrupt while the handler is running |
| 58 | * @end: end of interrupt |
| 59 | * @set_affinity: set the CPU affinity on SMP machines |
| 60 | * @retrigger: resend an IRQ to the CPU |
| 61 | * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ |
| 62 | * @set_wake: enable/disable power-management wake-on of an IRQ |
| 63 | * |
| 64 | * @release: release function solely used by UML |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | */ |
| 66 | struct hw_interrupt_type { |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 67 | const char *typename; |
| 68 | unsigned int (*startup)(unsigned int irq); |
| 69 | void (*shutdown)(unsigned int irq); |
| 70 | void (*enable)(unsigned int irq); |
| 71 | void (*disable)(unsigned int irq); |
| 72 | void (*ack)(unsigned int irq); |
| 73 | void (*end)(unsigned int irq); |
| 74 | void (*set_affinity)(unsigned int irq, cpumask_t dest); |
Ingo Molnar | c0ad90a | 2006-06-29 02:24:44 -0700 | [diff] [blame] | 75 | int (*retrigger)(unsigned int irq); |
| 76 | |
Paolo 'Blaisorblade' Giarrusso | b77d6ad | 2005-06-21 17:16:24 -0700 | [diff] [blame] | 77 | /* Currently used only by UML, might disappear one day.*/ |
| 78 | #ifdef CONFIG_IRQ_RELEASE_METHOD |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 79 | void (*release)(unsigned int irq, void *dev_id); |
Paolo 'Blaisorblade' Giarrusso | b77d6ad | 2005-06-21 17:16:24 -0700 | [diff] [blame] | 80 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | typedef struct hw_interrupt_type hw_irq_controller; |
| 84 | |
Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame] | 85 | struct proc_dir_entry; |
| 86 | |
Ingo Molnar | 8fee5c3 | 2006-06-29 02:24:45 -0700 | [diff] [blame] | 87 | /** |
| 88 | * struct irq_desc - interrupt descriptor |
| 89 | * |
| 90 | * @handler: interrupt type dependent handler functions |
| 91 | * @handler_data: data for the type handlers |
| 92 | * @action: the irq action chain |
| 93 | * @status: status information |
| 94 | * @depth: disable-depth, for nested irq_disable() calls |
| 95 | * @irq_count: stats field to detect stalled irqs |
| 96 | * @irqs_unhandled: stats field for spurious unhandled interrupts |
| 97 | * @lock: locking for SMP |
| 98 | * @affinity: IRQ affinity on SMP |
| 99 | * @pending_mask: pending rebalanced interrupts |
| 100 | * @move_irq: need to re-target IRQ destination |
| 101 | * @dir: /proc/irq/ procfs entry |
| 102 | * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | * |
| 104 | * Pad this out to 32 bytes for cache and indexing reasons. |
| 105 | */ |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 106 | struct irq_desc { |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 107 | hw_irq_controller *chip; |
| 108 | void *chip_data; |
| 109 | struct irqaction *action; /* IRQ action list */ |
| 110 | unsigned int status; /* IRQ status */ |
| 111 | unsigned int depth; /* nested irq disables */ |
| 112 | unsigned int irq_count; /* For detecting broken IRQs */ |
| 113 | unsigned int irqs_unhandled; |
| 114 | spinlock_t lock; |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 115 | #ifdef CONFIG_SMP |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 116 | cpumask_t affinity; |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 117 | #endif |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 118 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
Ingo Molnar | cd916d3 | 2006-06-29 02:24:42 -0700 | [diff] [blame] | 119 | cpumask_t pending_mask; |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 120 | unsigned int move_irq; /* need to re-target IRQ dest */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 121 | #endif |
Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame] | 122 | #ifdef CONFIG_PROC_FS |
| 123 | struct proc_dir_entry *dir; |
| 124 | #endif |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 125 | } ____cacheline_aligned; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 127 | extern struct irq_desc irq_desc[NR_IRQS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 129 | /* |
| 130 | * Migration helpers for obsolete names, they will go away: |
| 131 | */ |
| 132 | typedef struct irq_desc irq_desc_t; |
| 133 | |
| 134 | /* |
| 135 | * Pick up the arch-dependent methods: |
| 136 | */ |
| 137 | #include <asm/hw_irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 139 | extern int setup_irq(unsigned int irq, struct irqaction *new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | #ifdef CONFIG_GENERIC_HARDIRQS |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 142 | |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 143 | #ifdef CONFIG_SMP |
| 144 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 145 | { |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 146 | irq_desc[irq].affinity = mask; |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 147 | } |
| 148 | #else |
| 149 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 150 | { |
| 151 | } |
| 152 | #endif |
| 153 | |
| 154 | #ifdef CONFIG_SMP |
| 155 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 156 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 157 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 158 | void set_pending_irq(unsigned int irq, cpumask_t mask); |
| 159 | void move_native_irq(int irq); |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 160 | |
| 161 | #ifdef CONFIG_PCI_MSI |
| 162 | /* |
| 163 | * Wonder why these are dummies? |
| 164 | * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq() |
| 165 | * counter part after translating the vector to irq info. We need to perform |
| 166 | * this operation on the real irq, when we dont use vector, i.e when |
| 167 | * pci_use_vector() is false. |
| 168 | */ |
| 169 | static inline void move_irq(int irq) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 174 | { |
| 175 | } |
| 176 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 177 | #else /* CONFIG_PCI_MSI */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 178 | |
| 179 | static inline void move_irq(int irq) |
| 180 | { |
| 181 | move_native_irq(irq); |
| 182 | } |
| 183 | |
| 184 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 185 | { |
| 186 | set_native_irq_info(irq, mask); |
| 187 | } |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 188 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 189 | #endif /* CONFIG_PCI_MSI */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 190 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 191 | #else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */ |
| 192 | |
| 193 | static inline void move_irq(int irq) |
| 194 | { |
| 195 | } |
| 196 | |
| 197 | static inline void move_native_irq(int irq) |
| 198 | { |
| 199 | } |
| 200 | |
| 201 | static inline void set_pending_irq(unsigned int irq, cpumask_t mask) |
| 202 | { |
| 203 | } |
| 204 | |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 205 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 206 | { |
| 207 | set_native_irq_info(irq, mask); |
| 208 | } |
| 209 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 210 | #endif /* CONFIG_GENERIC_PENDING_IRQ */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 211 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 212 | #else /* CONFIG_SMP */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 213 | |
| 214 | #define move_irq(x) |
| 215 | #define move_native_irq(x) |
| 216 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 217 | #endif /* CONFIG_SMP */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 218 | |
Zhang Yanmin | 1b61b91 | 2006-06-23 02:04:22 -0700 | [diff] [blame] | 219 | #ifdef CONFIG_IRQBALANCE |
| 220 | extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); |
| 221 | #else |
| 222 | static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) |
| 223 | { |
| 224 | } |
| 225 | #endif |
| 226 | |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 227 | #ifdef CONFIG_AUTO_IRQ_AFFINITY |
| 228 | extern int select_smp_affinity(unsigned int irq); |
| 229 | #else |
| 230 | static inline int select_smp_affinity(unsigned int irq) |
| 231 | { |
| 232 | return 1; |
| 233 | } |
| 234 | #endif |
| 235 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | extern int no_irq_affinity; |
| 237 | extern int noirqdebug_setup(char *str); |
| 238 | |
Ingo Molnar | 2e60bbb | 2006-06-29 02:24:39 -0700 | [diff] [blame] | 239 | extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, |
| 240 | struct irqaction *action); |
| 241 | /* |
| 242 | * Explicit fastcall, because i386 4KSTACKS calls it from assembly: |
| 243 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); |
Ingo Molnar | 2e60bbb | 2006-06-29 02:24:39 -0700 | [diff] [blame] | 245 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 246 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, |
Ingo Molnar | 2e60bbb | 2006-06-29 02:24:39 -0700 | [diff] [blame] | 247 | int action_ret, struct pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); |
| 249 | |
Thomas Gleixner | a4633adc | 2006-06-29 02:24:48 -0700 | [diff] [blame] | 250 | /* Resending of interrupts :*/ |
| 251 | void check_irq_resend(struct irq_desc *desc, unsigned int irq); |
| 252 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | extern void init_irq_proc(void); |
Ivan Kokshaysky | eee4526 | 2006-01-06 00:12:21 -0800 | [diff] [blame] | 254 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 255 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
| 257 | extern hw_irq_controller no_irq_type; /* needed in every arch ? */ |
| 258 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 259 | #endif /* !CONFIG_S390 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 261 | #endif /* _LINUX_IRQ_H */ |