From patchwork Thu Mar 23 00:17:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 95863 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp496684qgd; Wed, 22 Mar 2017 17:31:39 -0700 (PDT) X-Received: by 10.98.31.20 with SMTP id f20mr49426893pff.193.1490229099113; Wed, 22 Mar 2017 17:31:39 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id n1si3518752pld.289.2017.03.22.17.31.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 17:31:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Ina560D3wNJET0xcKWYTYUjdMObPbz6fQ8Aya3/on68=; b=XQpFNepeyB6ZL8fiD6XfJoNr8W smp1f12KITBqrhKqrcGvWKTTpT1Wnb2W9O0QiUJpaurBV0wDW/ODzsjNOhSxR5mMxptndWN8j3/z0 IY7SCOa59rRn0ahTZhvKQQe4cQ/jCsXE/0x/pQQXi3lP9WoSxXCu7ak8P/Umyd03RT3OyRfUI/fxx W477l5Ty7ScfUXK2p51JIyuQDRNl3+9b59bObwe9gv19lb2OY5/A8jAC3Wmb0g9h75sRnamZvbOpA m3f3njOoJdBZ196kt6FGK63/9ZHk9Dm480aeZEhB53NM0pa2nqFkJ47uCtJFNLocrkdAww8lNwCM8 O6+PwBDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqqf7-00039M-Es; Thu, 23 Mar 2017 00:31:33 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqqT6-0004a1-Ai for linux-mtd@lists.infradead.org; Thu, 23 Mar 2017 00:19:10 +0000 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-09.nifty.com with ESMTP id v2N0I4bt008011; Thu, 23 Mar 2017 09:18:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v2N0I4bt008011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490228306; bh=Ua3N32X8WuCHaHzeIoLo+h1GqaaKlzMltoQgNpDRZqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=atAzOdrjR+dPL25TWnJ4ZuE8x7ykVvOAEKjZPWj+07AGFWXG1RXU81jqzsyMJMR2k p/u0RF1y0eJrFbZlMFaCJYkxEtfns4w1zQvn1LUTefn+opLmcoB0lo3d30q9qe5O4m ftFkisaWdIDO+OQmX04TTmCgPPig7iPQT0o2dvFxAUkRCTuscnwKNk8aIN4ouiB2VR RBkSqZa1vBg3q9PQ/fpXUFsMNW3zfgnAAz90NSjWSEKjJwt2EcEfCrMOQuTDE4xIjc j2tKOIJdOr58b+C8qNmhFj6ctPpfJlX2Kk+iWVFuNmWNVovFme2m543zfqvh6i2rY0 k2Bk1uIV0jtDg== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [RESEND PATCH v2 43/53] mtd: nand: denali: fix bank reset function Date: Thu, 23 Mar 2017 09:17:52 +0900 Message-Id: <1490228282-10805-17-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> References: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent.monat@idquantique.com, Boris Brezillon , thorsten.christiansson@idquantique.com, Dinh Nguyen , Enrico Jorns , Artem Bityutskiy , Marek Vasut , Masahiro Yamada , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , David Woodhouse , Rob Herring , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The function denali_nand_reset() is called during the driver probe, and polls the INTR__RST_COMP and INTR__TIME_OUT bits. However, INTR__RST_COMP is set anyway even if no NAND device is connected to that bank. This can be a problem for ONFi devices. The nand_scan_ident() iterates over maxchips, and calls nand_reset() for each chip. Now, this driver implements ->setup_data_interface() method, so nand_setup_data_interface() issues Set Features (0xEF) command to each chip. This can cause time-out error since denali_nand_reset() did not check the chip existence. If no chip there, the controller will wait long for R/B# response, which never happens. (The timeout error is correctly handled in this driver, so the driver will be successfully probed anyway, but it will take longer than needed.) The Reset (0xFF) command also toggles the R/B# pin, and it sets INTR__INT_ACT bit. The driver should check this bit to see if the chip has responded, then it can update denali->max_banks. Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mtd/nand/denali.c | 52 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 2d25b2f..ef28411 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -85,33 +85,6 @@ static void index_addr(struct denali_nand_info *denali, iowrite32(data, denali->flash_mem + 0x10); } -/* Reset the flash controller */ -static uint16_t denali_nand_reset(struct denali_nand_info *denali) -{ - int i; - - for (i = 0; i < denali->max_banks; i++) - iowrite32(INTR__RST_COMP | INTR__TIME_OUT, - denali->flash_reg + INTR_STATUS(i)); - - for (i = 0; i < denali->max_banks; i++) { - iowrite32(1 << i, denali->flash_reg + DEVICE_RESET); - while (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & - (INTR__RST_COMP | INTR__TIME_OUT))) - cpu_relax(); - if (ioread32(denali->flash_reg + INTR_STATUS(i)) & - INTR__TIME_OUT) - dev_dbg(denali->dev, - "NAND Reset operation timed out on bank %d\n", i); - } - - for (i = 0; i < denali->max_banks; i++) - iowrite32(INTR__RST_COMP | INTR__TIME_OUT, - denali->flash_reg + INTR_STATUS(i)); - - return PASS; -} - /* * Use the configuration feature register to determine the maximum number of * banks that the hardware supports. @@ -963,7 +936,28 @@ static int denali_setup_data_interface(struct mtd_info *mtd, return 0; } -/* Initialization code to bring the device up to a known good state */ +static void denali_reset_banks(struct denali_nand_info *denali) +{ + int i; + + denali_clear_irq_all(denali); + + for (i = 0; i < denali->max_banks; i++) { + iowrite32(1 << i, denali->flash_reg + DEVICE_RESET); + while (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & + (INTR__RST_COMP | INTR__TIME_OUT))) + cpu_relax(); + if (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & + INTR__INT_ACT)) + break; + } + + dev_dbg(denali->dev, "%d chips connected\n", i); + denali->max_banks = i; + + denali_clear_irq_all(denali); +} + static void denali_hw_init(struct denali_nand_info *denali) { if (!denali->revision) @@ -979,7 +973,7 @@ static void denali_hw_init(struct denali_nand_info *denali) denali->bbtskipbytes = ioread32(denali->flash_reg + SPARE_AREA_SKIP_BYTES); detect_max_banks(denali); - denali_nand_reset(denali); + denali_reset_banks(denali); iowrite32(0x0F, denali->flash_reg + RB_PIN_ENABLED); iowrite32(CHIP_EN_DONT_CARE__FLAG, denali->flash_reg + CHIP_ENABLE_DONT_CARE);