From patchwork Sat Feb 23 11:38:58 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: 222715 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 047052C02A3 for ; Sat, 23 Feb 2013 22:40:15 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 853D44A19E; Sat, 23 Feb 2013 12:40:01 +0100 (CET) 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 DCiJJEuxa04g; Sat, 23 Feb 2013 12:40:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 696D24A1B2; Sat, 23 Feb 2013 12:39:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8D77A4A181 for ; Sat, 23 Feb 2013 12:39:43 +0100 (CET) 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 U-RW8XIapxGA for ; Sat, 23 Feb 2013 12:39:42 +0100 (CET) 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 ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) by theia.denx.de (Postfix) with ESMTPS id 301474A174 for ; Sat, 23 Feb 2013 12:39:40 +0100 (CET) Received: from mail108-ch1-R.bigfish.com (10.43.68.231) by CH1EHSOBE005.bigfish.com (10.43.70.55) with Microsoft SMTP Server id 14.1.225.23; Sat, 23 Feb 2013 11:39:38 +0000 Received: from mail108-ch1 (localhost [127.0.0.1]) by mail108-ch1-R.bigfish.com (Postfix) with ESMTP id 9EC563001E5; Sat, 23 Feb 2013 11:39: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(zzzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275bhz2fh95h668h839hd24hf0ah119dh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h906i1155h) Received-SPF: pass (mail108-ch1: 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 mail108-ch1 (localhost.localdomain [127.0.0.1]) by mail108-ch1 (MessageSwitch) id 1361619576599681_26027; Sat, 23 Feb 2013 11:39:36 +0000 (UTC) Received: from CH1EHSMHS015.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.253]) by mail108-ch1.bigfish.com (Postfix) with ESMTP id 86F30160073; Sat, 23 Feb 2013 11:39:34 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by CH1EHSMHS015.bigfish.com (10.43.70.15) with Microsoft SMTP Server id 14.1.225.23; Sat, 23 Feb 2013 11:39:32 +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 1U9DS0-0004VH-Kn; Sat, 23 Feb 2013 03:39:32 -0800 From: Jagannadha Sutradharudu Teki To: Date: Sat, 23 Feb 2013 17:08:58 +0530 X-Mailer: git-send-email 1.7.4 In-Reply-To: <1361619541-18299-1-git-send-email-jaganna@xilinx.com> References: <1361619541-18299-1-git-send-email-jaganna@xilinx.com> X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: <45e9b255-7557-41ce-9feb-bc524e23aedb@CH1EHSMHS015.ehs.local> X-OriginatorOrg: xilinx.com Cc: Michal@theia.denx.de, Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH 1/4] sf: Add extended address register writing support 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 This patch provides support to program a flash extended address register. extended/bank address register contains an information to access the 4th byte addressing in 3-byte address mode. Currently added an extended/bank address register writing support for spansion flashes. Signed-off-by: Jagannadha Sutradharudu Teki --- drivers/mtd/spi/spi_flash.c | 41 ++++++++++++++++++++++++++++++++++ drivers/mtd/spi/spi_flash_internal.h | 6 +++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 00aece9..232ccc0 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -269,6 +269,47 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr) return 0; } +int spi_flash_cmd_extaddr_write(struct spi_flash *flash, u8 ear) +{ + u8 cmd; + u8 idcode0; + int ret; + + ret = spi_flash_cmd(flash->spi, CMD_READ_ID, &idcode0, 1); + if (ret) { + debug("SF: fail to read read id\n"); + return ret; + } + + if (idcode0 == 0x01) + cmd = CMD_EXT_BRWR; + else { + printf("SF: unable to support extaddr reg write" + " for %s flash\n", flash->name); + return -1; + } + + ret = spi_flash_cmd_write_enable(flash); + if (ret < 0) { + debug("SF: enabling write failed\n"); + return ret; + } + + ret = spi_flash_cmd_write(flash->spi, &cmd, 1, &ear, 1); + if (ret) { + debug("SF: fail to write ext addr register\n"); + return ret; + } + + ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT); + if (ret < 0) { + debug("SF: write config register timed out\n"); + return ret; + } + + return 0; +} + /* * The following table holds all device probe functions * diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 141cfa8..dbceb81 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -28,6 +28,9 @@ #define CMD_ERASE_64K 0xd8 #define CMD_ERASE_CHIP 0xc7 +/* Extended addr acess commands */ +#define CMD_EXT_BRWR 0x17 + /* Common status */ #define STATUS_WIP 0x01 @@ -77,6 +80,9 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash) /* Program the status register. */ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); +/* Program the extended address register */ +int spi_flash_cmd_extaddr_write(struct spi_flash *flash, u8 ear); + /* * Same as spi_flash_cmd_read() except it also claims/releases the SPI * bus. Used as common part of the ->read() operation.