]> 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 37c7150423c04bf964503f0ce9e6469fecf3d454..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
@@ -46,8 +24,8 @@ static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = {
 
 #ifdef CONFIG_USE_CPCIDVI
 typedef struct {
-        unsigned int base;
-        unsigned int init;
+       unsigned int base;
+       unsigned int init;
 } GT_CPCIDVI_ROM_T;
 
 static GT_CPCIDVI_ROM_T gt_cpcidvi_rom = {0, 0};
@@ -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);
@@ -133,20 +111,20 @@ static const unsigned int pci_p2p_configuration[] = {
 
 /********************************************************************
 * pciWriteConfigReg - Write to a PCI configuration register
-*                    - Make sure the GT is configured as a master before writing
-*                      to another device on the PCI.
-*                    - The function takes care of Big/Little endian conversion.
+*                  - Make sure the GT is configured as a master before writing
+*                    to another device on the PCI.
+*                  - The function takes care of Big/Little endian conversion.
 *
 *
 * Inputs:   unsigned int regOffset: The register offset as it apears in the GT spec
-*                   (or any other PCI device spec)
-*           pciDevNum: The device number needs to be addressed.
+*                 (or any other PCI device spec)
+*          pciDevNum: The device number needs to be addressed.
 *
 *  Configuration Address 0xCF8:
 *
-*       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+*      31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
 *  |congif|Reserved|  Bus |Device|Function|Register|00|
-*  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+*  |Enable|       |Number|Number| Number | Number |  |    <=field Name
 *
 *********************************************************************/
 void pciWriteConfigReg (PCI_HOST host, unsigned int regOffset,
@@ -180,20 +158,20 @@ void pciWriteConfigReg (PCI_HOST host, unsigned int regOffset,
 
 /********************************************************************
 * pciReadConfigReg  - Read from a PCI0 configuration register
-*                    - Make sure the GT is configured as a master before reading
-*                     from another device on the PCI.
-*                   - The function takes care of Big/Little endian conversion.
+*                  - Make sure the GT is configured as a master before reading
+*                    from another device on the PCI.
+*                  - The function takes care of Big/Little endian conversion.
 * INPUTS:   regOffset: The register offset as it apears in the GT spec (or PCI
-*                        spec)
-*           pciDevNum: The device number needs to be addressed.
+*                      spec)
+*          pciDevNum: The device number needs to be addressed.
 * RETURNS: data , if the data == 0xffffffff check the master abort bit in the
-*                 cause register to make sure the data is valid
+*                cause register to make sure the data is valid
 *
 *  Configuration Address 0xCF8:
 *
-*       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+*      31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
 *  |congif|Reserved|  Bus |Device|Function|Register|00|
-*  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+*  |Enable|       |Number|Number| Number | Number |  |    <=field Name
 *
 *********************************************************************/
 unsigned int pciReadConfigReg (PCI_HOST host, unsigned int regOffset,
@@ -228,21 +206,21 @@ unsigned int pciReadConfigReg (PCI_HOST host, unsigned int regOffset,
 
 /********************************************************************
 * pciOverBridgeWriteConfigReg - Write to a PCI configuration register where
-*                               the agent is placed on another Bus. For more
-*                               information read P2P in the PCI spec.
+*                              the agent is placed on another Bus. For more
+*                              information read P2P in the PCI spec.
 *
 * Inputs:   unsigned int regOffset - The register offset as it apears in the
-*           GT spec (or any other PCI device spec).
-*           unsigned int pciDevNum - The device number needs to be addressed.
-*           unsigned int busNum - On which bus does the Target agent connect
-*                                 to.
-*           unsigned int data - data to be written.
+*          GT spec (or any other PCI device spec).
+*          unsigned int pciDevNum - The device number needs to be addressed.
+*          unsigned int busNum - On which bus does the Target agent connect
+*                                to.
+*          unsigned int data - data to be written.
 *
 *  Configuration Address 0xCF8:
 *
-*       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+*      31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
 *  |congif|Reserved|  Bus |Device|Function|Register|01|
-*  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+*  |Enable|       |Number|Number| Number | Number |  |    <=field Name
 *
 *  The configuration Address is configure as type-I (bits[1:0] = '01') due to
 *   PCI spec referring to P2P.
@@ -273,23 +251,23 @@ void pciOverBridgeWriteConfigReg (PCI_HOST host,
 
 /********************************************************************
 * pciOverBridgeReadConfigReg  - Read from a PCIn configuration register where
-*                               the agent target locate on another PCI bus.
-*                             - Make sure the GT is configured as a master
-*                               before reading from another device on the PCI.
-*                             - The function takes care of Big/Little endian
-*                               conversion.
+*                              the agent target locate on another PCI bus.
+*                            - Make sure the GT is configured as a master
+*                              before reading from another device on the PCI.
+*                            - The function takes care of Big/Little endian
+*                              conversion.
 * INPUTS:   regOffset: The register offset as it apears in the GT spec (or PCI
-*                        spec). (configuration register offset.)
-*           pciDevNum: The device number needs to be addressed.
-*           busNum: the Bus number where the agent is place.
+*                       spec). (configuration register offset.)
+*          pciDevNum: The device number needs to be addressed.
+*          busNum: the Bus number where the agent is place.
 * RETURNS: data , if the data == 0xffffffff check the master abort bit in the
-*                 cause register to make sure the data is valid
+*                cause register to make sure the data is valid
 *
 *  Configuration Address 0xCF8:
 *
-*       31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
+*      31 30    24 23  16 15  11 10     8 7      2  0     <=bit Number
 *  |congif|Reserved|  Bus |Device|Function|Register|01|
-*  |Enable|        |Number|Number| Number | Number |  |    <=field Name
+*  |Enable|       |Number|Number| Number | Number |  |    <=field Name
 *
 *********************************************************************/
 unsigned int pciOverBridgeReadConfigReg (PCI_HOST host,
@@ -393,7 +371,7 @@ static unsigned int pciGetRemapOffset (PCI_HOST host, PCI_REGION region)
 
 /********************************************************************
 * pciGetBaseAddress - Gets the base address of a PCI.
-*           - If the PCI size is 0 then this base address has no meaning!!!
+*          - If the PCI size is 0 then this base address has no meaning!!!
 *
 *
 * INPUT:   Bus, Region - The bus and region we ask for its base address.
@@ -501,13 +479,13 @@ void pciMapMemoryBank (PCI_HOST host, MEMORY_BANK bank,
 
 /********************************************************************
 * pciSetRegionFeatures - This function modifys one of the 8 regions with
-*                         feature bits given as an input.
-*                       - Be advised to check the spec before modifying them.
+*                        feature bits given as an input.
+*                      - Be advised to check the spec before modifying them.
 * Inputs: PCI_PROTECT_REGION region - one of the eight regions.
-*         unsigned int features - See file: pci.h there are defintion for those
-*                                 region features.
-*         unsigned int baseAddress - The region base Address.
-*         unsigned int topAddress - The region top Address.
+*        unsigned int features - See file: pci.h there are defintion for those
+*                                region features.
+*        unsigned int baseAddress - The region base Address.
+*        unsigned int topAddress - The region top Address.
 * Returns: false if one of the parameters is erroneous true otherwise.
 *********************************************************************/
 bool pciSetRegionFeatures (PCI_HOST host, PCI_ACCESS_REGIONS region,
@@ -541,7 +519,7 @@ bool pciSetRegionFeatures (PCI_HOST host, PCI_ACCESS_REGIONS region,
 
 /********************************************************************
 * pciDisableAccessRegion - Disable The given Region by writing MAX size
-*                           to its low Address and MIN size to its high Address.
+*                          to its low Address and MIN size to its high Address.
 *
 * Inputs:   PCI_ACCESS_REGIONS region - The region we to be Disabled.
 * Returns:  N/A.
@@ -588,12 +566,12 @@ bool pciArbiterDisable (PCI_HOST host)
 * pciSetArbiterAgentsPriority - Priority setup for the PCI agents (Hi or Low)
 *
 * Inputs:   PCI_AGENT_PRIO internalAgent - priotity for internal agent.
-*           PCI_AGENT_PRIO externalAgent0 - priotity for external#0 agent.
-*           PCI_AGENT_PRIO externalAgent1 - priotity for external#1 agent.
-*           PCI_AGENT_PRIO externalAgent2 - priotity for external#2 agent.
-*           PCI_AGENT_PRIO externalAgent3 - priotity for external#3 agent.
-*           PCI_AGENT_PRIO externalAgent4 - priotity for external#4 agent.
-*           PCI_AGENT_PRIO externalAgent5 - priotity for external#5 agent.
+*          PCI_AGENT_PRIO externalAgent0 - priotity for external#0 agent.
+*          PCI_AGENT_PRIO externalAgent1 - priotity for external#1 agent.
+*          PCI_AGENT_PRIO externalAgent2 - priotity for external#2 agent.
+*          PCI_AGENT_PRIO externalAgent3 - priotity for external#3 agent.
+*          PCI_AGENT_PRIO externalAgent4 - priotity for external#4 agent.
+*          PCI_AGENT_PRIO externalAgent5 - priotity for external#5 agent.
 * Returns:  true
 *********************************************************************/
 bool pciSetArbiterAgentsPriority (PCI_HOST host, PCI_AGENT_PRIO internalAgent,
@@ -619,17 +597,17 @@ bool pciSetArbiterAgentsPriority (PCI_HOST host, PCI_AGENT_PRIO internalAgent,
 
 /********************************************************************
 * pciParkingDisable - Park on last option disable, with this function you can
-*                      disable the park on last mechanism for each agent.
-*                      disabling this option for all agents results parking
-*                      on the internal master.
+*                     disable the park on last mechanism for each agent.
+*                     disabling this option for all agents results parking
+*                     on the internal master.
 *
 * Inputs: PCI_AGENT_PARK internalAgent -  parking Disable for internal agent.
-*         PCI_AGENT_PARK externalAgent0 - parking Disable for external#0 agent.
-*         PCI_AGENT_PARK externalAgent1 - parking Disable for external#1 agent.
-*         PCI_AGENT_PARK externalAgent2 - parking Disable for external#2 agent.
-*         PCI_AGENT_PARK externalAgent3 - parking Disable for external#3 agent.
-*         PCI_AGENT_PARK externalAgent4 - parking Disable for external#4 agent.
-*         PCI_AGENT_PARK externalAgent5 - parking Disable for external#5 agent.
+*        PCI_AGENT_PARK externalAgent0 - parking Disable for external#0 agent.
+*        PCI_AGENT_PARK externalAgent1 - parking Disable for external#1 agent.
+*        PCI_AGENT_PARK externalAgent2 - parking Disable for external#2 agent.
+*        PCI_AGENT_PARK externalAgent3 - parking Disable for external#3 agent.
+*        PCI_AGENT_PARK externalAgent4 - parking Disable for external#4 agent.
+*        PCI_AGENT_PARK externalAgent5 - parking Disable for external#5 agent.
 * Returns:  true
 *********************************************************************/
 bool pciParkingDisable (PCI_HOST host, PCI_AGENT_PARK internalAgent,
@@ -655,11 +633,11 @@ bool pciParkingDisable (PCI_HOST host, PCI_AGENT_PARK internalAgent,
 
 /********************************************************************
 * pciEnableBrokenAgentDetection - A master is said to be broken if it fails to
-*                       respond to grant assertion within a window specified in
-*                       the input value: 'brokenValue'.
+*                      respond to grant assertion within a window specified in
+*                      the input value: 'brokenValue'.
 *
 * Inputs: unsigned char brokenValue -  A value which limits the Master to hold the
-*                       grant without asserting frame.
+*                      grant without asserting frame.
 * Returns:  Error for illegal broken value otherwise true.
 *********************************************************************/
 bool pciEnableBrokenAgentDetection (PCI_HOST host, unsigned char brokenValue)
@@ -678,9 +656,9 @@ bool pciEnableBrokenAgentDetection (PCI_HOST host, unsigned char brokenValue)
 
 /********************************************************************
 * pciDisableBrokenAgentDetection - This function disable the Broken agent
-*                           Detection mechanism.
-*                           NOTE: This operation may cause a dead lock on the
-*                           pci0 arbitration.
+*                          Detection mechanism.
+*                          NOTE: This operation may cause a dead lock on the
+*                          pci0 arbitration.
 *
 * Inputs:   N/A
 * Returns:  true.
@@ -697,15 +675,15 @@ bool pciDisableBrokenAgentDetection (PCI_HOST host)
 
 /********************************************************************
 * pciP2PConfig - This function set the PCI_n P2P configurate.
-*                 For more information on the P2P read PCI spec.
+*                For more information on the P2P read PCI spec.
 *
 * Inputs:  unsigned int SecondBusLow - Secondery PCI interface Bus Range Lower
-*                                      Boundry.
-*          unsigned int SecondBusHigh - Secondry PCI interface Bus Range upper
-*                                      Boundry.
-*          unsigned int busNum - The CPI bus number to which the PCI interface
-*                                      is connected.
-*          unsigned int devNum - The PCI interface's device number.
+*                                     Boundry.
+*         unsigned int SecondBusHigh - Secondry PCI interface Bus Range upper
+*                                     Boundry.
+*         unsigned int busNum - The CPI bus number to which the PCI interface
+*                                     is connected.
+*         unsigned int devNum - The PCI interface's device number.
 *
 * Returns:  true.
 *********************************************************************/
@@ -723,15 +701,15 @@ bool pciP2PConfig (PCI_HOST host, unsigned int SecondBusLow,
 
 /********************************************************************
 * pciSetRegionSnoopMode - This function modifys one of the 4 regions which
-*                          supports Cache Coherency in the PCI_n interface.
+*                         supports Cache Coherency in the PCI_n interface.
 * Inputs: region - One of the four regions.
-*         snoopType - There is four optional Types:
-*                        1. No Snoop.
-*                        2. Snoop to WT region.
-*                        3. Snoop to WB region.
-*                        4. Snoop & Invalidate to WB region.
-*         baseAddress - Base Address of this region.
-*         regionLength - Region length.
+*        snoopType - There is four optional Types:
+*                       1. No Snoop.
+*                       2. Snoop to WT region.
+*                       3. Snoop to WB region.
+*                       4. Snoop & Invalidate to WB region.
+*        baseAddress - Base Address of this region.
+*        regionLength - Region length.
 * Returns: false if one of the parameters is wrong otherwise return true.
 *********************************************************************/
 bool pciSetRegionSnoopMode (PCI_HOST host, PCI_SNOOP_REGION region,
@@ -754,7 +732,7 @@ bool pciSetRegionSnoopMode (PCI_HOST host, PCI_SNOOP_REGION region,
                GT_REG_WRITE (snoopXtopAddress, 0);
                return true;
        }
-       baseAddress = baseAddress & 0xfff00000; /* Granularity of 1MByte */
+       baseAddress = baseAddress & 0xfff00000; /* Granularity of 1MByte */
        data = (baseAddress >> 20) | snoopType << 12;
        GT_REG_WRITE (snoopXbaseAddress, data);
        snoopHigh = (snoopHigh & 0xfff00000) >> 20;
@@ -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 =
@@ -827,7 +811,10 @@ static void gt_setup_ide (struct pci_controller *hose,
 static void gt_setup_cpcidvi (struct pci_controller *hose,
                              pci_dev_t dev, struct pci_config_table *entry)
 {
-       u32               bar_value, pci_response;
+       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);
@@ -843,30 +830,30 @@ static void gt_setup_cpcidvi (struct pci_controller *hose,
 
 unsigned char gt_cpcidvi_in8(unsigned int offset)
 {
-        unsigned char     data;
+       unsigned char     data;
 
        if (gt_cpcidvi_rom.init == 0) {
-               return(0);
-               }
-        data = in8((offset & 0x04) + 0x3f000 + gt_cpcidvi_rom.base);
-        return(data);
+               return(0);
+               }
+       data = in8((offset & 0x04) + 0x3f000 + gt_cpcidvi_rom.base);
+       return(data);
 }
 
 void gt_cpcidvi_out8(unsigned int offset, unsigned char data)
 {
-        unsigned int      off;
-               
+       unsigned int      off;
+
        if (gt_cpcidvi_rom.init == 0) {
-               return;
-               }
+               return;
+       }
        off = data;
        off = ((off << 3) & 0x7f8) + (offset & 0x4) + 0x3e000 + gt_cpcidvi_rom.base;
-        in8(off);
-        return;
+       in8(off);
+       return;
 }
 #endif
 
-/* TODO BJW: Change this for DB64360. This was pulled from the EV64260  */
+/* TODO BJW: Change this for DB64360. This was pulled from the EV64260 */
 /* and is curently not called *. */
 #if 0
 static void gt_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
@@ -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;
 
@@ -932,14 +922,14 @@ void pci_init_board (void)
 
        /* PCI memory space */
        pci_set_region (pci0_hose.regions + 0,
-                       CFG_PCI0_0_MEM_SPACE,
-                       CFG_PCI0_0_MEM_SPACE,
-                       CFG_PCI0_MEM_SIZE, PCI_REGION_MEM);
+                       CONFIG_SYS_PCI0_0_MEM_SPACE,
+                       CONFIG_SYS_PCI0_0_MEM_SPACE,
+                       CONFIG_SYS_PCI0_MEM_SIZE, PCI_REGION_MEM);
 
        /* PCI I/O space */
        pci_set_region (pci0_hose.regions + 1,
-                       CFG_PCI0_IO_SPACE_PCI,
-                       CFG_PCI0_IO_SPACE, CFG_PCI0_IO_SIZE, PCI_REGION_IO);
+                       CONFIG_SYS_PCI0_IO_SPACE_PCI,
+                       CONFIG_SYS_PCI0_IO_SPACE, CONFIG_SYS_PCI0_IO_SIZE, PCI_REGION_IO);
 
        pci_set_ops (&pci0_hose,
                     pci_hose_read_config_byte_via_dword,
@@ -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;
@@ -981,14 +984,14 @@ void pci_init_board (void)
 
        /* PCI memory space */
        pci_set_region (pci1_hose.regions + 0,
-                       CFG_PCI1_0_MEM_SPACE,
-                       CFG_PCI1_0_MEM_SPACE,
-                       CFG_PCI1_MEM_SIZE, PCI_REGION_MEM);
+                       CONFIG_SYS_PCI1_0_MEM_SPACE,
+                       CONFIG_SYS_PCI1_0_MEM_SPACE,
+                       CONFIG_SYS_PCI1_MEM_SIZE, PCI_REGION_MEM);
 
        /* PCI I/O space */
        pci_set_region (pci1_hose.regions + 1,
-                       CFG_PCI1_IO_SPACE_PCI,
-                       CFG_PCI1_IO_SPACE, CFG_PCI1_IO_SIZE, PCI_REGION_IO);
+                       CONFIG_SYS_PCI1_IO_SPACE_PCI,
+                       CONFIG_SYS_PCI1_IO_SPACE, CONFIG_SYS_PCI1_IO_SIZE, PCI_REGION_IO);
 
        pci_set_ops (&pci1_hose,
                     pci_hose_read_config_byte_via_dword,