]> git.sur5r.net Git - u-boot/blobdiff - board/mpl/common/pci.c
Merge branch 'next' of git://git.denx.de/u-boot-mpc83xx
[u-boot] / board / mpl / common / pci.c
index d1965f95f640090934c4166a32fa16da5534e7d4..cd969cb5182d4e3bb6a9b4dcaf739f2495f18ae0 100644 (file)
@@ -1,23 +1,6 @@
-/*-----------------------------------------------------------------------------+
-|
-|       This source code has been made available to you by IBM on an AS-IS
-|       basis.  Anyone receiving this source is licensed under IBM
-|       copyrights to use it in any way he or she deems fit, including
-|       copying it, modifying it, compiling it, and redistributing it either
-|       with or without modifications.  No license under IBM patents or
-|       patent applications is to be implied by the copyright license.
-|
-|       Any user of this software should understand that IBM cannot provide
-|       technical support for this software and will not be responsible for
-|       any consequences resulting from the use of this software.
-|
-|       Any person who transfers this source code or any derivative work
-|       must include the IBM copyright notice, this paragraph, and the
-|       preceding two paragraphs in the transferred software.
-|
-|       COPYRIGHT   I B M   CORPORATION 1995
-|       LICENSED MATERIAL  -  PROGRAM PROPERTY OF I B M
-+-----------------------------------------------------------------------------*/
+/*
+ * SPDX-License-Identifier:    GPL-2.0 IBM-pibs
+ */
 /*
  * Adapted for PIP405 03.07.01
  * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
@@ -32,7 +15,7 @@
 #ifdef CONFIG_405GP
 #ifdef CONFIG_PCI
 
-#undef DEBUG
+DECLARE_GLOBAL_DATA_PTR;
 
 #include "piix4_pci.h"
 #include "pci_parts.h"
@@ -65,21 +48,22 @@ void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev,
 static void pci_pip405_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
 {
        unsigned char int_line = 0xff;
+       unsigned char pin;
        /*
         * Write pci interrupt line register
         */
        if(PCI_DEV(dev)==0) /* Device0 = PPC405 -> skip */
                return;
-       if(PCI_FUNC(dev)==0)
-       {
-               /* assuming all function 0 are using their INTA# Pin*/
-               int_line=PCI_IRQ_VECTOR(dev);
-               pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
+       pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &pin);
+       if ((pin == 0) || (pin > 4))
+           return;
+
+       int_line = ((PCI_DEV(dev) + (pin-1) + 10) % 4) + 28;
+       pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
 #ifdef DEBUG
-               printf("Fixup IRQ: dev %d (%x) int line %d 0x%x\n",
-                      PCI_DEV(dev),dev,int_line,int_line);
+       printf("Fixup IRQ: dev %d (%x) int line %d 0x%x\n",
+              PCI_DEV(dev),dev,int_line,int_line);
 #endif
-       }
 }
 
 extern void pci_405gp_init(struct pci_controller *hose);
@@ -90,11 +74,15 @@ static struct pci_controller hose = {
   fixup_irq: pci_pip405_fixup_irq,
 };
 
-void pci_init(void)
+
+void pci_init_board(void)
 {
        /*we want the ptrs to RAM not flash (ie don't use init list)*/
        hose.fixup_irq    = pci_pip405_fixup_irq;
        hose.config_table = pci_pip405_config_table;
+#ifdef DEBUG
+       printf("Init PCI: fixup_irq=%p config_table=%p hose=%p\n",pci_pip405_fixup_irq,pci_pip405_config_table,hose);
+#endif
        pci_405gp_init(&hose);
 }