Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifdef __KERNEL__ |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 2 | #ifndef _ASM_POWERPC_IRQ_H |
| 3 | #define _ASM_POWERPC_IRQ_H |
| 4 | |
| 5 | /* |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 12 | #include <linux/irqdomain.h> |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 13 | #include <linux/threads.h> |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 14 | #include <linux/list.h> |
| 15 | #include <linux/radix-tree.h> |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 16 | |
| 17 | #include <asm/types.h> |
Arun Sharma | 6006349 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 18 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 20 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 21 | /* Define a way to iterate across irqs. */ |
| 22 | #define for_each_irq(i) \ |
| 23 | for ((i) = 0; (i) < NR_IRQS; ++(i)) |
| 24 | |
| 25 | extern atomic_t ppc_n_lost_interrupts; |
| 26 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 27 | /* This number is used when no interrupt has been assigned */ |
| 28 | #define NO_IRQ (0) |
| 29 | |
| 30 | /* This is a special irq number to return from get_irq() to tell that |
| 31 | * no interrupt happened _and_ ignore it (don't count it as bad). Some |
| 32 | * platforms like iSeries rely on that. |
| 33 | */ |
| 34 | #define NO_IRQ_IGNORE ((unsigned int)-1) |
| 35 | |
Michael Ellerman | 551b81f | 2009-10-13 19:44:44 +0000 | [diff] [blame] | 36 | /* Total number of virq in the platform */ |
| 37 | #define NR_IRQS CONFIG_NR_IRQS |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 38 | |
| 39 | /* Number of irqs reserved for the legacy controller */ |
| 40 | #define NUM_ISA_INTERRUPTS 16 |
| 41 | |
Michael Ellerman | cd01570 | 2009-10-13 19:45:03 +0000 | [diff] [blame] | 42 | /* Same thing, used by the generic IRQ code */ |
| 43 | #define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS |
| 44 | |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 45 | /* |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 46 | * The host code and data structures are fairly agnostic to the fact that |
| 47 | * we use an open firmware device-tree. We do have references to struct |
| 48 | * device_node in two places: in irq_find_host() to find the host matching |
| 49 | * a given interrupt controller node, and of course as an argument to its |
| 50 | * counterpart host->ops->match() callback. However, those are treated as |
| 51 | * generic pointers by the core and the fact that it's actually a device-node |
| 52 | * pointer is purely a convention between callers and implementation. This |
| 53 | * code could thus be used on other architectures by replacing those two |
| 54 | * by some sort of arch-specific void * "token" used to identify interrupt |
| 55 | * controllers. |
| 56 | */ |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 57 | |
Grant Likely | 476eb49 | 2011-05-04 15:02:15 +1000 | [diff] [blame] | 58 | struct irq_data; |
| 59 | extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d); |
Olof Johansson | 35923f1 | 2007-06-04 14:47:04 +1000 | [diff] [blame] | 60 | extern irq_hw_number_t virq_to_hw(unsigned int virq); |
Benjamin Herrenschmidt | 0b05ac6 | 2011-04-04 13:46:58 +1000 | [diff] [blame] | 61 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 62 | /** |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 63 | * irq_alloc_host - Allocate a new irq_domain data structure |
Michael Ellerman | 52964f8 | 2007-08-28 18:47:54 +1000 | [diff] [blame] | 64 | * @of_node: optional device-tree node of the interrupt controller |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 65 | * @revmap_type: type of reverse mapping to use |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 66 | * @revmap_arg: for IRQ_DOMAIN_MAP_LINEAR linear only: size of the map |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 67 | * @ops: map/unmap host callbacks |
| 68 | * @inval_irq: provide a hw number in that host space that is always invalid |
| 69 | * |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 70 | * Allocates and initialize and irq_domain structure. Note that in the case of |
| 71 | * IRQ_DOMAIN_MAP_LEGACY, the map() callback will be called before this returns |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 72 | * for all legacy interrupts except 0 (which is always the invalid irq for |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 73 | * a legacy controller). For a IRQ_DOMAIN_MAP_LINEAR, the map is allocated by |
| 74 | * this call as well. For a IRQ_DOMAIN_MAP_TREE, the radix tree will be allocated |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 75 | * later during boot automatically (the reverse mapping will use the slow path |
| 76 | * until that happens). |
| 77 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 78 | extern struct irq_domain *irq_alloc_host(struct device_node *of_node, |
Michael Ellerman | 52964f8 | 2007-08-28 18:47:54 +1000 | [diff] [blame] | 79 | unsigned int revmap_type, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 80 | unsigned int revmap_arg, |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 81 | struct irq_domain_ops *ops, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 82 | irq_hw_number_t inval_irq); |
| 83 | |
| 84 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 85 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 86 | * irq_find_host - Locates a host for a given device node |
| 87 | * @node: device-tree node of the interrupt controller |
| 88 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 89 | extern struct irq_domain *irq_find_host(struct device_node *node); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 90 | |
| 91 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 92 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 93 | * irq_set_default_host - Set a "default" host |
| 94 | * @host: default host pointer |
| 95 | * |
| 96 | * For convenience, it's possible to set a "default" host that will be used |
| 97 | * whenever NULL is passed to irq_create_mapping(). It makes life easier for |
| 98 | * platforms that want to manipulate a few hard coded interrupt numbers that |
| 99 | * aren't properly represented in the device-tree. |
| 100 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 101 | extern void irq_set_default_host(struct irq_domain *host); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 102 | |
| 103 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 104 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 105 | * irq_set_virq_count - Set the maximum number of virt irqs |
| 106 | * @count: number of linux virtual irqs, capped with NR_IRQS |
| 107 | * |
| 108 | * This is mainly for use by platforms like iSeries who want to program |
| 109 | * the virtual irq number in the controller to avoid the reverse mapping |
| 110 | */ |
| 111 | extern void irq_set_virq_count(unsigned int count); |
| 112 | |
| 113 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 114 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 115 | * irq_create_mapping - Map a hardware interrupt into linux virq space |
| 116 | * @host: host owning this hardware interrupt or NULL for default host |
| 117 | * @hwirq: hardware irq number in that host space |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 118 | * |
| 119 | * Only one mapping per hardware interrupt is permitted. Returns a linux |
Benjamin Herrenschmidt | 6e99e45 | 2006-07-10 04:44:42 -0700 | [diff] [blame] | 120 | * virq number. |
| 121 | * If the sense/trigger is to be specified, set_irq_type() should be called |
| 122 | * on the number returned from that call. |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 123 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 124 | extern unsigned int irq_create_mapping(struct irq_domain *host, |
Benjamin Herrenschmidt | 6e99e45 | 2006-07-10 04:44:42 -0700 | [diff] [blame] | 125 | irq_hw_number_t hwirq); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 126 | |
| 127 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 128 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 129 | * irq_dispose_mapping - Unmap an interrupt |
| 130 | * @virq: linux virq number of the interrupt to unmap |
| 131 | */ |
| 132 | extern void irq_dispose_mapping(unsigned int virq); |
| 133 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 134 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 135 | * irq_find_mapping - Find a linux virq from an hw irq number. |
| 136 | * @host: host owning this hardware interrupt |
| 137 | * @hwirq: hardware irq number in that host space |
| 138 | * |
| 139 | * This is a slow path, for use by generic code. It's expected that an |
| 140 | * irq controller implementation directly calls the appropriate low level |
| 141 | * mapping function. |
| 142 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 143 | extern unsigned int irq_find_mapping(struct irq_domain *host, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 144 | irq_hw_number_t hwirq); |
| 145 | |
Michael Ellerman | ee51de5 | 2007-06-04 23:00:00 +1000 | [diff] [blame] | 146 | /** |
| 147 | * irq_create_direct_mapping - Allocate a virq for direct mapping |
| 148 | * @host: host to allocate the virq for or NULL for default host |
| 149 | * |
| 150 | * This routine is used for irq controllers which can choose the hardware |
| 151 | * interrupt numbers they generate. In such a case it's simplest to use |
| 152 | * the linux virq as the hardware interrupt number. |
| 153 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 154 | extern unsigned int irq_create_direct_mapping(struct irq_domain *host); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 155 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 156 | /** |
Sebastien Dugue | 967e012 | 2008-09-04 22:37:07 +1000 | [diff] [blame] | 157 | * irq_radix_revmap_insert - Insert a hw irq to linux virq number mapping. |
| 158 | * @host: host owning this hardware interrupt |
| 159 | * @virq: linux irq number |
| 160 | * @hwirq: hardware irq number in that host space |
| 161 | * |
| 162 | * This is for use by irq controllers that use a radix tree reverse |
| 163 | * mapping for fast lookup. |
| 164 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 165 | extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq, |
Sebastien Dugue | 967e012 | 2008-09-04 22:37:07 +1000 | [diff] [blame] | 166 | irq_hw_number_t hwirq); |
| 167 | |
| 168 | /** |
| 169 | * irq_radix_revmap_lookup - Find a linux virq from a hw irq number. |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 170 | * @host: host owning this hardware interrupt |
| 171 | * @hwirq: hardware irq number in that host space |
| 172 | * |
| 173 | * This is a fast path, for use by irq controller code that uses radix tree |
| 174 | * revmaps |
| 175 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 176 | extern unsigned int irq_radix_revmap_lookup(struct irq_domain *host, |
Sebastien Dugue | 967e012 | 2008-09-04 22:37:07 +1000 | [diff] [blame] | 177 | irq_hw_number_t hwirq); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 178 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 179 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 180 | * irq_linear_revmap - Find a linux virq from a hw irq number. |
| 181 | * @host: host owning this hardware interrupt |
| 182 | * @hwirq: hardware irq number in that host space |
| 183 | * |
| 184 | * This is a fast path, for use by irq controller code that uses linear |
| 185 | * revmaps. It does fallback to the slow path if the revmap doesn't exist |
| 186 | * yet and will create the revmap entry with appropriate locking |
| 187 | */ |
| 188 | |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame] | 189 | extern unsigned int irq_linear_revmap(struct irq_domain *host, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 190 | irq_hw_number_t hwirq); |
| 191 | |
| 192 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 193 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 194 | * irq_early_init - Init irq remapping subsystem |
| 195 | */ |
| 196 | extern void irq_early_init(void); |
| 197 | |
| 198 | static __inline__ int irq_canonicalize(int irq) |
| 199 | { |
| 200 | return irq; |
| 201 | } |
| 202 | |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 203 | extern int distribute_irqs; |
| 204 | |
| 205 | struct irqaction; |
| 206 | struct pt_regs; |
| 207 | |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 208 | #define __ARCH_HAS_DO_SOFTIRQ |
| 209 | |
Kumar Gala | bcf0b08 | 2008-04-30 03:49:55 -0500 | [diff] [blame] | 210 | #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) |
| 211 | /* |
| 212 | * Per-cpu stacks for handling critical, debug and machine check |
| 213 | * level interrupts. |
| 214 | */ |
| 215 | extern struct thread_info *critirq_ctx[NR_CPUS]; |
| 216 | extern struct thread_info *dbgirq_ctx[NR_CPUS]; |
| 217 | extern struct thread_info *mcheckirq_ctx[NR_CPUS]; |
| 218 | extern void exc_lvl_ctx_init(void); |
| 219 | #else |
| 220 | #define exc_lvl_ctx_init() |
| 221 | #endif |
| 222 | |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 223 | /* |
| 224 | * Per-cpu stacks for handling hard and soft interrupts. |
| 225 | */ |
| 226 | extern struct thread_info *hardirq_ctx[NR_CPUS]; |
| 227 | extern struct thread_info *softirq_ctx[NR_CPUS]; |
| 228 | |
| 229 | extern void irq_ctx_init(void); |
| 230 | extern void call_do_softirq(struct thread_info *tp); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 231 | extern int call_handle_irq(int irq, void *p1, |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 232 | struct thread_info *tp, void *func); |
Paul Mackerras | f2783c1 | 2005-10-20 09:23:26 +1000 | [diff] [blame] | 233 | extern void do_IRQ(struct pt_regs *regs); |
| 234 | |
Stuart Yoder | 6ec36b5 | 2011-05-19 08:54:26 -0500 | [diff] [blame] | 235 | int irq_choose_cpu(const struct cpumask *mask); |
| 236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | #endif /* _ASM_IRQ_H */ |
| 238 | #endif /* __KERNEL__ */ |