public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards
@ 2008-10-02 15:17 Anton Vorontsov
  2008-10-09  5:01 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards Liu Dave-R63238
  2008-10-14  0:26 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Kim Phillips
  0 siblings, 2 replies; 4+ messages in thread
From: Anton Vorontsov @ 2008-10-02 15:17 UTC (permalink / raw)
  To: u-boot

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>
---
 board/freescale/mpc837xemds/mpc837xemds.c |   41 +++++++++++++++++++++++++++++
 board/freescale/mpc837xemds/pci.c         |    3 ++
 include/configs/MPC837XEMDS.h             |    3 ++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c
index b6b9678..8bc54d1 100644
--- a/board/freescale/mpc837xemds/mpc837xemds.c
+++ b/board/freescale/mpc837xemds/mpc837xemds.c
@@ -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 *)CFG_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 */
diff --git a/board/freescale/mpc837xemds/pci.c b/board/freescale/mpc837xemds/pci.c
index ab90979..0eba7df 100644
--- a/board/freescale/mpc837xemds/pci.c
+++ b/board/freescale/mpc837xemds/pci.c
@@ -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);
diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h
index ed70b9e..adf7c8c 100644
--- a/include/configs/MPC837XEMDS.h
+++ b/include/configs/MPC837XEMDS.h
@@ -347,6 +347,9 @@
 #define CFG_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 */
 
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards
  2008-10-02 15:17 [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Anton Vorontsov
@ 2008-10-09  5:01 ` Liu Dave-R63238
  2008-10-09 10:08   ` Anton Vorontsov
  2008-10-14  0:26 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Kim Phillips
  1 sibling, 1 reply; 4+ messages in thread
From: Liu Dave-R63238 @ 2008-10-09  5:01 UTC (permalink / raw)
  To: u-boot

Hello Anton,

1)
I strongly suggest you use the hardware reset configuration word from
flash,
not from FPGA.
You can set the PCI host and internal arbiter enabled in the HRCW in
flash
to avoid these issue.

2)
Also, I strongly suggest you use the production 837xEMDS pilot rev2.05
board.
Because the early 837xEMDS board is missing PCI bus pull up resistors.

Thanks,
Dave 

> -----Original Message-----
> From: u-boot-bounces at lists.denx.de 
> [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Anton Vorontsov
> Sent: 2008?10?2? 11:18 PM
> To: Phillips Kim-R1AAHA
> Cc: u-boot at lists.denx.de; Kumar Gala
> Subject: [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the 
> standaloneMPC837xE-MDS boards
> 
> 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>
> ---
>  board/freescale/mpc837xemds/mpc837xemds.c |   41 
> +++++++++++++++++++++++++++++
>  board/freescale/mpc837xemds/pci.c         |    3 ++
>  include/configs/MPC837XEMDS.h             |    3 ++
>  3 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/board/freescale/mpc837xemds/mpc837xemds.c 
> b/board/freescale/mpc837xemds/mpc837xemds.c
> index b6b9678..8bc54d1 100644
> --- a/board/freescale/mpc837xemds/mpc837xemds.c
> +++ b/board/freescale/mpc837xemds/mpc837xemds.c
> @@ -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 *)CFG_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 */
> diff --git a/board/freescale/mpc837xemds/pci.c 
> b/board/freescale/mpc837xemds/pci.c
> index ab90979..0eba7df 100644
> --- a/board/freescale/mpc837xemds/pci.c
> +++ b/board/freescale/mpc837xemds/pci.c
> @@ -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);
> diff --git a/include/configs/MPC837XEMDS.h 
> b/include/configs/MPC837XEMDS.h
> index ed70b9e..adf7c8c 100644
> --- a/include/configs/MPC837XEMDS.h
> +++ b/include/configs/MPC837XEMDS.h
> @@ -347,6 +347,9 @@
>  #define CFG_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 */
>  
> -- 
> 1.5.6.3
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards
  2008-10-09  5:01 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards Liu Dave-R63238
@ 2008-10-09 10:08   ` Anton Vorontsov
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2008-10-09 10:08 UTC (permalink / raw)
  To: u-boot

Hi,

On Thu, Oct 09, 2008 at 01:01:04PM +0800, Liu Dave-R63238 wrote:
> Hello Anton,
> 
> 1)
> I strongly suggest you use the hardware reset configuration word from
> flash,
> not from FPGA.

Well, then we always have to re-flash the u-boot for every change
of the SGMII/RGMII setup... not very convenient. :-/

Other option is to use I2C EEPROM as a HRCW source, and change
SGMII/RGMII setup there. But this feels quite hackish... Never tried
this approach though.

> You can set the PCI host and internal arbiter enabled in the HRCW in
> flash
> to avoid these issue.

Luckily there is easy workaround for this problem.

> 2)
> Also, I strongly suggest you use the production 837xEMDS pilot rev2.05
> board.
> Because the early 837xEMDS board is missing PCI bus pull up resistors.

Much thanks for the information.

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards
  2008-10-02 15:17 [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Anton Vorontsov
  2008-10-09  5:01 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards Liu Dave-R63238
@ 2008-10-14  0:26 ` Kim Phillips
  1 sibling, 0 replies; 4+ messages in thread
From: Kim Phillips @ 2008-10-14  0:26 UTC (permalink / raw)
  To: u-boot

On Thu, 2 Oct 2008 19:17:33 +0400
Anton Vorontsov <avorontsov@ru.mvista.com> wrote:

> 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>

applied to mpc83xx/next.

Thanks,

Kim

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-10-14  0:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-02 15:17 [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Anton Vorontsov
2008-10-09  5:01 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standaloneMPC837xE-MDS boards Liu Dave-R63238
2008-10-09 10:08   ` Anton Vorontsov
2008-10-14  0:26 ` [U-Boot] [PATCH] mpc83xx: fix PCI scan hang on the standalone MPC837xE-MDS boards Kim Phillips

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox