1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <asm/prom.h>
20
21#include "pseries.h"
22
23void request_event_sources_irqs(struct device_node *np,
24 irq_handler_t handler,
25 const char *name)
26{
27 int i, index, count = 0;
28 struct of_irq oirq;
29 const u32 *opicprop;
30 unsigned int opicplen;
31 unsigned int virqs[16];
32
33
34
35
36
37 opicprop = of_get_property(np, "open-pic-interrupt", &opicplen);
38 if (opicprop) {
39 opicplen /= sizeof(u32);
40 for (i = 0; i < opicplen; i++) {
41 if (count > 15)
42 break;
43 virqs[count] = irq_create_mapping(NULL, *(opicprop++));
44 if (virqs[count] == NO_IRQ) {
45 pr_err("event-sources: Unable to allocate "
46 "interrupt number for %s\n",
47 np->full_name);
48 WARN_ON(1);
49 }
50 else
51 count++;
52
53 }
54 }
55
56 else {
57
58 for (index = 0; of_irq_map_one(np, index, &oirq) == 0;
59 index++) {
60 if (count > 15)
61 break;
62 virqs[count] = irq_create_of_mapping(oirq.controller,
63 oirq.specifier,
64 oirq.size);
65 if (virqs[count] == NO_IRQ) {
66 pr_err("event-sources: Unable to allocate "
67 "interrupt number for %s\n",
68 np->full_name);
69 WARN_ON(1);
70 }
71 else
72 count++;
73 }
74 }
75
76
77 for (i = 0; i < count; i++) {
78 if (request_irq(virqs[i], handler, 0, name, NULL)) {
79 pr_err("event-sources: Unable to request interrupt "
80 "%d for %s\n", virqs[i], np->full_name);
81 WARN_ON(1);
82 return;
83 }
84 }
85}
86
87