
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This patch adds a pci_get_legacy_ide_irq() function to
include/asm-generic/pci.h that returns the interrupt to use for a PCI IDE
controller that is set to "legacy mode".  It also adds a ppc64 specific
implementation that allows the platform code to provide it's own number. 
Finally, it adds a call to this routine to the amd7xxx driver (instead of
hard coding the numbers) when no interrupt was found.  I decided to fix
individual drivers rather 

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/ide/pci/amd74xx.c   |    4 ++--
 25-akpm/include/asm-generic/pci.h   |    7 +++++++
 25-akpm/include/asm-ppc64/machdep.h |    3 +++
 25-akpm/include/asm-ppc64/pci.h     |   11 ++++++++++-
 4 files changed, 22 insertions(+), 3 deletions(-)

diff -puN drivers/ide/pci/amd74xx.c~add-pci_get_legacy_ide_irq drivers/ide/pci/amd74xx.c
--- 25/drivers/ide/pci/amd74xx.c~add-pci_get_legacy_ide_irq	2004-10-26 00:42:50.205729872 -0700
+++ 25-akpm/drivers/ide/pci/amd74xx.c	2004-10-26 00:42:50.214728504 -0700
@@ -416,8 +416,8 @@ static void __init init_hwif_amd74xx(ide
 {
 	int i;
 
-	if (!hwif->irq)
-		hwif->irq = hwif->channel ? 15 : 14;
+	if (hwif->irq == 0) /* 0 is bogus but will do for now */
+		hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel);
 
 	hwif->autodma = 0;
 
diff -puN include/asm-generic/pci.h~add-pci_get_legacy_ide_irq include/asm-generic/pci.h
--- 25/include/asm-generic/pci.h~add-pci_get_legacy_ide_irq	2004-10-26 00:42:50.206729720 -0700
+++ 25-akpm/include/asm-generic/pci.h	2004-10-26 00:42:50.215728352 -0700
@@ -24,4 +24,11 @@ pcibios_resource_to_bus(struct pci_dev *
 
 #define pcibios_scan_all_fns(a, b)	0
 
+#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	return channel ? 15 : 14;
+}
+#endif /* HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ */
+
 #endif
diff -puN include/asm-ppc64/machdep.h~add-pci_get_legacy_ide_irq include/asm-ppc64/machdep.h
--- 25/include/asm-ppc64/machdep.h~add-pci_get_legacy_ide_irq	2004-10-26 00:42:50.208729416 -0700
+++ 25-akpm/include/asm-ppc64/machdep.h	2004-10-26 00:42:50.215728352 -0700
@@ -119,6 +119,9 @@ struct machdep_calls {
 	/* Check availability of legacy devices like i8042 */
 	int 		(*check_legacy_ioport)(unsigned int baseport);
 
+	/* Get legacy PCI/IDE interrupt mapping */
+	int		(*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
+
 };
 
 extern struct machdep_calls ppc_md;
diff -puN include/asm-ppc64/pci.h~add-pci_get_legacy_ide_irq include/asm-ppc64/pci.h
--- 25/include/asm-ppc64/pci.h~add-pci_get_legacy_ide_irq	2004-10-26 00:42:50.209729264 -0700
+++ 25-akpm/include/asm-ppc64/pci.h	2004-10-26 00:42:50.214728504 -0700
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/dma-mapping.h>
+#include <asm/machdep.h>
 #include <asm/scatterlist.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -20,6 +21,8 @@
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0x10000000
 
+struct pci_dev;
+
 #ifdef CONFIG_PPC_ISERIES
 #define pcibios_scan_all_fns(a, b)	0
 #else
@@ -36,7 +39,13 @@ static inline void pcibios_penalize_isa_
 	/* We don't do dynamic PCI IRQ allocation */
 }
 
-struct pci_dev;
+#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
+static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
+{
+	if (ppc_md.pci_get_legacy_ide_irq)
+		return ppc_md.pci_get_legacy_ide_irq(dev, channel);
+	return channel ? 15 : 14;
+}
 
 #define HAVE_ARCH_PCI_MWI 1
 static inline int pcibios_prep_mwi(struct pci_dev *dev)
_
