From 030103d780490096c7052ecee8f2af1cb422217d Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Tue, 18 Jan 2011 11:13:56 +0800 Subject: nios2: reset cfi flash before reading env 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 --- board/altera/nios2-generic/nios2-generic.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'board') diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c index 89848cf041f..220a4c44a4d 100644 --- a/board/altera/nios2-generic/nios2-generic.c +++ b/board/altera/nios2-generic/nios2-generic.c @@ -24,12 +24,28 @@ #include #include +#include +#include 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; } -- cgit v1.2.3