public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/8] drivers/pci/pci_mvebu: Fix for boards with X4 lanes
Date: Tue, 22 Dec 2015 09:24:21 +0100	[thread overview]
Message-ID: <567908B5.3030708@denx.de> (raw)
In-Reply-To: <20151221232441.D035661201@mail.nwl.cc>

On 22.12.2015 00:25, Phil Sutter wrote:
> Armada XP has support for X4 lanes, boards specify this in their
> serdes_cfg. During PEX init in high_speed_env_lib.c, the configuration
> is stored in GEN_PURP_RES_2_REG.
> 
> When enumerating PEX, subsequent interfaces of an X4 lane must be
> skipped. Otherwise the enumeration hangs up the board.
> 
> The way this is implemented here is not exactly beautiful, but it mimics
> how Marvell's BSP does it. Alternatively we could get the information
> using board_serdes_cfg_get(), but that won't lead to clean code, either.
> Especially since the ugly includes will have to be done anyway.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
>   drivers/pci/pci_mvebu.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c
> index fd2744d..aab53f4 100644
> --- a/drivers/pci/pci_mvebu.c
> +++ b/drivers/pci/pci_mvebu.c
> @@ -18,6 +18,11 @@
>   #include <asm/arch/soc.h>
>   #include <linux/mbus.h>
>   
> +#if defined(CONFIG_ARMADA_XP)
> +#include "../ddr/marvell/axp/ddr3_init.h"
> +#include "../../arch/arm/mach-mvebu/serdes/axp/board_env_spec.h"
> +#endif

Yes, this is ugly. And AFAICT, you only need it to include the 
GEN_PURP_RES_2_REG define from these headers.

I would prefer to add this macro either here (again), or in soc.h.
And use the name from the Marvell manual, so something like

#define COMPHY_REFCLK_ALIGNMENT		(MVEBU_REGISTER(0x182f8))

> +
>   DECLARE_GLOBAL_DATA_PTR;
>   
>   /* PCIe unit register offsets */
> @@ -155,6 +160,16 @@ static void mvebu_get_port_lane(struct mvebu_pcie *pcie, int pex_idx,
>   }
>   #endif
>   
> +#if defined(CONFIG_ARMADA_XP)
> +static int mvebu_pex_unit_is_x4(int pex_idx)
> +{
> +	int pex_unit = pex_idx < 9 ? pex_idx >> 2 : 3;
> +	u32 mask = (0x0f << (pex_unit * 8));
> +
> +	return (reg_read(GEN_PURP_RES_2_REG) & mask) == mask;

readl() with the new define please.

> +}
> +#endif

Please drop the #ifdef here. This can go in unconditionally.

> +
>   static inline bool mvebu_pcie_link_up(struct mvebu_pcie *pcie)
>   {
>   	u32 val;
> @@ -419,5 +434,11 @@ void pci_init_board(void)
>   		writel(0, pcie->base + PCIE_BAR_HI_OFF(0));
>   
>   		bus = hose->last_busno + 1;
> +
> +#if defined(CONFIG_ARMADA_XP)
> +		/* need to skip more for X4 links, otherwise scan will hang */
> +		if (mvebu_pex_unit_is_x4(i))
> +			i += 3;
> +#endif

And please use this version here:

		/* need to skip more for X4 links, otherwise scan will hang */
		if (mvebu_soc_family() == MVEBU_SOC_AXP) {
			if (mvebu_pex_unit_is_x4(i))
				i += 3;
		}

Thanks,
Stefan

  reply	other threads:[~2015-12-22  8:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1450740358-5014-1-git-send-email-phil@nwl.cc>
2015-12-21 23:25 ` [U-Boot] [PATCH v2 1/8] drivers/pci: Fix for debug builds without CONFIG_PCI_ENUM_ONLY Phil Sutter
2015-12-22  8:06   ` Stefan Roese
2015-12-21 23:25 ` [U-Boot] [PATCH v2 2/8] mvebu: Fix for non-DM ehci-marvell support Phil Sutter
2015-12-22  8:02   ` Stefan Roese
2015-12-22 14:24     ` Phil Sutter
2015-12-22 14:27       ` Stefan Roese
2015-12-21 23:25 ` [U-Boot] [PATCH v2 3/8] README: Review the u-boot porting guide list Phil Sutter
2015-12-22  8:08   ` Stefan Roese
2015-12-21 23:25 ` [U-Boot] [PATCH v2 4/8] axp: Fix debugging support in DDR3 write leveling Phil Sutter
2015-12-22  8:08   ` Stefan Roese
2015-12-21 23:25 ` [U-Boot] [PATCH v2 5/8] drivers/pci/pci_mvebu: Fix for boards with X4 lanes Phil Sutter
2015-12-22  8:24   ` Stefan Roese [this message]
2015-12-21 23:25 ` [U-Boot] [PATCH v2 6/8] mvebu: Add rudimental MV78320 support Phil Sutter
2015-12-22  8:32   ` Stefan Roese
2015-12-21 23:25 ` [U-Boot] [PATCH v2 7/8] mvebu: Support Synology DS414 Phil Sutter
2015-12-22  9:05   ` Stefan Roese
2015-12-23  0:31     ` Phil Sutter
2015-12-23  7:56       ` Stefan Roese
2015-12-23 11:30         ` Phil Sutter
2015-12-23 11:43           ` Stefan Roese
2017-06-16 14:04   ` Bin Meng
2015-12-21 23:25 ` [U-Boot] [PATCH v2 8/8] common: Implement Synology specific command set Phil Sutter
2015-12-22  9:06   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=567908B5.3030708@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox