From patchwork Mon Apr 25 16:59:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 92761 X-Patchwork-Delegate: wd@denx.de 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 06BDDB6F44 for ; Tue, 26 Apr 2011 02:59:56 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7B8628158; Mon, 25 Apr 2011 18:59:54 +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 5DFVHS4i5Gdw; Mon, 25 Apr 2011 18:59:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C29922815A; Mon, 25 Apr 2011 18:59:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D2B652815A for ; Mon, 25 Apr 2011 18:59:50 +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 REPa7KfoEmoi for ; Mon, 25 Apr 2011 18:59:50 +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 smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 051F028158 for ; Mon, 25 Apr 2011 18:59:48 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id D287E1B4064 for ; Mon, 25 Apr 2011 16:59:46 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Mon, 25 Apr 2011 12:59:53 -0400 Message-Id: <1303750794-8043-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.5.rc1 In-Reply-To: <1303635958-10985-1-git-send-email-vapier@gentoo.org> References: <1303635958-10985-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 5/4] sf: unify write disable commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Every spi flash uses the same write disnable command, so unify this in the common code. Signed-off-by: Mike Frysinger --- drivers/mtd/spi/spi_flash_internal.h | 9 +++++++++ drivers/mtd/spi/sst.c | 2 +- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index f80f717..91e036a 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -20,6 +20,7 @@ #define CMD_READ_ARRAY_LEGACY 0xe8 #define CMD_PAGE_PROGRAM 0x02 +#define CMD_WRITE_DISABLE 0x04 #define CMD_READ_STATUS 0x05 #define CMD_WRITE_ENABLE 0x06 @@ -62,6 +63,14 @@ static inline int spi_flash_cmd_write_enable(struct spi_flash *flash) } /* + * Disable writing on the SPI flash. + */ +static inline int spi_flash_cmd_write_disable(struct spi_flash *flash) +{ + return spi_flash_cmd(flash->spi, CMD_WRITE_DISABLE, NULL, 0); +} + +/* * 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/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c index 6691c1d..d1e8a93 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -105,7 +105,7 @@ sst_enable_writing(struct spi_flash *flash) static int sst_disable_writing(struct spi_flash *flash) { - int ret = spi_flash_cmd(flash->spi, CMD_SST_WRDI, NULL, 0); + int ret = spi_flash_cmd_write_disable(flash); if (ret) debug("SF: Disabling Write failed\n"); return ret;