From patchwork Sun Feb 14 20:48:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 582588 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 5107A140321 for ; Mon, 15 Feb 2016 07:57:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7505BA75EE; Sun, 14 Feb 2016 21:53:58 +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 lCB2HqeK89-T; Sun, 14 Feb 2016 21:53:58 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CFE09A756B; Sun, 14 Feb 2016 21:53:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4BF78A76EB for ; Sun, 14 Feb 2016 21:53:07 +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 UEHxgBKCisVd for ; Sun, 14 Feb 2016 21:53:07 +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-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by theia.denx.de (Postfix) with ESMTPS id 22BEEA76A5 for ; Sun, 14 Feb 2016 21:52:33 +0100 (CET) Received: by mail-pa0-f44.google.com with SMTP id fy10so35031354pac.1 for ; Sun, 14 Feb 2016 12:52:33 -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=PnPptcygHpOsmRNMG7e7F69T0rcncHOCsoVsTKYvAIE=; b=AXYXXpEEdz7gyw/AgYomke7EizFolFVaCgEbVT2mkUqVy0/SAHGZ7qhtAeunmKAro+ Y4Io7rDh34OFOKGCv57fDVMw4oSFYz9VC+fhcZ2KaYeHwj+n7CKg8qd19Ae9uao1XAb4 GKdavZjS25fFNqR8OB48Uc+YpRr/e0YedLpblYLy9Zu+lFK6ZFizlzlhoeV830Qltc3F RaHX53BAhb1RQXqa+kk/AxjGslaxlpiNAfamn7NO7an5ltPx1MPh8Doh+AidQ9aUgpyR KD1kN8ZerAK0TFneQ2J8YwEV9AIj3adGPUW0IsseDqQXE1P4cu4nc9jz0Q3FI1nAgg8j 9tVQ== X-Gm-Message-State: AG10YOTg2TlaXOES1h8ppqbOn0VoIXyE1e+Jh4h8hF2JU5Qx56XAtjx+ex5PwxILO5gXjQ== X-Received: by 10.66.160.7 with SMTP id xg7mr18682959pab.10.1455483152568; Sun, 14 Feb 2016 12:52:32 -0800 (PST) Received: from localhost.localdomain ([123.236.183.254]) by smtp.gmail.com with ESMTPSA id cq9sm11423890pac.26.2016.02.14.12.52.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Feb 2016 12:52:30 -0800 (PST) From: Jagan Teki To: u-boot@lists.denx.de Date: Mon, 15 Feb 2016 02:18:36 +0530 Message-Id: <1455482955-19053-37-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455482955-19053-1-git-send-email-jteki@openedev.com> References: <1455482955-19053-1-git-send-email-jteki@openedev.com> Cc: Jagan Teki , Haikun Wang Subject: [U-Boot] [PATCH v6 37/76] mtd: 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: Simon Glass Cc: York Sun Cc: Haikun Wang Signed-off-by: Jagan Teki --- drivers/mtd/spi-nor/sf_dataflash.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi-nor/sf_dataflash.c b/drivers/mtd/spi-nor/sf_dataflash.c index 6a9dfef..7c6c8d2 100644 --- a/drivers/mtd/spi-nor/sf_dataflash.c +++ b/drivers/mtd/spi-nor/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,