blob: 79ae0ebb90ba429ad79faf7167d03ec05a78a72f [file] [log] [blame]
Paul Mundt54a90582012-05-19 15:11:47 +09001#define pr_fmt(fmt) "irq: " fmt
2
Grant Likelycc79ca62012-02-16 01:37:49 -07003#include <linux/debugfs.h>
4#include <linux/hardirq.h>
5#include <linux/interrupt.h>
Grant Likely08a543a2011-07-26 03:19:06 -06006#include <linux/irq.h>
Grant Likelycc79ca62012-02-16 01:37:49 -07007#include <linux/irqdesc.h>
Grant Likely08a543a2011-07-26 03:19:06 -06008#include <linux/irqdomain.h>
9#include <linux/module.h>
10#include <linux/mutex.h>
11#include <linux/of.h>
Grant Likely7e713302011-07-26 03:19:06 -060012#include <linux/of_address.h>
Paul Mundt5ca4db62012-06-03 22:04:34 -070013#include <linux/topology.h>
Grant Likelycc79ca62012-02-16 01:37:49 -070014#include <linux/seq_file.h>
Grant Likely7e713302011-07-26 03:19:06 -060015#include <linux/slab.h>
Grant Likelycc79ca62012-02-16 01:37:49 -070016#include <linux/smp.h>
17#include <linux/fs.h>
Grant Likely08a543a2011-07-26 03:19:06 -060018
Grant Likely1bc04f22012-02-14 14:06:55 -070019#define IRQ_DOMAIN_MAP_LEGACY 0 /* driver allocated fixed range of irqs.
20 * ie. legacy 8259, gets irqs 1..15 */
Grant Likelya8db8cf2012-02-14 14:06:54 -070021#define IRQ_DOMAIN_MAP_NOMAP 1 /* no fast reverse mapping */
22#define IRQ_DOMAIN_MAP_LINEAR 2 /* linear map of interrupts */
23#define IRQ_DOMAIN_MAP_TREE 3 /* radix tree */
24
Grant Likely08a543a2011-07-26 03:19:06 -060025static LIST_HEAD(irq_domain_list);
26static DEFINE_MUTEX(irq_domain_mutex);
27
Grant Likelycc79ca62012-02-16 01:37:49 -070028static DEFINE_MUTEX(revmap_trees_mutex);
Grant Likely68700652012-02-14 14:06:53 -070029static struct irq_domain *irq_default_domain;
Grant Likelycc79ca62012-02-16 01:37:49 -070030
Grant Likelycc79ca62012-02-16 01:37:49 -070031/**
Grant Likelya8db8cf2012-02-14 14:06:54 -070032 * irq_domain_alloc() - Allocate a new irq_domain data structure
Grant Likelycc79ca62012-02-16 01:37:49 -070033 * @of_node: optional device-tree node of the interrupt controller
34 * @revmap_type: type of reverse mapping to use
Grant Likely68700652012-02-14 14:06:53 -070035 * @ops: map/unmap domain callbacks
Grant Likelya8db8cf2012-02-14 14:06:54 -070036 * @host_data: Controller private data pointer
Grant Likelycc79ca62012-02-16 01:37:49 -070037 *
Grant Likelya8db8cf2012-02-14 14:06:54 -070038 * Allocates and initialize and irq_domain structure. Caller is expected to
39 * register allocated irq_domain with irq_domain_register(). Returns pointer
40 * to IRQ domain, or NULL on failure.
Grant Likelycc79ca62012-02-16 01:37:49 -070041 */
Grant Likelya8db8cf2012-02-14 14:06:54 -070042static struct irq_domain *irq_domain_alloc(struct device_node *of_node,
43 unsigned int revmap_type,
Grant Likelya18dc812012-01-26 12:12:14 -070044 const struct irq_domain_ops *ops,
Grant Likelya8db8cf2012-02-14 14:06:54 -070045 void *host_data)
Grant Likelycc79ca62012-02-16 01:37:49 -070046{
Grant Likelya8db8cf2012-02-14 14:06:54 -070047 struct irq_domain *domain;
Grant Likelycc79ca62012-02-16 01:37:49 -070048
Paul Mundt5ca4db62012-06-03 22:04:34 -070049 domain = kzalloc_node(sizeof(*domain), GFP_KERNEL,
50 of_node_to_nid(of_node));
Grant Likelya8db8cf2012-02-14 14:06:54 -070051 if (WARN_ON(!domain))
Grant Likelycc79ca62012-02-16 01:37:49 -070052 return NULL;
53
54 /* Fill structure */
Grant Likely68700652012-02-14 14:06:53 -070055 domain->revmap_type = revmap_type;
Grant Likely68700652012-02-14 14:06:53 -070056 domain->ops = ops;
Grant Likelya8db8cf2012-02-14 14:06:54 -070057 domain->host_data = host_data;
Grant Likely68700652012-02-14 14:06:53 -070058 domain->of_node = of_node_get(of_node);
Grant Likelycc79ca62012-02-16 01:37:49 -070059
Grant Likelya8db8cf2012-02-14 14:06:54 -070060 return domain;
61}
62
Paul Mundt58ee99a2012-05-19 15:11:41 +090063static void irq_domain_free(struct irq_domain *domain)
64{
65 of_node_put(domain->of_node);
66 kfree(domain);
67}
68
Grant Likelya8db8cf2012-02-14 14:06:54 -070069static void irq_domain_add(struct irq_domain *domain)
70{
71 mutex_lock(&irq_domain_mutex);
72 list_add(&domain->link, &irq_domain_list);
73 mutex_unlock(&irq_domain_mutex);
Paul Mundt54a90582012-05-19 15:11:47 +090074 pr_debug("Allocated domain of type %d @0x%p\n",
Grant Likelya8db8cf2012-02-14 14:06:54 -070075 domain->revmap_type, domain);
76}
77
Paul Mundt58ee99a2012-05-19 15:11:41 +090078/**
79 * irq_domain_remove() - Remove an irq domain.
80 * @domain: domain to remove
81 *
82 * This routine is used to remove an irq domain. The caller must ensure
83 * that all mappings within the domain have been disposed of prior to
84 * use, depending on the revmap type.
85 */
86void irq_domain_remove(struct irq_domain *domain)
87{
88 mutex_lock(&irq_domain_mutex);
89
90 switch (domain->revmap_type) {
91 case IRQ_DOMAIN_MAP_LEGACY:
92 /*
93 * Legacy domains don't manage their own irq_desc
94 * allocations, we expect the caller to handle irq_desc
95 * freeing on their own.
96 */
97 break;
98 case IRQ_DOMAIN_MAP_TREE:
99 /*
100 * radix_tree_delete() takes care of destroying the root
101 * node when all entries are removed. Shout if there are
102 * any mappings left.
103 */
104 WARN_ON(domain->revmap_data.tree.height);
105 break;
106 case IRQ_DOMAIN_MAP_LINEAR:
107 kfree(domain->revmap_data.linear.revmap);
108 domain->revmap_data.linear.size = 0;
109 break;
110 case IRQ_DOMAIN_MAP_NOMAP:
111 break;
112 }
113
114 list_del(&domain->link);
115
116 /*
117 * If the going away domain is the default one, reset it.
118 */
119 if (unlikely(irq_default_domain == domain))
120 irq_set_default_host(NULL);
121
122 mutex_unlock(&irq_domain_mutex);
123
Paul Mundt54a90582012-05-19 15:11:47 +0900124 pr_debug("Removed domain of type %d @0x%p\n",
Paul Mundt58ee99a2012-05-19 15:11:41 +0900125 domain->revmap_type, domain);
126
127 irq_domain_free(domain);
128}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900129EXPORT_SYMBOL_GPL(irq_domain_remove);
Paul Mundt58ee99a2012-05-19 15:11:41 +0900130
Grant Likely1bc04f22012-02-14 14:06:55 -0700131static unsigned int irq_domain_legacy_revmap(struct irq_domain *domain,
132 irq_hw_number_t hwirq)
133{
134 irq_hw_number_t first_hwirq = domain->revmap_data.legacy.first_hwirq;
135 int size = domain->revmap_data.legacy.size;
136
137 if (WARN_ON(hwirq < first_hwirq || hwirq >= first_hwirq + size))
138 return 0;
139 return hwirq - first_hwirq + domain->revmap_data.legacy.first_irq;
140}
141
Grant Likelya8db8cf2012-02-14 14:06:54 -0700142/**
143 * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.
144 * @of_node: pointer to interrupt controller's device tree node.
Grant Likely1bc04f22012-02-14 14:06:55 -0700145 * @size: total number of irqs in legacy mapping
146 * @first_irq: first number of irq block assigned to the domain
147 * @first_hwirq: first hwirq number to use for the translation. Should normally
148 * be '0', but a positive integer can be used if the effective
149 * hwirqs numbering does not begin at zero.
Grant Likelya8db8cf2012-02-14 14:06:54 -0700150 * @ops: map/unmap domain callbacks
151 * @host_data: Controller private data pointer
152 *
153 * Note: the map() callback will be called before this function returns
154 * for all legacy interrupts except 0 (which is always the invalid irq for
155 * a legacy controller).
156 */
157struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
Grant Likely1bc04f22012-02-14 14:06:55 -0700158 unsigned int size,
159 unsigned int first_irq,
160 irq_hw_number_t first_hwirq,
Grant Likelya18dc812012-01-26 12:12:14 -0700161 const struct irq_domain_ops *ops,
Grant Likelya8db8cf2012-02-14 14:06:54 -0700162 void *host_data)
163{
Grant Likely1bc04f22012-02-14 14:06:55 -0700164 struct irq_domain *domain;
Grant Likelya8db8cf2012-02-14 14:06:54 -0700165 unsigned int i;
166
167 domain = irq_domain_alloc(of_node, IRQ_DOMAIN_MAP_LEGACY, ops, host_data);
168 if (!domain)
169 return NULL;
170
Grant Likely1bc04f22012-02-14 14:06:55 -0700171 domain->revmap_data.legacy.first_irq = first_irq;
172 domain->revmap_data.legacy.first_hwirq = first_hwirq;
173 domain->revmap_data.legacy.size = size;
174
Grant Likelycc79ca62012-02-16 01:37:49 -0700175 mutex_lock(&irq_domain_mutex);
Grant Likely1bc04f22012-02-14 14:06:55 -0700176 /* Verify that all the irqs are available */
177 for (i = 0; i < size; i++) {
178 int irq = first_irq + i;
179 struct irq_data *irq_data = irq_get_irq_data(irq);
180
181 if (WARN_ON(!irq_data || irq_data->domain)) {
Grant Likelya8db8cf2012-02-14 14:06:54 -0700182 mutex_unlock(&irq_domain_mutex);
Paul Mundt58ee99a2012-05-19 15:11:41 +0900183 irq_domain_free(domain);
Grant Likelya8db8cf2012-02-14 14:06:54 -0700184 return NULL;
Grant Likelycc79ca62012-02-16 01:37:49 -0700185 }
186 }
Grant Likely1bc04f22012-02-14 14:06:55 -0700187
188 /* Claim all of the irqs before registering a legacy domain */
189 for (i = 0; i < size; i++) {
190 struct irq_data *irq_data = irq_get_irq_data(first_irq + i);
191 irq_data->hwirq = first_hwirq + i;
192 irq_data->domain = domain;
193 }
Grant Likelycc79ca62012-02-16 01:37:49 -0700194 mutex_unlock(&irq_domain_mutex);
195
Grant Likely1bc04f22012-02-14 14:06:55 -0700196 for (i = 0; i < size; i++) {
197 int irq = first_irq + i;
198 int hwirq = first_hwirq + i;
199
200 /* IRQ0 gets ignored */
201 if (!irq)
202 continue;
Grant Likelycc79ca62012-02-16 01:37:49 -0700203
Grant Likelya8db8cf2012-02-14 14:06:54 -0700204 /* Legacy flags are left to default at this point,
205 * one can then use irq_create_mapping() to
206 * explicitly change them
207 */
Grant Likely1bc04f22012-02-14 14:06:55 -0700208 ops->map(domain, irq, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700209
Grant Likelya8db8cf2012-02-14 14:06:54 -0700210 /* Clear norequest flags */
Grant Likely1bc04f22012-02-14 14:06:55 -0700211 irq_clear_status_flags(irq, IRQ_NOREQUEST);
Grant Likelycc79ca62012-02-16 01:37:49 -0700212 }
Grant Likely1bc04f22012-02-14 14:06:55 -0700213
214 irq_domain_add(domain);
Grant Likelya8db8cf2012-02-14 14:06:54 -0700215 return domain;
216}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900217EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
Grant Likelycc79ca62012-02-16 01:37:49 -0700218
Grant Likelya8db8cf2012-02-14 14:06:54 -0700219/**
220 * irq_domain_add_linear() - Allocate and register a legacy revmap irq_domain.
221 * @of_node: pointer to interrupt controller's device tree node.
Mark Browna87487e2012-05-19 12:15:35 +0100222 * @size: Number of interrupts in the domain.
Grant Likelya8db8cf2012-02-14 14:06:54 -0700223 * @ops: map/unmap domain callbacks
224 * @host_data: Controller private data pointer
225 */
226struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
227 unsigned int size,
Grant Likelya18dc812012-01-26 12:12:14 -0700228 const struct irq_domain_ops *ops,
Grant Likelya8db8cf2012-02-14 14:06:54 -0700229 void *host_data)
230{
231 struct irq_domain *domain;
232 unsigned int *revmap;
Grant Likelycc79ca62012-02-16 01:37:49 -0700233
Paul Mundt5ca4db62012-06-03 22:04:34 -0700234 revmap = kzalloc_node(sizeof(*revmap) * size, GFP_KERNEL,
235 of_node_to_nid(of_node));
Grant Likelya8db8cf2012-02-14 14:06:54 -0700236 if (WARN_ON(!revmap))
237 return NULL;
238
239 domain = irq_domain_alloc(of_node, IRQ_DOMAIN_MAP_LINEAR, ops, host_data);
240 if (!domain) {
241 kfree(revmap);
242 return NULL;
243 }
244 domain->revmap_data.linear.size = size;
245 domain->revmap_data.linear.revmap = revmap;
246 irq_domain_add(domain);
247 return domain;
248}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900249EXPORT_SYMBOL_GPL(irq_domain_add_linear);
Grant Likelya8db8cf2012-02-14 14:06:54 -0700250
251struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700252 unsigned int max_irq,
Grant Likelya18dc812012-01-26 12:12:14 -0700253 const struct irq_domain_ops *ops,
Grant Likelya8db8cf2012-02-14 14:06:54 -0700254 void *host_data)
255{
256 struct irq_domain *domain = irq_domain_alloc(of_node,
257 IRQ_DOMAIN_MAP_NOMAP, ops, host_data);
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700258 if (domain) {
259 domain->revmap_data.nomap.max_irq = max_irq ? max_irq : ~0;
Grant Likelya8db8cf2012-02-14 14:06:54 -0700260 irq_domain_add(domain);
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700261 }
Grant Likelya8db8cf2012-02-14 14:06:54 -0700262 return domain;
263}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900264EXPORT_SYMBOL_GPL(irq_domain_add_nomap);
Grant Likelya8db8cf2012-02-14 14:06:54 -0700265
266/**
267 * irq_domain_add_tree()
268 * @of_node: pointer to interrupt controller's device tree node.
269 * @ops: map/unmap domain callbacks
270 *
271 * Note: The radix tree will be allocated later during boot automatically
272 * (the reverse mapping will use the slow path until that happens).
273 */
274struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
Grant Likelya18dc812012-01-26 12:12:14 -0700275 const struct irq_domain_ops *ops,
Grant Likelya8db8cf2012-02-14 14:06:54 -0700276 void *host_data)
277{
278 struct irq_domain *domain = irq_domain_alloc(of_node,
279 IRQ_DOMAIN_MAP_TREE, ops, host_data);
280 if (domain) {
281 INIT_RADIX_TREE(&domain->revmap_data.tree, GFP_KERNEL);
282 irq_domain_add(domain);
283 }
Grant Likely68700652012-02-14 14:06:53 -0700284 return domain;
Grant Likelycc79ca62012-02-16 01:37:49 -0700285}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900286EXPORT_SYMBOL_GPL(irq_domain_add_tree);
Grant Likelycc79ca62012-02-16 01:37:49 -0700287
288/**
289 * irq_find_host() - Locates a domain for a given device node
290 * @node: device-tree node of the interrupt controller
291 */
292struct irq_domain *irq_find_host(struct device_node *node)
293{
294 struct irq_domain *h, *found = NULL;
Grant Likelya18dc812012-01-26 12:12:14 -0700295 int rc;
Grant Likelycc79ca62012-02-16 01:37:49 -0700296
297 /* We might want to match the legacy controller last since
298 * it might potentially be set to match all interrupts in
299 * the absence of a device node. This isn't a problem so far
300 * yet though...
301 */
302 mutex_lock(&irq_domain_mutex);
Grant Likelya18dc812012-01-26 12:12:14 -0700303 list_for_each_entry(h, &irq_domain_list, link) {
304 if (h->ops->match)
305 rc = h->ops->match(h, node);
306 else
307 rc = (h->of_node != NULL) && (h->of_node == node);
308
309 if (rc) {
Grant Likelycc79ca62012-02-16 01:37:49 -0700310 found = h;
311 break;
312 }
Grant Likelya18dc812012-01-26 12:12:14 -0700313 }
Grant Likelycc79ca62012-02-16 01:37:49 -0700314 mutex_unlock(&irq_domain_mutex);
315 return found;
316}
317EXPORT_SYMBOL_GPL(irq_find_host);
318
319/**
320 * irq_set_default_host() - Set a "default" irq domain
Grant Likely68700652012-02-14 14:06:53 -0700321 * @domain: default domain pointer
Grant Likelycc79ca62012-02-16 01:37:49 -0700322 *
323 * For convenience, it's possible to set a "default" domain that will be used
324 * whenever NULL is passed to irq_create_mapping(). It makes life easier for
325 * platforms that want to manipulate a few hard coded interrupt numbers that
326 * aren't properly represented in the device-tree.
327 */
Grant Likely68700652012-02-14 14:06:53 -0700328void irq_set_default_host(struct irq_domain *domain)
Grant Likelycc79ca62012-02-16 01:37:49 -0700329{
Paul Mundt54a90582012-05-19 15:11:47 +0900330 pr_debug("Default domain set to @0x%p\n", domain);
Grant Likelycc79ca62012-02-16 01:37:49 -0700331
Grant Likely68700652012-02-14 14:06:53 -0700332 irq_default_domain = domain;
Grant Likelycc79ca62012-02-16 01:37:49 -0700333}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900334EXPORT_SYMBOL_GPL(irq_set_default_host);
Grant Likelycc79ca62012-02-16 01:37:49 -0700335
Grant Likely68700652012-02-14 14:06:53 -0700336static int irq_setup_virq(struct irq_domain *domain, unsigned int virq,
Grant Likelycc79ca62012-02-16 01:37:49 -0700337 irq_hw_number_t hwirq)
338{
339 struct irq_data *irq_data = irq_get_irq_data(virq);
340
341 irq_data->hwirq = hwirq;
Grant Likely68700652012-02-14 14:06:53 -0700342 irq_data->domain = domain;
343 if (domain->ops->map(domain, virq, hwirq)) {
Paul Mundt54a90582012-05-19 15:11:47 +0900344 pr_debug("irq-%i==>hwirq-0x%lx mapping failed\n", virq, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700345 irq_data->domain = NULL;
346 irq_data->hwirq = 0;
347 return -1;
348 }
349
350 irq_clear_status_flags(virq, IRQ_NOREQUEST);
351
352 return 0;
353}
354
355/**
356 * irq_create_direct_mapping() - Allocate an irq for direct mapping
Grant Likely68700652012-02-14 14:06:53 -0700357 * @domain: domain to allocate the irq for or NULL for default domain
Grant Likelycc79ca62012-02-16 01:37:49 -0700358 *
359 * This routine is used for irq controllers which can choose the hardware
360 * interrupt numbers they generate. In such a case it's simplest to use
361 * the linux irq as the hardware interrupt number.
362 */
Grant Likely68700652012-02-14 14:06:53 -0700363unsigned int irq_create_direct_mapping(struct irq_domain *domain)
Grant Likelycc79ca62012-02-16 01:37:49 -0700364{
365 unsigned int virq;
366
Grant Likely68700652012-02-14 14:06:53 -0700367 if (domain == NULL)
368 domain = irq_default_domain;
Grant Likelycc79ca62012-02-16 01:37:49 -0700369
Grant Likely68700652012-02-14 14:06:53 -0700370 BUG_ON(domain == NULL);
371 WARN_ON(domain->revmap_type != IRQ_DOMAIN_MAP_NOMAP);
Grant Likelycc79ca62012-02-16 01:37:49 -0700372
Paul Mundt5ca4db62012-06-03 22:04:34 -0700373 virq = irq_alloc_desc_from(1, of_node_to_nid(domain->of_node));
Grant Likely03848372012-02-14 14:06:52 -0700374 if (!virq) {
Paul Mundt54a90582012-05-19 15:11:47 +0900375 pr_debug("create_direct virq allocation failed\n");
Grant Likely03848372012-02-14 14:06:52 -0700376 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700377 }
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700378 if (virq >= domain->revmap_data.nomap.max_irq) {
Grant Likelycc79ca62012-02-16 01:37:49 -0700379 pr_err("ERROR: no free irqs available below %i maximum\n",
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700380 domain->revmap_data.nomap.max_irq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700381 irq_free_desc(virq);
382 return 0;
383 }
Paul Mundt54a90582012-05-19 15:11:47 +0900384 pr_debug("create_direct obtained virq %d\n", virq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700385
Grant Likely68700652012-02-14 14:06:53 -0700386 if (irq_setup_virq(domain, virq, virq)) {
Grant Likelycc79ca62012-02-16 01:37:49 -0700387 irq_free_desc(virq);
Grant Likely03848372012-02-14 14:06:52 -0700388 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700389 }
390
391 return virq;
392}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900393EXPORT_SYMBOL_GPL(irq_create_direct_mapping);
Grant Likelycc79ca62012-02-16 01:37:49 -0700394
395/**
396 * irq_create_mapping() - Map a hardware interrupt into linux irq space
Grant Likely68700652012-02-14 14:06:53 -0700397 * @domain: domain owning this hardware interrupt or NULL for default domain
398 * @hwirq: hardware irq number in that domain space
Grant Likelycc79ca62012-02-16 01:37:49 -0700399 *
400 * Only one mapping per hardware interrupt is permitted. Returns a linux
401 * irq number.
402 * If the sense/trigger is to be specified, set_irq_type() should be called
403 * on the number returned from that call.
404 */
Grant Likely68700652012-02-14 14:06:53 -0700405unsigned int irq_create_mapping(struct irq_domain *domain,
Grant Likelycc79ca62012-02-16 01:37:49 -0700406 irq_hw_number_t hwirq)
407{
David Daney5b7526e2012-04-05 16:52:13 -0700408 unsigned int hint;
409 int virq;
Grant Likelycc79ca62012-02-16 01:37:49 -0700410
Paul Mundt54a90582012-05-19 15:11:47 +0900411 pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700412
Grant Likely68700652012-02-14 14:06:53 -0700413 /* Look for default domain if nececssary */
414 if (domain == NULL)
415 domain = irq_default_domain;
416 if (domain == NULL) {
Paul Mundt54a90582012-05-19 15:11:47 +0900417 pr_warning("irq_create_mapping called for"
418 " NULL domain, hwirq=%lx\n", hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700419 WARN_ON(1);
Grant Likely03848372012-02-14 14:06:52 -0700420 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700421 }
Paul Mundt54a90582012-05-19 15:11:47 +0900422 pr_debug("-> using domain @%p\n", domain);
Grant Likelycc79ca62012-02-16 01:37:49 -0700423
424 /* Check if mapping already exists */
Grant Likely68700652012-02-14 14:06:53 -0700425 virq = irq_find_mapping(domain, hwirq);
Grant Likely03848372012-02-14 14:06:52 -0700426 if (virq) {
Paul Mundt54a90582012-05-19 15:11:47 +0900427 pr_debug("-> existing mapping on virq %d\n", virq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700428 return virq;
429 }
430
431 /* Get a virtual interrupt number */
Grant Likely1bc04f22012-02-14 14:06:55 -0700432 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
433 return irq_domain_legacy_revmap(domain, hwirq);
434
435 /* Allocate a virtual interrupt number */
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700436 hint = hwirq % nr_irqs;
Grant Likely1bc04f22012-02-14 14:06:55 -0700437 if (hint == 0)
438 hint++;
Paul Mundt5ca4db62012-06-03 22:04:34 -0700439 virq = irq_alloc_desc_from(hint, of_node_to_nid(domain->of_node));
David Daney5b7526e2012-04-05 16:52:13 -0700440 if (virq <= 0)
Paul Mundt5ca4db62012-06-03 22:04:34 -0700441 virq = irq_alloc_desc_from(1, of_node_to_nid(domain->of_node));
David Daney5b7526e2012-04-05 16:52:13 -0700442 if (virq <= 0) {
Paul Mundt54a90582012-05-19 15:11:47 +0900443 pr_debug("-> virq allocation failed\n");
Grant Likely1bc04f22012-02-14 14:06:55 -0700444 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700445 }
446
Grant Likely68700652012-02-14 14:06:53 -0700447 if (irq_setup_virq(domain, virq, hwirq)) {
448 if (domain->revmap_type != IRQ_DOMAIN_MAP_LEGACY)
Grant Likelycc79ca62012-02-16 01:37:49 -0700449 irq_free_desc(virq);
Grant Likely03848372012-02-14 14:06:52 -0700450 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700451 }
452
Paul Mundt54a90582012-05-19 15:11:47 +0900453 pr_debug("irq %lu on domain %s mapped to virtual irq %u\n",
Grant Likelyefd68e72012-06-03 22:04:33 -0700454 hwirq, of_node_full_name(domain->of_node), virq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700455
456 return virq;
457}
458EXPORT_SYMBOL_GPL(irq_create_mapping);
459
460unsigned int irq_create_of_mapping(struct device_node *controller,
461 const u32 *intspec, unsigned int intsize)
462{
Grant Likely68700652012-02-14 14:06:53 -0700463 struct irq_domain *domain;
Grant Likelycc79ca62012-02-16 01:37:49 -0700464 irq_hw_number_t hwirq;
465 unsigned int type = IRQ_TYPE_NONE;
466 unsigned int virq;
467
Grant Likely68700652012-02-14 14:06:53 -0700468 domain = controller ? irq_find_host(controller) : irq_default_domain;
469 if (!domain) {
Grant Likelyabd23632012-02-24 08:07:06 -0700470#ifdef CONFIG_MIPS
471 /*
472 * Workaround to avoid breaking interrupt controller drivers
473 * that don't yet register an irq_domain. This is temporary
474 * code. ~~~gcl, Feb 24, 2012
475 *
476 * Scheduled for removal in Linux v3.6. That should be enough
477 * time.
478 */
479 if (intsize > 0)
480 return intspec[0];
481#endif
Paul Mundt54a90582012-05-19 15:11:47 +0900482 pr_warning("no irq domain found for %s !\n",
Grant Likelyefd68e72012-06-03 22:04:33 -0700483 of_node_full_name(controller));
Grant Likely03848372012-02-14 14:06:52 -0700484 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700485 }
486
Grant Likely68700652012-02-14 14:06:53 -0700487 /* If domain has no translation, then we assume interrupt line */
488 if (domain->ops->xlate == NULL)
Grant Likelycc79ca62012-02-16 01:37:49 -0700489 hwirq = intspec[0];
490 else {
Grant Likely68700652012-02-14 14:06:53 -0700491 if (domain->ops->xlate(domain, controller, intspec, intsize,
Grant Likelycc79ca62012-02-16 01:37:49 -0700492 &hwirq, &type))
Grant Likely03848372012-02-14 14:06:52 -0700493 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700494 }
495
496 /* Create mapping */
Grant Likely68700652012-02-14 14:06:53 -0700497 virq = irq_create_mapping(domain, hwirq);
Grant Likely03848372012-02-14 14:06:52 -0700498 if (!virq)
Grant Likelycc79ca62012-02-16 01:37:49 -0700499 return virq;
500
501 /* Set type if specified and different than the current one */
502 if (type != IRQ_TYPE_NONE &&
503 type != (irqd_get_trigger_type(irq_get_irq_data(virq))))
504 irq_set_irq_type(virq, type);
505 return virq;
506}
507EXPORT_SYMBOL_GPL(irq_create_of_mapping);
508
509/**
510 * irq_dispose_mapping() - Unmap an interrupt
511 * @virq: linux irq number of the interrupt to unmap
512 */
513void irq_dispose_mapping(unsigned int virq)
514{
515 struct irq_data *irq_data = irq_get_irq_data(virq);
Grant Likely68700652012-02-14 14:06:53 -0700516 struct irq_domain *domain;
Grant Likelycc79ca62012-02-16 01:37:49 -0700517 irq_hw_number_t hwirq;
518
Grant Likely03848372012-02-14 14:06:52 -0700519 if (!virq || !irq_data)
Grant Likelycc79ca62012-02-16 01:37:49 -0700520 return;
521
Grant Likely68700652012-02-14 14:06:53 -0700522 domain = irq_data->domain;
523 if (WARN_ON(domain == NULL))
Grant Likelycc79ca62012-02-16 01:37:49 -0700524 return;
525
526 /* Never unmap legacy interrupts */
Grant Likely68700652012-02-14 14:06:53 -0700527 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
Grant Likelycc79ca62012-02-16 01:37:49 -0700528 return;
529
530 irq_set_status_flags(virq, IRQ_NOREQUEST);
531
532 /* remove chip and handler */
533 irq_set_chip_and_handler(virq, NULL, NULL);
534
535 /* Make sure it's completed */
536 synchronize_irq(virq);
537
538 /* Tell the PIC about it */
Grant Likely68700652012-02-14 14:06:53 -0700539 if (domain->ops->unmap)
540 domain->ops->unmap(domain, virq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700541 smp_mb();
542
543 /* Clear reverse map */
544 hwirq = irq_data->hwirq;
Grant Likely68700652012-02-14 14:06:53 -0700545 switch(domain->revmap_type) {
Grant Likelycc79ca62012-02-16 01:37:49 -0700546 case IRQ_DOMAIN_MAP_LINEAR:
Grant Likely68700652012-02-14 14:06:53 -0700547 if (hwirq < domain->revmap_data.linear.size)
548 domain->revmap_data.linear.revmap[hwirq] = 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700549 break;
550 case IRQ_DOMAIN_MAP_TREE:
551 mutex_lock(&revmap_trees_mutex);
Grant Likely68700652012-02-14 14:06:53 -0700552 radix_tree_delete(&domain->revmap_data.tree, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700553 mutex_unlock(&revmap_trees_mutex);
554 break;
555 }
556
Grant Likelycc79ca62012-02-16 01:37:49 -0700557 irq_free_desc(virq);
558}
559EXPORT_SYMBOL_GPL(irq_dispose_mapping);
560
561/**
562 * irq_find_mapping() - Find a linux irq from an hw irq number.
Grant Likely68700652012-02-14 14:06:53 -0700563 * @domain: domain owning this hardware interrupt
564 * @hwirq: hardware irq number in that domain space
Grant Likelycc79ca62012-02-16 01:37:49 -0700565 *
566 * This is a slow path, for use by generic code. It's expected that an
567 * irq controller implementation directly calls the appropriate low level
568 * mapping function.
569 */
Grant Likely68700652012-02-14 14:06:53 -0700570unsigned int irq_find_mapping(struct irq_domain *domain,
Grant Likelycc79ca62012-02-16 01:37:49 -0700571 irq_hw_number_t hwirq)
572{
573 unsigned int i;
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700574 unsigned int hint = hwirq % nr_irqs;
Grant Likelycc79ca62012-02-16 01:37:49 -0700575
Grant Likely68700652012-02-14 14:06:53 -0700576 /* Look for default domain if nececssary */
577 if (domain == NULL)
578 domain = irq_default_domain;
579 if (domain == NULL)
Grant Likely03848372012-02-14 14:06:52 -0700580 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700581
582 /* legacy -> bail early */
Grant Likely68700652012-02-14 14:06:53 -0700583 if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
Grant Likely1bc04f22012-02-14 14:06:55 -0700584 return irq_domain_legacy_revmap(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700585
586 /* Slow path does a linear search of the map */
587 if (hint == 0)
588 hint = 1;
589 i = hint;
590 do {
591 struct irq_data *data = irq_get_irq_data(i);
Grant Likely68700652012-02-14 14:06:53 -0700592 if (data && (data->domain == domain) && (data->hwirq == hwirq))
Grant Likelycc79ca62012-02-16 01:37:49 -0700593 return i;
594 i++;
Grant Likely6fa6c8e22012-02-15 15:06:08 -0700595 if (i >= nr_irqs)
Grant Likelycc79ca62012-02-16 01:37:49 -0700596 i = 1;
597 } while(i != hint);
Grant Likely03848372012-02-14 14:06:52 -0700598 return 0;
Grant Likelycc79ca62012-02-16 01:37:49 -0700599}
600EXPORT_SYMBOL_GPL(irq_find_mapping);
601
602/**
603 * irq_radix_revmap_lookup() - Find a linux irq from a hw irq number.
Grant Likely68700652012-02-14 14:06:53 -0700604 * @domain: domain owning this hardware interrupt
605 * @hwirq: hardware irq number in that domain space
Grant Likelycc79ca62012-02-16 01:37:49 -0700606 *
607 * This is a fast path, for use by irq controller code that uses radix tree
608 * revmaps
609 */
Grant Likely68700652012-02-14 14:06:53 -0700610unsigned int irq_radix_revmap_lookup(struct irq_domain *domain,
Grant Likelycc79ca62012-02-16 01:37:49 -0700611 irq_hw_number_t hwirq)
612{
613 struct irq_data *irq_data;
614
Grant Likely68700652012-02-14 14:06:53 -0700615 if (WARN_ON_ONCE(domain->revmap_type != IRQ_DOMAIN_MAP_TREE))
616 return irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700617
618 /*
619 * Freeing an irq can delete nodes along the path to
620 * do the lookup via call_rcu.
621 */
622 rcu_read_lock();
Grant Likely68700652012-02-14 14:06:53 -0700623 irq_data = radix_tree_lookup(&domain->revmap_data.tree, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700624 rcu_read_unlock();
625
626 /*
627 * If found in radix tree, then fine.
628 * Else fallback to linear lookup - this should not happen in practice
629 * as it means that we failed to insert the node in the radix tree.
630 */
Grant Likely68700652012-02-14 14:06:53 -0700631 return irq_data ? irq_data->irq : irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700632}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900633EXPORT_SYMBOL_GPL(irq_radix_revmap_lookup);
Grant Likelycc79ca62012-02-16 01:37:49 -0700634
635/**
636 * irq_radix_revmap_insert() - Insert a hw irq to linux irq number mapping.
Grant Likely68700652012-02-14 14:06:53 -0700637 * @domain: domain owning this hardware interrupt
Grant Likelycc79ca62012-02-16 01:37:49 -0700638 * @virq: linux irq number
Grant Likely68700652012-02-14 14:06:53 -0700639 * @hwirq: hardware irq number in that domain space
Grant Likelycc79ca62012-02-16 01:37:49 -0700640 *
641 * This is for use by irq controllers that use a radix tree reverse
642 * mapping for fast lookup.
643 */
Grant Likely68700652012-02-14 14:06:53 -0700644void irq_radix_revmap_insert(struct irq_domain *domain, unsigned int virq,
Grant Likelycc79ca62012-02-16 01:37:49 -0700645 irq_hw_number_t hwirq)
646{
647 struct irq_data *irq_data = irq_get_irq_data(virq);
648
Grant Likely68700652012-02-14 14:06:53 -0700649 if (WARN_ON(domain->revmap_type != IRQ_DOMAIN_MAP_TREE))
Grant Likelycc79ca62012-02-16 01:37:49 -0700650 return;
651
Grant Likely03848372012-02-14 14:06:52 -0700652 if (virq) {
Grant Likelycc79ca62012-02-16 01:37:49 -0700653 mutex_lock(&revmap_trees_mutex);
Grant Likely68700652012-02-14 14:06:53 -0700654 radix_tree_insert(&domain->revmap_data.tree, hwirq, irq_data);
Grant Likelycc79ca62012-02-16 01:37:49 -0700655 mutex_unlock(&revmap_trees_mutex);
656 }
657}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900658EXPORT_SYMBOL_GPL(irq_radix_revmap_insert);
Grant Likelycc79ca62012-02-16 01:37:49 -0700659
660/**
661 * irq_linear_revmap() - Find a linux irq from a hw irq number.
Grant Likely68700652012-02-14 14:06:53 -0700662 * @domain: domain owning this hardware interrupt
663 * @hwirq: hardware irq number in that domain space
Grant Likelycc79ca62012-02-16 01:37:49 -0700664 *
665 * This is a fast path, for use by irq controller code that uses linear
666 * revmaps. It does fallback to the slow path if the revmap doesn't exist
667 * yet and will create the revmap entry with appropriate locking
668 */
Grant Likely68700652012-02-14 14:06:53 -0700669unsigned int irq_linear_revmap(struct irq_domain *domain,
Grant Likelycc79ca62012-02-16 01:37:49 -0700670 irq_hw_number_t hwirq)
671{
672 unsigned int *revmap;
673
Grant Likely68700652012-02-14 14:06:53 -0700674 if (WARN_ON_ONCE(domain->revmap_type != IRQ_DOMAIN_MAP_LINEAR))
675 return irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700676
677 /* Check revmap bounds */
Grant Likely68700652012-02-14 14:06:53 -0700678 if (unlikely(hwirq >= domain->revmap_data.linear.size))
679 return irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700680
681 /* Check if revmap was allocated */
Grant Likely68700652012-02-14 14:06:53 -0700682 revmap = domain->revmap_data.linear.revmap;
Grant Likelycc79ca62012-02-16 01:37:49 -0700683 if (unlikely(revmap == NULL))
Grant Likely68700652012-02-14 14:06:53 -0700684 return irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700685
686 /* Fill up revmap with slow path if no mapping found */
Grant Likely03848372012-02-14 14:06:52 -0700687 if (unlikely(!revmap[hwirq]))
Grant Likely68700652012-02-14 14:06:53 -0700688 revmap[hwirq] = irq_find_mapping(domain, hwirq);
Grant Likelycc79ca62012-02-16 01:37:49 -0700689
690 return revmap[hwirq];
691}
Paul Mundtecd84eb2012-05-19 15:11:42 +0900692EXPORT_SYMBOL_GPL(irq_linear_revmap);
Grant Likelycc79ca62012-02-16 01:37:49 -0700693
Grant Likely092b2fb2012-03-29 14:10:30 -0600694#ifdef CONFIG_IRQ_DOMAIN_DEBUG
Grant Likelycc79ca62012-02-16 01:37:49 -0700695static int virq_debug_show(struct seq_file *m, void *private)
696{
697 unsigned long flags;
698 struct irq_desc *desc;
699 const char *p;
700 static const char none[] = "none";
701 void *data;
702 int i;
703
Grant Likely15e06bf2012-04-11 00:26:25 -0600704 seq_printf(m, "%-5s %-7s %-15s %-*s %s\n", "irq", "hwirq",
Grant Likely5269a9a2012-04-12 14:42:15 -0600705 "chip name", (int)(2 * sizeof(void *) + 2), "chip data",
706 "domain name");
Grant Likelycc79ca62012-02-16 01:37:49 -0700707
708 for (i = 1; i < nr_irqs; i++) {
709 desc = irq_to_desc(i);
710 if (!desc)
711 continue;
712
713 raw_spin_lock_irqsave(&desc->lock, flags);
714
715 if (desc->action && desc->action->handler) {
716 struct irq_chip *chip;
717
718 seq_printf(m, "%5d ", i);
719 seq_printf(m, "0x%05lx ", desc->irq_data.hwirq);
720
721 chip = irq_desc_get_chip(desc);
722 if (chip && chip->name)
723 p = chip->name;
724 else
725 p = none;
726 seq_printf(m, "%-15s ", p);
727
728 data = irq_desc_get_chip_data(desc);
Grant Likely15e06bf2012-04-11 00:26:25 -0600729 seq_printf(m, data ? "0x%p " : " %p ", data);
Grant Likelycc79ca62012-02-16 01:37:49 -0700730
Grant Likelyefd68e72012-06-03 22:04:33 -0700731 if (desc->irq_data.domain)
732 p = of_node_full_name(desc->irq_data.domain->of_node);
Grant Likelycc79ca62012-02-16 01:37:49 -0700733 else
734 p = none;
735 seq_printf(m, "%s\n", p);
736 }
737
738 raw_spin_unlock_irqrestore(&desc->lock, flags);
739 }
740
741 return 0;
742}
743
744static int virq_debug_open(struct inode *inode, struct file *file)
745{
746 return single_open(file, virq_debug_show, inode->i_private);
747}
748
749static const struct file_operations virq_debug_fops = {
750 .open = virq_debug_open,
751 .read = seq_read,
752 .llseek = seq_lseek,
753 .release = single_release,
754};
755
756static int __init irq_debugfs_init(void)
757{
Grant Likely092b2fb2012-03-29 14:10:30 -0600758 if (debugfs_create_file("irq_domain_mapping", S_IRUGO, NULL,
Grant Likelycc79ca62012-02-16 01:37:49 -0700759 NULL, &virq_debug_fops) == NULL)
760 return -ENOMEM;
761
762 return 0;
763}
764__initcall(irq_debugfs_init);
Grant Likely092b2fb2012-03-29 14:10:30 -0600765#endif /* CONFIG_IRQ_DOMAIN_DEBUG */
Grant Likelycc79ca62012-02-16 01:37:49 -0700766
Paul Mundt5c5806e2012-05-19 15:11:43 +0900767static int irq_domain_simple_map(struct irq_domain *d, unsigned int irq,
768 irq_hw_number_t hwirq)
Grant Likely08a543a2011-07-26 03:19:06 -0600769{
Grant Likely75294952012-02-14 14:06:57 -0700770 return 0;
Grant Likely08a543a2011-07-26 03:19:06 -0600771}
772
Grant Likely16b2e6e2012-01-26 11:26:52 -0700773/**
774 * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
775 *
776 * Device Tree IRQ specifier translation function which works with one cell
777 * bindings where the cell value maps directly to the hwirq number.
778 */
779int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
780 const u32 *intspec, unsigned int intsize,
781 unsigned long *out_hwirq, unsigned int *out_type)
Grant Likely7e713302011-07-26 03:19:06 -0600782{
Grant Likely16b2e6e2012-01-26 11:26:52 -0700783 if (WARN_ON(intsize < 1))
Grant Likely7e713302011-07-26 03:19:06 -0600784 return -EINVAL;
Grant Likely7e713302011-07-26 03:19:06 -0600785 *out_hwirq = intspec[0];
786 *out_type = IRQ_TYPE_NONE;
Grant Likely7e713302011-07-26 03:19:06 -0600787 return 0;
788}
Grant Likely16b2e6e2012-01-26 11:26:52 -0700789EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell);
790
791/**
792 * irq_domain_xlate_twocell() - Generic xlate for direct two cell bindings
793 *
794 * Device Tree IRQ specifier translation function which works with two cell
795 * bindings where the cell values map directly to the hwirq number
796 * and linux irq flags.
797 */
798int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
799 const u32 *intspec, unsigned int intsize,
800 irq_hw_number_t *out_hwirq, unsigned int *out_type)
801{
802 if (WARN_ON(intsize < 2))
803 return -EINVAL;
804 *out_hwirq = intspec[0];
805 *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
806 return 0;
807}
808EXPORT_SYMBOL_GPL(irq_domain_xlate_twocell);
809
810/**
811 * irq_domain_xlate_onetwocell() - Generic xlate for one or two cell bindings
812 *
813 * Device Tree IRQ specifier translation function which works with either one
814 * or two cell bindings where the cell values map directly to the hwirq number
815 * and linux irq flags.
816 *
817 * Note: don't use this function unless your interrupt controller explicitly
818 * supports both one and two cell bindings. For the majority of controllers
819 * the _onecell() or _twocell() variants above should be used.
820 */
821int irq_domain_xlate_onetwocell(struct irq_domain *d,
822 struct device_node *ctrlr,
823 const u32 *intspec, unsigned int intsize,
824 unsigned long *out_hwirq, unsigned int *out_type)
825{
826 if (WARN_ON(intsize < 1))
827 return -EINVAL;
828 *out_hwirq = intspec[0];
829 *out_type = (intsize > 1) ? intspec[1] : IRQ_TYPE_NONE;
830 return 0;
831}
832EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell);
Grant Likely7e713302011-07-26 03:19:06 -0600833
Grant Likelya18dc812012-01-26 12:12:14 -0700834const struct irq_domain_ops irq_domain_simple_ops = {
Grant Likely75294952012-02-14 14:06:57 -0700835 .map = irq_domain_simple_map,
Grant Likely16b2e6e2012-01-26 11:26:52 -0700836 .xlate = irq_domain_xlate_onetwocell,
Grant Likely75294952012-02-14 14:06:57 -0700837};
838EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
839
840#ifdef CONFIG_OF_IRQ
Grant Likely7e713302011-07-26 03:19:06 -0600841void irq_domain_generate_simple(const struct of_device_id *match,
842 u64 phys_base, unsigned int irq_start)
843{
844 struct device_node *node;
Grant Likelye1964c52012-02-14 14:06:48 -0700845 pr_debug("looking for phys_base=%llx, irq_start=%i\n",
Grant Likely7e713302011-07-26 03:19:06 -0600846 (unsigned long long) phys_base, (int) irq_start);
847 node = of_find_matching_node_by_address(NULL, match, phys_base);
848 if (node)
Grant Likely6b783f72012-01-10 17:09:30 -0700849 irq_domain_add_legacy(node, 32, irq_start, 0,
850 &irq_domain_simple_ops, NULL);
Grant Likely7e713302011-07-26 03:19:06 -0600851}
852EXPORT_SYMBOL_GPL(irq_domain_generate_simple);
Grant Likely75294952012-02-14 14:06:57 -0700853#endif