]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Thu, 2 Oct 2008 15:17:33 +0000 (19:17 +0400)
committerKim Phillips <kim.phillips@freescale.com>
Tue, 21 Oct 2008 23:34:14 +0000 (18:34 -0500)
The MPC837xE-MDS board's CPLD can auto-detect if the board is on the PIB,
standalone or acting as a PCI agent. User's Guide says:

- When the CPLD recognizes its location on the PIB it automatically
  configures RCW to the PCI Host.
- If the CPLD fails to recognize its location then it is automatically
  configured as an Agent and the PCI is configured to an external arbiter.

This sounds good. Though in the standalone setup the CPLD sets PCI_HOST
flag (it's ok, we can't act as PCI agents since we receive CLKIN, not
PCICLK), but the CPLD doesn't set the ARBITER_ENABLE flag, and without
any arbiter bad things will happen (here the board hangs during any config
space reads).

In this situation we must disable the PCI. And in case of anybody really
want to use an external arbiter, we provide "pci_external_aribter"
environment variable.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
board/freescale/mpc837xemds/mpc837xemds.c
board/freescale/mpc837xemds/pci.c
include/configs/MPC837XEMDS.h

index f4bdb89914f55830fd364306990a6a8d534b1d09..49afa7cf84e7019b771bdf5049a10c9170eb888b 100644 (file)
@@ -270,6 +270,45 @@ int checkboard(void)
        return 0;
 }
 
+#ifdef CONFIG_PCI
+int board_pci_host_broken(void)
+{
+       struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
+       const u32 rcw_mask = HRCWH_PCI1_ARBITER_ENABLE | HRCWH_PCI_HOST;
+       const char *pci_ea = getenv("pci_external_arbiter");
+
+       /* It's always OK in case of external arbiter. */
+       if (pci_ea && !strcmp(pci_ea, "yes"))
+               return 0;
+
+       if ((in_be32(&im->reset.rcwh) & rcw_mask) != rcw_mask)
+               return 1;
+
+       return 0;
+}
+
+static void ft_pci_fixup(void *blob, bd_t *bd)
+{
+       const char *status = "broken (no arbiter)";
+       int off;
+       int err;
+
+       off = fdt_path_offset(blob, "pci0");
+       if (off < 0) {
+               printf("WARNING: could not find pci0 alias: %s.\n",
+                       fdt_strerror(off));
+               return;
+       }
+
+       err = fdt_setprop(blob, off, "status", status, strlen(status) + 1);
+       if (err) {
+               printf("WARNING: could not set status for pci0: %s.\n",
+                       fdt_strerror(err));
+               return;
+       }
+}
+#endif
+
 #if defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_setup(void *blob, bd_t *bd)
 {
@@ -277,6 +316,8 @@ void ft_board_setup(void *blob, bd_t *bd)
        ft_tsec_fixup(blob, bd);
 #ifdef CONFIG_PCI
        ft_pci_setup(blob, bd);
+       if (board_pci_host_broken())
+               ft_pci_fixup(blob, bd);
 #endif
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
index 24cc1301482c3967605b9e50a1ac8eb511a6ebe6..df4e748e971070a3e5fc600e2c9efa84251a1c2f 100644 (file)
@@ -47,6 +47,9 @@ void pci_init_board(void)
        volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
        struct pci_region *reg[] = { pci_regions };
 
+       if (board_pci_host_broken())
+               return;
+
        /* Enable all 5 PCI_CLK_OUTPUTS */
        clk->occr |= 0xf8000000;
        udelay(2000);
index e2f0942ce93a311d78c8678d2faf83c5a9113622..c3431ee4cce7954a6e1775483e8fc78d05371d8c 100644 (file)
 #define CONFIG_SYS_PCI_SLV_MEM_SIZE    0x80000000
 
 #ifdef CONFIG_PCI
+#ifndef __ASSEMBLY__
+extern int board_pci_host_broken(void);
+#endif
 #define CONFIG_83XX_GENERIC_PCI        1 /* Use generic PCI setup */
 #define CONFIG_PQ_MDS_PIB      1 /* PQ MDS Platform IO Board */