diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2006-06-29 05:24:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-29 13:26:24 -0400 |
commit | 6a6de9ef5850d063c3d3fb50784bfe3a6d0712c6 (patch) | |
tree | d09f1887fd8890c820559b931140afe4c68f2d7f /include/linux/irq.h | |
parent | a34db9b28a1c63317e1d6f1080a12d711579e7d0 (diff) |
[PATCH] genirq: core
Core genirq support: add the irq-chip and irq-flow abstractions.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/irq.h')
-rw-r--r-- | include/linux/irq.h | 160 |
1 files changed, 141 insertions, 19 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index 14d7e94048dd..437f2c635db6 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -43,20 +43,36 @@ | |||
43 | #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ | 43 | #define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ |
44 | #define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ | 44 | #define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ |
45 | #define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ | 45 | #define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ |
46 | #define IRQ_DELAYED_DISABLE \ | ||
47 | 4096 /* IRQ disable (masking) happens delayed. */ | ||
48 | |||
49 | /* | ||
50 | * IRQ types, see also include/linux/interrupt.h | ||
51 | */ | ||
52 | #define IRQ_TYPE_NONE 0x0000 /* Default, unspecified type */ | ||
53 | #define IRQ_TYPE_EDGE_RISING 0x0001 /* Edge rising type */ | ||
54 | #define IRQ_TYPE_EDGE_FALLING 0x0002 /* Edge falling type */ | ||
55 | #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) | ||
56 | #define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */ | ||
57 | #define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */ | ||
58 | #define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */ | ||
59 | #define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */ | ||
60 | #define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */ | ||
61 | |||
62 | struct proc_dir_entry; | ||
63 | |||
46 | /** | 64 | /** |
47 | * struct hw_interrupt_type - hardware interrupt type descriptor | 65 | * struct irq_chip - hardware interrupt chip descriptor |
48 | * | 66 | * |
49 | * @name: name for /proc/interrupts | 67 | * @name: name for /proc/interrupts |
50 | * @startup: start up the interrupt (defaults to ->enable if NULL) | 68 | * @startup: start up the interrupt (defaults to ->enable if NULL) |
51 | * @shutdown: shut down the interrupt (defaults to ->disable if NULL) | 69 | * @shutdown: shut down the interrupt (defaults to ->disable if NULL) |
52 | * @enable: enable the interrupt (defaults to chip->unmask if NULL) | 70 | * @enable: enable the interrupt (defaults to chip->unmask if NULL) |
53 | * @disable: disable the interrupt (defaults to chip->mask if NULL) | 71 | * @disable: disable the interrupt (defaults to chip->mask if NULL) |
54 | * @handle_irq: irq flow handler called from the arch IRQ glue code | ||
55 | * @ack: start of a new interrupt | 72 | * @ack: start of a new interrupt |
56 | * @mask: mask an interrupt source | 73 | * @mask: mask an interrupt source |
57 | * @mask_ack: ack and mask an interrupt source | 74 | * @mask_ack: ack and mask an interrupt source |
58 | * @unmask: unmask an interrupt source | 75 | * @unmask: unmask an interrupt source |
59 | * @hold: same interrupt while the handler is running | ||
60 | * @end: end of interrupt | 76 | * @end: end of interrupt |
61 | * @set_affinity: set the CPU affinity on SMP machines | 77 | * @set_affinity: set the CPU affinity on SMP machines |
62 | * @retrigger: resend an IRQ to the CPU | 78 | * @retrigger: resend an IRQ to the CPU |
@@ -64,33 +80,45 @@ | |||
64 | * @set_wake: enable/disable power-management wake-on of an IRQ | 80 | * @set_wake: enable/disable power-management wake-on of an IRQ |
65 | * | 81 | * |
66 | * @release: release function solely used by UML | 82 | * @release: release function solely used by UML |
83 | * @typename: obsoleted by name, kept as migration helper | ||
67 | */ | 84 | */ |
68 | struct hw_interrupt_type { | 85 | struct irq_chip { |
69 | const char *typename; | 86 | const char *name; |
70 | unsigned int (*startup)(unsigned int irq); | 87 | unsigned int (*startup)(unsigned int irq); |
71 | void (*shutdown)(unsigned int irq); | 88 | void (*shutdown)(unsigned int irq); |
72 | void (*enable)(unsigned int irq); | 89 | void (*enable)(unsigned int irq); |
73 | void (*disable)(unsigned int irq); | 90 | void (*disable)(unsigned int irq); |
91 | |||
74 | void (*ack)(unsigned int irq); | 92 | void (*ack)(unsigned int irq); |
93 | void (*mask)(unsigned int irq); | ||
94 | void (*mask_ack)(unsigned int irq); | ||
95 | void (*unmask)(unsigned int irq); | ||
96 | |||
75 | void (*end)(unsigned int irq); | 97 | void (*end)(unsigned int irq); |
76 | void (*set_affinity)(unsigned int irq, cpumask_t dest); | 98 | void (*set_affinity)(unsigned int irq, cpumask_t dest); |
77 | int (*retrigger)(unsigned int irq); | 99 | int (*retrigger)(unsigned int irq); |
100 | int (*set_type)(unsigned int irq, unsigned int flow_type); | ||
101 | int (*set_wake)(unsigned int irq, unsigned int on); | ||
78 | 102 | ||
79 | /* Currently used only by UML, might disappear one day.*/ | 103 | /* Currently used only by UML, might disappear one day.*/ |
80 | #ifdef CONFIG_IRQ_RELEASE_METHOD | 104 | #ifdef CONFIG_IRQ_RELEASE_METHOD |
81 | void (*release)(unsigned int irq, void *dev_id); | 105 | void (*release)(unsigned int irq, void *dev_id); |
82 | #endif | 106 | #endif |
107 | /* | ||
108 | * For compatibility, ->typename is copied into ->name. | ||
109 | * Will disappear. | ||
110 | */ | ||
111 | const char *typename; | ||
83 | }; | 112 | }; |
84 | 113 | ||
85 | typedef struct hw_interrupt_type hw_irq_controller; | ||
86 | |||
87 | struct proc_dir_entry; | ||
88 | |||
89 | /** | 114 | /** |
90 | * struct irq_desc - interrupt descriptor | 115 | * struct irq_desc - interrupt descriptor |
91 | * | 116 | * |
92 | * @handler: interrupt type dependent handler functions | 117 | * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()] |
93 | * @handler_data: data for the type handlers | 118 | * @chip: low level interrupt hardware access |
119 | * @handler_data: per-IRQ data for the irq_chip methods | ||
120 | * @chip_data: platform-specific per-chip private data for the chip | ||
121 | * methods, to allow shared chip implementations | ||
94 | * @action: the irq action chain | 122 | * @action: the irq action chain |
95 | * @status: status information | 123 | * @status: status information |
96 | * @depth: disable-depth, for nested irq_disable() calls | 124 | * @depth: disable-depth, for nested irq_disable() calls |
@@ -98,6 +126,7 @@ struct proc_dir_entry; | |||
98 | * @irqs_unhandled: stats field for spurious unhandled interrupts | 126 | * @irqs_unhandled: stats field for spurious unhandled interrupts |
99 | * @lock: locking for SMP | 127 | * @lock: locking for SMP |
100 | * @affinity: IRQ affinity on SMP | 128 | * @affinity: IRQ affinity on SMP |
129 | * @cpu: cpu index useful for balancing | ||
101 | * @pending_mask: pending rebalanced interrupts | 130 | * @pending_mask: pending rebalanced interrupts |
102 | * @move_irq: need to re-target IRQ destination | 131 | * @move_irq: need to re-target IRQ destination |
103 | * @dir: /proc/irq/ procfs entry | 132 | * @dir: /proc/irq/ procfs entry |
@@ -106,16 +135,22 @@ struct proc_dir_entry; | |||
106 | * Pad this out to 32 bytes for cache and indexing reasons. | 135 | * Pad this out to 32 bytes for cache and indexing reasons. |
107 | */ | 136 | */ |
108 | struct irq_desc { | 137 | struct irq_desc { |
109 | hw_irq_controller *chip; | 138 | void fastcall (*handle_irq)(unsigned int irq, |
139 | struct irq_desc *desc, | ||
140 | struct pt_regs *regs); | ||
141 | struct irq_chip *chip; | ||
142 | void *handler_data; | ||
110 | void *chip_data; | 143 | void *chip_data; |
111 | struct irqaction *action; /* IRQ action list */ | 144 | struct irqaction *action; /* IRQ action list */ |
112 | unsigned int status; /* IRQ status */ | 145 | unsigned int status; /* IRQ status */ |
146 | |||
113 | unsigned int depth; /* nested irq disables */ | 147 | unsigned int depth; /* nested irq disables */ |
114 | unsigned int irq_count; /* For detecting broken IRQs */ | 148 | unsigned int irq_count; /* For detecting broken IRQs */ |
115 | unsigned int irqs_unhandled; | 149 | unsigned int irqs_unhandled; |
116 | spinlock_t lock; | 150 | spinlock_t lock; |
117 | #ifdef CONFIG_SMP | 151 | #ifdef CONFIG_SMP |
118 | cpumask_t affinity; | 152 | cpumask_t affinity; |
153 | unsigned int cpu; | ||
119 | #endif | 154 | #endif |
120 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) | 155 | #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) |
121 | cpumask_t pending_mask; | 156 | cpumask_t pending_mask; |
@@ -131,6 +166,9 @@ extern struct irq_desc irq_desc[NR_IRQS]; | |||
131 | /* | 166 | /* |
132 | * Migration helpers for obsolete names, they will go away: | 167 | * Migration helpers for obsolete names, they will go away: |
133 | */ | 168 | */ |
169 | #define hw_interrupt_type irq_chip | ||
170 | typedef struct irq_chip hw_irq_controller; | ||
171 | #define no_irq_type no_irq_chip | ||
134 | typedef struct irq_desc irq_desc_t; | 172 | typedef struct irq_desc irq_desc_t; |
135 | 173 | ||
136 | /* | 174 | /* |
@@ -138,6 +176,17 @@ typedef struct irq_desc irq_desc_t; | |||
138 | */ | 176 | */ |
139 | #include <asm/hw_irq.h> | 177 | #include <asm/hw_irq.h> |
140 | 178 | ||
179 | /* | ||
180 | * Architectures call this to let the generic IRQ layer | ||
181 | * handle an interrupt: | ||
182 | */ | ||
183 | static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs) | ||
184 | { | ||
185 | struct irq_desc *desc = irq_desc + irq; | ||
186 | |||
187 | desc->handle_irq(irq, desc, regs); | ||
188 | } | ||
189 | |||
141 | extern int setup_irq(unsigned int irq, struct irqaction *new); | 190 | extern int setup_irq(unsigned int irq, struct irqaction *new); |
142 | 191 | ||
143 | #ifdef CONFIG_GENERIC_HARDIRQS | 192 | #ifdef CONFIG_GENERIC_HARDIRQS |
@@ -236,27 +285,100 @@ static inline int select_smp_affinity(unsigned int irq) | |||
236 | #endif | 285 | #endif |
237 | 286 | ||
238 | extern int no_irq_affinity; | 287 | extern int no_irq_affinity; |
239 | extern int noirqdebug_setup(char *str); | ||
240 | 288 | ||
241 | extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, | 289 | /* Handle irq action chains: */ |
242 | struct irqaction *action); | 290 | extern int handle_IRQ_event(unsigned int irq, struct pt_regs *regs, |
291 | struct irqaction *action); | ||
292 | |||
293 | /* | ||
294 | * Built-in IRQ handlers for various IRQ types, | ||
295 | * callable via desc->chip->handle_irq() | ||
296 | */ | ||
297 | extern void fastcall | ||
298 | handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); | ||
299 | extern void fastcall | ||
300 | handle_fastack_irq(unsigned int irq, struct irq_desc *desc, | ||
301 | struct pt_regs *regs); | ||
302 | extern void fastcall | ||
303 | handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); | ||
304 | extern void fastcall | ||
305 | handle_simple_irq(unsigned int irq, struct irq_desc *desc, | ||
306 | struct pt_regs *regs); | ||
307 | extern void fastcall | ||
308 | handle_percpu_irq(unsigned int irq, struct irq_desc *desc, | ||
309 | struct pt_regs *regs); | ||
310 | extern void fastcall | ||
311 | handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs); | ||
312 | |||
313 | /* | ||
314 | * Get a descriptive string for the highlevel handler, for | ||
315 | * /proc/interrupts output: | ||
316 | */ | ||
317 | extern const char * | ||
318 | handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *, | ||
319 | struct pt_regs *)); | ||
320 | |||
243 | /* | 321 | /* |
244 | * Explicit fastcall, because i386 4KSTACKS calls it from assembly: | 322 | * Monolithic do_IRQ implementation. |
323 | * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly) | ||
245 | */ | 324 | */ |
246 | extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); | 325 | extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); |
247 | 326 | ||
327 | /* Handling of unhandled and spurious interrupts: */ | ||
248 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, | 328 | extern void note_interrupt(unsigned int irq, struct irq_desc *desc, |
249 | int action_ret, struct pt_regs *regs); | 329 | int action_ret, struct pt_regs *regs); |
250 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); | ||
251 | 330 | ||
252 | /* Resending of interrupts :*/ | 331 | /* Resending of interrupts :*/ |
253 | void check_irq_resend(struct irq_desc *desc, unsigned int irq); | 332 | void check_irq_resend(struct irq_desc *desc, unsigned int irq); |
254 | 333 | ||
334 | /* Initialize /proc/irq/ */ | ||
255 | extern void init_irq_proc(void); | 335 | extern void init_irq_proc(void); |
256 | 336 | ||
257 | #endif /* CONFIG_GENERIC_HARDIRQS */ | 337 | /* Enable/disable irq debugging output: */ |
338 | extern int noirqdebug_setup(char *str); | ||
339 | |||
340 | /* Checks whether the interrupt can be requested by request_irq(): */ | ||
341 | extern int can_request_irq(unsigned int irq, unsigned long irqflags); | ||
342 | |||
343 | /* Dummy irq-chip implementation: */ | ||
344 | extern struct irq_chip no_irq_chip; | ||
345 | |||
346 | extern void | ||
347 | set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, | ||
348 | void fastcall (*handle)(unsigned int, | ||
349 | struct irq_desc *, | ||
350 | struct pt_regs *)); | ||
351 | extern void | ||
352 | __set_irq_handler(unsigned int irq, | ||
353 | void fastcall (*handle)(unsigned int, struct irq_desc *, | ||
354 | struct pt_regs *), | ||
355 | int is_chained); | ||
258 | 356 | ||
259 | extern hw_irq_controller no_irq_type; /* needed in every arch ? */ | 357 | /* |
358 | * Set a highlevel flow handler for a given IRQ: | ||
359 | */ | ||
360 | static inline void | ||
361 | set_irq_handler(unsigned int irq, | ||
362 | void fastcall (*handle)(unsigned int, struct irq_desc *, | ||
363 | struct pt_regs *)) | ||
364 | { | ||
365 | __set_irq_handler(irq, handle, 0); | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * Set a highlevel chained flow handler for a given IRQ. | ||
370 | * (a chained handler is automatically enabled and set to | ||
371 | * IRQ_NOREQUEST and IRQ_NOPROBE) | ||
372 | */ | ||
373 | static inline void | ||
374 | set_irq_chained_handler(unsigned int irq, | ||
375 | void fastcall (*handle)(unsigned int, struct irq_desc *, | ||
376 | struct pt_regs *)) | ||
377 | { | ||
378 | __set_irq_handler(irq, handle, 1); | ||
379 | } | ||
380 | |||
381 | #endif /* CONFIG_GENERIC_HARDIRQS */ | ||
260 | 382 | ||
261 | #endif /* !CONFIG_S390 */ | 383 | #endif /* !CONFIG_S390 */ |
262 | 384 | ||