From patchwork Mon Oct 12 15:01:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 529149 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 C863F1402B2 for ; Tue, 13 Oct 2015 02:03:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 159914B8E6; Mon, 12 Oct 2015 17:02:56 +0200 (CEST) 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 TrIDBNxi_oYj; Mon, 12 Oct 2015 17:02:55 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E23C4B8FA; Mon, 12 Oct 2015 17:02:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 22DCB4B8CE for ; Mon, 12 Oct 2015 17:02:44 +0200 (CEST) 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 S7jDgo4vgjhu for ; Mon, 12 Oct 2015 17:02:44 +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-pa0-f67.google.com (mail-pa0-f67.google.com [209.85.220.67]) by theia.denx.de (Postfix) with ESMTPS id 0BAD04B8FA for ; Mon, 12 Oct 2015 17:02:39 +0200 (CEST) Received: by padew5 with SMTP id ew5so19259130pad.0 for ; Mon, 12 Oct 2015 08:02:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4m3IeS4xGQRhsuA/ubK6NoIs0R3tuhYqfHdugBgG430=; b=gpkA2BYooUjVzpPi4Cioi+wTe7kupXYFebe0zybjnpz/asgFIr4xQTcXyikod+StDq Uq/yCCgL1NsNURQa9m9usXFAVpwqqKTEV7OUDNxoY3qmuqFY1lojveJ3oYHFhEvQdhoe XbEZTUT7yn2AXBlR+cg3x35tOZrsugMbrpABmxiLBG2Ccl2pmH49TzwZFmnVv4tTAu96 6/oGUf+L0EtEGPRm4lMkgOxpokXsZDHuMTqLReb9B8+x1F8r6p13rTolGvjmwEZh8TFV w7oUc76nsnz6iK76cuV0oL0WJhdSD0SpTLZ4ybWVgkPmO1Lq7Hf31/so61hbT1npcJGk S3wQ== X-Received: by 10.66.162.227 with SMTP id yd3mr35369058pab.53.1444662158747; Mon, 12 Oct 2015 08:02:38 -0700 (PDT) Received: from Jubuntu.amcc.com ([182.73.239.130]) by smtp.gmail.com with ESMTPSA id qy5sm18924909pbb.16.2015.10.12.08.02.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 08:02:37 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Mon, 12 Oct 2015 20:31:03 +0530 Message-Id: <1444662074-2424-11-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444662074-2424-1-git-send-email-jteki@openedev.com> References: <1444662074-2424-1-git-send-email-jteki@openedev.com> Cc: fabio.estevam@freescale.com, Marek Vasut , qiwang@micron.com, Tom Rini , Michal Simek , Siva Durga Prasad Paladugu , frankliu@micron.com, Jagan Teki Subject: [U-Boot] [PATCH v4 10/21] sf: Move the read_id code to sf_ops X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" read_id code is related to spi_flash stuff hence moved to sf_ops. Signed-off-by: Jagan Teki --- Changes for v4, v3, v2: - none drivers/mtd/spi/sf_internal.h | 3 +-- drivers/mtd/spi/sf_ops.c | 21 ++++++++++++++++++--- drivers/mtd/spi/sf_probe.c | 15 +-------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 3f07560..8216fdc 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -235,7 +235,6 @@ void spi_flash_mtd_unregister(void); /** * spi_flash_scan - scan the SPI FLASH * @spi: the spi slave structure - * @idcode: idcode of spi flash * @flash: the spi flash structure * * The drivers can use this fuction to scan the SPI FLASH. @@ -244,6 +243,6 @@ void spi_flash_mtd_unregister(void); * * Return: 0 for success, others for failure. */ -int spi_flash_scan(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash); +int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash); #endif /* _SF_INTERNAL_H_ */ diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index d37b0a9..016a5df 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -706,14 +706,29 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) } #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ -int spi_flash_scan(struct spi_slave *spi, u8 *idcode, struct spi_flash *flash) +int spi_flash_scan(struct spi_slave *spi, struct spi_flash *flash) { const struct spi_flash_params *params; + u16 jedec, ext_jedec; + u8 idcode[5]; u8 cmd; - u16 jedec = idcode[1] << 8 | idcode[2]; - u16 ext_jedec = idcode[3] << 8 | idcode[4]; int ret; + /* Read the ID codes */ + ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode)); + if (ret) { + printf("SF: Failed to get idcodes\n"); + return -EINVAL; + } + +#ifdef DEBUG + printf("SF: Got idcodes\n"); + print_buffer(0, idcode, 1, sizeof(idcode), 0); +#endif + + jedec = idcode[1] << 8 | idcode[2]; + ext_jedec = idcode[3] << 8 | idcode[4]; + /* Validate params from spi_flash_params table */ params = spi_flash_params_table; for (; params->name != NULL; params++) { diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index d2991de..a712792 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -29,7 +29,6 @@ */ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash) { - u8 idcode[5]; int ret; /* Setup spi_slave */ @@ -45,19 +44,7 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash) return ret; } - /* Read the ID codes */ - ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode)); - if (ret) { - printf("SF: Failed to get idcodes\n"); - goto err_read_id; - } - -#ifdef DEBUG - printf("SF: Got idcodes\n"); - print_buffer(0, idcode, 1, sizeof(idcode), 0); -#endif - - ret = spi_flash_scan(spi, idcode, flash); + ret = spi_flash_scan(spi, flash); if (ret) { ret = -EINVAL; goto err_read_id;