From patchwork Mon Jun 6 09:44:52 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: 630761 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 3rNVGn2Tplz9snm for ; Mon, 6 Jun 2016 19:47:13 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5045AA759A; Mon, 6 Jun 2016 11:47:10 +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 FyIJ--5yNZQs; Mon, 6 Jun 2016 11:47:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B10E1A7552; Mon, 6 Jun 2016 11:46:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 727C2A74DB for ; Mon, 6 Jun 2016 11:45:22 +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 xNl6nGuFAmG0 for ; Mon, 6 Jun 2016 11:45:22 +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-sn1nam02on0085.outbound.protection.outlook.com [104.47.36.85]) by theia.denx.de (Postfix) with ESMTPS id 4CA70A74EE for ; Mon, 6 Jun 2016 11:45:15 +0200 (CEST) Received: from SN1NAM02FT012.eop-nam02.prod.protection.outlook.com (10.152.72.57) by SN1NAM02HT022.eop-nam02.prod.protection.outlook.com (10.152.72.124) 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.83) 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.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT012.mail.protection.outlook.com (10.152.72.95) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Mon, 6 Jun 2016 09:45:13 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1b9r5q-0008Ao-Qj; 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-Dz; Mon, 06 Jun 2016 02:45:12 -0700 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u569j1in032597; 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-0003X9-UU; Mon, 06 Jun 2016 02:45:01 -0700 Received: by xhdl3763.xilinx.com (Postfix, from userid 13899) id 5481F2CE0534; Mon, 6 Jun 2016 15:14:59 +0530 (IST) From: Siva Durga Prasad Paladugu To: Date: Mon, 6 Jun 2016 15:14:52 +0530 Message-ID: <1465206294-38490-7-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.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(19580405001)(107886002)(110136002)(50986999)(63266004)(81156014)(33646002)(42186005)(6806005)(5003940100001)(8676002)(19580395003)(2950100001)(76176999)(11100500001)(106466001)(52956003)(36756003)(81166006)(50466002)(189998001)(86362001)(48376002)(229853001)(90966002)(2351001)(2906002)(4001430100002)(586003)(87936001)(15650500001)(575784001)(92566002)(36386004)(45336002)(5008740100001)(8936002)(4326007)(50226002)(47776003)(46386002)(103686003)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1NAM02HT022; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7f530439-8868-4058-c08f-08d38def4205 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:SN1NAM02HT022; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(13024025)(13018025)(8121501046)(13015025)(5005006)(13023025)(10201501046)(3002001)(6055026); SRVR:SN1NAM02HT022; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT022; X-Forefront-PRVS: 096507C068 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2016 09:45:13.2495 (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.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT022 Cc: michals@xilinx.com, Siva Durga Prasad Paladugu Subject: [U-Boot] [PATCH 7/9] spi: spi_flash: Correct bank select incase of dual stacked 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" Correct the bank selection issue incase of Dual stacked mode. This fix corrects the wrong bank selection if banks are accessed as below. 1. Access the bank2 in upper flash. 2. Access the bank1 in lower flash. 3. Now access the bank1 in upper flash. But here in the step3, the present code was accessing the bank2 in upper flash not bank1. This was because the code thinks the bank1 was already selected as part of step2 but it was not taking care of upper or lower flash. Signed-off-by: Siva Durga Prasad Paladugu --- drivers/mtd/spi/spi_flash.c | 20 +++++++++++++++++--- include/spi_flash.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index e4c7ff5..93980bd 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -146,12 +146,26 @@ static int write_evcr(struct spi_flash *flash, u8 evcr) #ifdef CONFIG_SPI_FLASH_BAR static int spi_flash_write_bar(struct spi_flash *flash, u32 offset) { - u8 cmd, bank_sel; + u8 cmd, bank_sel, upage_curr; int ret; bank_sel = offset / (SPI_FLASH_16MB_BOUN << flash->shift); - if (bank_sel == flash->bank_curr) - goto bar_end; + + upage_curr = flash->spi->flags & SPI_XFER_U_PAGE; + + if (flash->dual_flash != SF_DUAL_STACKED_FLASH) { + if (flash->bank_curr == bank_sel) { + debug("SF: not require to enable bank%d\n", bank_sel); + goto bar_end; + } + } else if (flash->upage_prev == upage_curr) { + if (flash->bank_curr == bank_sel) { + debug("SF: not require to enable bank%d\n", bank_sel); + goto bar_end; + } + } else { + flash->upage_prev = upage_curr; + } cmd = flash->bank_write_cmd; ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1); diff --git a/include/spi_flash.h b/include/spi_flash.h index d0ce9e7..83052e0 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -78,6 +78,7 @@ struct spi_flash { u8 bank_read_cmd; u8 bank_write_cmd; u8 bank_curr; + u8 upage_prev; #endif u8 erase_cmd; u8 read_cmd;