irqdomain: Introduce irq_domain_create_{linear, tree}
[firefly-linux-kernel-4.4.55.git] / kernel / irq / irqdomain.c
1 #define pr_fmt(fmt)  "irq: " fmt
2
3 #include <linux/debugfs.h>
4 #include <linux/hardirq.h>
5 #include <linux/interrupt.h>
6 #include <linux/irq.h>
7 #include <linux/irqdesc.h>
8 #include <linux/irqdomain.h>
9 #include <linux/module.h>
10 #include <linux/mutex.h>
11 #include <linux/of.h>
12 #include <linux/of_address.h>
13 #include <linux/of_irq.h>
14 #include <linux/topology.h>
15 #include <linux/seq_file.h>
16 #include <linux/slab.h>
17 #include <linux/smp.h>
18 #include <linux/fs.h>
19
20 static LIST_HEAD(irq_domain_list);
21 static DEFINE_MUTEX(irq_domain_mutex);
22
23 static DEFINE_MUTEX(revmap_trees_mutex);
24 static struct irq_domain *irq_default_domain;
25
26 static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
27                                   irq_hw_number_t hwirq, int node);
28 static void irq_domain_check_hierarchy(struct irq_domain *domain);
29
30 /**
31  * __irq_domain_add() - Allocate a new irq_domain data structure
32  * @of_node: optional device-tree node of the interrupt controller
33  * @size: Size of linear map; 0 for radix mapping only
34  * @hwirq_max: Maximum number of interrupts supported by controller
35  * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no
36  *              direct mapping
37  * @ops: domain callbacks
38  * @host_data: Controller private data pointer
39  *
40  * Allocates and initialize and irq_domain structure.
41  * Returns pointer to IRQ domain, or NULL on failure.
42  */
43 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
44                                     irq_hw_number_t hwirq_max, int direct_max,
45                                     const struct irq_domain_ops *ops,
46                                     void *host_data)
47 {
48         struct irq_domain *domain;
49         struct device_node *of_node;
50
51         of_node = to_of_node(fwnode);
52
53         domain = kzalloc_node(sizeof(*domain) + (sizeof(unsigned int) * size),
54                               GFP_KERNEL, of_node_to_nid(of_node));
55         if (WARN_ON(!domain))
56                 return NULL;
57
58         of_node_get(of_node);
59
60         /* Fill structure */
61         INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL);
62         domain->ops = ops;
63         domain->host_data = host_data;
64         domain->fwnode = fwnode;
65         domain->hwirq_max = hwirq_max;
66         domain->revmap_size = size;
67         domain->revmap_direct_max_irq = direct_max;
68         irq_domain_check_hierarchy(domain);
69
70         mutex_lock(&irq_domain_mutex);
71         list_add(&domain->link, &irq_domain_list);
72         mutex_unlock(&irq_domain_mutex);
73
74         pr_debug("Added domain %s\n", domain->name);
75         return domain;
76 }
77 EXPORT_SYMBOL_GPL(__irq_domain_add);
78
79 /**
80  * irq_domain_remove() - Remove an irq domain.
81  * @domain: domain to remove
82  *
83  * This routine is used to remove an irq domain. The caller must ensure
84  * that all mappings within the domain have been disposed of prior to
85  * use, depending on the revmap type.
86  */
87 void irq_domain_remove(struct irq_domain *domain)
88 {
89         mutex_lock(&irq_domain_mutex);
90
91         /*
92          * radix_tree_delete() takes care of destroying the root
93          * node when all entries are removed. Shout if there are
94          * any mappings left.
95          */
96         WARN_ON(domain->revmap_tree.height);
97
98         list_del(&domain->link);
99
100         /*
101          * If the going away domain is the default one, reset it.
102          */
103         if (unlikely(irq_default_domain == domain))
104                 irq_set_default_host(NULL);
105
106         mutex_unlock(&irq_domain_mutex);
107
108         pr_debug("Removed domain %s\n", domain->name);
109
110         of_node_put(irq_domain_get_of_node(domain));
111         kfree(domain);
112 }
113 EXPORT_SYMBOL_GPL(irq_domain_remove);
114
115 /**
116  * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs
117  * @of_node: pointer to interrupt controller's device tree node.
118  * @size: total number of irqs in mapping
119  * @first_irq: first number of irq block assigned to the domain,
120  *      pass zero to assign irqs on-the-fly. If first_irq is non-zero, then
121  *      pre-map all of the irqs in the domain to virqs starting at first_irq.
122  * @ops: domain callbacks
123  * @host_data: Controller private data pointer
124  *
125  * Allocates an irq_domain, and optionally if first_irq is positive then also
126  * allocate irq_descs and map all of the hwirqs to virqs starting at first_irq.
127  *
128  * This is intended to implement the expected behaviour for most
129  * interrupt controllers. If device tree is used, then first_irq will be 0 and
130  * irqs get mapped dynamically on the fly. However, if the controller requires
131  * static virq assignments (non-DT boot) then it will set that up correctly.
132  */
133 struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
134                                          unsigned int size,
135                                          unsigned int first_irq,
136                                          const struct irq_domain_ops *ops,
137                                          void *host_data)
138 {
139         struct irq_domain *domain;
140
141         domain = __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data);
142         if (!domain)
143                 return NULL;
144
145         if (first_irq > 0) {
146                 if (IS_ENABLED(CONFIG_SPARSE_IRQ)) {
147                         /* attempt to allocated irq_descs */
148                         int rc = irq_alloc_descs(first_irq, first_irq, size,
149                                                  of_node_to_nid(of_node));
150                         if (rc < 0)
151                                 pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
152                                         first_irq);
153                 }
154                 irq_domain_associate_many(domain, first_irq, 0, size);
155         }
156
157         return domain;
158 }
159 EXPORT_SYMBOL_GPL(irq_domain_add_simple);
160
161 /**
162  * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.
163  * @of_node: pointer to interrupt controller's device tree node.
164  * @size: total number of irqs in legacy mapping
165  * @first_irq: first number of irq block assigned to the domain
166  * @first_hwirq: first hwirq number to use for the translation. Should normally
167  *               be '0', but a positive integer can be used if the effective
168  *               hwirqs numbering does not begin at zero.
169  * @ops: map/unmap domain callbacks
170  * @host_data: Controller private data pointer
171  *
172  * Note: the map() callback will be called before this function returns
173  * for all legacy interrupts except 0 (which is always the invalid irq for
174  * a legacy controller).
175  */
176 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
177                                          unsigned int size,
178                                          unsigned int first_irq,
179                                          irq_hw_number_t first_hwirq,
180                                          const struct irq_domain_ops *ops,
181                                          void *host_data)
182 {
183         struct irq_domain *domain;
184
185         domain = __irq_domain_add(of_node_to_fwnode(of_node), first_hwirq + size,
186                                   first_hwirq + size, 0, ops, host_data);
187         if (domain)
188                 irq_domain_associate_many(domain, first_irq, first_hwirq, size);
189
190         return domain;
191 }
192 EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
193
194 /**
195  * irq_find_matching_fwnode() - Locates a domain for a given fwnode
196  * @fwnode: FW descriptor of the interrupt controller
197  * @bus_token: domain-specific data
198  */
199 struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
200                                             enum irq_domain_bus_token bus_token)
201 {
202         struct irq_domain *h, *found = NULL;
203         int rc;
204
205         /* We might want to match the legacy controller last since
206          * it might potentially be set to match all interrupts in
207          * the absence of a device node. This isn't a problem so far
208          * yet though...
209          *
210          * bus_token == DOMAIN_BUS_ANY matches any domain, any other
211          * values must generate an exact match for the domain to be
212          * selected.
213          */
214         mutex_lock(&irq_domain_mutex);
215         list_for_each_entry(h, &irq_domain_list, link) {
216                 if (h->ops->match)
217                         rc = h->ops->match(h, to_of_node(fwnode), bus_token);
218                 else
219                         rc = ((fwnode != NULL) && (h->fwnode == fwnode) &&
220                               ((bus_token == DOMAIN_BUS_ANY) ||
221                                (h->bus_token == bus_token)));
222
223                 if (rc) {
224                         found = h;
225                         break;
226                 }
227         }
228         mutex_unlock(&irq_domain_mutex);
229         return found;
230 }
231 EXPORT_SYMBOL_GPL(irq_find_matching_fwnode);
232
233 /**
234  * irq_set_default_host() - Set a "default" irq domain
235  * @domain: default domain pointer
236  *
237  * For convenience, it's possible to set a "default" domain that will be used
238  * whenever NULL is passed to irq_create_mapping(). It makes life easier for
239  * platforms that want to manipulate a few hard coded interrupt numbers that
240  * aren't properly represented in the device-tree.
241  */
242 void irq_set_default_host(struct irq_domain *domain)
243 {
244         pr_debug("Default domain set to @0x%p\n", domain);
245
246         irq_default_domain = domain;
247 }
248 EXPORT_SYMBOL_GPL(irq_set_default_host);
249
250 void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq)
251 {
252         struct irq_data *irq_data = irq_get_irq_data(irq);
253         irq_hw_number_t hwirq;
254
255         if (WARN(!irq_data || irq_data->domain != domain,
256                  "virq%i doesn't exist; cannot disassociate\n", irq))
257                 return;
258
259         hwirq = irq_data->hwirq;
260         irq_set_status_flags(irq, IRQ_NOREQUEST);
261
262         /* remove chip and handler */
263         irq_set_chip_and_handler(irq, NULL, NULL);
264
265         /* Make sure it's completed */
266         synchronize_irq(irq);
267
268         /* Tell the PIC about it */
269         if (domain->ops->unmap)
270                 domain->ops->unmap(domain, irq);
271         smp_mb();
272
273         irq_data->domain = NULL;
274         irq_data->hwirq = 0;
275
276         /* Clear reverse map for this hwirq */
277         if (hwirq < domain->revmap_size) {
278                 domain->linear_revmap[hwirq] = 0;
279         } else {
280                 mutex_lock(&revmap_trees_mutex);
281                 radix_tree_delete(&domain->revmap_tree, hwirq);
282                 mutex_unlock(&revmap_trees_mutex);
283         }
284 }
285
286 int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
287                          irq_hw_number_t hwirq)
288 {
289         struct irq_data *irq_data = irq_get_irq_data(virq);
290         int ret;
291
292         if (WARN(hwirq >= domain->hwirq_max,
293                  "error: hwirq 0x%x is too large for %s\n", (int)hwirq, domain->name))
294                 return -EINVAL;
295         if (WARN(!irq_data, "error: virq%i is not allocated", virq))
296                 return -EINVAL;
297         if (WARN(irq_data->domain, "error: virq%i is already associated", virq))
298                 return -EINVAL;
299
300         mutex_lock(&irq_domain_mutex);
301         irq_data->hwirq = hwirq;
302         irq_data->domain = domain;
303         if (domain->ops->map) {
304                 ret = domain->ops->map(domain, virq, hwirq);
305                 if (ret != 0) {
306                         /*
307                          * If map() returns -EPERM, this interrupt is protected
308                          * by the firmware or some other service and shall not
309                          * be mapped. Don't bother telling the user about it.
310                          */
311                         if (ret != -EPERM) {
312                                 pr_info("%s didn't like hwirq-0x%lx to VIRQ%i mapping (rc=%d)\n",
313                                        domain->name, hwirq, virq, ret);
314                         }
315                         irq_data->domain = NULL;
316                         irq_data->hwirq = 0;
317                         mutex_unlock(&irq_domain_mutex);
318                         return ret;
319                 }
320
321                 /* If not already assigned, give the domain the chip's name */
322                 if (!domain->name && irq_data->chip)
323                         domain->name = irq_data->chip->name;
324         }
325
326         if (hwirq < domain->revmap_size) {
327                 domain->linear_revmap[hwirq] = virq;
328         } else {
329                 mutex_lock(&revmap_trees_mutex);
330                 radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
331                 mutex_unlock(&revmap_trees_mutex);
332         }
333         mutex_unlock(&irq_domain_mutex);
334
335         irq_clear_status_flags(virq, IRQ_NOREQUEST);
336
337         return 0;
338 }
339 EXPORT_SYMBOL_GPL(irq_domain_associate);
340
341 void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base,
342                                irq_hw_number_t hwirq_base, int count)
343 {
344         struct device_node *of_node;
345         int i;
346
347         of_node = irq_domain_get_of_node(domain);
348         pr_debug("%s(%s, irqbase=%i, hwbase=%i, count=%i)\n", __func__,
349                 of_node_full_name(of_node), irq_base, (int)hwirq_base, count);
350
351         for (i = 0; i < count; i++) {
352                 irq_domain_associate(domain, irq_base + i, hwirq_base + i);
353         }
354 }
355 EXPORT_SYMBOL_GPL(irq_domain_associate_many);
356
357 /**
358  * irq_create_direct_mapping() - Allocate an irq for direct mapping
359  * @domain: domain to allocate the irq for or NULL for default domain
360  *
361  * This routine is used for irq controllers which can choose the hardware
362  * interrupt numbers they generate. In such a case it's simplest to use
363  * the linux irq as the hardware interrupt number. It still uses the linear
364  * or radix tree to store the mapping, but the irq controller can optimize
365  * the revmap path by using the hwirq directly.
366  */
367 unsigned int irq_create_direct_mapping(struct irq_domain *domain)
368 {
369         struct device_node *of_node;
370         unsigned int virq;
371
372         if (domain == NULL)
373                 domain = irq_default_domain;
374
375         of_node = irq_domain_get_of_node(domain);
376         virq = irq_alloc_desc_from(1, of_node_to_nid(of_node));
377         if (!virq) {
378                 pr_debug("create_direct virq allocation failed\n");
379                 return 0;
380         }
381         if (virq >= domain->revmap_direct_max_irq) {
382                 pr_err("ERROR: no free irqs available below %i maximum\n",
383                         domain->revmap_direct_max_irq);
384                 irq_free_desc(virq);
385                 return 0;
386         }
387         pr_debug("create_direct obtained virq %d\n", virq);
388
389         if (irq_domain_associate(domain, virq, virq)) {
390                 irq_free_desc(virq);
391                 return 0;
392         }
393
394         return virq;
395 }
396 EXPORT_SYMBOL_GPL(irq_create_direct_mapping);
397
398 /**
399  * irq_create_mapping() - Map a hardware interrupt into linux irq space
400  * @domain: domain owning this hardware interrupt or NULL for default domain
401  * @hwirq: hardware irq number in that domain space
402  *
403  * Only one mapping per hardware interrupt is permitted. Returns a linux
404  * irq number.
405  * If the sense/trigger is to be specified, set_irq_type() should be called
406  * on the number returned from that call.
407  */
408 unsigned int irq_create_mapping(struct irq_domain *domain,
409                                 irq_hw_number_t hwirq)
410 {
411         struct device_node *of_node;
412         int virq;
413
414         pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
415
416         /* Look for default domain if nececssary */
417         if (domain == NULL)
418                 domain = irq_default_domain;
419         if (domain == NULL) {
420                 WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq);
421                 return 0;
422         }
423         pr_debug("-> using domain @%p\n", domain);
424
425         of_node = irq_domain_get_of_node(domain);
426
427         /* Check if mapping already exists */
428         virq = irq_find_mapping(domain, hwirq);
429         if (virq) {
430                 pr_debug("-> existing mapping on virq %d\n", virq);
431                 return virq;
432         }
433
434         /* Allocate a virtual interrupt number */
435         virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node));
436         if (virq <= 0) {
437                 pr_debug("-> virq allocation failed\n");
438                 return 0;
439         }
440
441         if (irq_domain_associate(domain, virq, hwirq)) {
442                 irq_free_desc(virq);
443                 return 0;
444         }
445
446         pr_debug("irq %lu on domain %s mapped to virtual irq %u\n",
447                 hwirq, of_node_full_name(of_node), virq);
448
449         return virq;
450 }
451 EXPORT_SYMBOL_GPL(irq_create_mapping);
452
453 /**
454  * irq_create_strict_mappings() - Map a range of hw irqs to fixed linux irqs
455  * @domain: domain owning the interrupt range
456  * @irq_base: beginning of linux IRQ range
457  * @hwirq_base: beginning of hardware IRQ range
458  * @count: Number of interrupts to map
459  *
460  * This routine is used for allocating and mapping a range of hardware
461  * irqs to linux irqs where the linux irq numbers are at pre-defined
462  * locations. For use by controllers that already have static mappings
463  * to insert in to the domain.
464  *
465  * Non-linear users can use irq_create_identity_mapping() for IRQ-at-a-time
466  * domain insertion.
467  *
468  * 0 is returned upon success, while any failure to establish a static
469  * mapping is treated as an error.
470  */
471 int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base,
472                                irq_hw_number_t hwirq_base, int count)
473 {
474         struct device_node *of_node;
475         int ret;
476
477         of_node = irq_domain_get_of_node(domain);
478         ret = irq_alloc_descs(irq_base, irq_base, count,
479                               of_node_to_nid(of_node));
480         if (unlikely(ret < 0))
481                 return ret;
482
483         irq_domain_associate_many(domain, irq_base, hwirq_base, count);
484         return 0;
485 }
486 EXPORT_SYMBOL_GPL(irq_create_strict_mappings);
487
488 static int irq_domain_translate(struct irq_domain *d,
489                                 struct irq_fwspec *fwspec,
490                                 irq_hw_number_t *hwirq, unsigned int *type)
491 {
492 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
493         if (d->ops->translate)
494                 return d->ops->translate(d, fwspec, hwirq, type);
495 #endif
496         if (d->ops->xlate)
497                 return d->ops->xlate(d, to_of_node(fwspec->fwnode),
498                                      fwspec->param, fwspec->param_count,
499                                      hwirq, type);
500
501         /* If domain has no translation, then we assume interrupt line */
502         *hwirq = fwspec->param[0];
503         return 0;
504 }
505
506 static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,
507                                       struct irq_fwspec *fwspec)
508 {
509         int i;
510
511         fwspec->fwnode = irq_data->np ? &irq_data->np->fwnode : NULL;
512         fwspec->param_count = irq_data->args_count;
513
514         for (i = 0; i < irq_data->args_count; i++)
515                 fwspec->param[i] = irq_data->args[i];
516 }
517
518 unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
519 {
520         struct irq_domain *domain;
521         irq_hw_number_t hwirq;
522         unsigned int type = IRQ_TYPE_NONE;
523         int virq;
524
525         if (fwspec->fwnode)
526                 domain = irq_find_matching_fwnode(fwspec->fwnode, DOMAIN_BUS_ANY);
527         else
528                 domain = irq_default_domain;
529
530         if (!domain) {
531                 pr_warn("no irq domain found for %s !\n",
532                         of_node_full_name(to_of_node(fwspec->fwnode)));
533                 return 0;
534         }
535
536         if (irq_domain_translate(domain, fwspec, &hwirq, &type))
537                 return 0;
538
539         if (irq_domain_is_hierarchy(domain)) {
540                 /*
541                  * If we've already configured this interrupt,
542                  * don't do it again, or hell will break loose.
543                  */
544                 virq = irq_find_mapping(domain, hwirq);
545                 if (virq)
546                         return virq;
547
548                 virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec);
549                 if (virq <= 0)
550                         return 0;
551         } else {
552                 /* Create mapping */
553                 virq = irq_create_mapping(domain, hwirq);
554                 if (!virq)
555                         return virq;
556         }
557
558         /* Set type if specified and different than the current one */
559         if (type != IRQ_TYPE_NONE &&
560             type != irq_get_trigger_type(virq))
561                 irq_set_irq_type(virq, type);
562         return virq;
563 }
564 EXPORT_SYMBOL_GPL(irq_create_fwspec_mapping);
565
566 unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
567 {
568         struct irq_fwspec fwspec;
569
570         of_phandle_args_to_fwspec(irq_data, &fwspec);
571         return irq_create_fwspec_mapping(&fwspec);
572 }
573 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
574
575 /**
576  * irq_dispose_mapping() - Unmap an interrupt
577  * @virq: linux irq number of the interrupt to unmap
578  */
579 void irq_dispose_mapping(unsigned int virq)
580 {
581         struct irq_data *irq_data = irq_get_irq_data(virq);
582         struct irq_domain *domain;
583
584         if (!virq || !irq_data)
585                 return;
586
587         domain = irq_data->domain;
588         if (WARN_ON(domain == NULL))
589                 return;
590
591         irq_domain_disassociate(domain, virq);
592         irq_free_desc(virq);
593 }
594 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
595
596 /**
597  * irq_find_mapping() - Find a linux irq from an hw irq number.
598  * @domain: domain owning this hardware interrupt
599  * @hwirq: hardware irq number in that domain space
600  */
601 unsigned int irq_find_mapping(struct irq_domain *domain,
602                               irq_hw_number_t hwirq)
603 {
604         struct irq_data *data;
605
606         /* Look for default domain if nececssary */
607         if (domain == NULL)
608                 domain = irq_default_domain;
609         if (domain == NULL)
610                 return 0;
611
612         if (hwirq < domain->revmap_direct_max_irq) {
613                 data = irq_domain_get_irq_data(domain, hwirq);
614                 if (data && data->hwirq == hwirq)
615                         return hwirq;
616         }
617
618         /* Check if the hwirq is in the linear revmap. */
619         if (hwirq < domain->revmap_size)
620                 return domain->linear_revmap[hwirq];
621
622         rcu_read_lock();
623         data = radix_tree_lookup(&domain->revmap_tree, hwirq);
624         rcu_read_unlock();
625         return data ? data->irq : 0;
626 }
627 EXPORT_SYMBOL_GPL(irq_find_mapping);
628
629 #ifdef CONFIG_IRQ_DOMAIN_DEBUG
630 static int virq_debug_show(struct seq_file *m, void *private)
631 {
632         unsigned long flags;
633         struct irq_desc *desc;
634         struct irq_domain *domain;
635         struct radix_tree_iter iter;
636         void *data, **slot;
637         int i;
638
639         seq_printf(m, " %-16s  %-6s  %-10s  %-10s  %s\n",
640                    "name", "mapped", "linear-max", "direct-max", "devtree-node");
641         mutex_lock(&irq_domain_mutex);
642         list_for_each_entry(domain, &irq_domain_list, link) {
643                 struct device_node *of_node;
644                 int count = 0;
645                 of_node = irq_domain_get_of_node(domain);
646                 radix_tree_for_each_slot(slot, &domain->revmap_tree, &iter, 0)
647                         count++;
648                 seq_printf(m, "%c%-16s  %6u  %10u  %10u  %s\n",
649                            domain == irq_default_domain ? '*' : ' ', domain->name,
650                            domain->revmap_size + count, domain->revmap_size,
651                            domain->revmap_direct_max_irq,
652                            of_node ? of_node_full_name(of_node) : "");
653         }
654         mutex_unlock(&irq_domain_mutex);
655
656         seq_printf(m, "%-5s  %-7s  %-15s  %-*s  %6s  %-14s  %s\n", "irq", "hwirq",
657                       "chip name", (int)(2 * sizeof(void *) + 2), "chip data",
658                       "active", "type", "domain");
659
660         for (i = 1; i < nr_irqs; i++) {
661                 desc = irq_to_desc(i);
662                 if (!desc)
663                         continue;
664
665                 raw_spin_lock_irqsave(&desc->lock, flags);
666                 domain = desc->irq_data.domain;
667
668                 if (domain) {
669                         struct irq_chip *chip;
670                         int hwirq = desc->irq_data.hwirq;
671                         bool direct;
672
673                         seq_printf(m, "%5d  ", i);
674                         seq_printf(m, "0x%05x  ", hwirq);
675
676                         chip = irq_desc_get_chip(desc);
677                         seq_printf(m, "%-15s  ", (chip && chip->name) ? chip->name : "none");
678
679                         data = irq_desc_get_chip_data(desc);
680                         seq_printf(m, data ? "0x%p  " : "  %p  ", data);
681
682                         seq_printf(m, "   %c    ", (desc->action && desc->action->handler) ? '*' : ' ');
683                         direct = (i == hwirq) && (i < domain->revmap_direct_max_irq);
684                         seq_printf(m, "%6s%-8s  ",
685                                    (hwirq < domain->revmap_size) ? "LINEAR" : "RADIX",
686                                    direct ? "(DIRECT)" : "");
687                         seq_printf(m, "%s\n", desc->irq_data.domain->name);
688                 }
689
690                 raw_spin_unlock_irqrestore(&desc->lock, flags);
691         }
692
693         return 0;
694 }
695
696 static int virq_debug_open(struct inode *inode, struct file *file)
697 {
698         return single_open(file, virq_debug_show, inode->i_private);
699 }
700
701 static const struct file_operations virq_debug_fops = {
702         .open = virq_debug_open,
703         .read = seq_read,
704         .llseek = seq_lseek,
705         .release = single_release,
706 };
707
708 static int __init irq_debugfs_init(void)
709 {
710         if (debugfs_create_file("irq_domain_mapping", S_IRUGO, NULL,
711                                  NULL, &virq_debug_fops) == NULL)
712                 return -ENOMEM;
713
714         return 0;
715 }
716 __initcall(irq_debugfs_init);
717 #endif /* CONFIG_IRQ_DOMAIN_DEBUG */
718
719 /**
720  * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
721  *
722  * Device Tree IRQ specifier translation function which works with one cell
723  * bindings where the cell value maps directly to the hwirq number.
724  */
725 int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
726                              const u32 *intspec, unsigned int intsize,
727                              unsigned long *out_hwirq, unsigned int *out_type)
728 {
729         if (WARN_ON(intsize < 1))
730                 return -EINVAL;
731         *out_hwirq = intspec[0];
732         *out_type = IRQ_TYPE_NONE;
733         return 0;
734 }
735 EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell);
736
737 /**
738  * irq_domain_xlate_twocell() - Generic xlate for direct two cell bindings
739  *
740  * Device Tree IRQ specifier translation function which works with two cell
741  * bindings where the cell values map directly to the hwirq number
742  * and linux irq flags.
743  */
744 int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
745                         const u32 *intspec, unsigned int intsize,
746                         irq_hw_number_t *out_hwirq, unsigned int *out_type)
747 {
748         if (WARN_ON(intsize < 2))
749                 return -EINVAL;
750         *out_hwirq = intspec[0];
751         *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
752         return 0;
753 }
754 EXPORT_SYMBOL_GPL(irq_domain_xlate_twocell);
755
756 /**
757  * irq_domain_xlate_onetwocell() - Generic xlate for one or two cell bindings
758  *
759  * Device Tree IRQ specifier translation function which works with either one
760  * or two cell bindings where the cell values map directly to the hwirq number
761  * and linux irq flags.
762  *
763  * Note: don't use this function unless your interrupt controller explicitly
764  * supports both one and two cell bindings.  For the majority of controllers
765  * the _onecell() or _twocell() variants above should be used.
766  */
767 int irq_domain_xlate_onetwocell(struct irq_domain *d,
768                                 struct device_node *ctrlr,
769                                 const u32 *intspec, unsigned int intsize,
770                                 unsigned long *out_hwirq, unsigned int *out_type)
771 {
772         if (WARN_ON(intsize < 1))
773                 return -EINVAL;
774         *out_hwirq = intspec[0];
775         *out_type = (intsize > 1) ? intspec[1] : IRQ_TYPE_NONE;
776         return 0;
777 }
778 EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell);
779
780 const struct irq_domain_ops irq_domain_simple_ops = {
781         .xlate = irq_domain_xlate_onetwocell,
782 };
783 EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
784
785 static int irq_domain_alloc_descs(int virq, unsigned int cnt,
786                                   irq_hw_number_t hwirq, int node)
787 {
788         unsigned int hint;
789
790         if (virq >= 0) {
791                 virq = irq_alloc_descs(virq, virq, cnt, node);
792         } else {
793                 hint = hwirq % nr_irqs;
794                 if (hint == 0)
795                         hint++;
796                 virq = irq_alloc_descs_from(hint, cnt, node);
797                 if (virq <= 0 && hint > 1)
798                         virq = irq_alloc_descs_from(1, cnt, node);
799         }
800
801         return virq;
802 }
803
804 #ifdef  CONFIG_IRQ_DOMAIN_HIERARCHY
805 /**
806  * irq_domain_add_hierarchy - Add a irqdomain into the hierarchy
807  * @parent:     Parent irq domain to associate with the new domain
808  * @flags:      Irq domain flags associated to the domain
809  * @size:       Size of the domain. See below
810  * @node:       Optional device-tree node of the interrupt controller
811  * @ops:        Pointer to the interrupt domain callbacks
812  * @host_data:  Controller private data pointer
813  *
814  * If @size is 0 a tree domain is created, otherwise a linear domain.
815  *
816  * If successful the parent is associated to the new domain and the
817  * domain flags are set.
818  * Returns pointer to IRQ domain, or NULL on failure.
819  */
820 struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
821                                             unsigned int flags,
822                                             unsigned int size,
823                                             struct device_node *node,
824                                             const struct irq_domain_ops *ops,
825                                             void *host_data)
826 {
827         struct irq_domain *domain;
828
829         if (size)
830                 domain = irq_domain_add_linear(node, size, ops, host_data);
831         else
832                 domain = irq_domain_add_tree(node, ops, host_data);
833         if (domain) {
834                 domain->parent = parent;
835                 domain->flags |= flags;
836         }
837
838         return domain;
839 }
840
841 static void irq_domain_insert_irq(int virq)
842 {
843         struct irq_data *data;
844
845         for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
846                 struct irq_domain *domain = data->domain;
847                 irq_hw_number_t hwirq = data->hwirq;
848
849                 if (hwirq < domain->revmap_size) {
850                         domain->linear_revmap[hwirq] = virq;
851                 } else {
852                         mutex_lock(&revmap_trees_mutex);
853                         radix_tree_insert(&domain->revmap_tree, hwirq, data);
854                         mutex_unlock(&revmap_trees_mutex);
855                 }
856
857                 /* If not already assigned, give the domain the chip's name */
858                 if (!domain->name && data->chip)
859                         domain->name = data->chip->name;
860         }
861
862         irq_clear_status_flags(virq, IRQ_NOREQUEST);
863 }
864
865 static void irq_domain_remove_irq(int virq)
866 {
867         struct irq_data *data;
868
869         irq_set_status_flags(virq, IRQ_NOREQUEST);
870         irq_set_chip_and_handler(virq, NULL, NULL);
871         synchronize_irq(virq);
872         smp_mb();
873
874         for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
875                 struct irq_domain *domain = data->domain;
876                 irq_hw_number_t hwirq = data->hwirq;
877
878                 if (hwirq < domain->revmap_size) {
879                         domain->linear_revmap[hwirq] = 0;
880                 } else {
881                         mutex_lock(&revmap_trees_mutex);
882                         radix_tree_delete(&domain->revmap_tree, hwirq);
883                         mutex_unlock(&revmap_trees_mutex);
884                 }
885         }
886 }
887
888 static struct irq_data *irq_domain_insert_irq_data(struct irq_domain *domain,
889                                                    struct irq_data *child)
890 {
891         struct irq_data *irq_data;
892
893         irq_data = kzalloc_node(sizeof(*irq_data), GFP_KERNEL,
894                                 irq_data_get_node(child));
895         if (irq_data) {
896                 child->parent_data = irq_data;
897                 irq_data->irq = child->irq;
898                 irq_data->common = child->common;
899                 irq_data->domain = domain;
900         }
901
902         return irq_data;
903 }
904
905 static void irq_domain_free_irq_data(unsigned int virq, unsigned int nr_irqs)
906 {
907         struct irq_data *irq_data, *tmp;
908         int i;
909
910         for (i = 0; i < nr_irqs; i++) {
911                 irq_data = irq_get_irq_data(virq + i);
912                 tmp = irq_data->parent_data;
913                 irq_data->parent_data = NULL;
914                 irq_data->domain = NULL;
915
916                 while (tmp) {
917                         irq_data = tmp;
918                         tmp = tmp->parent_data;
919                         kfree(irq_data);
920                 }
921         }
922 }
923
924 static int irq_domain_alloc_irq_data(struct irq_domain *domain,
925                                      unsigned int virq, unsigned int nr_irqs)
926 {
927         struct irq_data *irq_data;
928         struct irq_domain *parent;
929         int i;
930
931         /* The outermost irq_data is embedded in struct irq_desc */
932         for (i = 0; i < nr_irqs; i++) {
933                 irq_data = irq_get_irq_data(virq + i);
934                 irq_data->domain = domain;
935
936                 for (parent = domain->parent; parent; parent = parent->parent) {
937                         irq_data = irq_domain_insert_irq_data(parent, irq_data);
938                         if (!irq_data) {
939                                 irq_domain_free_irq_data(virq, i + 1);
940                                 return -ENOMEM;
941                         }
942                 }
943         }
944
945         return 0;
946 }
947
948 /**
949  * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
950  * @domain:     domain to match
951  * @virq:       IRQ number to get irq_data
952  */
953 struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
954                                          unsigned int virq)
955 {
956         struct irq_data *irq_data;
957
958         for (irq_data = irq_get_irq_data(virq); irq_data;
959              irq_data = irq_data->parent_data)
960                 if (irq_data->domain == domain)
961                         return irq_data;
962
963         return NULL;
964 }
965
966 /**
967  * irq_domain_set_hwirq_and_chip - Set hwirq and irqchip of @virq at @domain
968  * @domain:     Interrupt domain to match
969  * @virq:       IRQ number
970  * @hwirq:      The hwirq number
971  * @chip:       The associated interrupt chip
972  * @chip_data:  The associated chip data
973  */
974 int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
975                                   irq_hw_number_t hwirq, struct irq_chip *chip,
976                                   void *chip_data)
977 {
978         struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
979
980         if (!irq_data)
981                 return -ENOENT;
982
983         irq_data->hwirq = hwirq;
984         irq_data->chip = chip ? chip : &no_irq_chip;
985         irq_data->chip_data = chip_data;
986
987         return 0;
988 }
989
990 /**
991  * irq_domain_set_info - Set the complete data for a @virq in @domain
992  * @domain:             Interrupt domain to match
993  * @virq:               IRQ number
994  * @hwirq:              The hardware interrupt number
995  * @chip:               The associated interrupt chip
996  * @chip_data:          The associated interrupt chip data
997  * @handler:            The interrupt flow handler
998  * @handler_data:       The interrupt flow handler data
999  * @handler_name:       The interrupt handler name
1000  */
1001 void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
1002                          irq_hw_number_t hwirq, struct irq_chip *chip,
1003                          void *chip_data, irq_flow_handler_t handler,
1004                          void *handler_data, const char *handler_name)
1005 {
1006         irq_domain_set_hwirq_and_chip(domain, virq, hwirq, chip, chip_data);
1007         __irq_set_handler(virq, handler, 0, handler_name);
1008         irq_set_handler_data(virq, handler_data);
1009 }
1010
1011 /**
1012  * irq_domain_reset_irq_data - Clear hwirq, chip and chip_data in @irq_data
1013  * @irq_data:   The pointer to irq_data
1014  */
1015 void irq_domain_reset_irq_data(struct irq_data *irq_data)
1016 {
1017         irq_data->hwirq = 0;
1018         irq_data->chip = &no_irq_chip;
1019         irq_data->chip_data = NULL;
1020 }
1021
1022 /**
1023  * irq_domain_free_irqs_common - Clear irq_data and free the parent
1024  * @domain:     Interrupt domain to match
1025  * @virq:       IRQ number to start with
1026  * @nr_irqs:    The number of irqs to free
1027  */
1028 void irq_domain_free_irqs_common(struct irq_domain *domain, unsigned int virq,
1029                                  unsigned int nr_irqs)
1030 {
1031         struct irq_data *irq_data;
1032         int i;
1033
1034         for (i = 0; i < nr_irqs; i++) {
1035                 irq_data = irq_domain_get_irq_data(domain, virq + i);
1036                 if (irq_data)
1037                         irq_domain_reset_irq_data(irq_data);
1038         }
1039         irq_domain_free_irqs_parent(domain, virq, nr_irqs);
1040 }
1041
1042 /**
1043  * irq_domain_free_irqs_top - Clear handler and handler data, clear irqdata and free parent
1044  * @domain:     Interrupt domain to match
1045  * @virq:       IRQ number to start with
1046  * @nr_irqs:    The number of irqs to free
1047  */
1048 void irq_domain_free_irqs_top(struct irq_domain *domain, unsigned int virq,
1049                               unsigned int nr_irqs)
1050 {
1051         int i;
1052
1053         for (i = 0; i < nr_irqs; i++) {
1054                 irq_set_handler_data(virq + i, NULL);
1055                 irq_set_handler(virq + i, NULL);
1056         }
1057         irq_domain_free_irqs_common(domain, virq, nr_irqs);
1058 }
1059
1060 static bool irq_domain_is_auto_recursive(struct irq_domain *domain)
1061 {
1062         return domain->flags & IRQ_DOMAIN_FLAG_AUTO_RECURSIVE;
1063 }
1064
1065 static void irq_domain_free_irqs_recursive(struct irq_domain *domain,
1066                                            unsigned int irq_base,
1067                                            unsigned int nr_irqs)
1068 {
1069         domain->ops->free(domain, irq_base, nr_irqs);
1070         if (irq_domain_is_auto_recursive(domain)) {
1071                 BUG_ON(!domain->parent);
1072                 irq_domain_free_irqs_recursive(domain->parent, irq_base,
1073                                                nr_irqs);
1074         }
1075 }
1076
1077 static int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
1078                                            unsigned int irq_base,
1079                                            unsigned int nr_irqs, void *arg)
1080 {
1081         int ret = 0;
1082         struct irq_domain *parent = domain->parent;
1083         bool recursive = irq_domain_is_auto_recursive(domain);
1084
1085         BUG_ON(recursive && !parent);
1086         if (recursive)
1087                 ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
1088                                                       nr_irqs, arg);
1089         if (ret >= 0)
1090                 ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
1091         if (ret < 0 && recursive)
1092                 irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
1093
1094         return ret;
1095 }
1096
1097 /**
1098  * __irq_domain_alloc_irqs - Allocate IRQs from domain
1099  * @domain:     domain to allocate from
1100  * @irq_base:   allocate specified IRQ nubmer if irq_base >= 0
1101  * @nr_irqs:    number of IRQs to allocate
1102  * @node:       NUMA node id for memory allocation
1103  * @arg:        domain specific argument
1104  * @realloc:    IRQ descriptors have already been allocated if true
1105  *
1106  * Allocate IRQ numbers and initialized all data structures to support
1107  * hierarchy IRQ domains.
1108  * Parameter @realloc is mainly to support legacy IRQs.
1109  * Returns error code or allocated IRQ number
1110  *
1111  * The whole process to setup an IRQ has been split into two steps.
1112  * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
1113  * descriptor and required hardware resources. The second step,
1114  * irq_domain_activate_irq(), is to program hardwares with preallocated
1115  * resources. In this way, it's easier to rollback when failing to
1116  * allocate resources.
1117  */
1118 int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
1119                             unsigned int nr_irqs, int node, void *arg,
1120                             bool realloc)
1121 {
1122         int i, ret, virq;
1123
1124         if (domain == NULL) {
1125                 domain = irq_default_domain;
1126                 if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
1127                         return -EINVAL;
1128         }
1129
1130         if (!domain->ops->alloc) {
1131                 pr_debug("domain->ops->alloc() is NULL\n");
1132                 return -ENOSYS;
1133         }
1134
1135         if (realloc && irq_base >= 0) {
1136                 virq = irq_base;
1137         } else {
1138                 virq = irq_domain_alloc_descs(irq_base, nr_irqs, 0, node);
1139                 if (virq < 0) {
1140                         pr_debug("cannot allocate IRQ(base %d, count %d)\n",
1141                                  irq_base, nr_irqs);
1142                         return virq;
1143                 }
1144         }
1145
1146         if (irq_domain_alloc_irq_data(domain, virq, nr_irqs)) {
1147                 pr_debug("cannot allocate memory for IRQ%d\n", virq);
1148                 ret = -ENOMEM;
1149                 goto out_free_desc;
1150         }
1151
1152         mutex_lock(&irq_domain_mutex);
1153         ret = irq_domain_alloc_irqs_recursive(domain, virq, nr_irqs, arg);
1154         if (ret < 0) {
1155                 mutex_unlock(&irq_domain_mutex);
1156                 goto out_free_irq_data;
1157         }
1158         for (i = 0; i < nr_irqs; i++)
1159                 irq_domain_insert_irq(virq + i);
1160         mutex_unlock(&irq_domain_mutex);
1161
1162         return virq;
1163
1164 out_free_irq_data:
1165         irq_domain_free_irq_data(virq, nr_irqs);
1166 out_free_desc:
1167         irq_free_descs(virq, nr_irqs);
1168         return ret;
1169 }
1170
1171 /**
1172  * irq_domain_free_irqs - Free IRQ number and associated data structures
1173  * @virq:       base IRQ number
1174  * @nr_irqs:    number of IRQs to free
1175  */
1176 void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs)
1177 {
1178         struct irq_data *data = irq_get_irq_data(virq);
1179         int i;
1180
1181         if (WARN(!data || !data->domain || !data->domain->ops->free,
1182                  "NULL pointer, cannot free irq\n"))
1183                 return;
1184
1185         mutex_lock(&irq_domain_mutex);
1186         for (i = 0; i < nr_irqs; i++)
1187                 irq_domain_remove_irq(virq + i);
1188         irq_domain_free_irqs_recursive(data->domain, virq, nr_irqs);
1189         mutex_unlock(&irq_domain_mutex);
1190
1191         irq_domain_free_irq_data(virq, nr_irqs);
1192         irq_free_descs(virq, nr_irqs);
1193 }
1194
1195 /**
1196  * irq_domain_alloc_irqs_parent - Allocate interrupts from parent domain
1197  * @irq_base:   Base IRQ number
1198  * @nr_irqs:    Number of IRQs to allocate
1199  * @arg:        Allocation data (arch/domain specific)
1200  *
1201  * Check whether the domain has been setup recursive. If not allocate
1202  * through the parent domain.
1203  */
1204 int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
1205                                  unsigned int irq_base, unsigned int nr_irqs,
1206                                  void *arg)
1207 {
1208         /* irq_domain_alloc_irqs_recursive() has called parent's alloc() */
1209         if (irq_domain_is_auto_recursive(domain))
1210                 return 0;
1211
1212         domain = domain->parent;
1213         if (domain)
1214                 return irq_domain_alloc_irqs_recursive(domain, irq_base,
1215                                                        nr_irqs, arg);
1216         return -ENOSYS;
1217 }
1218
1219 /**
1220  * irq_domain_free_irqs_parent - Free interrupts from parent domain
1221  * @irq_base:   Base IRQ number
1222  * @nr_irqs:    Number of IRQs to free
1223  *
1224  * Check whether the domain has been setup recursive. If not free
1225  * through the parent domain.
1226  */
1227 void irq_domain_free_irqs_parent(struct irq_domain *domain,
1228                                  unsigned int irq_base, unsigned int nr_irqs)
1229 {
1230         /* irq_domain_free_irqs_recursive() will call parent's free */
1231         if (!irq_domain_is_auto_recursive(domain) && domain->parent)
1232                 irq_domain_free_irqs_recursive(domain->parent, irq_base,
1233                                                nr_irqs);
1234 }
1235
1236 /**
1237  * irq_domain_activate_irq - Call domain_ops->activate recursively to activate
1238  *                           interrupt
1239  * @irq_data:   outermost irq_data associated with interrupt
1240  *
1241  * This is the second step to call domain_ops->activate to program interrupt
1242  * controllers, so the interrupt could actually get delivered.
1243  */
1244 void irq_domain_activate_irq(struct irq_data *irq_data)
1245 {
1246         if (irq_data && irq_data->domain) {
1247                 struct irq_domain *domain = irq_data->domain;
1248
1249                 if (irq_data->parent_data)
1250                         irq_domain_activate_irq(irq_data->parent_data);
1251                 if (domain->ops->activate)
1252                         domain->ops->activate(domain, irq_data);
1253         }
1254 }
1255
1256 /**
1257  * irq_domain_deactivate_irq - Call domain_ops->deactivate recursively to
1258  *                             deactivate interrupt
1259  * @irq_data: outermost irq_data associated with interrupt
1260  *
1261  * It calls domain_ops->deactivate to program interrupt controllers to disable
1262  * interrupt delivery.
1263  */
1264 void irq_domain_deactivate_irq(struct irq_data *irq_data)
1265 {
1266         if (irq_data && irq_data->domain) {
1267                 struct irq_domain *domain = irq_data->domain;
1268
1269                 if (domain->ops->deactivate)
1270                         domain->ops->deactivate(domain, irq_data);
1271                 if (irq_data->parent_data)
1272                         irq_domain_deactivate_irq(irq_data->parent_data);
1273         }
1274 }
1275
1276 static void irq_domain_check_hierarchy(struct irq_domain *domain)
1277 {
1278         /* Hierarchy irq_domains must implement callback alloc() */
1279         if (domain->ops->alloc)
1280                 domain->flags |= IRQ_DOMAIN_FLAG_HIERARCHY;
1281 }
1282 #else   /* CONFIG_IRQ_DOMAIN_HIERARCHY */
1283 /**
1284  * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
1285  * @domain:     domain to match
1286  * @virq:       IRQ number to get irq_data
1287  */
1288 struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
1289                                          unsigned int virq)
1290 {
1291         struct irq_data *irq_data = irq_get_irq_data(virq);
1292
1293         return (irq_data && irq_data->domain == domain) ? irq_data : NULL;
1294 }
1295
1296 /**
1297  * irq_domain_set_info - Set the complete data for a @virq in @domain
1298  * @domain:             Interrupt domain to match
1299  * @virq:               IRQ number
1300  * @hwirq:              The hardware interrupt number
1301  * @chip:               The associated interrupt chip
1302  * @chip_data:          The associated interrupt chip data
1303  * @handler:            The interrupt flow handler
1304  * @handler_data:       The interrupt flow handler data
1305  * @handler_name:       The interrupt handler name
1306  */
1307 void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
1308                          irq_hw_number_t hwirq, struct irq_chip *chip,
1309                          void *chip_data, irq_flow_handler_t handler,
1310                          void *handler_data, const char *handler_name)
1311 {
1312         irq_set_chip_and_handler_name(virq, chip, handler, handler_name);
1313         irq_set_chip_data(virq, chip_data);
1314         irq_set_handler_data(virq, handler_data);
1315 }
1316
1317 static void irq_domain_check_hierarchy(struct irq_domain *domain)
1318 {
1319 }
1320 #endif  /* CONFIG_IRQ_DOMAIN_HIERARCHY */