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 | 60063497 | 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 | 35923f12 | 2007-06-04 14:47:04 +1000 | [diff] [blame] | 60 | extern irq_hw_number_t virq_to_hw(unsigned int virq); |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 61 | extern bool virq_is_host(unsigned int virq, struct irq_domain *host); |
Benjamin Herrenschmidt | 0b05ac6 | 2011-04-04 13:46:58 +1000 | [diff] [blame] | 62 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 63 | /** |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 64 | * irq_alloc_host - Allocate a new irq_domain data structure |
Michael Ellerman | 52964f8 | 2007-08-28 18:47:54 +1000 | [diff] [blame] | 65 | * @of_node: optional device-tree node of the interrupt controller |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 66 | * @revmap_type: type of reverse mapping to use |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 67 | * @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] | 68 | * @ops: map/unmap host callbacks |
| 69 | * @inval_irq: provide a hw number in that host space that is always invalid |
| 70 | * |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 71 | * Allocates and initialize and irq_domain structure. Note that in the case of |
| 72 | * 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] | 73 | * 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^] | 74 | * a legacy controller). For a IRQ_DOMAIN_MAP_LINEAR, the map is allocated by |
| 75 | * 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] | 76 | * later during boot automatically (the reverse mapping will use the slow path |
| 77 | * until that happens). |
| 78 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 79 | extern struct irq_domain *irq_alloc_host(struct device_node *of_node, |
Michael Ellerman | 52964f8 | 2007-08-28 18:47:54 +1000 | [diff] [blame] | 80 | unsigned int revmap_type, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 81 | unsigned int revmap_arg, |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 82 | struct irq_domain_ops *ops, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 83 | irq_hw_number_t inval_irq); |
| 84 | |
| 85 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 86 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 87 | * irq_find_host - Locates a host for a given device node |
| 88 | * @node: device-tree node of the interrupt controller |
| 89 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 90 | extern struct irq_domain *irq_find_host(struct device_node *node); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 91 | |
| 92 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 93 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 94 | * irq_set_default_host - Set a "default" host |
| 95 | * @host: default host pointer |
| 96 | * |
| 97 | * For convenience, it's possible to set a "default" host that will be used |
| 98 | * whenever NULL is passed to irq_create_mapping(). It makes life easier for |
| 99 | * platforms that want to manipulate a few hard coded interrupt numbers that |
| 100 | * aren't properly represented in the device-tree. |
| 101 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 102 | extern void irq_set_default_host(struct irq_domain *host); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 103 | |
| 104 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 105 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 106 | * irq_set_virq_count - Set the maximum number of virt irqs |
| 107 | * @count: number of linux virtual irqs, capped with NR_IRQS |
| 108 | * |
| 109 | * This is mainly for use by platforms like iSeries who want to program |
| 110 | * the virtual irq number in the controller to avoid the reverse mapping |
| 111 | */ |
| 112 | extern void irq_set_virq_count(unsigned int count); |
| 113 | |
| 114 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 115 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 116 | * irq_create_mapping - Map a hardware interrupt into linux virq space |
| 117 | * @host: host owning this hardware interrupt or NULL for default host |
| 118 | * @hwirq: hardware irq number in that host space |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 119 | * |
| 120 | * Only one mapping per hardware interrupt is permitted. Returns a linux |
Benjamin Herrenschmidt | 6e99e45 | 2006-07-10 04:44:42 -0700 | [diff] [blame] | 121 | * virq number. |
| 122 | * If the sense/trigger is to be specified, set_irq_type() should be called |
| 123 | * on the number returned from that call. |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 124 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 125 | extern unsigned int irq_create_mapping(struct irq_domain *host, |
Benjamin Herrenschmidt | 6e99e45 | 2006-07-10 04:44:42 -0700 | [diff] [blame] | 126 | irq_hw_number_t hwirq); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 127 | |
| 128 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 129 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 130 | * irq_dispose_mapping - Unmap an interrupt |
| 131 | * @virq: linux virq number of the interrupt to unmap |
| 132 | */ |
| 133 | extern void irq_dispose_mapping(unsigned int virq); |
| 134 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 135 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 136 | * irq_find_mapping - Find a linux virq from an hw irq number. |
| 137 | * @host: host owning this hardware interrupt |
| 138 | * @hwirq: hardware irq number in that host space |
| 139 | * |
| 140 | * This is a slow path, for use by generic code. It's expected that an |
| 141 | * irq controller implementation directly calls the appropriate low level |
| 142 | * mapping function. |
| 143 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 144 | extern unsigned int irq_find_mapping(struct irq_domain *host, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 145 | irq_hw_number_t hwirq); |
| 146 | |
Michael Ellerman | ee51de5 | 2007-06-04 23:00:00 +1000 | [diff] [blame] | 147 | /** |
| 148 | * irq_create_direct_mapping - Allocate a virq for direct mapping |
| 149 | * @host: host to allocate the virq for or NULL for default host |
| 150 | * |
| 151 | * This routine is used for irq controllers which can choose the hardware |
| 152 | * interrupt numbers they generate. In such a case it's simplest to use |
| 153 | * the linux virq as the hardware interrupt number. |
| 154 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 155 | extern unsigned int irq_create_direct_mapping(struct irq_domain *host); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 156 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 157 | /** |
Sebastien Dugue | 967e012 | 2008-09-04 22:37:07 +1000 | [diff] [blame] | 158 | * irq_radix_revmap_insert - Insert a hw irq to linux virq number mapping. |
| 159 | * @host: host owning this hardware interrupt |
| 160 | * @virq: linux irq number |
| 161 | * @hwirq: hardware irq number in that host space |
| 162 | * |
| 163 | * This is for use by irq controllers that use a radix tree reverse |
| 164 | * mapping for fast lookup. |
| 165 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 166 | 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] | 167 | irq_hw_number_t hwirq); |
| 168 | |
| 169 | /** |
| 170 | * 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] | 171 | * @host: host owning this hardware interrupt |
| 172 | * @hwirq: hardware irq number in that host space |
| 173 | * |
| 174 | * This is a fast path, for use by irq controller code that uses radix tree |
| 175 | * revmaps |
| 176 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 177 | extern unsigned int irq_radix_revmap_lookup(struct irq_domain *host, |
Sebastien Dugue | 967e012 | 2008-09-04 22:37:07 +1000 | [diff] [blame] | 178 | irq_hw_number_t hwirq); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 179 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 180 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 181 | * irq_linear_revmap - Find a linux virq from a hw irq number. |
| 182 | * @host: host owning this hardware interrupt |
| 183 | * @hwirq: hardware irq number in that host space |
| 184 | * |
| 185 | * This is a fast path, for use by irq controller code that uses linear |
| 186 | * revmaps. It does fallback to the slow path if the revmap doesn't exist |
| 187 | * yet and will create the revmap entry with appropriate locking |
| 188 | */ |
| 189 | |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 190 | extern unsigned int irq_linear_revmap(struct irq_domain *host, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 191 | irq_hw_number_t hwirq); |
| 192 | |
| 193 | |
| 194 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 195 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 196 | * irq_alloc_virt - Allocate virtual irq numbers |
| 197 | * @host: host owning these new virtual irqs |
| 198 | * @count: number of consecutive numbers to allocate |
| 199 | * @hint: pass a hint number, the allocator will try to use a 1:1 mapping |
| 200 | * |
| 201 | * This is a low level function that is used internally by irq_create_mapping() |
| 202 | * and that can be used by some irq controllers implementations for things |
| 203 | * like allocating ranges of numbers for MSIs. The revmaps are left untouched. |
| 204 | */ |
Grant Likely | bae1d8f | 2012-02-14 14:06:50 -0700 | [diff] [blame^] | 205 | extern unsigned int irq_alloc_virt(struct irq_domain *host, |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 206 | unsigned int count, |
| 207 | unsigned int hint); |
| 208 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 209 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 210 | * irq_free_virt - Free virtual irq numbers |
| 211 | * @virq: virtual irq number of the first interrupt to free |
| 212 | * @count: number of interrupts to free |
| 213 | * |
| 214 | * This function is the opposite of irq_alloc_virt. It will not clear reverse |
| 215 | * maps, this should be done previously by unmap'ing the interrupt. In fact, |
| 216 | * all interrupts covered by the range being freed should have been unmapped |
| 217 | * prior to calling this. |
| 218 | */ |
| 219 | extern void irq_free_virt(unsigned int virq, unsigned int count); |
| 220 | |
Michael Ellerman | 40681b9 | 2006-08-02 11:13:50 +1000 | [diff] [blame] | 221 | /** |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 222 | * irq_early_init - Init irq remapping subsystem |
| 223 | */ |
| 224 | extern void irq_early_init(void); |
| 225 | |
| 226 | static __inline__ int irq_canonicalize(int irq) |
| 227 | { |
| 228 | return irq; |
| 229 | } |
| 230 | |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 231 | extern int distribute_irqs; |
| 232 | |
| 233 | struct irqaction; |
| 234 | struct pt_regs; |
| 235 | |
Paul Mackerras | c6622f6 | 2006-02-24 10:06:59 +1100 | [diff] [blame] | 236 | #define __ARCH_HAS_DO_SOFTIRQ |
| 237 | |
Kumar Gala | bcf0b08 | 2008-04-30 03:49:55 -0500 | [diff] [blame] | 238 | #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) |
| 239 | /* |
| 240 | * Per-cpu stacks for handling critical, debug and machine check |
| 241 | * level interrupts. |
| 242 | */ |
| 243 | extern struct thread_info *critirq_ctx[NR_CPUS]; |
| 244 | extern struct thread_info *dbgirq_ctx[NR_CPUS]; |
| 245 | extern struct thread_info *mcheckirq_ctx[NR_CPUS]; |
| 246 | extern void exc_lvl_ctx_init(void); |
| 247 | #else |
| 248 | #define exc_lvl_ctx_init() |
| 249 | #endif |
| 250 | |
Paul Mackerras | 1b92313 | 2005-10-10 22:54:57 +1000 | [diff] [blame] | 251 | /* |
| 252 | * Per-cpu stacks for handling hard and soft interrupts. |
| 253 | */ |
| 254 | extern struct thread_info *hardirq_ctx[NR_CPUS]; |
| 255 | extern struct thread_info *softirq_ctx[NR_CPUS]; |
| 256 | |
| 257 | extern void irq_ctx_init(void); |
| 258 | extern void call_do_softirq(struct thread_info *tp); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 259 | extern int call_handle_irq(int irq, void *p1, |
Benjamin Herrenschmidt | b9e5b4e | 2006-07-03 19:32:51 +1000 | [diff] [blame] | 260 | struct thread_info *tp, void *func); |
Paul Mackerras | f2783c1 | 2005-10-20 09:23:26 +1000 | [diff] [blame] | 261 | extern void do_IRQ(struct pt_regs *regs); |
| 262 | |
Stuart Yoder | 6ec36b5 | 2011-05-19 08:54:26 -0500 | [diff] [blame] | 263 | int irq_choose_cpu(const struct cpumask *mask); |
| 264 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | #endif /* _ASM_IRQ_H */ |
| 266 | #endif /* __KERNEL__ */ |