Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2145812ima; Sat, 2 Feb 2019 15:21:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/9bNZKkQookgNlTZblZN7CrBIBib2QrT9qIvX7g3hcXjCxuVhw0r4r0egW9byBDWSRTyJ X-Received: by 2002:a62:1d8f:: with SMTP id d137mr44863007pfd.11.1549149662005; Sat, 02 Feb 2019 15:21:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549149661; cv=none; d=google.com; s=arc-20160816; b=BrRyFxdgaWrlkvnS+FT7iEfGDgHrySqyQI5VJ0B4Hmtet1zEwTrOgZTnylvG5ugJAI 2saQnYUia4HYgcFyQU1eAbLA7Y+AIrw6HoTScEtT6UKZ/h3zKVF2y67ZT2mkinJ7Jy3P 2p1DopD/IpjApR/4VFqYiJDJn9w0xGhWe6UXT5Qv71rvuZyHfNn5J84WC8hJVKpy4mzq +Hvi1Jqy+yg2jvCSdBfNWCMAZGytvzE0S58/wwA4Qauh4VG20peWrpdR7RFd2+q69UeA jfby40jeeqS0myM9GUaFcXISSr4tDXTzADjTu81KWaKuT83hOjWW/z51INRTcGJjJrTg fP0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6DQ/fdFeik3NcGgbnEiiOqaU+te3pfdcWm4W2rT05DA=; b=nKYGDIP23cmiCSi533Ll00RfyKbmNJBA09pM/9Ms9fYvX4rTLZF72RTR6KRszcIWEu 2tqDiw+rdRUiUAZR72Qw/0z3/XgZRoOY0+jL6KSCjHG0/m9mLhhILnyEi1qhV+rAbqwR 1WZ1v+o1SiSlt+ifIzddPBdM/BlIJvs/5xmFgxqW1+qwQQ9DOsEeQXhJ714CAbeR7ame Uk4xRRwixRZl24LksNoRAVYNIQnMnl/5kkYv5SrLAKN20TLHwvVa9poBUqS+NTnCMGS1 1T9fTP6AL82oYcVobYTVbJZFg6i2rUmTKCkhStFm1+rhoKxSQj0xeryHt3W2b03agBVz zA+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="XfBV/cnA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si12044116pfq.129.2019.02.02.15.20.46; Sat, 02 Feb 2019 15:21:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="XfBV/cnA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbfBBXUS (ORCPT + 99 others); Sat, 2 Feb 2019 18:20:18 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:53466 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbfBBXUR (ORCPT ); Sat, 2 Feb 2019 18:20:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1549149615; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=6DQ/fdFeik3NcGgbnEiiOqaU+te3pfdcWm4W2rT05DA=; b=XfBV/cnA3R6f+cjXShFs5iV7OZ+812jP9PqFiiCHKJCoIAzYUr1BdvOgDWd+ep5x3G3TdQ 6kx1mLGCabe9HqhNaSb7FSKRpFoOz1CAsPmJORZS/FiLuiruUPkhJmhYKmQI8Klr0mpnlV JZDdNmLtU6iutFaZD2h1Yg1Dt/+Wg50= From: Paul Cercueil To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Miquel Raynal , Harvey Hunt Cc: Mathieu Malaterre , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 6/9] mtd: rawnand: jz4780: Add ooblayout for the Qi Ben Nanonote Date: Sat, 2 Feb 2019 20:19:23 -0300 Message-Id: <20190202231926.2444-7-paul@crapouillou.net> In-Reply-To: <20190202231926.2444-1-paul@crapouillou.net> References: <20190202231926.2444-1-paul@crapouillou.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Ben Nanonote from Qi Hardware expects a specific OOB layout on its NAND. If the "ingenic,oob-layout" device property is set to "qi,lb60", this specific OOB layout is used. Signed-off-by: Paul Cercueil --- Changes: v2: New patch drivers/mtd/nand/raw/ingenic/jz4780_nand.c | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/mtd/nand/raw/ingenic/jz4780_nand.c b/drivers/mtd/nand/raw/ingenic/jz4780_nand.c index baebb9a5c7c8..4b304eceae8d 100644 --- a/drivers/mtd/nand/raw/ingenic/jz4780_nand.c +++ b/drivers/mtd/nand/raw/ingenic/jz4780_nand.c @@ -346,6 +346,41 @@ static int jz4780_nand_init_chips(struct jz4780_nand_controller *nfc, return 0; } +static int qi_lb60_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct nand_ecc_ctrl *ecc = &chip->ecc; + + if (section || !ecc->total) + return -ERANGE; + + oobregion->length = ecc->total; + oobregion->offset = 12; + + return 0; +} + +static int qi_lb60_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct nand_ecc_ctrl *ecc = &chip->ecc; + + if (section) + return -ERANGE; + + oobregion->length = mtd->oobsize - ecc->total - 12; + oobregion->offset = 12 + ecc->total; + + return 0; +} + +const struct mtd_ooblayout_ops qi_lb60_ooblayout_ops = { + .ecc = qi_lb60_ooblayout_ecc, + .free = qi_lb60_ooblayout_free, +}; + static int jz4725b_ooblayout_ecc(struct mtd_info *mtd, int section, struct mtd_oob_region *oobregion) { @@ -409,6 +444,8 @@ static int jz4780_nand_probe(struct platform_device *pdev) if (!ret) { if (!strcmp(layout, "ingenic,jz4725b")) { nfc->oob_layout = &jz4725b_ooblayout_ops; + } else if (!strcmp(layout, "qi,lb60")) { + nfc->oob_layout = &qi_lb60_ooblayout_ops; } else { dev_err(dev, "Unrecognized OOB layout %s\n", layout); return -EINVAL; -- 2.20.1