]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ppc4xx: Consolidate pci_master_init() function
authorStefan Roese <sr@denx.de>
Thu, 12 Nov 2009 16:19:37 +0000 (17:19 +0100)
committerStefan Roese <sr@denx.de>
Thu, 19 Nov 2009 10:35:34 +0000 (11:35 +0100)
This patch removes the duplicted implementations of the pci_master_init()
function by introducing a weak default function for it. It can be
overridden by a board specific version.

Signed-off-by: Stefan Roese <sr@denx.de>
12 files changed:
board/amcc/bamboo/bamboo.c
board/amcc/sequoia/sequoia.c
board/amcc/yosemite/yosemite.c
board/esd/du440/du440.c
board/esd/pmc440/pmc440.c
board/gdsys/gdppc440etx/gdppc440etx.c
board/korat/korat.c
board/lwmon5/lwmon5.c
board/netstal/hcu5/hcu5.c
board/pcs440ep/pcs440ep.c
cpu/ppc4xx/4xx_pci.c
include/asm-ppc/4xx_pci.h

index 7c34c4445f3e867f2c30ae4aa03b66ebe480d9ed..c90f86b8d802748afef24e4abb924609726af846 100644 (file)
@@ -466,27 +466,6 @@ phys_size_t initdram (int board_type)
 #endif
 }
 
-/*************************************************************************
- *  pci_master_init
- *
- ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*--------------------------------------------------------------------------+
-         | Write the PowerPC440 EP PCI Configuration regs.
-         |   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-         |   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-         +--------------------------------------------------------------------------*/
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif                         /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 /*----------------------------------------------------------------------------+
   | is_powerpc440ep_pass1.
   +----------------------------------------------------------------------------*/
index 8c0a6476135350fbe3516d7511f90f6138b38638..cb34c9d7df8ad2e2a69fff4779871647b52ed5f9 100644 (file)
@@ -370,23 +370,6 @@ void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
 }
 #endif
 
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*
-        * Write the PowerPC440 EP PCI Configuration regs.
-        * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        * Enable PowerPC440 EP to act as a PCI memory target (PTM).
-        */
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 #if defined(CONFIG_POST)
 /*
  * Returns 1 if keys pressed to start the power-on long-running tests
index b6f8b7028e7e835411d770bb34bdb87c083f024a..98c1f3b81e8ea7b9a60834b3a82b343cf1217429 100644 (file)
@@ -352,27 +352,6 @@ phys_size_t initdram(int board)
        return CONFIG_SYS_SDRAM_BANKS * (CONFIG_SYS_KBYTES_SDRAM * 1024);       /* return bytes */
 }
 
-/*************************************************************************
- *  pci_master_init
- *
- ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*--------------------------------------------------------------------------+
-         | Write the PowerPC440 EP PCI Configuration regs.
-         |   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-         |   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-         +--------------------------------------------------------------------------*/
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif                         /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 /*************************************************************************
  *  hw_watchdog_reset
  *
index af50a1ef8aa23c29f884ff4ffd3547665b46350e..111cce52a2a3a200eb8772b96593e5872d8cadde 100644 (file)
@@ -360,23 +360,6 @@ int checkboard(void)
        return (0);
 }
 
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*
-        * Write the PowerPC440 EP PCI Configuration regs.
-        * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        * Enable PowerPC440 EP to act as a PCI memory target (PTM).
-        */
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 int last_stage_init(void)
 {
        int e, i;
index c5dc486cd405c2319fb1d5b842a0b2a265fd4f2a..d0ff080fadefe1b90fa5baf1e1e6f7b9bd632dd7 100644 (file)
@@ -39,6 +39,8 @@
 #include <miiphy.h>
 #endif
 #include <serial.h>
+#include <asm/4xx_pci.h>
+
 #include "fpga.h"
 #include "pmc440.h"
 
@@ -600,24 +602,16 @@ void pci_target_init(struct pci_controller *hose)
 #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
 
 /*
- * pci_master_init
+ * Override weak default pci_master_init()
  */
 #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
 void pci_master_init(struct pci_controller *hose)
 {
-       unsigned short temp_short;
-
        /*
-        * Write the PowerPC440 EP PCI Configuration regs.
-        * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        * Enable PowerPC440 EP to act as a PCI memory target (PTM).
+        * Only configure the master in monach mode
         */
-       if (is_monarch()) {
-               pci_read_config_word(0, PCI_COMMAND, &temp_short);
-               pci_write_config_word(0, PCI_COMMAND,
-                                     temp_short | PCI_COMMAND_MASTER |
-                                     PCI_COMMAND_MEMORY);
-       }
+       if (is_monarch())
+               __pci_master_init(hose);
 }
 #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
 
index 10e146b4291c51669ae51e89562f17d29c18e4ce..ecbc3c3d1a540ede7afb2eff1c24d92e62d2fd87 100644 (file)
@@ -174,24 +174,3 @@ int pci_pre_init(struct pci_controller *hose)
        return 1;
 }
 #endif /* defined(CONFIG_PCI) */
