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_phandle_args 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_parse_one(np, index, &oirq) == 0;
59 index++) {
60 if (count > 15)
61 break;
62 virqs[count] = irq_create_of_mapping(&oirq);
63 if (virqs[count] == NO_IRQ) {
64 pr_err("event-sources: Unable to allocate "
65 "interrupt number for %s\n",
66 np->full_name);
67 WARN_ON(1);
68 }
69 else
70 count++;
71 }
72 }
73
74
75 for (i = 0; i < count; i++) {
76 if (request_irq(virqs[i], handler, 0, name, NULL)) {
77 pr_err("event-sources: Unable to request interrupt "
78 "%d for %s\n", virqs[i], np->full_name);
79 WARN_ON(1);
80 return;
81 }
82 }
83}
84
85