All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] am33xx: add 600us wait in DDR3 initialization sequence
Date: Fri, 17 Jul 2015 15:55:56 +0200	[thread overview]
Message-ID: <55A9096C.4000007@denx.de> (raw)
In-Reply-To: <27E9275BC1C8554E840881B19B62BE421B3C2D@DENBGAT9EI1MSX.ww902.siemens.net>

Hi Sam,

On 17.07.2015 13:46, Egli, Samuel wrote:
> the current implementation in ./arch/arm/cpu/armv7/am33xx/emif4.c does not respect
> the the initialization steps as documented in the DDR3 specification [1]. We noticed
> that for our am335x based siemens boards a delay after config_ddr(...) call was
> necessary otherwise boot would fail. See 61159b76844437bf9004c3a38b5a4ff1a24860d5
> commit that added a 2ms delay which was merly combating symptoms.
>
> This is because SDRAM wouldn't be ready yet. We didn't realy know why it should
> be necessary but the delay did the job. However, we figured out now that an
> important wait time is not respected, specifically, step 4:
>
> "After RESET# transitions HIGH, wait 500?s (minus one clock) with CKE LOW" [1]
>
> We also noticed that it is vendor specific and some SDRAM wouldn't bother if
> 500 us wait is done or not.
>
> See below the patch that guarantees that we have a 600?s wait time before
> the clock enable gets enabled. Maybe a comment on the main steps:
>
> (1) The first time we call config_sdram the CKE controll is still refused
>      EMIF/DDR PHY. But it has the effect that the init sequence is started
>      anyway, and as a consequence puts RESET to high which is the sole goal
>      of this line.
>
> In (2) + (3) we wait 600us. 100us more to be on the safe side and then give
> control to EMIF/DDR PHY.
>
> (4) Now, that the wait time is ensured and CKE can be used by the EMIF/DDR PHY
>      we trigger the real sdram configuration sequence.
>
>
> This patch works fine for us but I'm not sure if some revising of the EMIF_4D5
> case is necessary, too. With this patch no delay after config_ddr(...) is
> necessary anymore.
>
> One thing that I cannot explain well, however, is why no issue was observed
> with other TI boards. A possible explenation is that some delay stems from
> code execution time that is done after sdram config before loading u-boot.
>
> But maybe it has also to do with different DDR3 vendors being used. Our
> observation was that Samsung SDRAM is more likely to not work. And that
> smaller sized SDRAM is less/not prone to ignoring the spec. I.e. SDRAM with
> only 128 MB didn't cause any problem. But 256/512 MB from Samsung would not work.
>
> Kind regards
>
> Sam
>
> [1] http://www.micron.com/products/datasheets/%7B2ADCEEB1-307F-4B37-99C9-7302CAA8BC5C%7D?page=8#topic=c_Initialization
>
>
> ---
>   arch/arm/cpu/armv7/am33xx/emif4.c |   18 +++++++++++++-----
>   1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/am33xx/emif4.c b/arch/arm/cpu/armv7/am33xx/emif4.c
> index 9cf816c..084b45a 100644
> --- a/arch/arm/cpu/armv7/am33xx/emif4.c
> +++ b/arch/arm/cpu/armv7/am33xx/emif4.c
> @@ -109,10 +109,6 @@ void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
>   	config_ddr_data(data, nr);
>   #ifdef CONFIG_AM33XX
>   	config_io_ctrl(ioregs);
> -
> -	/* Set CKE to be controlled by EMIF/DDR PHY */
> -	writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
> -
>   #endif
>   #ifdef CONFIG_AM43XX
>   	writel(readl(&cm_device->cm_dll_ctrl) & ~0x1, &cm_device->cm_dll_ctrl);
> @@ -131,9 +127,21 @@ void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
>   	/* Program EMIF instance */
>   	config_ddr_phy(regs, nr);
>   	set_sdram_timings(regs, nr);
> +
>   	if (get_emif_rev(EMIF1_BASE) == EMIF_4D5)
>   		config_sdram_emif4d5(regs, nr);
> -	else
> +	else {
> +		/* (1) Set reset signal with CKE still off */
> +		config_sdram(regs, nr);
> +
> +		/* (2) Add 600us delay between Reset and CKE */
> +		udelay(600);
> +
> +		/* (3) Set CKE to be controlled by EMIF/DDR PHY */
> +		writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);
> +
> +		/* (4) Configure sdram */
>   		config_sdram(regs, nr);
> +	}

A small nitpicking comment: Please use braces on this "if" patch as well 
in this case (as documented in the codingstyle text).

Otherwise this looks like a sane change / fix (without any deeper look 
in the DDR manual). So:

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

  reply	other threads:[~2015-07-17 13:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 11:46 [U-Boot] [RFC] am33xx: add 600us wait in DDR3 initialization sequence Egli, Samuel
2015-07-17 13:55 ` Stefan Roese [this message]
2015-07-28 14:31 ` Egli, Samuel
2015-07-28 14:42   ` Tom Rini
2015-07-29  6:48     ` Egli, Samuel
2015-07-28 19:58   ` Doublesin, James
2015-07-29 11:57     ` Egli, Samuel
2015-07-29 22:51       ` Tom Rini

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=55A9096C.4000007@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.