From patchwork Tue Jan 24 16:18:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Nelson X-Patchwork-Id: 137588 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 CC0A7B6F62 for ; Wed, 25 Jan 2012 03:19:29 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 116432819D; Tue, 24 Jan 2012 17:19:06 +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 Hn+0am3-RV7m; Tue, 24 Jan 2012 17:19:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A29022819E; Tue, 24 Jan 2012 17:18:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C5F3028180 for ; Tue, 24 Jan 2012 17:18:38 +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 bw6SzKiQ9R3Q for ; Tue, 24 Jan 2012 17:18:38 +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.integraonline.com (relay1.integra.net [204.130.255.180]) by theia.denx.de (Postfix) with SMTP id E150728184 for ; Tue, 24 Jan 2012 17:18:35 +0100 (CET) Received: (qmail 26411 invoked from network); 24 Jan 2012 16:18:35 -0000 Received: from unknown (HELO ericsony.example.org) (70.96.116.236) by relay1.integra.net with SMTP; 24 Jan 2012 16:18:35 -0000 From: Eric Nelson To: u-boot@lists.denx.de Date: Tue, 24 Jan 2012 09:18:22 -0700 Message-Id: <1327421904-21487-5-git-send-email-eric.nelson@boundarydevices.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1327421904-21487-1-git-send-email-eric.nelson@boundarydevices.com> References: <1327421904-21487-1-git-send-email-eric.nelson@boundarydevices.com> Cc: dirk.behme@de.bosch.com, jason.hui@linaro.org Subject: [U-Boot] [PATCH V3 4/6] sf command: allow default chip select through CONFIG_SPI_FLASH_CS 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 allows a board configuration file to provide a default chip-select for serial flash so that first argument to the 'sf' command is optional. On boards that use the mxc_spi driver and a GPIO for chip select, this allows a much simpler command line: U-Boot> sf probe instead of U-Boot> sf probe 0x5300 Signed-off-by: Eric Nelson Acked-by: Dirk Behme Acked-by: Stefano Babic Acked-by: Fabio Estevam --- common/cmd_sf.c | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 7225656..4b32171 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -70,20 +70,28 @@ static int do_spi_flash_probe(int argc, char * const argv[]) char *endp; struct spi_flash *new; - if (argc < 2) - return -1; - - cs = simple_strtoul(argv[1], &endp, 0); - if (*argv[1] == 0 || (*endp != 0 && *endp != ':')) +#ifndef CONFIG_SPI_FLASH_CS + if (argc < 2) { + printf("%s: missing arguments\n", __func__); return -1; - if (*endp == ':') { - if (endp[1] == 0) - return -1; + } +#else + cs = CONFIG_SPI_FLASH_CS ; +#endif - bus = cs; - cs = simple_strtoul(endp + 1, &endp, 0); - if (*endp != 0) + if (argc >= 2) { + cs = simple_strtoul(argv[1], &endp, 0); + if (*argv[1] == 0 || (*endp != 0 && *endp != ':')) return -1; + if (*endp == ':') { + if (endp[1] == 0) + return -1; + + bus = cs; + cs = simple_strtoul(endp + 1, &endp, 0); + if (*endp != 0) + return -1; + } } if (argc >= 3) { @@ -299,7 +307,11 @@ usage: U_BOOT_CMD( sf, 5, 1, do_spi_flash, "SPI flash sub-system", +#ifndef CONFIG_SPI_FLASH_CS "probe [bus:]cs [hz] [mode] - init flash device on given SPI bus\n" +#else + "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n" +#endif " and chip select\n" "sf read addr offset len - read `len' bytes starting at\n" " `offset' to memory at `addr'\n"