From patchwork Tue Jan 18 03:13:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Chou X-Patchwork-Id: 79245 X-Patchwork-Delegate: smcnutt@psyent.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id EDE78B711B for ; Tue, 18 Jan 2011 14:12:27 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 386282811E; Tue, 18 Jan 2011 04:12:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2Eg1TZadgM20; Tue, 18 Jan 2011 04:12:23 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 062E228117; Tue, 18 Jan 2011 04:12:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 26B1E28117 for ; Tue, 18 Jan 2011 04:12:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SNuyZMdugfEl for ; Tue, 18 Jan 2011 04:12:15 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from www.wytron.com.tw (www.wytron.com.tw [211.75.82.101]) by theia.denx.de (Postfix) with ESMTPS id 05A6E28116 for ; Tue, 18 Jan 2011 04:12:12 +0100 (CET) Received: from [192.168.1.15] (helo=darkstar.wytron.com.tw) by www.wytron.com.tw with esmtp (Exim 4.69) (envelope-from ) id 1Pf1zH-0007y7-Ob; Tue, 18 Jan 2011 11:12:03 +0800 From: Thomas Chou To: Wolfgang Denk Date: Tue, 18 Jan 2011 11:13:56 +0800 Message-Id: <1295320436-31046-1-git-send-email-thomas@wytron.com.tw> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <20110117210220.CB2EDD1CAD5@gemini.denx.de> References: <20110117210220.CB2EDD1CAD5@gemini.denx.de> X-SA-Exim-Connect-IP: 192.168.1.15 X-SA-Exim-Mail-From: thomas@wytron.com.tw X-SA-Exim-Scanned: No (on www.wytron.com.tw); SAEximRunCond expanded to false Cc: Scott McNutt , u-boot@lists.denx.de, nios2-dev@sopc.et.ntust.edu.tw, Stefan Roese Subject: [U-Boot] [PATCH v2] nios2: reset cfi flash before reading env X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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 #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; }