2 #ifndef _ASM_POWERPC_IRQ_H
3 #define _ASM_POWERPC_IRQ_H
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.
12 #include <linux/irqdomain.h>
13 #include <linux/threads.h>
14 #include <linux/list.h>
15 #include <linux/radix-tree.h>
17 #include <asm/types.h>
18 #include <linux/atomic.h>
21 /* Define a way to iterate across irqs. */
22 #define for_each_irq(i) \
23 for ((i) = 0; (i) < NR_IRQS; ++(i))
25 extern atomic_t ppc_n_lost_interrupts;
27 /* This number is used when no interrupt has been assigned */
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.
34 #define NO_IRQ_IGNORE ((unsigned int)-1)
36 /* Total number of virq in the platform */
37 #define NR_IRQS CONFIG_NR_IRQS
39 /* Number of irqs reserved for the legacy controller */
40 #define NUM_ISA_INTERRUPTS 16
42 /* Same thing, used by the generic IRQ code */
43 #define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS
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
59 extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
60 extern irq_hw_number_t virq_to_hw(unsigned int virq);
61 extern bool virq_is_host(unsigned int virq, struct irq_domain *host);
64 * irq_alloc_host - Allocate a new irq_domain data structure
65 * @of_node: optional device-tree node of the interrupt controller
66 * @revmap_type: type of reverse mapping to use
67 * @revmap_arg: for IRQ_DOMAIN_MAP_LINEAR linear only: size of the map
68 * @ops: map/unmap host callbacks
69 * @inval_irq: provide a hw number in that host space that is always invalid
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
73 * for all legacy interrupts except 0 (which is always the invalid irq for
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
76 * later during boot automatically (the reverse mapping will use the slow path
77 * until that happens).
79 extern struct irq_domain *irq_alloc_host(struct device_node *of_node,
80 unsigned int revmap_type,
81 unsigned int revmap_arg,
82 struct irq_domain_ops *ops,
83 irq_hw_number_t inval_irq);
87 * irq_find_host - Locates a host for a given device node
88 * @node: device-tree node of the interrupt controller
90 extern struct irq_domain *irq_find_host(struct device_node *node);
94 * irq_set_default_host - Set a "default" host
95 * @host: default host pointer
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.
102 extern void irq_set_default_host(struct irq_domain *host);
106 * irq_set_virq_count - Set the maximum number of virt irqs
107 * @count: number of linux virtual irqs, capped with NR_IRQS
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
112 extern void irq_set_virq_count(unsigned int count);
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
120 * Only one mapping per hardware interrupt is permitted. Returns a linux
122 * If the sense/trigger is to be specified, set_irq_type() should be called
123 * on the number returned from that call.
125 extern unsigned int irq_create_mapping(struct irq_domain *host,
126 irq_hw_number_t hwirq);
130 * irq_dispose_mapping - Unmap an interrupt
131 * @virq: linux virq number of the interrupt to unmap
133 extern void irq_dispose_mapping(unsigned int virq);
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
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
144 extern unsigned int irq_find_mapping(struct irq_domain *host,
145 irq_hw_number_t hwirq);
148 * irq_create_direct_mapping - Allocate a virq for direct mapping
149 * @host: host to allocate the virq for or NULL for default host
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.
155 extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
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
163 * This is for use by irq controllers that use a radix tree reverse
164 * mapping for fast lookup.
166 extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq,
167 irq_hw_number_t hwirq);
170 * irq_radix_revmap_lookup - Find a linux virq from a hw irq number.
171 * @host: host owning this hardware interrupt
172 * @hwirq: hardware irq number in that host space
174 * This is a fast path, for use by irq controller code that uses radix tree
177 extern unsigned int irq_radix_revmap_lookup(struct irq_domain *host,
178 irq_hw_number_t hwirq);
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
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
190 extern unsigned int irq_linear_revmap(struct irq_domain *host,
191 irq_hw_number_t hwirq);
195 * irq_early_init - Init irq remapping subsystem
197 extern void irq_early_init(void);
199 static __inline__ int irq_canonicalize(int irq)
204 extern int distribute_irqs;
209 #define __ARCH_HAS_DO_SOFTIRQ
211 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
213 * Per-cpu stacks for handling critical, debug and machine check
216 extern struct thread_info *critirq_ctx[NR_CPUS];
217 extern struct thread_info *dbgirq_ctx[NR_CPUS];
218 extern struct thread_info *mcheckirq_ctx[NR_CPUS];
219 extern void exc_lvl_ctx_init(void);
221 #define exc_lvl_ctx_init()
225 * Per-cpu stacks for handling hard and soft interrupts.
227 extern struct thread_info *hardirq_ctx[NR_CPUS];
228 extern struct thread_info *softirq_ctx[NR_CPUS];
230 extern void irq_ctx_init(void);
231 extern void call_do_softirq(struct thread_info *tp);
232 extern int call_handle_irq(int irq, void *p1,
233 struct thread_info *tp, void *func);
234 extern void do_IRQ(struct pt_regs *regs);
236 int irq_choose_cpu(const struct cpumask *mask);
238 #endif /* _ASM_IRQ_H */
239 #endif /* __KERNEL__ */