Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
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 | |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 14 | #if !defined(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 */ |
Karsten Wiese | f26fdd5 | 2005-09-06 15:17:25 -0700 | [diff] [blame] | 36 | #if defined(ARCH_HAS_IRQ_PER_CPU) |
| 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 { |
| 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 |
Paolo 'Blaisorblade' Giarrusso | dbce706 | 2005-06-21 17:16:19 -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 | |
| 64 | /* |
| 65 | * This is the "IRQ descriptor", which contains various information |
| 66 | * about the irq, including what kind of hardware handling it has, |
| 67 | * whether it is disabled etc etc. |
| 68 | * |
| 69 | * Pad this out to 32 bytes for cache and indexing reasons. |
| 70 | */ |
| 71 | typedef struct irq_desc { |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 72 | hw_irq_controller *chip; |
| 73 | void *chip_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | struct irqaction *action; /* IRQ action list */ |
| 75 | unsigned int status; /* IRQ status */ |
| 76 | unsigned int depth; /* nested irq disables */ |
| 77 | unsigned int irq_count; /* For detecting broken interrupts */ |
| 78 | unsigned int irqs_unhandled; |
| 79 | spinlock_t lock; |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame^] | 80 | #ifdef CONFIG_SMP |
| 81 | cpumask_t affinity; |
| 82 | #endif |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 83 | #if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) |
| 84 | unsigned int move_irq; /* Flag need to re-target intr dest*/ |
| 85 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } ____cacheline_aligned irq_desc_t; |
| 87 | |
| 88 | extern irq_desc_t irq_desc [NR_IRQS]; |
| 89 | |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 90 | /* Return a pointer to the irq descriptor for IRQ. */ |
| 91 | static inline irq_desc_t * |
| 92 | irq_descp (int irq) |
| 93 | { |
| 94 | return irq_desc + irq; |
| 95 | } |
| 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | #include <asm/hw_irq.h> /* the arch dependent stuff */ |
| 98 | |
| 99 | extern int setup_irq(unsigned int irq, struct irqaction * new); |
| 100 | |
| 101 | #ifdef CONFIG_GENERIC_HARDIRQS |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 102 | #ifdef CONFIG_SMP |
| 103 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 104 | { |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame^] | 105 | irq_desc[irq].affinity = mask; |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 106 | } |
| 107 | #else |
| 108 | static inline void set_native_irq_info(int irq, cpumask_t mask) |
| 109 | { |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | #ifdef CONFIG_SMP |
| 114 | |
| 115 | #if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE) |
| 116 | extern cpumask_t pending_irq_cpumask[NR_IRQS]; |
| 117 | |
Andrew Morton | c777ac5 | 2006-03-25 03:07:36 -0800 | [diff] [blame] | 118 | void set_pending_irq(unsigned int irq, cpumask_t mask); |
| 119 | void move_native_irq(int irq); |
Ashok Raj | 54d5d42 | 2005-09-06 15:16:15 -0700 | [diff] [blame] | 120 | |
| 121 | #ifdef CONFIG_PCI_MSI |
| 122 | /* |
| 123 | * Wonder why these are dummies? |
| 124 | * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq() |
| 125 | * counter part after translating the vector to irq info. We need to perform |
| 126 | * this operation on the real irq, when we dont use vector, i.e when |
| 127 | * pci_use_vector() is false. |
| 128 | */ |
| 129 | static inline void move_irq(int irq) |
| 130 | { |
| 131 | } |
| 132 | |
| 133 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 134 | { |
| 135 | } |
| 136 | |
| 137 | #else // CONFIG_PCI_MSI |
| 138 | |
| 139 | static inline void move_irq(int irq) |
| 140 | { |
| 141 | move_native_irq(irq); |
| 142 | } |
| 143 | |
| 144 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 145 | { |
| 146 | set_native_irq_info(irq, mask); |
| 147 | } |
| 148 | #endif // CONFIG_PCI_MSI |
| 149 | |
| 150 | #else // CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE |
| 151 | |
| 152 | #define move_irq(x) |
| 153 | #define move_native_irq(x) |
| 154 | #define set_pending_irq(x,y) |
| 155 | static inline void set_irq_info(int irq, cpumask_t mask) |
| 156 | { |
| 157 | set_native_irq_info(irq, mask); |
| 158 | } |
| 159 | |
| 160 | #endif // CONFIG_GENERIC_PENDING_IRQ |
| 161 | |
| 162 | #else // CONFIG_SMP |
| 163 | |
| 164 | #define move_irq(x) |
| 165 | #define move_native_irq(x) |
| 166 | |
| 167 | #endif // CONFIG_SMP |
| 168 | |
Zhang Yanmin | 1b61b91 | 2006-06-23 02:04:22 -0700 | [diff] [blame] | 169 | #ifdef CONFIG_IRQBALANCE |
| 170 | extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask); |
| 171 | #else |
| 172 | static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask) |
| 173 | { |
| 174 | } |
| 175 | #endif |
| 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | extern int no_irq_affinity; |
| 178 | extern int noirqdebug_setup(char *str); |
| 179 | |
Jan Beulich | 908dcec | 2006-06-23 02:06:00 -0700 | [diff] [blame] | 180 | extern fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, |
Alan Cox | 200803d | 2005-06-28 20:45:18 -0700 | [diff] [blame] | 181 | struct irqaction *action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); |
Alan Cox | 200803d | 2005-06-28 20:45:18 -0700 | [diff] [blame] | 183 | extern void note_interrupt(unsigned int irq, irq_desc_t *desc, |
| 184 | int action_ret, struct pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); |
| 186 | |
| 187 | extern void init_irq_proc(void); |
Ivan Kokshaysky | eee4526 | 2006-01-06 00:12:21 -0800 | [diff] [blame] | 188 | |
| 189 | #ifdef CONFIG_AUTO_IRQ_AFFINITY |
| 190 | extern int select_smp_affinity(unsigned int irq); |
| 191 | #else |
| 192 | static inline int |
| 193 | select_smp_affinity(unsigned int irq) |
| 194 | { |
| 195 | return 1; |
| 196 | } |
| 197 | #endif |
| 198 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | #endif |
| 200 | |
| 201 | extern hw_irq_controller no_irq_type; /* needed in every arch ? */ |
| 202 | |
| 203 | #endif |
| 204 | |
| 205 | #endif /* __irq_h */ |