]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - arch/ppc64/kernel/iSeries_irq.c
[PATCH] ppc64 iSeries: remove XmPciLpEvent.c
[linux-2.6.git] / arch / ppc64 / kernel / iSeries_irq.c
index f831d259dbb7707715bad82a55af8a85ad7afe67..96a1f8cd67e775cd316c492a9d8110940ef7559e 100644 (file)
@@ -1,27 +1,29 @@
-/************************************************************************/
-/* This module supports the iSeries PCI bus interrupt handling          */
-/* Copyright (C) 20yy  <Robert L Holtorf> <IBM Corp>                    */
-/*                                                                      */
-/* This program is free software; you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation; either version 2 of the License, or    */
-/* (at your option) any later version.                                  */
-/*                                                                      */
-/* This program is distributed in the hope that it will be useful,      */ 
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
-/* GNU General Public License for more details.                         */
-/*                                                                      */
-/* You should have received a copy of the GNU General Public License    */ 
-/* along with this program; if not, write to the:                       */
-/* Free Software Foundation, Inc.,                                      */ 
-/* 59 Temple Place, Suite 330,                                          */ 
-/* Boston, MA  02111-1307  USA                                          */
-/************************************************************************/
-/* Change Activity:                                                     */
-/*   Created, December 13, 2000 by Wayne Holm                           */ 
-/* End Change Activity                                                  */
-/************************************************************************/
+/*
+ * This module supports the iSeries PCI bus interrupt handling
+ * Copyright (C) 20yy  <Robert L Holtorf> <IBM Corp>
+ * Copyright (C) 2004-2005 IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the:
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330,
+ * Boston, MA  02111-1307  USA
+ *
+ * Change Activity:
+ *   Created, December 13, 2000 by Wayne Holm
+ * End Change Activity
+ */
+#include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/threads.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
 #include <linux/ide.h>
-
 #include <linux/irq.h>
 #include <linux/spinlock.h>
-#include <asm/ppcdebug.h>
 
+#include <asm/ppcdebug.h>
+#include <asm/iSeries/HvTypes.h>
+#include <asm/iSeries/HvLpEvent.h>
 #include <asm/iSeries/HvCallPci.h>
 #include <asm/iSeries/HvCallXm.h>
 #include <asm/iSeries/iSeries_irq.h>
-#include <asm/iSeries/XmPciLpEvent.h>
-
-static unsigned int iSeries_startup_IRQ(unsigned int irq);
-static void iSeries_shutdown_IRQ(unsigned int irq);
-static void iSeries_enable_IRQ(unsigned int irq);
-static void iSeries_disable_IRQ(unsigned int irq);
-static void iSeries_end_IRQ(unsigned int irq);
-
-static hw_irq_controller iSeries_IRQ_handler = {
-       .typename = "iSeries irq controller",
-       .startup = iSeries_startup_IRQ,
-       .shutdown = iSeries_shutdown_IRQ,
-       .enable = iSeries_enable_IRQ,
-       .disable = iSeries_disable_IRQ,
-       .end = iSeries_end_IRQ
-};
 
 /* This maps virtual irq numbers to real irqs */
 unsigned int virt_irq_to_real_map[NR_IRQS];
@@ -62,6 +49,169 @@ unsigned int virt_irq_to_real_map[NR_IRQS];
 /* Note: the pcnet32 driver assumes irq numbers < 2 aren't valid. :( */
 static int next_virtual_irq = 2;
 
