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 | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 36 | #ifdef ARCH_HAS_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 | |
| 43 | /* |
| 44 | * Interrupt controller descriptor. This is all we need |
| 45 | * to describe about the low-level hardware. |
| 46 | */ |
| 47 | struct hw_interrupt_type { |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 48 | 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); |
Paolo 'Blaisorblade' Giarrusso | b77d6ad | 2005-06-21 17:16:24 -0700 | [diff] [blame] | 56 | /* Currently used only by UML, might disappear one day.*/ |
| 57 | #ifdef CONFIG_IRQ_RELEASE_METHOD |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 58 | void (*release)(unsigned int irq, void *dev_id); |
Paolo 'Blaisorblade' Giarrusso | b77d6ad | 2005-06-21 17:16:24 -0700 | [diff] [blame] | 59 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | typedef struct hw_interrupt_type hw_irq_controller; |
| 63 | |
Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame^] | 64 | struct proc_dir_entry; |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* |
| 67 | * This is the "IRQ descriptor", which contains various information |
| 68 | * about the irq, including what kind of hardware handling it has, |
| 69 | * whether it is disabled etc etc. |
| 70 | * |
| 71 | * Pad this out to 32 bytes for cache and indexing reasons. |
| 72 | */ |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 73 | struct irq_desc { |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 74 | hw_irq_controller *chip; |
| 75 | void *chip_data; |
| 76 | struct irqaction *action; /* IRQ action list */ |
| 77 | unsigned int status; /* IRQ status */ |
| 78 | unsigned int depth; /* nested irq disables */ |
| 79 | unsigned int irq_count; /* For detecting broken IRQs */ |
| 80 | unsigned int irqs_unhandled; |
| 81 | spinlock_t lock; |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 82 | #ifdef CONFIG_SMP |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 83 | cpumask_t affinity; |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 84 | #endif |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 85 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 86 | unsigned int move_irq; /* need to re-target IRQ dest */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 87 | #endif |
Ingo Molnar | 4a733ee | 2006-06-29 02:24:42 -0700 | [diff] [blame^] | 88 | #ifdef CONFIG_PROC_FS |
| 89 | struct proc_dir_entry *dir; |
| 90 | #endif |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 91 | } ____cacheline_aligned; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 93 | extern struct irq_desc irq_desc[NR_IRQS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 95 | /* |
| 96 | * Migration helpers for obsolete names, they will go away: |
| 97 | */ |
| 98 | typedef struct irq_desc irq_desc_t; |
| 99 | |
| 100 | /* |
| 101 | * Pick up the arch-dependent methods: |
| 102 | */ |
| 103 | #include <asm/hw_irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 105 | extern int setup_irq(unsigned int irq, struct irqaction *new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
| 107 | #ifdef CONFIG_GENERIC_HARDIRQS |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 108 | |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 109 | #ifdef CONFIG_SMP |
| 110 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 111 | { |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 112 | irq_desc[irq].affinity = mask; |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 113 | } |
| 114 | #else |
| 115 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 116 | { |
| 117 | } |
| 118 | #endif |
| 119 | |
| 120 | #ifdef CONFIG_SMP |
| 121 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 122 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 123 | extern cpumask_t pending_irq_cpumask[NR_IRQS]; |
| 124 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 125 | void set_pending_irq(unsigned int irq, cpumask_t mask); |
| 126 | void move_native_irq(int irq); |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 127 | |
| 128 | #ifdef CONFIG_PCI_MSI |
| 129 | /* |
| 130 | * Wonder why these are dummies? |
| 131 | * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq() |
| 132 | * counter part after translating the vector to irq info. We need to perform |
| 133 | * this operation on the real irq, when we dont use vector, i.e when |
| 134 | * pci_use_vector() is false. |
| 135 | */ |
| 136 | static inline void move_irq(int irq) |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 141 | { |
| 142 | } |
| 143 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 144 | #else /* CONFIG_PCI_MSI */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 145 | |
| 146 | static inline void move_irq(int irq) |
| 147 | { |
| 148 | move_native_irq(irq); |
| 149 | } |
| 150 | |
| 151 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 152 | { |
| 153 | set_native_irq_info(irq, mask); |
| 154 | } |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 155 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 156 | #endif /* CONFIG_PCI_MSI */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 157 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 158 | #else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */ |
| 159 | |
| 160 | static inline void move_irq(int irq) |
| 161 | { |
| 162 | } |
| 163 | |
| 164 | static inline void move_native_irq(int irq) |
| 165 | { |
| 166 | } |
| 167 | |
| 168 | static inline void set_pending_irq(unsigned int irq, cpumask_t mask) |
| 169 | { |
| 170 | } |
| 171 | |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 172 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 173 | { |
| 174 | set_native_irq_info(irq, mask); |
| 175 | } |
| 176 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 177 | #endif /* CONFIG_GENERIC_PENDING_IRQ */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 178 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 179 | #else /* CONFIG_SMP */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 180 | |
| 181 | #define move_irq(x) |
| 182 | #define move_native_irq(x) |
| 183 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 184 | #endif /* CONFIG_SMP */ |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 185 | |
Zhang Yanmin | 1b61b91 | 2006-06-23 02:04:22 -0700 | [diff] [blame] | 186 | #ifdef CONFIG_IRQBALANCE |
| 187 | extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); |
| 188 | #else |
| 189 | static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) |
| 190 | { |
| 191 | } |
| 192 | #endif |
| 193 | |
Ingo Molnar | 71d218b | 2006-06-29 02:24:41 -0700 | [diff] [blame] | 194 | #ifdef CONFIG_AUTO_IRQ_AFFINITY |
| 195 | extern int select_smp_affinity(unsigned int irq); |
| 196 | #else |
| 197 | static inline int select_smp_affinity(unsigned int irq) |
| 198 | { |
| 199 | return 1; |
| 200 | } |
| 201 | #endif |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | extern int no_irq_affinity; |
| 204 | extern int noirqdebug_setup(char *str); |
| 205 | |
Ingo Molnar | 2e60bbb | 2006-06-29 02:24:39 -0700 | [diff] [blame] | 206 | extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, |
| 207 | struct irqaction *action); |
| 208 | /* |
| 209 | * Explicit fastcall, because i386 4KSTACKS calls it from assembly: |
| 210 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | 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] | 212 | |
Ingo Molnar | 34ffdb7 | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 213 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, |
Ingo Molnar | 2e60bbb | 2006-06-29 02:24:39 -0700 | [diff] [blame] | 214 | int action_ret, struct pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); |
| 216 | |
| 217 | extern void init_irq_proc(void); |
Ivan Kokshaysky | eee4526 | 2006-01-06 00:12:21 -0800 | [diff] [blame] | 218 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 219 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | extern hw_irq_controller no_irq_type; /* needed in every arch ? */ |
| 222 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 223 | #endif /* !CONFIG_S390 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Ingo Molnar | 06fcb0c | 2006-06-29 02:24:40 -0700 | [diff] [blame] | 225 | #endif /* _LINUX_IRQ_H */ |