From patchwork Sat Aug 4 09:57:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 953426 X-Patchwork-Delegate: miquel.raynal@bootlin.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=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CEWjmVgd"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 41jK9644zqz9s0R for ; Sat, 4 Aug 2018 19:58:02 +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: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:In-Reply-To: References:List-Owner; bh=zXgYMYFagbhJUD0w+F7DccLJGYb8FmvTS+/uQLA8pLw=; b=CEW jmVgdByLroFY6MnZwpDD6W+THvBXyxT0w2sVfbGU9iLNZiNAA6hRXkeQdnPQgWccpawgA1EikSajY x0F6caYok8kWVEzAUtofOgz8/L/uvFcumkESrPWbPpyG2iEw0Eg6lYuvd6ls2fD2VmW6TYxaQGIhr jSQY9mSmHp+xP7kNOS9ecsBAkBIRrHP14iEC+N2QS7RaL+lxYSC5tSRMEz8RT8OJiFuxGp+F5r/cS LfPvLU9MZtZuG5Q+LDzcYvZBu5qjI8lXdgOdMTm3s2vERRBRKTjPNhQHbSwtMHyxHP3ilPl0bl/l/ gG+W46GCHlnW8GcrOamUUil2mgkY1Yg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fltJp-0003qg-Lg; Sat, 04 Aug 2018 09:57:53 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fltJf-0003gA-NP for linux-mtd@lists.infradead.org; Sat, 04 Aug 2018 09:57:45 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id B48CB207BD; Sat, 4 Aug 2018 11:57:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (AToulouse-657-1-1031-177.w92-134.abo.wanadoo.fr [92.134.9.177]) by mail.bootlin.com (Postfix) with ESMTPSA id 1104F206A6; Sat, 4 Aug 2018 11:57:19 +0200 (CEST) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut Subject: [PATCH v3 1/2] mtd: rawnand: marvell: document a bit more the driver Date: Sat, 4 Aug 2018 11:57:16 +0200 Message-Id: <20180804095717.8089-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180804_025744_038770_C79AAE71 X-CRM114-Status: GOOD ( 18.69 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [62.4.15.54 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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-mtd@lists.infradead.org, Miquel Raynal MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org A stale document about the old pxa3cc_nand.c driver is available in Documentation/mtd/nand/. Rewrite the parts that explain the IP itself and some non-trivial choices made in the driver directly in marvell_nand.c to then be able to remove this file. Signed-off-by: Miquel Raynal --- Changes since v2: ================= * Addressed Boris comments, mostly typos and rewritting as suggested. Changes since v1: ================= * Corrected mistakes pointed by Boris. * Enlarged the documentation as suggested by Thomas to mention the layouts as seen per the controller. * Added a mention about the maximum ECC size which is 2kiB. drivers/mtd/nand/raw/marvell_nand.c | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index 218e09431d3d..dc1da132e684 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -5,6 +5,69 @@ * Copyright (C) 2017 Marvell * Author: Miquel RAYNAL * + * + * This NAND controller driver handles two versions of the hardware, + * one is called NFCv1 and is available on PXA SoCs and the other is + * called NFCv2 and is available on almost Armada SoCs. + * + * The main visible difference is that NFCv1 only has Hamming ECC + * capabilities, while NFCv2 also embeds a BCH ECC engine. Also, DMA + * is not used with NFCv2. + * + * The ECC layouts are depicted in details in Marvell AN-379. + * + * When using Hamming, the data is split in 512B chunks (either 0, 1 + * or 2) and each chunk will have its own ECC "digest" of 6B at the + * beginning of the OOB area and eventually the remaining fee OOB + * bytes. This engine corrects up to 1 bit per chunk and detects + * reliably an error if there are at most 2 bitflips. Here the page + * layout used by the controller when Hamming is chosen: + * + * +-------------------------------------------------------------+ + * | Data 1 | ... | Data N | ECC 1 | ... | ECCN | Free OOB bytes | + * +-------------------------------------------------------------+ + * + * When using the BCH engine, there are N identical (data + spare + + * ECC) sections and potentially an extra one to deal with + * configurations where the chosen (data + spare + ECC) sizes do not align + * with the page (data + OOB) size. Here the page layout used by + * the controller when BCH is chosen: + * + * +----------------------------------------- + * | Data 1 | Free OOB bytes 1 | ECC 1 | ... + * +----------------------------------------- + * + * ------------------------------------------- + * ... | Data N | Free OOB bytes N | ECC N | + * ------------------------------------------- + * + * --------------------------------------------+ + * Last Data | Last Free OOB bytes | Last ECC | + * --------------------------------------------+ + * + * In both cases, the layout seen by the user is always: all the + * data in one chunk, all the free OOB bytes and finally all the ECC + * bytes. With BCH, ECC bytes are 30B long and are padded to 32B with + * 0xFF. + * + * The controller has certain limitations that are handled by the + * driver: + * - It can only read 2k at a time. To overcome this limitation, the + * driver makes use of 'naked' operations. + * - The ECC strength in BCH mode cannot be tuned easily. It is + * fixed 16 bits. What can be tuned in the ECC block size as long + * as it stays between 512B and 2kiB. It's usually chosen based on + * the chip ECC requirements. For instance, using 2kiB ECC chunks + * provides 4b/512B correctability. + * - The controller will always treat data bytes, free OOB bytes + * (also referred as "spare bytes") and ECC bytes in that order, + * no matter the real standard layout (which is usually all data + * then all OOB bytes). The marvell_nfc_layouts array below + * contains the currently supported layouts. + * - Because of these weird layouts, the Bad Block Markers can be + * located in data section. In this case, the NAND_BBT_NO_OOB_BBM + * option must be set to prevent scanning/writing bad block + * markers.. */ #include