From patchwork Sat Jul 16 17:32:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Pretzsch X-Patchwork-Id: 104986 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 67FD0B6F82 for ; Sun, 17 Jul 2011 03:32:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A49E12809B; Sat, 16 Jul 2011 19:32:31 +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 fkrj6j-jukNG; Sat, 16 Jul 2011 19:32:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B39228090; Sat, 16 Jul 2011 19:32:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 15B9128090 for ; Sat, 16 Jul 2011 19:32:27 +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 WuTQVAERLOCB for ; Sat, 16 Jul 2011 19:32:26 +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 mail.mars-solutions.de (mars-solutions.de [213.239.212.107]) by theia.denx.de (Postfix) with ESMTP id 3FFB12808D for ; Sat, 16 Jul 2011 19:32:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.mars-solutions.de (Postfix) with ESMTP id B6C09A040D0 for ; Sat, 16 Jul 2011 19:30:38 +0200 (CEST) Received: from mail.mars-solutions.de ([127.0.0.1]) by localhost (mars-solutions.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XkumO+exInj6 for ; Sat, 16 Jul 2011 19:30:31 +0200 (CEST) Received: by mail.mars-solutions.de (Postfix, from userid 1036) id 8C29BA040E7; Sat, 16 Jul 2011 19:30:31 +0200 (CEST) Received: from ws-apr.office.loc (HSI-KBW-078-043-059-252.hsi4.kabel-badenwuerttemberg.de [78.43.59.252]) by mail.mars-solutions.de (Postfix) with ESMTP id 32352A040D0 for ; Sat, 16 Jul 2011 19:30:31 +0200 (CEST) Received: by ws-apr.office.loc (Postfix, from userid 1000) id 47B7E276052; Sat, 16 Jul 2011 19:32:13 +0200 (CEST) From: Andreas Pretzsch To: u-boot@lists.denx.de Date: Sat, 16 Jul 2011 19:32:06 +0200 Message-Id: <1310837526-3394-1-git-send-email-apr@cn-eng.de> X-Mailer: git-send-email 1.7.5.4 Cc: Andreas Pretzsch Subject: [U-Boot] [PATCH] command "sspi": add write-only flag '.w' (discard read data) 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 The sspi command writes the given data out on SPI and prints the data it reads to the console. For write-only slaves (i.e. a SPI-connected latch used as output expander), this is pointless and clutters the console. When called as "sspi.w", this output is omitted. The flag is optional and backwards compatible, previous sspi revisions would simply ignore the flag (checked back to 2011.03). Signed-off-by: Andreas Pretzsch --- Data size (number of bits) are passed as separate parameter to sspi, hence .w is "free" and not used as data size anyway. --- common/cmd_spi.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/cmd_spi.c b/common/cmd_spi.c index 8c623c9..c56c191 100644 --- a/common/cmd_spi.c +++ b/common/cmd_spi.c @@ -72,12 +72,17 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) uchar tmp; int j; int rcode = 0; + int write_only = 0; /* * We use the last specified parameters, unless new ones are * entered. */ + j = strlen(argv[0]); + if (j > 2 && argv[0][j-2] == '.' && argv[0][j-1] == 'w') + write_only = 1; + if ((flag & CMD_FLAG_REPEAT) == 0) { if (argc >= 2) { @@ -131,10 +136,12 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("Error during SPI transaction\n"); rcode = 1; } else { - for(j = 0; j < ((bitlen + 7) / 8); j++) { - printf("%02X", din[j]); + if (!write_only) { + /* dump read values to console */ + for (j = 0; j < ((bitlen + 7) / 8); j++) + printf("%02X", din[j]); + printf("\n"); } - printf("\n"); } spi_release_bus(slave); spi_free_slave(slave); @@ -147,7 +154,8 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( sspi, 5, 1, do_spi, "SPI utility command", - "[:][.] - Send and receive bits\n" + "[.w] [:][.] - Send and receive bits\n" + ".w - write only => don't print read result\n" " - Identifies the SPI bus\n" " - Identifies the chip select\n" " - Identifies the SPI mode to use\n"