From patchwork Tue Sep 24 18:19:53 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: 277573 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 C23C52C0092 for ; Wed, 25 Sep 2013 04:34:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 724E34A0B6; Tue, 24 Sep 2013 20:33:37 +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 AM3hDRg20uG4; Tue, 24 Sep 2013 20:33:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D93C34A0D3; Tue, 24 Sep 2013 20:31:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 50E944A0C2 for ; Tue, 24 Sep 2013 20:31:18 +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 EIdN1t9BJyHW for ; Tue, 24 Sep 2013 20:31:11 +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 co1outboundpool.messaging.microsoft.com (co1ehsobe005.messaging.microsoft.com [216.32.180.188]) by theia.denx.de (Postfix) with ESMTPS id 13D124A06E for ; Tue, 24 Sep 2013 20:30:41 +0200 (CEST) Received: from mail129-co1-R.bigfish.com (10.243.78.237) by CO1EHSOBE035.bigfish.com (10.243.66.100) with Microsoft SMTP Server id 14.1.225.22; Tue, 24 Sep 2013 18:30:38 +0000 Received: from mail129-co1 (localhost [127.0.0.1]) by mail129-co1-R.bigfish.com (Postfix) with ESMTP id 81F2C44015C; Tue, 24 Sep 2013 18:30:38 +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 (mail129-co1: 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 mail129-co1 (localhost.localdomain [127.0.0.1]) by mail129-co1 (MessageSwitch) id 1380047436446147_11129; Tue, 24 Sep 2013 18:30:36 +0000 (UTC) Received: from CO1EHSMHS027.bigfish.com (unknown [10.243.78.247]) by mail129-co1.bigfish.com (Postfix) with ESMTP id 63D0DA8004E; Tue, 24 Sep 2013 18:30:36 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by CO1EHSMHS027.bigfish.com (10.243.66.37) with Microsoft SMTP Server id 14.16.227.3; Tue, 24 Sep 2013 18:30:34 +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 1VOXNa-0003Un-6Y; Tue, 24 Sep 2013 11:30:34 -0700 From: Jagannadha Sutradharudu Teki To: Date: Tue, 24 Sep 2013 23:49:53 +0530 X-Mailer: git-send-email 1.8.3 In-Reply-To: <1380046813-12174-1-git-send-email-jaganna@xilinx.com> References: <1380046813-12174-1-git-send-email-jaganna@xilinx.com> X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: <2cb3f0e2-5f70-4ccb-99a9-bb1a5bdd4a5a@CO1EHSMHS027.ehs.local> X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: Willis Max , Jagannadha Sutradharudu Teki , Syed Hussain , "Todd Legler \(tlegler\)" , Tom Rini , Sascha Silbe Subject: [U-Boot] [PATCH v4 16/36] sf: probe: Move BAR config to spi_flash_validate_ids 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 Moved BAR config to spi_flash_validate_ids, so its better to have all flash initalization at once. Signed-off-by: Jagannadha Sutradharudu Teki --- Changes for v4: - none Changes for v3: - none Changes for v2: - none drivers/mtd/spi/spi_flash_internal.h | 5 ----- drivers/mtd/spi/spi_flash_probe.c | 24 +++++++++++------------- include/spi_flash.h | 3 +++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index ce34ce0..6227d2e 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -31,11 +31,6 @@ #define SPI_FLASH_16MB_BOUN 0x1000000 -/* Manufacture ID's */ -#define SPI_FLASH_SPANSION_IDCODE0 0x01 -#define SPI_FLASH_STMICRO_IDCODE0 0x20 -#define SPI_FLASH_WINBOND_IDCODE0 0xef - #ifdef CONFIG_SPI_FLASH_BAR /* Bank addr access commands */ # define CMD_BANKADDR_BRWR 0x17 diff --git a/drivers/mtd/spi/spi_flash_probe.c b/drivers/mtd/spi/spi_flash_probe.c index c62a1ee..b62ec54 100644 --- a/drivers/mtd/spi/spi_flash_probe.c +++ b/drivers/mtd/spi/spi_flash_probe.c @@ -219,6 +219,12 @@ struct spi_flash *spi_flash_validate_ids(struct spi_slave *spi, u8 *idcode) if (params->flags & E_FSR) flash->poll_cmd = CMD_FLAG_STATUS; +#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) || @@ -236,12 +242,12 @@ int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0) /* discover bank cmds */ switch (idcode0) { - case SPI_FLASH_SPANSION_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_STMICRO_IDCODE0: - case SPI_FLASH_WINBOND_IDCODE0: + 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; @@ -299,7 +305,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, { struct spi_slave *spi; struct spi_flash *flash = NULL; - u8 idcode[5], *idp; + u8 idcode[5]; int ret; /* Setup spi_slave */ @@ -329,18 +335,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, #endif /* Validate ID's from flash dev table */ - idp = idcode; - flash = spi_flash_validate_ids(spi, idp); + flash = spi_flash_validate_ids(spi, idcode); if (!flash) goto err_read_id; -#ifdef CONFIG_SPI_FLASH_BAR - /* Configure the BAR - discover bank cmds and read current bank */ - ret = spi_flash_bank_config(flash, *idp); - if (ret < 0) - goto err_read_id; -#endif - #ifdef CONFIG_OF_CONTROL if (spi_flash_decode_fdt(gd->fdt_blob, flash)) { debug("SF: FDT decode error\n"); diff --git a/include/spi_flash.h b/include/spi_flash.h index 3e60fdc..14e4ae2 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -20,7 +20,10 @@ /* 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)