All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <matthias@kaehlcke.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] edb93xx sdram: fix initialization
Date: Fri, 12 Feb 2010 18:24:31 +0100	[thread overview]
Message-ID: <20100212172431.GN15905@darwin> (raw)
In-Reply-To: <20100212092358.GI15905@darwin>

hi alessandro,

El Fri, Feb 12, 2010 at 10:23:58AM +0100 Matthias Kaehlcke ha dit:

> El Fri, Feb 12, 2010 at 08:01:26AM +0100 Alessandro Rubini ha dit:
> 
> > > i gave my ack after a visual review of the patch, without having
> > > tested it. i just installed a patched u-boot on one of my boards and
> > > it doesn't boot :(
> > 
> > Oh. The opposite of my board.
> > 
> > Then, since I don't have a 9315A but only a similar one, it's better
> > to drop the patch.  I'll have a different sdram_cfg file for mine,
> > then.
> 
> i'm pretty sure we'll be able to track this down, the purpose of your
> patch is correct, i actually wonder why the current code works ...
> 
> if we can't solve the issue in the next days, you could still send a
> patch which only writes the GlConfig register in
> program_mode_registers(). this would fix at least on of the issues and
> make your code less different from the one in the tree

maybe i have found a clue: i think the original assembly code wasn't
correct either. the comment talks about reading from each bank, but
then code like this is excuted:

ldr r0, =0x00000000 /* A[22:21] = b00 */
str r0, [r0]

which *writes* to the bank, but doesn't read from it.

according to the errata note a bank is precharged by reading from
it. the current code does this, but before the bank is configured
properly. i suspect that is the cause for the hang i see on my
boards. i've put together some code which does the precharge after
setting up the mode registers. on my boards based on the edb9301 and
edb9307a design u-boot boots with this code.

below you find a patch, could you give it a try on your board, when
you find some time and feel well enough?

thanks

Matthias

---

diff --git a/board/edb93xx/sdram_cfg.c b/board/edb93xx/sdram_cfg.c
index 6155f0e..f3db750 100644
--- a/board/edb93xx/sdram_cfg.c
+++ b/board/edb93xx/sdram_cfg.c
@@ -47,25 +47,27 @@ void sdram_cfg(void)
 
 	early_udelay(200);
 
-	force_precharge();
+	/*
+	 * Errata of most EP93xx revisions say that PRECHARGE ALL isn't always
+	 * issued, so we omit it at this point. Instead we force a precharge
+	 * after having programmed the mode registers
+	 */
 
 	setup_refresh_timer();
 
 	program_mode_registers();
 
-	/* Select normal operation mode */
-	writel(GLCONFIG_CKE, &sdram->glconfig);
+	force_precharge();
 }
 
 static void force_precharge(void)
 {
-	/*
-	 * Errata most EP93xx revisions say that PRECHARGE ALL isn't always
-	 * issued.
-	 *
-	 * Do a read from each bank to make sure they're precharged
-	 */
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	/* Select normal operation mode */
+	writel(GLCONFIG_CKE, &sdram->glconfig);
 
+	/* Do a read from each bank to make sure they're precharged */
 	PRECHARGE_BANK(0);
 	PRECHARGE_BANK(1);
 	PRECHARGE_BANK(2);
@@ -101,6 +103,11 @@ static void setup_refresh_timer(void)
 
 static void program_mode_registers(void)
 {
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	/* Select mode register update mode */
+	writel(GLCONFIG_MRS | GLCONFIG_CKE, &sdram->glconfig);
+
 	/*
 	 * The mode registers are programmed by performing a read from each
 	 * SDRAM bank. The value of the address that is read defines the value

  reply	other threads:[~2010-02-12 17:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 20:46 [U-Boot] [PATCH 0/2] edb93xx: two patches for boot code Alessandro Rubini
2010-02-11 20:46 ` [U-Boot] [PATCH 1/2] ep93xx leds: remove arrays in data section Alessandro Rubini
2010-02-11 20:46 ` [U-Boot] [PATCH 2/2] edb93xx sdram: fix initialization Alessandro Rubini
2010-02-11 22:32   ` Matthias Kaehlcke
2010-02-12  7:01     ` Alessandro Rubini
2010-02-12  9:23       ` Matthias Kaehlcke
2010-02-12 17:24         ` Matthias Kaehlcke [this message]
2010-02-12 23:01           ` Alessandro Rubini
2010-02-16 19:24             ` Matthias Kaehlcke
2010-02-17 14:48               ` Alessandro Rubini

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=20100212172431.GN15905@darwin \
    --to=matthias@kaehlcke.net \
    --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.