From patchwork Fri Sep 15 14:04:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 814300 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="kBi+FyT1"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YxWca4af"; 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 3xty6X62pWz9s7m for ; Sat, 16 Sep 2017 00:13:08 +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=mb9niXxDvucXZK6J4fMkQbtGPzphSIX8W7Ss9xzNEmY=; b=kBi+FyT11mplxsGiQ1+TMBFRJd OhzmkidfWNhTHSl7Q0alnLg8+2q62eGakSnxk5NmcEcgkB5SOcmm/vvVQuV+39r+/TQkjB0CB9tqb xFaNRh/kCPty6EuR0fhui/syHq3qkG5MVez8NllX/tj1U7bQsajpn15BKPnThFcNd8divqTc91XkK dAo2QTXVomgYkpfRXbu4tlsPHk2fwOtnIMKG3/Zqp4wo195g7oN0pL9rQiDBrscIzJqAJv94912nC w5wDdzOCSDLKoRu7x6LZhyne2Wr3sVTOlGaw/xhmo295wKxylPLVRb1YVB0weTs9dlvuT9LcTJ3Nn zvB5VxYQ==; 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 1dsrMK-0003bq-Rf; Fri, 15 Sep 2017 14:12:44 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dsrFC-0003no-7P; Fri, 15 Sep 2017 14:05:33 +0000 Received: by mail-wm0-x241.google.com with SMTP id e64so2895155wmi.2; Fri, 15 Sep 2017 07:04:59 -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=owFYxnK787Ud9TRMMs531N3In48svKrtFKwYj7nv/wc=; b=YxWca4afXXd++jaVBaAXFaVt91CHnKpKJ9pUKAST9NOd6Sj0u5NWVV0+UPh3wggxJ6 VkXsqPT9nJ+EnFHRSARuMtR5C/p/lQRGB8eBvcfWd0THgyX6EIt0H+xr2tbiGbEilKix pfBA6iD9xDIxFkhE8D6jKCH7uR4CHmWlNqMaGvi+ZECuVV5UlPC/zxfsKMiMKdpoEDrl TSmTxw+qS/Ga6VIyX1jZ4iuBvAXa2x04g5tuOpfFK+53AczufHqa4WqVoHwz1MHHrEBy 4oUVH5Raf81PqXadDFS/gGU+i/FGbHuUh9gBmRkWL5j9ANEjXXK54ib2Ld2GGXQAEvKe Hzuw== 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=owFYxnK787Ud9TRMMs531N3In48svKrtFKwYj7nv/wc=; b=qxZyiyZ/1UjqM5mlq/Xvf5X0rzS7Y15XZed+iEQ/lLf/ewn29lzRKNC7ZYUdZoCo9G mUvW7Dl3FL5fLBbVYQdUZU7wEuajU0nmgglp5mlEi6+gPrVE7G7CN7KG5wfYoF0VXfLh KwE0RVm6fUj1EL+Z90EiiVMK49DRwkCjxoVgl1KWsPA9p0uGpuha7uD93YunX3ch+sAr pBooG9809bqDJL4jSa7IpV24CgpXpI8FvujScGX0J3X00Qkah3VNWPCayX9CxucR5IJv E3VoJFt6zjKQKZOjigo87hsf9nQg5Jc6w4G/AIvF7VpW2VWMBxA/Ij7eteSWLVlLe23j 44Ag== X-Gm-Message-State: AHPjjUjrK5twGedj4ksCzAfVTKuiFjDRGttl9/pjBKAAzM4uBKSwqAGV TxkUbpqYSujfgekc1A45LiY= X-Google-Smtp-Source: AOwi7QCNKS4lV/BQsBWIo0q3kBz4OTpfhHuaC03IOuO/Dq3FfZPOhELHDKF6UrUX3hx59KweFUKstQ== X-Received: by 10.28.130.130 with SMTP id e124mr2671760wmd.75.1505484298568; Fri, 15 Sep 2017 07:04:58 -0700 (PDT) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id 55sm1399225wrw.60.2017.09.15.07.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 07:04:58 -0700 (PDT) From: Romain Izard To: Nicolas Ferre , Alexandre Belloni , Boris Brezillon , Michael Turquette , Stephen Boyd , Ludovic Desroches , Wenyou Yang , Josh Wu , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Thierry Reding , Richard Genoud , Greg Kroah-Hartman , Alan Stern Subject: [PATCH v2 4/9] mtd: nand: atmel: Avoid ECC errors when leaving backup mode Date: Fri, 15 Sep 2017 16:04:06 +0200 Message-Id: <20170915140411.31716-5-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170915140411.31716-1-romain.izard.pro@gmail.com> References: <20170915140411.31716-1-romain.izard.pro@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170915_070526_035425_305ECFBF X-CRM114-Status: GOOD ( 14.50 ) 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:241 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, linux-arm-kernel@lists.infradead.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. In normal devices, it is up to the driver's suspend/resume code to restore the registers in a valid state. But the PMECC is not a regular device in the driver model when used with the legacy device tree binding for the Atmel NAND controller, and suspend/resume code is not called. As in my case the bootloader leaves the PMECC controller in a programmed state, and the controller is only reset at boot or after a NAND access, the first NAND Flash access with the Atmel controller will report uncorrectable ECC errors. To avoid this, systematically reset the PMECC controller before using it. Signed-off-by: Romain Izard --- drivers/mtd/nand/atmel/pmecc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c index 8c210a5776bc..8d1208f38025 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c @@ -777,6 +777,9 @@ int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op) mutex_lock(&user->pmecc->lock); + writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL); + writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL); + cfg = user->cache.cfg; if (op == NAND_ECC_WRITE) cfg |= PMECC_CFG_WRITE_OP; @@ -797,10 +800,6 @@ 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); mutex_unlock(&user->pmecc->lock); } EXPORT_SYMBOL_GPL(atmel_pmecc_disable); @@ -856,10 +855,6 @@ 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); - return pmecc; }