From patchwork Thu Sep 28 09:46:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 819470 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ci2j1Mpg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VCp6Y1HF"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2qbn3bLcz9t3w for ; Thu, 28 Sep 2017 19:47:16 +1000 (AEST) 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=LM2S+btrxgsoMuZm+v4vPgN8OVkDk5bNT1jLnbi09b4=; b=Ci2j1MpgM1y4ZIm19a8tSlrp2S ahBnsx6ak0PlLHCDDLR7vyyZZM6GaHlnsvFqLG9k65qnj1qu7j/5TEbpvWjTuy/Z3ZdxatwfJ8zPi IE3DrNKMye2wUTn403w4d22VlevsOfEuyXy+B2cTQT/0dSkKpMxPbw51wPHGYoEw/tH14LutDNQrm poQnttU+9h5xoqvU02rHS3N3aNwxrOixWiWyPH7S3IZG5n19zqTiGNg7uzw2ASqWEiK8zw2/b/W1h y1sjm/nE/2YRX+hiaS4dJFhYvEx1GNMVY0ZQ1MnUgIaO3rdtK/Xf920Uqsk0akm0VkuySdSawkbJ1 hhS3EheA==; 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 1dxVPQ-0002ox-7V; Thu, 28 Sep 2017 09:47:08 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dxVPK-0002S3-3L for linux-mtd@lists.infradead.org; Thu, 28 Sep 2017 09:47:05 +0000 Received: by mail-wm0-x243.google.com with SMTP id m72so1067471wmc.1 for ; Thu, 28 Sep 2017 02:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ekmUElve1eO9lFnfDY02U3uv6BFDIO3z+pfaU9Ayz0M=; b=VCp6Y1HFYfdPv1tkjLkFoDDbeVhR+pDtkstWO2bmtRPSGk1sI6w3x3YrFvtcmObHzY 6z4mHrE544OGrIsykpXnM3yNf3+13VySm17/cQTZJN8BJ9TfVWRMz37Z5V4j0tPL773d BesKG7JEqjf2ZlOxKiWW040lelS1aNIrsYSQWUST4cQYGWjv3HbP+QD8qpoTiZUuV05R 0AB1JMWRgUoOVojqVOKcm3zYNDX7VvNHCADitzVszcBCTp8RIGPpr82Kmpi86u9qJGQn 0HypKCfJ5zQb8vCrSa5zk+nJPQvrBAGACWGjxngWsd9yWQbJneIHhfUmh1pt0HYl8ltz rZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ekmUElve1eO9lFnfDY02U3uv6BFDIO3z+pfaU9Ayz0M=; b=o7WDqoVqZipBCQWFB1/s1qxRQYW3Q+F3Mcf9td87uSFK6o9v+5wlpql3D6EyG7Ohm1 KT3P/ed6AY6oVGak4xyuS9YJVNCI8uQIVKOayLrLqsoZj5pdT6CUmrMCJmRGlqJtllj4 uMocaL8FF0M//ka3JmdPPQhAcRhbmOXWMVomD8UBHNdnduIjGfajoRLcizpYEdhvygWD PcsALXVExwJApdoAtaAw3NREcoqXycqDf0jRDnYp2cuGl7yA7QSNmvMuKeiJLFJV1Sb/ nCUYkZO4h+j7TOtLogA/Vkj8kIB0NH7porYMg+8QpI0pcQPDY3q7Xsr0+GDzFnZGCTlu 7ImA== X-Gm-Message-State: AMCzsaWGaIglSVyAuDDKlnL+3ZhBdGu+/wFBXQZVVsYmhzM5ks94PKWZ M8Cdt5hcqydAya6hbGxwly0= X-Google-Smtp-Source: AOwi7QDNJz5hgGMatKKtMkVtKfrygnvWxSRzoM0OykizAp6/p8faG93WHnSN66Dq+U5Y/AcZlRzZIg== X-Received: by 10.28.17.79 with SMTP id 76mr520386wmr.74.1506592003906; Thu, 28 Sep 2017 02:46:43 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id z10sm3272395wre.6.2017.09.28.02.46.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:46:43 -0700 (PDT) From: Romain Izard To: Boris Brezillon , Michael Turquette , Stephen Boyd , Lee Jones , Wenyou Yang , Josh Wu , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Alan Stern , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Subject: [PATCH v4 4/8] mtd: nand: atmel: Avoid ECC errors when leaving backup mode Date: Thu, 28 Sep 2017 11:46:23 +0200 Message-Id: <20170928094627.31017-5-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com> References: <20170928094627.31017-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_024702_476930_3084E00F X-CRM114-Status: GOOD ( 16.75 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (romain.izard.pro[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: linux-pwm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-serial@vger.kernel.org, Romain Izard , linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During backup mode, the contents of all registers will be cleared as the SoC will be completely powered down. For a product that boots on NAND Flash memory, the bootloader will obviously use the related controller to read the Flash and correct any detected error in the memory, before handling back control to the kernel's resuming entry point. But it does not clean the NAND controller registers after use and on its side the kernel driver expects the error locator to be powered down and in a clean state. Add a resume hook for the PMECC error locator, and reset its registers. Signed-off-by: Romain Izard --- Changes in v3: * keep the PMECC disabled when not in use, and use atmel_pmecc_resume to reset the controller after the bootloader has left it enabled. Changes in v4: * export atmel_pmecc_reset instead of atmel_pmecc_resume * use the correct pointer in atmel_nand_controller_resume drivers/mtd/nand/atmel/nand-controller.c | 3 +++ drivers/mtd/nand/atmel/pmecc.c | 17 +++++++++-------- drivers/mtd/nand/atmel/pmecc.h | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index f25eca79f4e5..8afcff9a66ea 100644 --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c @@ -2530,6 +2530,9 @@ static __maybe_unused int atmel_nand_controller_resume(struct device *dev) struct atmel_nand_controller *nc = dev_get_drvdata(dev); struct atmel_nand *nand; + if (nc->pmecc) + atmel_pmecc_reset(nc->pmecc); + list_for_each_entry(nand, &nc->chips, node) { int i; diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c index 146af8218314..0a3f12141c45 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c @@ -765,6 +765,13 @@ void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user, } EXPORT_SYMBOL_GPL(atmel_pmecc_get_generated_eccbytes); +void atmel_pmecc_reset(struct atmel_pmecc *pmecc) +{ + writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); + writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); +} +EXPORT_SYMBOL_GPL(atmel_pmecc_reset); + int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op) { struct atmel_pmecc *pmecc = user->pmecc; @@ -797,10 +804,7 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable); void atmel_pmecc_disable(struct atmel_pmecc_user *user) { - struct atmel_pmecc *pmecc = user->pmecc; - - writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); - writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); + atmel_pmecc_reset(user->pmecc); mutex_unlock(&user->pmecc->lock); } EXPORT_SYMBOL_GPL(atmel_pmecc_disable); @@ -855,10 +859,7 @@ static struct atmel_pmecc *atmel_pmecc_create(struct platform_device *pdev, /* Disable all interrupts before registering the PMECC handler. */ writel(0xffffffff, pmecc->regs.base + ATMEL_PMECC_IDR); - - /* Reset the ECC engine */ - writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); - writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); + atmel_pmecc_reset(pmecc); return pmecc; } diff --git a/drivers/mtd/nand/atmel/pmecc.h b/drivers/mtd/nand/atmel/pmecc.h index a8ddbfca2ea5..817e0dd9fd15 100644 --- a/drivers/mtd/nand/atmel/pmecc.h +++ b/drivers/mtd/nand/atmel/pmecc.h @@ -61,6 +61,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc, struct atmel_pmecc_user_req *req); void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user); +void atmel_pmecc_reset(struct atmel_pmecc *pmecc); int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op); void atmel_pmecc_disable(struct atmel_pmecc_user *user); int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user);