From patchwork Thu Dec 6 06:21:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Kumar X-Patchwork-Id: 204136 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 ADAB52C0189 for ; Thu, 6 Dec 2012 17:22:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CC61B4A165; Thu, 6 Dec 2012 07:22:31 +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 1n3gmf08q8wj; Thu, 6 Dec 2012 07:22:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D0DE04A19A; Thu, 6 Dec 2012 07:22:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7945F4A17E for ; Thu, 6 Dec 2012 07:21:47 +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 Kiy2OJB03Dl8 for ; Thu, 6 Dec 2012 07:21:45 +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 eu1sys200aog118.obsmtp.com (eu1sys200aog118.obsmtp.com [207.126.144.145]) by theia.denx.de (Postfix) with ESMTPS id EBBBE4A165 for ; Thu, 6 Dec 2012 07:21:41 +0100 (CET) Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUMA5cYTohzwm/hXqaRdexyffI+WuUa2g@postini.com; Thu, 06 Dec 2012 06:21:44 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id B1CF7EB; Thu, 6 Dec 2012 06:13:23 +0000 (GMT) Received: from Webmail-ap.st.com (eapex1hubcas3.st.com [10.80.176.67]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 14EC1AA4; Thu, 6 Dec 2012 06:21:35 +0000 (GMT) Received: from localhost (10.199.82.27) by Webmail-ap.st.com (10.80.176.7) with Microsoft SMTP Server (TLS) id 8.3.245.1; Thu, 6 Dec 2012 14:21:34 +0800 From: Vipin Kumar To: , , Date: Thu, 6 Dec 2012 11:51:21 +0530 Message-ID: X-Mailer: git-send-email 1.8.0 In-Reply-To: References: MIME-Version: 1.0 Cc: spear-devel@list.st.com Subject: [U-Boot] [PATCH resend 4/7] mtd/st_smi: Avoid issuing multiple WE commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de At the start of an smi_write, if the destination address is page aligned, the Write Enable command is getting issued twice. This patch fixes it by keeping a flag. Signed-off-by: Vipin Kumar Acked-by: Stefan Roese --- drivers/mtd/st_smi.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c index a46b273..a84802a 100644 --- a/drivers/mtd/st_smi.c +++ b/drivers/mtd/st_smi.c @@ -374,7 +374,7 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr, u8 *src_addr8 = (u8 *)src_addr; u8 *dst_addr8 = (u8 *)dst_addr; int banknum; - int i; + int i, issue_we; switch (bank_addr) { case SMIBANK0_BASE: @@ -394,19 +394,16 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr, } writel(readl(&smicntl->smi_sr) & ~(ERF1 | ERF2), &smicntl->smi_sr); - - if (smi_wait_till_ready(banknum, CONFIG_SYS_FLASH_WRITE_TOUT)) - return -EBUSY; + issue_we = 1; /* Set SMI in Hardware Mode */ writel(readl(&smicntl->smi_cr1) & ~SW_MODE, &smicntl->smi_cr1); - if (smi_write_enable(banknum)) - return -EIO; - /* Perform the write command */ for (i = 0; i < length; i += 4) { - if (((ulong) (dst_addr) % SFLASH_PAGE_SIZE) == 0) { + if (issue_we || (((ulong)(dst_addr) % SFLASH_PAGE_SIZE) == 0)) { + issue_we = 0; + if (smi_wait_till_ready(banknum, CONFIG_SYS_FLASH_WRITE_TOUT)) return -EBUSY;