From patchwork Wed Sep 2 06:09:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 513345 X-Patchwork-Delegate: jagannadh.teki@gmail.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 9DB63140129 for ; Wed, 2 Sep 2015 18:05:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 24B8E4B82B; Wed, 2 Sep 2015 10:04:57 +0200 (CEST) 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 yxuNxvb4OEbe; Wed, 2 Sep 2015 10:04:56 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 19C7D4B7CC; Wed, 2 Sep 2015 10:04:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A4BDA4B768 for ; Wed, 2 Sep 2015 08:10:32 +0200 (CEST) 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 MnSQoN0P4jLD for ; Wed, 2 Sep 2015 08:10:32 +0200 (CEST) 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 mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by theia.denx.de (Postfix) with ESMTPS id 2E47F4B73C for ; Wed, 2 Sep 2015 08:10:28 +0200 (CEST) Received: by pacwi10 with SMTP id wi10so14863pac.3 for ; Tue, 01 Sep 2015 23:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5I13PPWUa2Xd9ef3OHYqP6l/x5j+u+JPEJUAgTBN2Vg=; b=Ul5zTaYVTqxUfpbJtwgmkvJuDNkh8yAPD6+l25D1qkw++P0kvCWaIZ0F9K/HUM+4If YG/Iu6jVyrSgn7joPQcYOV4lUQQ+i9LDFQiRq8Ad14kT28r3CKBbOtI/dukeAPBmmWbn 7gQwsiajTdBle64dvjV9apJ2gOmYpLTVk01aaec38PbemuZf6f/yAnvxVD4depIMoJdu q0W3nDNXjMt+GFkm0Mj7q3Hbk23BV3H9ibspDDnkd7Ik+s8NBzIyDW+WiOonFwZB2EIp RIHbvdn+Y0vwxXRlQZgyTePjQ969V8c2rDWrPn8VFuIKvvDCIgoMsY9sD0Oe+geTG5e7 tBSA== X-Received: by 10.68.189.161 with SMTP id gj1mr53430436pbc.4.1441174227597; Tue, 01 Sep 2015 23:10:27 -0700 (PDT) Received: from Jubuntu.amcc.com ([182.73.239.130]) by smtp.gmail.com with ESMTPSA id pi9sm20195859pbb.96.2015.09.01.23.10.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 23:10:26 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Wed, 2 Sep 2015 11:39:48 +0530 Message-Id: <1441174197-5096-5-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441174197-5096-1-git-send-email-jteki@openedev.com> References: <1441174197-5096-1-git-send-email-jteki@openedev.com> X-Mailman-Approved-At: Wed, 02 Sep 2015 10:04:22 +0200 Cc: Jagan Teki , Michal Simek , Siva Durga Prasad Paladugu Subject: [U-Boot] [PATCH v3 04/13] sf: Optimize BAR write code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Optimized spi-flash bar writing code and also removed unnecessary bank_sel in read_ops. Signed-off-by: Jagan Teki Cc: Simon Glass Cc: Michal Simek Cc: Siva Durga Prasad Paladugu --- Changes for v3: - none Changes for v2: - Use bank_sel variable in read ops drivers/mtd/spi/sf_ops.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index b33fe5a..6e457ec 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -95,15 +95,14 @@ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 wc) #endif #ifdef CONFIG_SPI_FLASH_BAR -static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) +static int spi_flash_write_bank(struct spi_flash *flash, u32 offset) { - u8 cmd; + u8 cmd, bank_sel; int ret; - if (flash->bank_curr == bank_sel) { - debug("SF: not require to enable bank%d\n", bank_sel); - return bank_sel; - } + bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift); + if (bank_sel == flash->bank_curr) + goto bar_end; cmd = flash->bank_write_cmd; ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1); @@ -111,25 +110,10 @@ static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) debug("SF: fail to write bank register\n"); return ret; } - flash->bank_curr = bank_sel; - - return 0; -} - -static int spi_flash_bank(struct spi_flash *flash, u32 offset) -{ - u8 bank_sel; - int ret; - - bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift); - - ret = spi_flash_cmd_bankaddr_write(flash, bank_sel); - if (ret) { - debug("SF: fail to set bank%d\n", bank_sel); - return ret; - } - return bank_sel; +bar_end: + flash->bank_curr = bank_sel; + return flash->bank_curr; } #endif @@ -285,7 +269,7 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) spi_flash_dual_flash(flash, &erase_addr); #endif #ifdef CONFIG_SPI_FLASH_BAR - ret = spi_flash_bank(flash, erase_addr); + ret = spi_flash_write_bank(flash, erase_addr); if (ret < 0) return ret; #endif @@ -327,7 +311,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, spi_flash_dual_flash(flash, &write_addr); #endif #ifdef CONFIG_SPI_FLASH_BAR - ret = spi_flash_bank(flash, write_addr); + ret = spi_flash_write_bank(flash, write_addr); if (ret < 0) return ret; #endif @@ -422,9 +406,10 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, spi_flash_dual_flash(flash, &read_addr); #endif #ifdef CONFIG_SPI_FLASH_BAR - bank_sel = spi_flash_bank(flash, read_addr); - if (bank_sel < 0) + ret = spi_flash_write_bank(flash, read_addr); + if (ret < 0) return ret; + bank_sel = flash->bank_curr; #endif remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) * (bank_sel + 1)) - offset;