+static long Pci_Interrupt_Count;
+static long Pci_Event_Count;
+
+enum XmPciLpEvent_Subtype {
+       XmPciLpEvent_BusCreated         = 0,    // PHB has been created
+       XmPciLpEvent_BusError           = 1,    // PHB has failed
+       XmPciLpEvent_BusFailed          = 2,    // Msg to Secondary, Primary failed bus
+       XmPciLpEvent_NodeFailed         = 4,    // Multi-adapter bridge has failed
+       XmPciLpEvent_NodeRecovered      = 5,    // Multi-adapter bridge has recovered
+       XmPciLpEvent_BusRecovered       = 12,   // PHB has been recovered
+       XmPciLpEvent_UnQuiesceBus       = 18,   // Secondary bus unqiescing
+       XmPciLpEvent_BridgeError        = 21,   // Bridge Error
+       XmPciLpEvent_SlotInterrupt      = 22    // Slot interrupt
+};
+
+struct XmPciLpEvent_BusInterrupt {
+       HvBusNumber     busNumber;
+       HvSubBusNumber  subBusNumber;
+};
+
+struct XmPciLpEvent_NodeInterrupt {
+       HvBusNumber     busNumber;
+       HvSubBusNumber  subBusNumber;
+       HvAgentId       deviceId;
+};
+
+struct XmPciLpEvent {
+       struct HvLpEvent hvLpEvent;
+
+       union {
+               u64 alignData;                  // Align on an 8-byte boundary
+
+               struct {
+                       u32             fisr;
+                       HvBusNumber     busNumber;
+                       HvSubBusNumber  subBusNumber;
+                       HvAgentId       deviceId;
+               } slotInterrupt;
+
+               struct XmPciLpEvent_BusInterrupt busFailed;
+               struct XmPciLpEvent_BusInterrupt busRecovered;
+               struct XmPciLpEvent_BusInterrupt busCreated;
+
+               struct XmPciLpEvent_NodeInterrupt nodeFailed;
+               struct XmPciLpEvent_NodeInterrupt nodeRecovered;
+
+       } eventData;
+
+};
+
+static void intReceived(struct XmPciLpEvent *eventParm,
+               struct pt_regs *regsParm)
+{
+       int irq;
+
+       ++Pci_Interrupt_Count;
+#if 0
+       PPCDBG(PPCDBG_BUSWALK, "PCI: XmPciLpEvent.c: intReceived\n");
+#endif
+
+       switch (eventParm->hvLpEvent.xSubtype) {
+       case XmPciLpEvent_SlotInterrupt:
+               irq = eventParm->hvLpEvent.xCorrelationToken;
+               /* Dispatch the interrupt handlers for this irq */
+               ppc_irq_dispatch_handler(regsParm, irq);
+               HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
+                       eventParm->eventData.slotInterrupt.subBusNumber,
+                       eventParm->eventData.slotInterrupt.deviceId);
+               break;
+               /* Ignore error recovery events for now */
+       case XmPciLpEvent_BusCreated:
+               printk(KERN_INFO "XmPciLpEvent.c: system bus %d created\n",
+                       eventParm->eventData.busCreated.busNumber);
+               break;
+       case XmPciLpEvent_BusError:
+       case XmPciLpEvent_BusFailed:
+               printk(KERN_INFO "XmPciLpEvent.c: system bus %d failed\n",
+                       eventParm->eventData.busFailed.busNumber);
+               break;
+       case XmPciLpEvent_BusRecovered:
+       case XmPciLpEvent_UnQuiesceBus:
+               printk(KERN_INFO "XmPciLpEvent.c: system bus %d recovered\n",
+                       eventParm->eventData.busRecovered.busNumber);
+               break;
+       case XmPciLpEvent_NodeFailed:
+       case XmPciLpEvent_BridgeError:
+               printk(KERN_INFO
+                       "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n",
+                       eventParm->eventData.nodeFailed.busNumber,
+                       eventParm->eventData.nodeFailed.subBusNumber,
+                       eventParm->eventData.nodeFailed.deviceId);
+               break;
+       case XmPciLpEvent_NodeRecovered:
+               printk(KERN_INFO
+                       "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n",
+                       eventParm->eventData.nodeRecovered.busNumber,
+                       eventParm->eventData.nodeRecovered.subBusNumber,
+                       eventParm->eventData.nodeRecovered.deviceId);
+               break;
+       default:
+               printk(KERN_ERR
+                       "XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
+                       eventParm->hvLpEvent.xSubtype);
+               break;
+       }
+}
+
+static void XmPciLpEvent_handler(struct HvLpEvent *eventParm,
+               struct pt_regs *regsParm)
+{
+#ifdef CONFIG_PCI
+#if 0
+       PPCDBG(PPCDBG_BUSWALK, "XmPciLpEvent_handler, type 0x%x\n",
+                       eventParm->xType);
+#endif
+       ++Pci_Event_Count;
+
+       if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) {
+               switch (eventParm->xFlags.xFunction) {
+               case HvLpEvent_Function_Int:
+                       intReceived((struct XmPciLpEvent *)eventParm, regsParm);
+                       break;
+               case HvLpEvent_Function_Ack:
+                       printk(KERN_ERR
+                               "XmPciLpEvent.c: unexpected ack received\n");
+                       break;
+               default:
+                       printk(KERN_ERR
+                               "XmPciLpEvent.c: unexpected event function %d\n",
+                               (int)eventParm->xFlags.xFunction);
+                       break;
+               }
+       } else if (eventParm)
+               printk(KERN_ERR
+                       "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",
+                       (int)eventParm->xType);
+       else
+               printk(KERN_ERR "XmPciLpEvent.c: NULL event received\n");
+#endif
+}
+
+/* This should be called sometime prior to buswalk (init_IRQ would be good) */
+int XmPciLpEvent_init()
+{
+       int xRc;
+
+       PPCDBG(PPCDBG_BUSWALK,
+                       "XmPciLpEvent_init, Register Event type 0x%04X\n",
+                       HvLpEvent_Type_PciIo);
+
+       xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
+                       &XmPciLpEvent_handler);
+       if (xRc == 0) {
+               xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
+               if (xRc != 0)
+                       printk(KERN_ERR "XmPciLpEvent.c: open event path "
+                                       "failed with rc 0x%x\n", xRc);
+       } else
+               printk(KERN_ERR "XmPciLpEvent.c: register handler "
+                               "failed with rc 0x%x\n", xRc);
+       return xRc;
+}
+
 /* This is called by init_IRQ.  set in ppc_md.init_IRQ by iSeries_setup.c */
 void __init iSeries_init_IRQ(void)
 {
@@ -69,30 +219,32 @@ void __init iSeries_init_IRQ(void)
        XmPciLpEvent_init();
 }
 
