From patchwork Mon Jun 6 09:44:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Durga Prasad Paladugu X-Patchwork-Id: 630760 X-Patchwork-Delegate: monstr@monstr.eu 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 3rNVGT51KSz9snm for ; Mon, 6 Jun 2016 19:46:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C04ACA7559; Mon, 6 Jun 2016 11:46:54 +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 Qn5W-QFXLUUz; Mon, 6 Jun 2016 11:46:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 12B56A7576; Mon, 6 Jun 2016 11:46:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D2390A750E for ; Mon, 6 Jun 2016 11:45:21 +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 RaDM5Tm1t-ox for ; Mon, 6 Jun 2016 11:45:21 +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 NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0087.outbound.protection.outlook.com [104.47.36.87]) by theia.denx.de (Postfix) with ESMTPS id 4BF6DA74DB for ; Mon, 6 Jun 2016 11:45:15 +0200 (CEST) Received: from CY1NAM02FT004.eop-nam02.prod.protection.outlook.com (10.152.74.51) by CY1NAM02HT025.eop-nam02.prod.protection.outlook.com (10.152.75.99) with Microsoft SMTP Server (TLS) id 15.1.497.8; Mon, 6 Jun 2016 09:45:13 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by CY1NAM02FT004.mail.protection.outlook.com (10.152.74.112) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Mon, 6 Jun 2016 09:45:12 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:42652 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1b9r5q-0003sV-JJ; Mon, 06 Jun 2016 02:45:10 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1b9r5s-0003sh-CQ; Mon, 06 Jun 2016 02:45:12 -0700 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u569j24p008404; Mon, 6 Jun 2016 02:45:02 -0700 Received: from [172.23.146.171] (helo=xhdl3763.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1b9r5g-0003XA-UV; Mon, 06 Jun 2016 02:45:01 -0700 Received: by xhdl3763.xilinx.com (Postfix, from userid 13899) id 699B72CE0859; Mon, 6 Jun 2016 15:14:59 +0530 (IST) From: Siva Durga Prasad Paladugu To: Date: Mon, 6 Jun 2016 15:14:53 +0530 Message-ID: <1465206294-38490-8-git-send-email-sivadur@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1465206294-38490-1-git-send-email-sivadur@xilinx.com> References: <1465206294-38490-1-git-send-email-sivadur@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22374.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(19580395003)(81166006)(19580405001)(189998001)(106466001)(586003)(46386002)(50226002)(48376002)(90966002)(36386004)(81156014)(4326007)(45336002)(4001430100002)(110136002)(107886002)(6806005)(2906002)(8936002)(5008740100001)(15650500001)(2950100001)(5003940100001)(42186005)(92566002)(47776003)(50466002)(36756003)(50986999)(229853001)(2351001)(8676002)(52956003)(76176999)(33646002)(63266004)(86362001)(87936001)(103686003)(107986001)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1NAM02HT025; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e871b5a2-6d44-46e5-6e52-08d38def41cb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:CY1NAM02HT025; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13015025)(13017025)(13023025)(8121501046)(13024025)(13018025)(3002001)(10201501046)(6055026); SRVR:CY1NAM02HT025; BCL:0; PCL:0; RULEID:; SRVR:CY1NAM02HT025; X-Forefront-PRVS: 096507C068 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2016 09:45:12.8204 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT025 Cc: michals@xilinx.com, Siva Durga Prasad Paladugu Subject: [U-Boot] [PATCH 8/9] spi: spi_flash: Fix Bank selection calculation for Dual parallel 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In Dual parallel connection the bank selection calculation should be performed using offset and not the calculated address Signed-off-by: Siva Durga Prasad Paladugu --- drivers/mtd/spi/spi_flash.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 93980bd..2de2a35 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -340,7 +340,7 @@ int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd, int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) { - u32 erase_size, erase_addr; + u32 erase_size, erase_addr, bank_addr; u8 cmd[SPI_FLASH_CMD_LEN]; int ret = -1; @@ -361,13 +361,16 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) cmd[0] = flash->erase_cmd; while (len) { erase_addr = offset; + bank_addr = offset; #ifdef CONFIG_SF_DUAL_FLASH if (flash->dual_flash > SF_SINGLE_FLASH) spi_flash_dual(flash, &erase_addr); + if (flash->dual_flash == SF_DUAL_STACKED_FLASH) + bank_addr = erase_addr; #endif #ifdef CONFIG_SPI_FLASH_BAR - ret = spi_flash_write_bar(flash, erase_addr); + ret = spi_flash_write_bar(flash, bank_addr); if (ret < 0) return ret; #endif @@ -394,7 +397,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, { struct spi_slave *spi = flash->spi; unsigned long byte_addr, page_size; - u32 write_addr; + u32 write_addr, bank_addr; size_t chunk_len, actual; u8 cmd[SPI_FLASH_CMD_LEN]; int ret = -1; @@ -412,13 +415,16 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset, cmd[0] = flash->write_cmd; for (actual = 0; actual < len; actual += chunk_len) { write_addr = offset; + bank_addr = offset; #ifdef CONFIG_SF_DUAL_FLASH if (flash->dual_flash > SF_SINGLE_FLASH) spi_flash_dual(flash, &write_addr); + if (flash->dual_flash == SF_DUAL_STACKED_FLASH) + bank_addr = write_addr; #endif #ifdef CONFIG_SPI_FLASH_BAR - ret = spi_flash_write_bar(flash, write_addr); + ret = spi_flash_write_bar(flash, bank_addr); if (ret < 0) return ret; #endif @@ -488,7 +494,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, { struct spi_slave *spi = flash->spi; u8 *cmd, cmdsz; - u32 remain_len, read_len, read_addr; + u32 remain_len, read_len, read_addr, bank_addr; int bank_sel = 0; int ret = -1; @@ -516,13 +522,16 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset, cmd[0] = flash->read_cmd; while (len) { read_addr = offset; + bank_addr = offset; #ifdef CONFIG_SF_DUAL_FLASH if (flash->dual_flash > SF_SINGLE_FLASH) spi_flash_dual(flash, &read_addr); + if (flash->dual_flash == SF_DUAL_STACKED_FLASH) + bank_addr = read_addr; #endif #ifdef CONFIG_SPI_FLASH_BAR - ret = spi_flash_write_bar(flash, read_addr); + ret = spi_flash_write_bar(flash, bank_addr); if (ret < 0) return ret; bank_sel = flash->bank_curr;