2 * File XmPciLpEvent.h created by Wayne Holm on Mon Jan 15 2001.
4 * This module handles PCI interrupt events sent by the iSeries Hypervisor.
7 #include <linux/config.h>
9 #include <linux/init.h>
10 #include <linux/threads.h>
11 #include <linux/smp.h>
12 #include <linux/param.h>
13 #include <linux/string.h>
14 #include <linux/bootmem.h>
15 #include <linux/ide.h>
17 #include <asm/iSeries/HvTypes.h>
18 #include <asm/iSeries/HvLpEvent.h>
19 #include <asm/iSeries/HvCallPci.h>
20 #include <asm/iSeries/XmPciLpEvent.h>
21 #include <asm/ppcdebug.h>
23 static long Pci_Interrupt_Count
;
24 static long Pci_Event_Count
;
26 enum XmPciLpEvent_Subtype
{
27 XmPciLpEvent_BusCreated
= 0, // PHB has been created
28 XmPciLpEvent_BusError
= 1, // PHB has failed
29 XmPciLpEvent_BusFailed
= 2, // Msg to Secondary, Primary failed bus
30 XmPciLpEvent_NodeFailed
= 4, // Multi-adapter bridge has failed
31 XmPciLpEvent_NodeRecovered
= 5, // Multi-adapter bridge has recovered
32 XmPciLpEvent_BusRecovered
= 12, // PHB has been recovered
33 XmPciLpEvent_UnQuiesceBus
= 18, // Secondary bus unqiescing
34 XmPciLpEvent_BridgeError
= 21, // Bridge Error
35 XmPciLpEvent_SlotInterrupt
= 22 // Slot interrupt
38 struct XmPciLpEvent_BusInterrupt
{
39 HvBusNumber busNumber
;
40 HvSubBusNumber subBusNumber
;
43 struct XmPciLpEvent_NodeInterrupt
{
44 HvBusNumber busNumber
;
45 HvSubBusNumber subBusNumber
;
50 struct HvLpEvent hvLpEvent
;
53 u64 alignData
; // Align on an 8-byte boundary
57 HvBusNumber busNumber
;
58 HvSubBusNumber subBusNumber
;
62 struct XmPciLpEvent_BusInterrupt busFailed
;
63 struct XmPciLpEvent_BusInterrupt busRecovered
;
64 struct XmPciLpEvent_BusInterrupt busCreated
;
66 struct XmPciLpEvent_NodeInterrupt nodeFailed
;
67 struct XmPciLpEvent_NodeInterrupt nodeRecovered
;
73 static void intReceived(struct XmPciLpEvent
*eventParm
,
74 struct pt_regs
*regsParm
);
76 static void XmPciLpEvent_handler(struct HvLpEvent
*eventParm
,
77 struct pt_regs
*regsParm
)
81 PPCDBG(PPCDBG_BUSWALK
, "XmPciLpEvent_handler, type 0x%x\n",
86 if (eventParm
&& (eventParm
->xType
== HvLpEvent_Type_PciIo
)) {
87 switch (eventParm
->xFlags
.xFunction
) {
88 case HvLpEvent_Function_Int
:
89 intReceived((struct XmPciLpEvent
*)eventParm
, regsParm
);
91 case HvLpEvent_Function_Ack
:
93 "XmPciLpEvent.c: unexpected ack received\n");
97 "XmPciLpEvent.c: unexpected event function %d\n",
98 (int)eventParm
->xFlags
.xFunction
);
101 } else if (eventParm
)
103 "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",
104 (int)eventParm
->xType
);
106 printk(KERN_ERR
"XmPciLpEvent.c: NULL event received\n");
110 static void intReceived(struct XmPciLpEvent
*eventParm
,
111 struct pt_regs
*regsParm
)
115 ++Pci_Interrupt_Count
;
117 PPCDBG(PPCDBG_BUSWALK
, "PCI: XmPciLpEvent.c: intReceived\n");
120 switch (eventParm
->hvLpEvent
.xSubtype
) {
121 case XmPciLpEvent_SlotInterrupt
:
122 irq
= eventParm
->hvLpEvent
.xCorrelationToken
;
123 /* Dispatch the interrupt handlers for this irq */
124 ppc_irq_dispatch_handler(regsParm
, irq
);
125 HvCallPci_eoi(eventParm
->eventData
.slotInterrupt
.busNumber
,
126 eventParm
->eventData
.slotInterrupt
.subBusNumber
,
127 eventParm
->eventData
.slotInterrupt
.deviceId
);
129 /* Ignore error recovery events for now */
130 case XmPciLpEvent_BusCreated
:
131 printk(KERN_INFO
"XmPciLpEvent.c: system bus %d created\n",
132 eventParm
->eventData
.busCreated
.busNumber
);
134 case XmPciLpEvent_BusError
:
135 case XmPciLpEvent_BusFailed
:
136 printk(KERN_INFO
"XmPciLpEvent.c: system bus %d failed\n",
137 eventParm
->eventData
.busFailed
.busNumber
);
139 case XmPciLpEvent_BusRecovered
:
140 case XmPciLpEvent_UnQuiesceBus
:
141 printk(KERN_INFO
"XmPciLpEvent.c: system bus %d recovered\n",
142 eventParm
->eventData
.busRecovered
.busNumber
);
144 case XmPciLpEvent_NodeFailed
:
145 case XmPciLpEvent_BridgeError
:
147 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n",
148 eventParm
->eventData
.nodeFailed
.busNumber
,
149 eventParm
->eventData
.nodeFailed
.subBusNumber
,
150 eventParm
->eventData
.nodeFailed
.deviceId
);
152 case XmPciLpEvent_NodeRecovered
:
154 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n",
155 eventParm
->eventData
.nodeRecovered
.busNumber
,
156 eventParm
->eventData
.nodeRecovered
.subBusNumber
,
157 eventParm
->eventData
.nodeRecovered
.deviceId
);
161 "XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
162 eventParm
->hvLpEvent
.xSubtype
);
168 /* This should be called sometime prior to buswalk (init_IRQ would be good) */
169 int XmPciLpEvent_init()
173 PPCDBG(PPCDBG_BUSWALK
,
174 "XmPciLpEvent_init, Register Event type 0x%04X\n",
175 HvLpEvent_Type_PciIo
);
177 xRc
= HvLpEvent_registerHandler(HvLpEvent_Type_PciIo
,
178 &XmPciLpEvent_handler
);
180 xRc
= HvLpEvent_openPath(HvLpEvent_Type_PciIo
, 0);
183 "XmPciLpEvent.c: open event path failed with rc 0x%x\n",
187 "XmPciLpEvent.c: register handler failed with rc 0x%x\n",