public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott McNutt <smcnutt@psyent.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] nios2: reset cfi flash before reading env
Date: Sat, 26 Mar 2011 10:47:11 -0400	[thread overview]
Message-ID: <4D8DFC6F.5020801@psyent.com> (raw)
In-Reply-To: <1295320436-31046-1-git-send-email-thomas@wytron.com.tw>

Applied to:

  git://git.denx.de/u-boot-nios next

Thanks,
--Scott

Thomas Chou wrote:
> Flash might be in unknown state when u-boot is started with jtag.
> And got wrong env data. So reset it in board early init.
> 
> We cannot use generic cfi flash routines, because flash_init() is
> not run yet.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
> v2 use weak func to reset flash, as Wolfgang suggested.
>    reset the chip where env is located.
> 
>  board/altera/nios2-generic/nios2-generic.c |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c
> index 89848cf..220a4c4 100644
> --- a/board/altera/nios2-generic/nios2-generic.c
> +++ b/board/altera/nios2-generic/nios2-generic.c
> @@ -24,12 +24,28 @@
>  
>  #include <common.h>
>  #include <netdev.h>
> +#include <mtd/cfi_flash.h>
> +#include <asm/io.h>
>  
>  void text_base_hook(void); /* nop hook for text_base.S */
>  
> +#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
> +static void __early_flash_cmd_reset(void)
> +{
> +	/* reset flash before we read env */
> +	writeb(AMD_CMD_RESET, CONFIG_ENV_ADDR);
> +	writeb(FLASH_CMD_RESET, CONFIG_ENV_ADDR);
> +}
> +void early_flash_cmd_reset(void)
> +	__attribute__((weak,alias("__early_flash_cmd_reset")));
> +#endif
> +
>  int board_early_init_f(void)
>  {
>  	text_base_hook();
> +#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
> +	early_flash_cmd_reset();
> +#endif
>  	return 0;
>  }
>  

      reply	other threads:[~2011-03-26 14:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05  7:17 [U-Boot] [PATCH] nios2: reset cfi flash before reading env Thomas Chou
2011-01-05  8:15 ` Wolfgang Denk
2011-01-06  2:36   ` Thomas Chou
2011-01-17 21:02     ` Wolfgang Denk
2011-01-18  2:05       ` Thomas Chou
2011-01-18  3:13       ` [U-Boot] [PATCH v2] " Thomas Chou
2011-03-26 14:47         ` Scott McNutt [this message]

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=4D8DFC6F.5020801@psyent.com \
    --to=smcnutt@psyent.com \
    --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