From patchwork Wed Nov 16 04:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 695436 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 3tJW1m5dbKz9syB for ; Wed, 16 Nov 2016 15:07:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF3FEB38CC; Wed, 16 Nov 2016 05:05:47 +0100 (CET) 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 GW7ONmLaMJNP; Wed, 16 Nov 2016 05:05:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 53B3DB3845; Wed, 16 Nov 2016 05:05:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 708FEA7559 for ; Wed, 16 Nov 2016 05:05:10 +0100 (CET) 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 zCJHUzhhzhaO for ; Wed, 16 Nov 2016 05:05:10 +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-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by theia.denx.de (Postfix) with ESMTPS id 28416B384B for ; Wed, 16 Nov 2016 05:04:57 +0100 (CET) Received: by mail-pg0-f65.google.com with SMTP id 3so13491450pgd.0 for ; Tue, 15 Nov 2016 20:04:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZU8fixNrZ5mo+ulmIiHkt4t1NEaoKaGtHvH4nyMGU0g=; b=j5cwYuxNy3+u/fWOGMf5T2HXnp1bCi8C3KROMUCF8DpHOYFAQCpG0bHFDI6SfieDTX RfgcuAbd7KbRAfz5dZeGQ5FJ5xknHNNgYjoKB7tMIrixWYoYqwSg7chAlg0BXPknqq8N RWVa1DlG9cZUDcEnZMUcJ8LFfbpyqJnojzOK15aHhGhMzq1VZfExwSc7MEAgeCRlCW9B TsAL/ZTfLtJbWrScqVyBMeQncXyuoC8cGT79NsX8+U3VkRUMiNMTv0M4OeqKXDlYL+2b eP53C903ruFxWh206X2FhBMepaCGJ5Nqpk7mYm60PuE2MMcl4hGVcBO/y8yG2ZfBomFF +t/Q== X-Gm-Message-State: ABUngvdQl5rDnFXBQvrFwpQ3oAr5MZVCYbdKW0N9GlCiOdcNEL5ktlc/4JyNGgTcSr696A== X-Received: by 10.99.167.67 with SMTP id w3mr3699870pgo.1.1479269095743; Tue, 15 Nov 2016 20:04:55 -0800 (PST) Received: from localhost.localdomain ([115.97.183.210]) by smtp.gmail.com with ESMTPSA id q145sm25217663pfq.22.2016.11.15.20.04.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 20:04:54 -0800 (PST) From: Jagan Teki To: u-boot@lists.denx.de Date: Wed, 16 Nov 2016 09:33:09 +0530 Message-Id: <1479268992-26811-19-git-send-email-jagan@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479268992-26811-1-git-send-email-jagan@openedev.com> References: <1479268992-26811-1-git-send-email-jagan@openedev.com> Cc: Jagan Teki Subject: [U-Boot] [PATCH v6 18/21] sf: dataflash: Move flash id detection into jedec_probe 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" Flash id detection should be the first step to enumerate the connected flash on the board, once ie done checking with respective id codes locally in the driver all this should be part of jedec_probe instead of id detection and validated through flash_info{} table separatly. Cc: Bin Meng Cc: York Sun Signed-off-by: Jagan Teki Reviewed-by: Simon Glass Reviewed-by: Jagan Teki --- drivers/mtd/spi/sf_dataflash.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c index 6a9dfef..7c6c8d2 100644 --- a/drivers/mtd/spi/sf_dataflash.c +++ b/drivers/mtd/spi/sf_dataflash.c @@ -501,9 +501,10 @@ static struct flash_info dataflash_data[] = { { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS}, }; -static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id) +static struct flash_info *jedec_probe(struct spi_slave *spi) { int tmp; + uint8_t id[5]; uint32_t jedec; struct flash_info *info; int status; @@ -517,6 +518,11 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id) * That's not an error; only rev C and newer chips handle it, and * only Atmel sells these chips. */ + tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id)); + if (tmp < 0) { + printf("dataflash: error %d reading JEDEC ID\n", tmp); + return ERR_PTR(tmp); + } if (id[0] != 0x1f) return NULL; @@ -580,7 +586,6 @@ static int spi_dataflash_probe(struct udevice *dev) struct spi_slave *spi = dev_get_parent_priv(dev); struct spi_flash *spi_flash; struct flash_info *info; - u8 idcode[5]; int ret, status = 0; spi_flash = dev_get_uclass_priv(dev); @@ -591,12 +596,6 @@ static int spi_dataflash_probe(struct udevice *dev) if (ret) return ret; - ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode)); - if (ret) { - printf("SPI DataFlash: Failed to get idcodes\n"); - goto err_read_cmd; - } - /* * Try to detect dataflash by JEDEC ID. * If it succeeds we know we have either a C or D part. @@ -604,7 +603,9 @@ static int spi_dataflash_probe(struct udevice *dev) * Both support the security register, though with different * write procedures. */ - info = jedec_probe(spi, idcode); + info = jedec_probe(spi); + if (IS_ERR(info)) + return PTR_ERR(info); if (info != NULL) add_dataflash(dev, info->name, info->nr_pages, info->pagesize, info->pageoffset,