From patchwork Tue Jun 28 17:38:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 102433 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 69DDBB6F59 for ; Wed, 29 Jun 2011 03:39:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 981C12814F; Tue, 28 Jun 2011 19:38:47 +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 f-ZShHl6nqZZ; Tue, 28 Jun 2011 19:38:47 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6CC80280F6; Tue, 28 Jun 2011 19:38:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D32D828099 for ; Tue, 28 Jun 2011 19:38:24 +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 8UJSlg+a2QCp for ; Tue, 28 Jun 2011 19:38:22 +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 2172D280F6 for ; Tue, 28 Jun 2011 19:38:20 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id CF8531BC022 for ; Tue, 28 Jun 2011 17:38:17 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Tue, 28 Jun 2011 13:38:08 -0400 Message-Id: <1309282694-27103-4-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1309282694-27103-1-git-send-email-vapier@gentoo.org> References: <1309282694-27103-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 3/9] sf: unify write enable 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 enable command, so unify this in the common code. Signed-off-by: Mike Frysinger --- drivers/mtd/spi/eon.c | 2 +- drivers/mtd/spi/macronix.c | 2 +- drivers/mtd/spi/ramtron.c | 2 +- drivers/mtd/spi/spansion.c | 2 +- drivers/mtd/spi/spi_flash.c | 2 +- drivers/mtd/spi/spi_flash_internal.h | 8 ++++++++ drivers/mtd/spi/sst.c | 2 +- drivers/mtd/spi/stmicro.c | 2 +- drivers/mtd/spi/winbond.c | 2 +- 9 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c index e3de3aa..6826708 100644 --- a/drivers/mtd/spi/eon.c +++ b/drivers/mtd/spi/eon.c @@ -91,7 +91,7 @@ static int eon_write(struct spi_flash *flash, ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); - ret = spi_flash_cmd(flash->spi, CMD_EN25Q128_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); break; diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index 90aa657..f1c2bbb 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -163,7 +163,7 @@ static int macronix_write(struct spi_flash *flash, ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); - ret = spi_flash_cmd(flash->spi, CMD_MX25XX_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); break; diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c index 078d16c..27d4039 100644 --- a/drivers/mtd/spi/ramtron.c +++ b/drivers/mtd/spi/ramtron.c @@ -198,7 +198,7 @@ static int ramtron_common(struct spi_flash *flash, if (command == CMD_RAMTRON_WRITE) { /* send WREN */ - ret = spi_flash_cmd(flash->spi, CMD_RAMTRON_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); goto releasebus; diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c index 8835e96..9dbab5d 100644 --- a/drivers/mtd/spi/spansion.c +++ b/drivers/mtd/spi/spansion.c @@ -177,7 +177,7 @@ static int spansion_write(struct spi_flash *flash, ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); - ret = spi_flash_cmd(flash->spi, CMD_S25FLXX_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); break; diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 016b586..3e0d02d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -163,7 +163,7 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd, debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1], cmd[2], cmd[3], offset); - ret = spi_flash_cmd(flash->spi, CMD_WRITE_ENABLE, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret) goto out; diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index fc109ce..6665bed 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -46,6 +46,14 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, const void *data, size_t data_len); /* + * Enable writing on the SPI flash. + */ +static inline int spi_flash_cmd_write_enable(struct spi_flash *flash) +{ + return spi_flash_cmd(flash->spi, CMD_WRITE_ENABLE, 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 4dc2db2..6691c1d 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -96,7 +96,7 @@ static const struct sst_spi_flash_params sst_spi_flash_table[] = { static int sst_enable_writing(struct spi_flash *flash) { - int ret = spi_flash_cmd(flash->spi, CMD_SST_WREN, NULL, 0); + int ret = spi_flash_cmd_write_enable(flash); if (ret) debug("SF: Enabling Write failed\n"); return ret; diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index a1959ca..80d97b4 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -169,7 +169,7 @@ static int stmicro_write(struct spi_flash *flash, ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); - ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); break; diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index e8d30ae..10fabf5 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -140,7 +140,7 @@ static int winbond_write(struct spi_flash *flash, buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); - ret = spi_flash_cmd(flash->spi, CMD_W25_WREN, NULL, 0); + ret = spi_flash_cmd_write_enable(flash); if (ret < 0) { debug("SF: Enabling Write failed\n"); goto out;