-
-/*
- *  pci_master_init
- *
- */
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*
-        * Write the PowerPC440 EP PCI Configuration regs.
-        *   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        *   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-        */
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
index 78ccb112278f9fd337b795933f616012a4fd9dbb..f942052bd50f246deb53c23e46926a26b33b88f3 100644 (file)
@@ -622,23 +622,6 @@ void pci_target_init(struct pci_controller *hose)
 }
 #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
 
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*
-        * Write the PowerPC440 EP PCI Configuration regs.
-        * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        * Enable PowerPC440 EP to act as a PCI memory target (PTM).
-        */
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif
-
 #if defined(CONFIG_POST)
 /*
  * Returns 1 if keys pressed to start the power-on long-running tests
index bd29437a24d9db8f68f90c72be3cc94efcf21643..415e036c006456e51a42321eb8a95ebdd4fbd12f 100644 (file)
@@ -275,27 +275,6 @@ int checkboard(void)
        return (0);
 }
 
-/*************************************************************************
- *  pci_master_init
- *
- ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*--------------------------------------------------------------------------+
-         | Write the PowerPC440 EP PCI Configuration regs.
-         |   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-         |   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-         +--------------------------------------------------------------------------*/
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif                         /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 void hw_watchdog_reset(void)
 {
        int val;
index 144fdd97047f0120eb05cbb312349a014d6a18d3..86156456441e771e85726dc3b42ced692a20ef5b 100644 (file)
@@ -22,6 +22,8 @@
 #include <asm/processor.h>
 #include <ppc440.h>
 #include <asm/io.h>
+#include <asm/4xx_pci.h>
+
 #include  "../common/nm.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -377,23 +379,14 @@ int pci_pre_init(struct pci_controller *hose)
 }
 
 /*
- *  pci_master_init
- *
+ * Override weak default pci_master_init()
  */
 void pci_master_init(struct pci_controller *hose)
 {
-       unsigned short temp_short;
-       if (!board_with_pci()) { return; }
-
-       /*---------------------------------------------------------------
-        * Write the PowerPC440 EP PCI Configuration regs.
-        *   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-        *   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-        *--------------------------------------------------------------*/
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
+       if (!board_with_pci())
+               return;
+
+       __pci_master_init(hose);
 }
 #endif  /* defined(CONFIG_PCI) */
 
index e7c575d8aacf071f105a66f0d7f5ea1bd8fa9d9d..ce1e616679f49fa77f792c61b5a072d32e702ef4 100644 (file)
@@ -550,27 +550,6 @@ phys_size_t initdram (int board_type)
        return dram_size;
 }
 
-/*************************************************************************
- *  pci_master_init
- *
- ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
-void pci_master_init(struct pci_controller *hose)
-{
-       unsigned short temp_short;
-
-       /*--------------------------------------------------------------------------+
-         | Write the PowerPC440 EP PCI Configuration regs.
-         |   Enable PowerPC440 EP to be a master on the PCI bus (PMM).
-         |   Enable PowerPC440 EP to act as a PCI memory target (PTM).
-         +--------------------------------------------------------------------------*/
-       pci_read_config_word(0, PCI_COMMAND, &temp_short);
-       pci_write_config_word(0, PCI_COMMAND,
-                             temp_short | PCI_COMMAND_MASTER |
-                             PCI_COMMAND_MEMORY);
-}
-#endif                         /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
-
 /*************************************************************************
  *  hw_watchdog_reset
  *
index 01b9cf7217abd7917271ec6d8ffb698a92fb4bdd..eed4534e5f50b146edd57ff27efddfa2c304ee11 100644 (file)
@@ -686,6 +686,24 @@ void pci_target_init(struct pci_controller * hose)
 int pci_pre_init(struct pci_controller *hose)
        __attribute__((weak, alias("__pci_pre_init")));
 
+#if defined(CONFIG_SYS_PCI_MASTER_INIT)
+void __pci_master_init(struct pci_controller *hose)
+{
+       u16 reg;
+
+       /*
+        * Write the PowerPC440 EP PCI Configuration regs.
+        * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
+        * Enable PowerPC440 EP to act as a PCI memory target (PTM).
+        */
+       pci_read_config_word(0, PCI_COMMAND, &reg);
+       pci_write_config_word(0, PCI_COMMAND, reg |
+                             PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
+}
+void pci_master_init(struct pci_controller *hose)
+       __attribute__((weak, alias("__pci_master_init")));
+#endif /* CONFIG_SYS_PCI_MASTER_INIT */
+
 int pci_440_init (struct pci_controller *hose)
 {
        int reg_num = 0;
index 31769901ca8e6d38bba3919cdc4df873579f1a2e..f686e7cb07b26a891b2a4017ee88015762ca4111 100644 (file)
@@ -55,5 +55,6 @@ void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
 int pci_arbiter_enabled(void);
 int __pci_pre_init(struct pci_controller *hose);
 void __pci_target_init(struct pci_controller *hose);
+void __pci_master_init(struct pci_controller *hose);
 
 #endif