5 * Please do not include this file in generic code. There is currently
6 * no requirement for any architecture to implement anything held
12 #include <linux/smp.h>
14 #ifndef CONFIG_GENERIC_HARDIRQS
15 # define nr_irqs NR_IRQS
17 # define for_each_irq_desc(irq, desc) \
18 for (irq = 0; irq < nr_irqs; irq++)
22 # define for_each_irq_desc(irq, desc) \
23 for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++)
28 #include <linux/linkage.h>
29 #include <linux/cache.h>
30 #include <linux/spinlock.h>
31 #include <linux/cpumask.h>
32 #include <linux/irqreturn.h>
33 #include <linux/errno.h>
36 #include <asm/ptrace.h>
37 #include <asm/irq_regs.h>
40 typedef void (*irq_flow_handler_t)(unsigned int irq,
41 struct irq_desc *desc);
47 * Bits 0-7 are reserved for the IRQF_* bits in linux/interrupt.h
51 #define IRQ_TYPE_NONE 0x00000000 /* Default, unspecified type */
52 #define IRQ_TYPE_EDGE_RISING 0x00000001 /* Edge rising type */
53 #define IRQ_TYPE_EDGE_FALLING 0x00000002 /* Edge falling type */
54 #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
55 #define IRQ_TYPE_LEVEL_HIGH 0x00000004 /* Level high type */
56 #define IRQ_TYPE_LEVEL_LOW 0x00000008 /* Level low type */
57 #define IRQ_TYPE_SENSE_MASK 0x0000000f /* Mask of the above */
58 #define IRQ_TYPE_PROBE 0x00000010 /* Probing in progress */
61 #define IRQ_INPROGRESS 0x00000100 /* IRQ handler active - do not enter! */
62 #define IRQ_DISABLED 0x00000200 /* IRQ disabled - do not enter! */
63 #define IRQ_PENDING 0x00000400 /* IRQ pending - replay on enable */
64 #define IRQ_REPLAY 0x00000800 /* IRQ has been replayed but not acked yet */
65 #define IRQ_AUTODETECT 0x00001000 /* IRQ is being autodetected */
66 #define IRQ_WAITING 0x00002000 /* IRQ not yet seen - for autodetection */
67 #define IRQ_LEVEL 0x00004000 /* IRQ level triggered */
68 #define IRQ_MASKED 0x00008000 /* IRQ masked - shouldn't be seen again */
69 #define IRQ_PER_CPU 0x00010000 /* IRQ is per CPU */
70 #define IRQ_NOPROBE 0x00020000 /* IRQ is not valid for probing */
71 #define IRQ_NOREQUEST 0x00040000 /* IRQ cannot be requested */
72 #define IRQ_NOAUTOEN 0x00080000 /* IRQ will not be enabled on request irq */
73 #define IRQ_WAKEUP 0x00100000 /* IRQ triggers system wakeup */
74 #define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */
75 #define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */
76 #define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */
77 #define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */
79 #ifdef CONFIG_IRQ_PER_CPU
80 # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
81 # define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
83 # define CHECK_IRQ_PER_CPU(var) 0
84 # define IRQ_NO_BALANCING_MASK IRQ_NO_BALANCING
87 struct proc_dir_entry;
91 * struct irq_chip - hardware interrupt chip descriptor
93 * @name: name for /proc/interrupts
94 * @startup: start up the interrupt (defaults to ->enable if NULL)
95 * @shutdown: shut down the interrupt (defaults to ->disable if NULL)
96 * @enable: enable the interrupt (defaults to chip->unmask if NULL)
97 * @disable: disable the interrupt (defaults to chip->mask if NULL)
98 * @ack: start of a new interrupt
99 * @mask: mask an interrupt source
100 * @mask_ack: ack and mask an interrupt source
101 * @unmask: unmask an interrupt source
102 * @eoi: end of interrupt - chip level
103 * @end: end of interrupt - flow level
104 * @set_affinity: set the CPU affinity on SMP machines
105 * @retrigger: resend an IRQ to the CPU
106 * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
107 * @set_wake: enable/disable power-management wake-on of an IRQ
109 * @release: release function solely used by UML
110 * @typename: obsoleted by name, kept as migration helper
114 unsigned int (*startup)(unsigned int irq);
115 void (*shutdown)(unsigned int irq);
116 void (*enable)(unsigned int irq);
117 void (*disable)(unsigned int irq);
119 void (*ack)(unsigned int irq);
120 void (*mask)(unsigned int irq);
121 void (*mask_ack)(unsigned int irq);
122 void (*unmask)(unsigned int irq);
123 void (*eoi)(unsigned int irq);
125 void (*end)(unsigned int irq);
126 void (*set_affinity)(unsigned int irq, cpumask_t dest);
127 int (*retrigger)(unsigned int irq);
128 int (*set_type)(unsigned int irq, unsigned int flow_type);
129 int (*set_wake)(unsigned int irq, unsigned int on);
131 /* Currently used only by UML, might disappear one day.*/
132 #ifdef CONFIG_IRQ_RELEASE_METHOD
133 void (*release)(unsigned int irq, void *dev_id);
136 * For compatibility, ->typename is copied into ->name.
139 const char *typename;
143 * struct irq_desc - interrupt descriptor
145 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
146 * @chip: low level interrupt hardware access
147 * @msi_desc: MSI descriptor
148 * @handler_data: per-IRQ data for the irq_chip methods
149 * @chip_data: platform-specific per-chip private data for the chip
150 * methods, to allow shared chip implementations
151 * @action: the irq action chain
152 * @status: status information
153 * @depth: disable-depth, for nested irq_disable() calls
154 * @wake_depth: enable depth, for multiple set_irq_wake() callers
155 * @irq_count: stats field to detect stalled irqs
156 * @irqs_unhandled: stats field for spurious unhandled interrupts
157 * @last_unhandled: aging timer for unhandled count
158 * @lock: locking for SMP
159 * @affinity: IRQ affinity on SMP
160 * @cpu: cpu index useful for balancing
161 * @pending_mask: pending rebalanced interrupts
162 * @dir: /proc/irq/ procfs entry
163 * @affinity_entry: /proc/irq/smp_affinity procfs entry on SMP
164 * @name: flow handler name for /proc/interrupts output
168 irq_flow_handler_t handle_irq;
169 struct irq_chip *chip;
170 struct msi_desc *msi_desc;
173 struct irqaction *action; /* IRQ action list */
174 unsigned int status; /* IRQ status */
176 unsigned int depth; /* nested irq disables */
177 unsigned int wake_depth; /* nested wake enables */
178 unsigned int irq_count; /* For detecting broken IRQs */
179 unsigned int irqs_unhandled;
180 unsigned long last_unhandled; /* Aging timer for unhandled count */
186 #ifdef CONFIG_GENERIC_PENDING_IRQ
187 cpumask_t pending_mask;
189 #ifdef CONFIG_PROC_FS
190 struct proc_dir_entry *dir;
193 } ____cacheline_internodealigned_in_smp;
196 extern struct irq_desc irq_desc[NR_IRQS];
198 static inline struct irq_desc *irq_to_desc(unsigned int irq)
200 return (irq < nr_irqs) ? irq_desc + irq : NULL;
204 * Migration helpers for obsolete names, they will go away:
206 #define hw_interrupt_type irq_chip
207 typedef struct irq_chip hw_irq_controller;
208 #define no_irq_type no_irq_chip
209 typedef struct irq_desc irq_desc_t;
212 * Pick up the arch-dependent methods:
214 #include <asm/hw_irq.h>
216 extern int setup_irq(unsigned int irq, struct irqaction *new);
218 #ifdef CONFIG_GENERIC_HARDIRQS
222 #ifdef CONFIG_GENERIC_PENDING_IRQ
224 void set_pending_irq(unsigned int irq, cpumask_t mask);
225 void move_native_irq(int irq);
226 void move_masked_irq(int irq);
228 #else /* CONFIG_GENERIC_PENDING_IRQ */
230 static inline void move_irq(int irq)
234 static inline void move_native_irq(int irq)
238 static inline void move_masked_irq(int irq)
242 static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
246 #endif /* CONFIG_GENERIC_PENDING_IRQ */
248 #else /* CONFIG_SMP */
250 #define move_native_irq(x)
251 #define move_masked_irq(x)
253 #endif /* CONFIG_SMP */
255 extern int no_irq_affinity;
257 static inline int irq_balancing_disabled(unsigned int irq)
259 struct irq_desc *desc;
261 desc = irq_to_desc(irq);
262 return desc->status & IRQ_NO_BALANCING_MASK;
265 /* Handle irq action chains: */
266 extern int handle_IRQ_event(unsigned int irq, struct irqaction *action);
269 * Built-in IRQ handlers for various IRQ types,
270 * callable via desc->chip->handle_irq()
272 extern void handle_level_irq(unsigned int irq, struct irq_desc *desc);
273 extern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc);
274 extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
275 extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
276 extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
277 extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
280 * Monolithic do_IRQ implementation.
282 #ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
283 extern unsigned int __do_IRQ(unsigned int irq);
287 * Architectures call this to let the generic IRQ layer
288 * handle an interrupt. If the descriptor is attached to an
289 * irqchip-style controller then we call the ->handle_irq() handler,
290 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
292 static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
294 #ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
295 desc->handle_irq(irq, desc);
297 if (likely(desc->handle_irq))
298 desc->handle_irq(irq, desc);
304 static inline void generic_handle_irq(unsigned int irq)
306 generic_handle_irq_desc(irq, irq_to_desc(irq));
309 /* Handling of unhandled and spurious interrupts: */
310 extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
313 /* Resending of interrupts :*/
314 void check_irq_resend(struct irq_desc *desc, unsigned int irq);
316 /* Enable/disable irq debugging output: */
317 extern int noirqdebug_setup(char *str);
319 /* Checks whether the interrupt can be requested by request_irq(): */
320 extern int can_request_irq(unsigned int irq, unsigned long irqflags);
322 /* Dummy irq-chip implementations: */
323 extern struct irq_chip no_irq_chip;
324 extern struct irq_chip dummy_irq_chip;
327 set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
328 irq_flow_handler_t handle);
330 set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
331 irq_flow_handler_t handle, const char *name);
334 __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
337 /* caller has locked the irq_desc and both params are valid */
338 static inline void __set_irq_handler_unlocked(int irq,
339 irq_flow_handler_t handler)
341 struct irq_desc *desc;
343 desc = irq_to_desc(irq);
344 desc->handle_irq = handler;
348 * Set a highlevel flow handler for a given IRQ:
351 set_irq_handler(unsigned int irq, irq_flow_handler_t handle)
353 __set_irq_handler(irq, handle, 0, NULL);
357 * Set a highlevel chained flow handler for a given IRQ.
358 * (a chained handler is automatically enabled and set to
359 * IRQ_NOREQUEST and IRQ_NOPROBE)
362 set_irq_chained_handler(unsigned int irq,
363 irq_flow_handler_t handle)
365 __set_irq_handler(irq, handle, 1, NULL);
368 extern void set_irq_noprobe(unsigned int irq);
369 extern void set_irq_probe(unsigned int irq);
371 /* Handle dynamic irq creation and destruction */
372 extern unsigned int create_irq_nr(unsigned int irq_want);
373 extern int create_irq(void);
374 extern void destroy_irq(unsigned int irq);
376 /* Test to see if a driver has successfully requested an irq */
377 static inline int irq_has_action(unsigned int irq)
379 struct irq_desc *desc = irq_to_desc(irq);
380 return desc->action != NULL;
383 /* Dynamic irq helper functions */
384 extern void dynamic_irq_init(unsigned int irq);
385 extern void dynamic_irq_cleanup(unsigned int irq);
387 /* Set/get chip/data for an IRQ: */
388 extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
389 extern int set_irq_data(unsigned int irq, void *data);
390 extern int set_irq_chip_data(unsigned int irq, void *data);
391 extern int set_irq_type(unsigned int irq, unsigned int type);
392 extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
394 #define get_irq_chip(irq) (irq_to_desc(irq)->chip)
395 #define get_irq_chip_data(irq) (irq_to_desc(irq)->chip_data)
396 #define get_irq_data(irq) (irq_to_desc(irq)->handler_data)
397 #define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc)
399 #endif /* CONFIG_GENERIC_HARDIRQS */
401 #endif /* !CONFIG_S390 */
403 #endif /* _LINUX_IRQ_H */