From patchwork Sun Sep 15 18:16:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagannadha Sutradharudu Teki X-Patchwork-Id: 275042 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 9DD042C010E for ; Mon, 16 Sep 2013 04:17:58 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8AAC34A0B0; Sun, 15 Sep 2013 20:17:53 +0200 (CEST) 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 jnWimC5hoDNx; Sun, 15 Sep 2013 20:17:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 543D34A0B3; Sun, 15 Sep 2013 20:16:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A7A84A09D for ; Sun, 15 Sep 2013 20:16:40 +0200 (CEST) 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 FhxXfr1Fo39Y for ; Sun, 15 Sep 2013 20:16:35 +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 db8outboundpool.messaging.microsoft.com (mail-db8lp0187.outbound.messaging.microsoft.com [213.199.154.187]) by theia.denx.de (Postfix) with ESMTPS id 45E944A064 for ; Sun, 15 Sep 2013 20:16:29 +0200 (CEST) Received: from mail136-db8-R.bigfish.com (10.174.8.247) by DB8EHSOBE034.bigfish.com (10.174.4.97) with Microsoft SMTP Server id 14.1.225.22; Sun, 15 Sep 2013 18:16:28 +0000 Received: from mail136-db8 (localhost [127.0.0.1]) by mail136-db8-R.bigfish.com (Postfix) with ESMTP id C60EB88014B; Sun, 15 Sep 2013 18:16:28 +0000 (UTC) X-Forefront-Antispam-Report: CIP:149.199.60.83; KIP:(null); UIP:(null); IPV:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI X-SpamScore: 1 X-BigFish: VPS1(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h1de097h8275bhz2fh95h839hd24hf0ah119dh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1e23h1fe8h1ff5h906i1155h192ch) Received-SPF: pass (mail136-db8: domain of xilinx.com designates 149.199.60.83 as permitted sender) client-ip=149.199.60.83; envelope-from=jagannadha.sutradharudu-teki@xilinx.com; helo=xsj-gw1 ; helo=xsj-gw1 ; Received: from mail136-db8 (localhost.localdomain [127.0.0.1]) by mail136-db8 (MessageSwitch) id 1379268986600106_30960; Sun, 15 Sep 2013 18:16:26 +0000 (UTC) Received: from DB8EHSMHS018.bigfish.com (unknown [10.174.8.239]) by mail136-db8.bigfish.com (Postfix) with ESMTP id 8BF60340041; Sun, 15 Sep 2013 18:16:26 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by DB8EHSMHS018.bigfish.com (10.174.4.28) with Microsoft SMTP Server id 14.16.227.3; Sun, 15 Sep 2013 18:16:25 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1.xilinx.com) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1VLGrx-0005HJ-29; Sun, 15 Sep 2013 11:16:25 -0700 From: Jagannadha Sutradharudu Teki To: Date: Sun, 15 Sep 2013 23:46:03 +0530 X-Mailer: git-send-email 1.8.3 In-Reply-To: <1379268966-21745-1-git-send-email-jaganna@xilinx.com> References: <1379268966-21745-1-git-send-email-jaganna@xilinx.com> X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: Willis Max , Jagannadha Sutradharudu Teki , Tom Rini , "Todd Legler \(tlegler\)" , Syed Hussain Subject: [U-Boot] [PATCH v3 25/28] sf: probe: Simply the BAR configuration logic 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 Signed-off-by: Jagannadha Sutradharudu Teki --- Changes for v3: - none Changes for v2: - none drivers/mtd/spi/spi_flash_internal.h | 3 -- drivers/mtd/spi/spi_flash_probe.c | 56 +++++++++++------------------------- include/spi_flash.h | 3 -- 3 files changed, 16 insertions(+), 46 deletions(-) diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 286082a..86966f6 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -97,9 +97,6 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); #ifdef CONFIG_SPI_FLASH_BAR /* Program the bank address register */ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel); - -/* Configure the BAR - discover the bank cmds */ -int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0); #endif /* diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c index 3bf336d..b6b4cb2 100644 --- a/drivers/mtd/spi/spi_flash_probe.c +++ b/drivers/mtd/spi/spi_flash_probe.c @@ -220,56 +220,32 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode) #ifdef CONFIG_SPI_FLASH_BAR /* Configure the BAR - discover bank cmds and read current bank */ - if (spi_flash_bank_config(flash, idcode[0]) < 0) - return NULL; -#endif - - /* Flash powers up read-only, so clear BP# bits */ - if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) || - ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) || - ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST)) - spi_flash_cmd_write_status(flash, 0); - - return flash; -} - -#ifdef CONFIG_SPI_FLASH_BAR -int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0) -{ - u8 cmd; u8 curr_bank = 0; - - /* discover bank cmds */ - switch (idcode0) { - case SPI_FLASH_CFI_MFR_SPANSION: - flash->bank_read_cmd = CMD_BANKADDR_BRRD; - flash->bank_write_cmd = CMD_BANKADDR_BRWR; - break; - case SPI_FLASH_CFI_MFR_STMICRO: - case SPI_FLASH_CFI_MFR_WINBOND: - flash->bank_read_cmd = CMD_EXTNADDR_RDEAR; - flash->bank_write_cmd = CMD_EXTNADDR_WREAR; - break; - default: - printf("SF: Unsupported bank commands %02x\n", idcode0); - return -1; - } - - /* read the bank reg - on which bank the flash is in currently */ - cmd = flash->bank_read_cmd; if (flash->size > SPI_FLASH_16MB_BOUN) { - if (spi_flash_read_common(flash, &cmd, 1, &curr_bank, 1)) { + flash->bank_read_cmd = (idcode[0] == 0x01) ? + CMD_BANKADDR_BRRD : CMD_EXTNADDR_RDEAR; + flash->bank_write_cmd = (idcode[0] == 0x01) ? + CMD_BANKADDR_BRWR : CMD_EXTNADDR_WREAR; + + if (spi_flash_read_common(flash, &flash->bank_read_cmd, 1, + &curr_bank, 1)) { debug("SF: fail to read bank addr register\n"); - return -1; + return NULL; } flash->bank_curr = curr_bank; } else { flash->bank_curr = curr_bank; } +#endif - return 0; + /* Flash powers up read-only, so clear BP# bits */ + if (((params->jedec >> 16) == SPI_FLASH_CFI_MFR_ATMEL) || + ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_MACRONIX) || + ((params->jedec >> 16) == SPI_FLASH_CFI_MFR_SST)) + spi_flash_cmd_write_status(flash, 0); + + return flash; } -#endif #ifdef CONFIG_OF_CONTROL int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) diff --git a/include/spi_flash.h b/include/spi_flash.h index 34a167b..939da05 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -20,10 +20,7 @@ /* SPI flash CFI Manufacture ID's */ #define SPI_FLASH_CFI_MFR_ATMEL 0x1f #define SPI_FLASH_CFI_MFR_MACRONIX 0xc2 -#define SPI_FLASH_CFI_MFR_SPANSION 0x01 #define SPI_FLASH_CFI_MFR_SST 0xbf -#define SPI_FLASH_CFI_MFR_STMICRO 0x20 -#define SPI_FLASH_CFI_MFR_WINBOND 0xef /* SECT flags */ #define SECT_4K (1 << 0)