]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/esd/cpci750/pci.c
Coding Style cleanup: replace leading SPACEs by TABs
[karo-tx-uboot.git] / board / esd / cpci750 / pci.c
index cbe766ffd232e708e44cfe9848d9a601f1d0d201..59f170a0df7108e79945bec78db2cf0072c5a8d7 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 /* PCI.c - PCI functions */
 
 #ifdef CONFIG_PCI
 #include <pci.h>
 
-#ifdef CONFIG_PCI_PNP
-void pciauto_config_init(struct pci_controller *hose);
-int  pciauto_region_allocate(struct pci_region* res, unsigned int size, unsigned int *bar);
-#endif
-
 #include "../../Marvell/include/pci.h"
 
 #undef DEBUG
@@ -66,13 +44,13 @@ static void gt_pci_bus_mode_display (PCI_HOST host)
                printf ("PCI %d bus mode: Conventional PCI\n", host);
                break;
        case 1:
-               printf ("PCI %d bus mode: 66 Mhz PCIX\n", host);
+               printf ("PCI %d bus mode: 66 MHz PCIX\n", host);
                break;
        case 2:
-               printf ("PCI %d bus mode: 100 Mhz PCIX\n", host);
+               printf ("PCI %d bus mode: 100 MHz PCIX\n", host);
                break;
        case 3:
-               printf ("PCI %d bus mode: 133 Mhz PCIX\n", host);
+               printf ("PCI %d bus mode: 133 MHz PCIX\n", host);
                break;
        default:
                printf ("Unknown BUS %d\n", mode);
@@ -768,11 +746,12 @@ static int gt_read_config_dword (struct pci_controller *hose,
        int bus = PCI_BUS (dev);
 
        if ((bus == local_buses[0]) || (bus == local_buses[1])) {
-               *value = pciReadConfigReg ((PCI_HOST) hose->cfg_addr, offset,
+               *value = pciReadConfigReg ((PCI_HOST) hose->cfg_addr,
+                                          offset | (PCI_FUNC(dev) << 8),
                                           PCI_DEV (dev));
        } else {
-               *value = pciOverBridgeReadConfigReg ((PCI_HOST) hose->
-                                                    cfg_addr, offset,
+               *value = pciOverBridgeReadConfigReg ((PCI_HOST) hose->cfg_addr,
+                                                    offset | (PCI_FUNC(dev) << 8),
                                                     PCI_DEV (dev), bus);
        }
 
@@ -785,11 +764,13 @@ static int gt_write_config_dword (struct pci_controller *hose,
        int bus = PCI_BUS (dev);
 
        if ((bus == local_buses[0]) || (bus == local_buses[1])) {
-               pciWriteConfigReg ((PCI_HOST) hose->cfg_addr, offset,
+               pciWriteConfigReg ((PCI_HOST) hose->cfg_addr,
+                                  offset | (PCI_FUNC(dev) << 8),
                                   PCI_DEV (dev), value);
        } else {
                pciOverBridgeWriteConfigReg ((PCI_HOST) hose->cfg_addr,
-                                            offset, PCI_DEV (dev), bus,
+                                            offset | (PCI_FUNC(dev) << 8),
+                                            PCI_DEV (dev), bus,
                                             value);
        }
        return 0;
@@ -803,6 +784,9 @@ static void gt_setup_ide (struct pci_controller *hose,
        u32 bar_response, bar_value;
        int bar;
 
+       if (CPCI750_SLAVE_TEST != 0)
+               return;
+
        for (bar = 0; bar < 6; bar++) {
                /*ronen different function for 3rd bank. */
                unsigned int offset =
@@ -829,6 +813,9 @@ static void gt_setup_cpcidvi (struct pci_controller *hose,
 {
        u32               bar_value, pci_response;
 
+       if (CPCI750_SLAVE_TEST != 0)
+               return;
+
        pci_hose_read_config_dword (hose, dev, PCI_COMMAND, &pci_response);
        pci_hose_write_config_dword (hose, dev, PCI_BASE_ADDRESS_0, 0xffffffff);
        pci_hose_read_config_dword (hose, dev, PCI_BASE_ADDRESS_0, &pci_response);
@@ -907,6 +894,7 @@ struct pci_controller pci1_hose = {
 void pci_init_board (void)
 {
        unsigned int command;
+       unsigned int slave;
 #ifdef CONFIG_PCI_PNP
        unsigned int bar;
 #endif
@@ -918,6 +906,8 @@ void pci_init_board (void)
        gt_cpcidvi_rom.base = 0;
 #endif
 
+       slave = CPCI750_SLAVE_TEST;
+
        pci0_hose.config_table = gt_config_table;
        pci1_hose.config_table = gt_config_table;
 
@@ -953,27 +943,40 @@ void pci_init_board (void)
        pci0_hose.cfg_addr = (unsigned int *) PCI_HOST0;
 
        pci_register_hose (&pci0_hose);
-       pciArbiterEnable (PCI_HOST0);
-       pciParkingDisable (PCI_HOST0, 1, 1, 1, 1, 1, 1, 1);
-       command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
-       command |= PCI_COMMAND_MASTER;
-       pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
-       command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
-       command |= PCI_COMMAND_MEMORY;
-       pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
+       if (slave == 0) {
+               pciArbiterEnable (PCI_HOST0);
+               pciParkingDisable (PCI_HOST0, 1, 1, 1, 1, 1, 1, 1);
+               command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
+               command |= PCI_COMMAND_MASTER;
+               pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
+               command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
+               command |= PCI_COMMAND_MEMORY;
+               pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
 
 #ifdef CONFIG_PCI_PNP
-       pciauto_config_init(&pci0_hose);
-       pciauto_region_allocate(pci0_hose.pci_io, 0x400, &bar);
+               pciauto_config_init(&pci0_hose);
+               pciauto_region_allocate(pci0_hose.pci_io, 0x400, &bar);
 #endif
 #ifdef CONFIG_PCI_SCAN_SHOW
-       printf("PCI:   Bus Dev VenId DevId Class Int\n");
+               printf("PCI:   Bus Dev VenId DevId Class Int\n");
 #endif
-       pci0_hose.last_busno = pci_hose_scan_bus (&pci0_hose, pci0_hose.first_busno);
+               pci0_hose.last_busno = pci_hose_scan_bus (&pci0_hose,
+                                                         pci0_hose.first_busno);
 
 #ifdef DEBUG
-       gt_pci_bus_mode_display (PCI_HOST1);
+               gt_pci_bus_mode_display (PCI_HOST1);
 #endif
+       } else {
+               pciArbiterDisable (PCI_HOST0);
+               pciParkingDisable (PCI_HOST0, 1, 1, 1, 1, 1, 1, 1);
+               command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
+               command |= PCI_COMMAND_MASTER;
+               pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
+               command = pciReadConfigReg (PCI_HOST0, PCI_COMMAND, SELF);
+               command |= PCI_COMMAND_MEMORY;
+               pciWriteConfigReg (PCI_HOST0, PCI_COMMAND, SELF, command);
+               pci0_hose.last_busno = pci0_hose.first_busno;
+       }
        pci1_hose.first_busno = pci0_hose.last_busno + 1;
        pci1_hose.last_busno = 0xff;
        pci1_hose.current_busno = pci1_hose.first_busno;