+#define REAL_IRQ_TO_BUS(irq)   ((((irq) >> 6) & 0xff) + 1)
+#define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1)
+#define REAL_IRQ_TO_FUNC(irq)  ((irq) & 7)
+
 /*
- * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot
- * It calculates the irq value for the slot.
- * Note that subBusNumber is always 0 (at the moment at least).
+ * This will be called by device drivers (via enable_IRQ)
+ * to enable INTA in the bridge interrupt status register.
  */
-int __init iSeries_allocate_IRQ(HvBusNumber busNumber,
-               HvSubBusNumber subBusNumber, HvAgentId deviceId)
+static void iSeries_enable_IRQ(unsigned int irq)
 {
-       unsigned int realirq, virtirq;
-       u8 idsel = (deviceId >> 4);
-       u8 function = deviceId & 7;
+       u32 bus, deviceId, function, mask;
+       const u32 subBus = 0;
+       unsigned int rirq = virt_irq_to_real_map[irq];
 
-       virtirq = next_virtual_irq++;
-       realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function;
-       virt_irq_to_real_map[virtirq] = realirq;
+       /* The IRQ has already been locked by the caller */
+       bus = REAL_IRQ_TO_BUS(rirq);
+       function = REAL_IRQ_TO_FUNC(rirq);
+       deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
 
-       irq_desc[virtirq].handler = &iSeries_IRQ_handler;
-       return virtirq;
+       /* Unmask secondary INTA */
+       mask = 0x80000000;
+       HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
+       PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
+                       bus, subBus, deviceId, irq);
 }
 
-#define REAL_IRQ_TO_BUS(irq)   ((((irq) >> 6) & 0xff) + 1)
-#define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1)
-#define REAL_IRQ_TO_FUNC(irq)  ((irq) & 7)
-
 /* This is called by iSeries_activate_IRQs */
 static unsigned int iSeries_startup_IRQ(unsigned int irq)
 {
@@ -131,7 +283,7 @@ void __init iSeries_activate_IRQs()
                        desc->handler->startup(irq);
                        spin_unlock_irqrestore(&desc->lock, flags);
                }
-       }
+       }
 }
 
 /*  this is not called anywhere currently */
@@ -173,29 +325,7 @@ static void iSeries_disable_IRQ(unsigned int irq)
        mask = 0x80000000;
        HvCallPci_maskInterrupts(bus, subBus, deviceId, mask);
        PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
-              bus, subBus, deviceId, irq);
-}
-
-/*
- * This will be called by device drivers (via enable_IRQ)
- * to enable INTA in the bridge interrupt status register.
- */
-static void iSeries_enable_IRQ(unsigned int irq)
-{
-       u32 bus, deviceId, function, mask;
-       const u32 subBus = 0;
-       unsigned int rirq = virt_irq_to_real_map[irq];
-
-       /* The IRQ has already been locked by the caller */
-       bus = REAL_IRQ_TO_BUS(rirq);
-       function = REAL_IRQ_TO_FUNC(rirq);
-       deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
-
-       /* Unmask secondary INTA */
-       mask = 0x80000000;
-       HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
-       PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
-              bus, subBus, deviceId, irq);
+                       bus, subBus, deviceId, irq);
 }
 
 /*
@@ -207,3 +337,32 @@ static void iSeries_enable_IRQ(unsigned int irq)
 static void iSeries_end_IRQ(unsigned int irq)
 {
 }
+
+static hw_irq_controller iSeries_IRQ_handler = {
+       .typename = "iSeries irq controller",
+       .startup = iSeries_startup_IRQ,
+       .shutdown = iSeries_shutdown_IRQ,
+       .enable = iSeries_enable_IRQ,
+       .disable = iSeries_disable_IRQ,
+       .end = iSeries_end_IRQ
+};
+
+/*
+ * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot
+ * It calculates the irq value for the slot.
+ * Note that subBusNumber is always 0 (at the moment at least).
+ */
+int __init iSeries_allocate_IRQ(HvBusNumber busNumber,
+               HvSubBusNumber subBusNumber, HvAgentId deviceId)
+{
+       unsigned int realirq, virtirq;
+       u8 idsel = (deviceId >> 4);
+       u8 function = deviceId & 7;
+
+       virtirq = next_virtual_irq++;
+       realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function;
+       virt_irq_to_real_map[virtirq] = realirq;
+
+       irq_desc[virtirq].handler = &iSeries_IRQ_handler;
+       return virtirq;
+}