From patchwork Mon Dec 31 11:13:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 208832 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 533B32C009A for ; Mon, 31 Dec 2012 22:16:17 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A13DC4A14C; Mon, 31 Dec 2012 12:16:12 +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 kn-RtToMq-HV; Mon, 31 Dec 2012 12:16:12 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67A194A14D; Mon, 31 Dec 2012 12:15:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 365174A11F for ; Mon, 31 Dec 2012 12:14:56 +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 VZfAaOywHiw0 for ; Mon, 31 Dec 2012 12:14:53 +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 mail-da0-f41.google.com (mail-da0-f41.google.com [209.85.210.41]) by theia.denx.de (Postfix) with ESMTPS id C8D6E4A126 for ; Mon, 31 Dec 2012 12:14:15 +0100 (CET) Received: by mail-da0-f41.google.com with SMTP id e20so5699805dak.14 for ; Mon, 31 Dec 2012 03:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=JhQBlFDA/1vnaFJ6kG/VcvwPkqDv8EUIE0JJWixJO9U=; b=gbMUoLFCvHhlvBgZ7y07PE1hhRxBKe52aW0ky1vhvHizVpGPYNnv7bgPpdFDfVuA3H +QZrJI/NzZhcY0mXnc87jrbas1Ma45cjPF0yM4dvk5v8sUX2QaERsVI7wsBG5mYUYDYd rO5CadxzbUqV0E3FOktfzj5vcg0ju01nKBItnCxg90bkSlr/uGl5rwgrT7LPyoIncPNP SHbfJs1+vNQ9jKh2UzO3XzJlC2vHXehHLqe/lngWi1b23yPBNNG2afB8dEGMAh2jlszG cUEzjShEzbJeNjrampF/M9VSD4oH7UM7inow7UgC1MVjHbp1RDrf/LL7XhYTdbVPyaGj rs8g== X-Received: by 10.68.233.201 with SMTP id ty9mr128545841pbc.14.1356952453972; Mon, 31 Dec 2012 03:14:13 -0800 (PST) Received: from localhost.localdomain ([49.204.11.250]) by mx.google.com with ESMTPS id nw9sm24715215pbb.42.2012.12.31.03.14.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 31 Dec 2012 03:14:13 -0800 (PST) From: Jagannadha Sutradharudu Teki To: u-boot@lists.denx.de Date: Mon, 31 Dec 2012 16:43:41 +0530 Message-Id: <1356952428-19824-3-git-send-email-jagannadh.teki@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1356952428-19824-1-git-send-email-jagannadh.teki@gmail.com> References: <1356952428-19824-1-git-send-email-jagannadh.teki@gmail.com> Subject: [U-Boot] [PATCH 02/12] cmd_sf: Add rd_inst argument to 'sf read' command 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch provides a support to add a read instruction(rd_inst) argument to 'sf read' command. User will dynamically use the specific read instruction while reading the flash using 'sf read' command. Currently added an existing read instruction called afr(Array Fast Read). Example: read 0x2000 length bytes starting at offset 0x0 to memory at 0x10000 using afr read instruction. u-boot> sf read afr 0x10000 0x0 0x2000 Signed-off-by: Jagannadha Sutradharudu Teki --- common/cmd_sf.c | 23 +++++++++++++++++------ drivers/mtd/spi/spi_flash.c | 4 ++-- drivers/mtd/spi/spi_flash_internal.h | 2 +- include/spi_flash.h | 10 +++++----- include/spi_flash_inst.h | 3 +++ 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index e7843f3..88b18f8 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -235,7 +235,7 @@ static int do_spi_flash_read_write(int argc, char * const argv[]) unsigned long len; void *buf; char *endp; - u8 wr_inst; + u8 wr_inst, rd_inst; int ret; if (argc < 5) @@ -266,9 +266,17 @@ static int do_spi_flash_read_write(int argc, char * const argv[]) if (strcmp(argv[0], "update") == 0) ret = spi_flash_update(flash, offset, len, buf); - else if (strcmp(argv[0], "read") == 0) - ret = spi_flash_read(flash, offset, len, buf); - else { + else if (strcmp(argv[0], "read") == 0) { + if (strcmp(argv[1], "afr") == 0) + rd_inst = CMD_READ_ARRAY_FAST; + else { + printf("SF: Unknown %s rd_inst on 'sf read'\n", + argv[1]); + return 1; + } + + ret = spi_flash_read(flash, rd_inst, offset, len, buf); + } else { if (strcmp(argv[1], "pp") == 0) wr_inst = CMD_PAGE_PROGRAM; else { @@ -535,8 +543,11 @@ U_BOOT_CMD( "SPI flash sub-system", "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n" " and chip select\n" - "sf read addr offset len - read `len' bytes starting at\n" - " `offset' to memory at `addr'\n" + "sf read rd_inst addr offset len\n" + " - read `len' bytes starting at\n" + " `offset' to memory at `addr' using\n" + " afr `rd_inst' read instruction\n" + " afr (Array Fast Read, 0bh)\n" "sf write wr_inst addr offset len\n" " - write `len' bytes from memory\n" " at `addr' to flash at `offset' using\n" diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 8ba2c65..0c64ac2 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -135,12 +135,12 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd, return ret; } -int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, +int spi_flash_cmd_read_fast(struct spi_flash *flash, u8 rd_inst, u32 offset, size_t len, void *data) { u8 cmd[5]; - cmd[0] = CMD_READ_ARRAY_FAST; + cmd[0] = rd_inst; spi_flash_addr(offset, cmd); cmd[4] = 0x00; diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 0d416b3..dcf8813 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -43,7 +43,7 @@ int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len); int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, void *data, size_t data_len); -int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, +int spi_flash_cmd_read_fast(struct spi_flash *flash, u8 rd_inst, u32 offset, size_t len, void *data); /* diff --git a/include/spi_flash.h b/include/spi_flash.h index 9b3a6a1..6728796 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -39,8 +39,8 @@ struct spi_flash { /* Erase (sector) size */ u32 sector_size; - int (*read)(struct spi_flash *flash, u32 offset, - size_t len, void *buf); + int (*read)(struct spi_flash *flash, u8 rd_inst, + u32 offset, size_t len, void *buf); int (*write)(struct spi_flash *flash, u8 wr_inst, u32 offset, size_t len, const void *buf); int (*erase)(struct spi_flash *flash, u32 offset, @@ -51,10 +51,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int spi_mode); void spi_flash_free(struct spi_flash *flash); -static inline int spi_flash_read(struct spi_flash *flash, u32 offset, - size_t len, void *buf) +static inline int spi_flash_read(struct spi_flash *flash, u8 rd_inst, + u32 offset, size_t len, void *buf) { - return flash->read(flash, offset, len, buf); + return flash->read(flash, rd_inst, offset, len, buf); } static inline int spi_flash_write(struct spi_flash *flash, u8 wr_inst, diff --git a/include/spi_flash_inst.h b/include/spi_flash_inst.h index 139f45b..7c1b910 100644 --- a/include/spi_flash_inst.h +++ b/include/spi_flash_inst.h @@ -27,4 +27,7 @@ /* Write commands */ #define CMD_PAGE_PROGRAM 0x02 +/* Read commands */ +#define CMD_READ_ARRAY_FAST 0x0b + #endif /* _SPI_FLASH_INST_H_ */