From patchwork Thu Jun 13 20:55:24 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: 251160 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 E1A182C0085 for ; Fri, 14 Jun 2013 06:57:51 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F2514A117; Thu, 13 Jun 2013 22:57:39 +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 PvC27LrGqUY4; Thu, 13 Jun 2013 22:57:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3502D4A0B0; Thu, 13 Jun 2013 22:56:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B6BA14A0A8 for ; Thu, 13 Jun 2013 22:56:38 +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 fUplsTbJV2HS for ; Thu, 13 Jun 2013 22:56:31 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from co9outboundpool.messaging.microsoft.com (co9ehsobe005.messaging.microsoft.com [207.46.163.28]) by theia.denx.de (Postfix) with ESMTPS id 898094A08B for ; Thu, 13 Jun 2013 22:56:29 +0200 (CEST) Received: from mail167-co9-R.bigfish.com (10.236.132.237) by CO9EHSOBE038.bigfish.com (10.236.130.101) with Microsoft SMTP Server id 14.1.225.23; Thu, 13 Jun 2013 20:56:25 +0000 Received: from mail167-co9 (localhost [127.0.0.1]) by mail167-co9-R.bigfish.com (Postfix) with ESMTP id 82CF14C027C; Thu, 13 Jun 2013 20:56:25 +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(zzzz1f42h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ah1fc6hzz8275bhz2fh95h668h839hd24hf0ah119dh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1e23h906i1155h192ch) Received-SPF: pass (mail167-co9: 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 mail167-co9 (localhost.localdomain [127.0.0.1]) by mail167-co9 (MessageSwitch) id 137115698453069_8314; Thu, 13 Jun 2013 20:56:24 +0000 (UTC) Received: from CO9EHSMHS026.bigfish.com (unknown [10.236.132.254]) by mail167-co9.bigfish.com (Postfix) with ESMTP id 0013C48005F; Thu, 13 Jun 2013 20:56:23 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by CO9EHSMHS026.bigfish.com (10.236.130.36) with Microsoft SMTP Server id 14.1.225.23; Thu, 13 Jun 2013 20:56:21 +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 1UnEZB-0001G8-GY; Thu, 13 Jun 2013 13:56:21 -0700 From: Jagannadha Sutradharudu Teki To: Date: Fri, 14 Jun 2013 02:25:24 +0530 X-Mailer: git-send-email 1.8.3 In-Reply-To: <1371156936-23067-1-git-send-email-jaganna@xilinx.com> References: <1371156936-23067-1-git-send-email-jaganna@xilinx.com> X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: <88edf5d6-efe2-494b-b101-a9e1d4ac2629@CO9EHSMHS026.ehs.local> X-OriginatorOrg: xilinx.com Cc: Hoyler Gernot , "Todd Legler (tlegler)" , Willis Max , Jagannadha Sutradharudu Teki , Syed@theia.denx.de, Hussain , Rajeshwari Shinde , Tom Rini , Daassi Bacem Subject: [U-Boot] [PATCH v4 02/14] sf: Discover the bank addr commands 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 Bank/Extended addr commands are specific to particular flash vendor so discover them based on the idocode0. Assign the discovered bank commands to spi_flash members so-that the bank read/write will use their specific operations. Signed-off-by: Jagannadha Sutradharudu Teki --- Changes for v4: - none Changes for v3: - none Changes for v2: - none drivers/mtd/spi/spi_flash.c | 21 +++++++++++++++++++++ drivers/mtd/spi/spi_flash_internal.h | 14 ++++++++++++++ include/spi_flash.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 9ddd070..9c90f00 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -304,6 +304,27 @@ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) return 0; } +int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0) +{ + /* discover bank cmds */ + switch (idcode0) { + case SPI_FLASH_SPANSION_IDCODE0: + flash->bank_cmd[0] = CMD_BANKADDR_BRRD; + flash->bank_cmd[1] = CMD_BANKADDR_BRWR; + break; + case SPI_FLASH_STMICRO_IDCODE0: + case SPI_FLASH_WINBOND_IDCODE0: + flash->bank_cmd[0] = CMD_EXTNADDR_RDEAR; + flash->bank_cmd[1] = CMD_EXTNADDR_WREAR; + break; + default: + printf("SF: Unsupported bank commands %02x\n", idcode0); + return -1; + } + + return 0; +} + #ifdef CONFIG_OF_CONTROL int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) { diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 772fef6..db6c444 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -28,6 +28,17 @@ #define CMD_ERASE_64K 0xd8 #define CMD_ERASE_CHIP 0xc7 +/* Manufacture ID's */ +#define SPI_FLASH_SPANSION_IDCODE0 0x01 +#define SPI_FLASH_STMICRO_IDCODE0 0x20 +#define SPI_FLASH_WINBOND_IDCODE0 0xef + +/* Bank addr access commands */ +#define CMD_BANKADDR_BRWR 0x17 +#define CMD_BANKADDR_BRRD 0x16 +#define CMD_EXTNADDR_WREAR 0xC5 +#define CMD_EXTNADDR_RDEAR 0xC8 + /* Common status */ #define STATUS_WIP 0x01 @@ -80,6 +91,9 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); /* 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); + /* * Same as spi_flash_cmd_read() except it also claims/releases the SPI * bus. Used as common part of the ->read() operation. diff --git a/include/spi_flash.h b/include/spi_flash.h index 3b6a44e..50a03bf 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -38,6 +38,8 @@ struct spi_flash { u32 page_size; /* Erase (sector) size */ u32 sector_size; + /* Bank cmds - cmd[0] - read, cmd[1] - write */ + u8 bank_cmd[2]; void *memory_map; /* Address of read-only SPI flash access */ int (*read)(struct spi_flash *flash, u32 offset,