Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2564250imu; Thu, 17 Jan 2019 17:08:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7o4wCC26xrLxobk24ToXy/jGpliEzU6sLHjuAkljjUc2S/zXFsGbq5o1c7eU+namvC7h/J X-Received: by 2002:a17:902:8f83:: with SMTP id z3mr16715538plo.328.1547773734172; Thu, 17 Jan 2019 17:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547773734; cv=none; d=google.com; s=arc-20160816; b=qky7Hsw4Avt7HEblkBlkpkCdZC8xEApsORbUhODNjVS69N99yIeLdhTLk91oFzDAdl +cBpnvWqytdTSvWhhBulC+mP85SeGf4b6KXraWZVT58dldx3NugedKgjn5lhMF6HmUya NreWUy8JyD5iPHVKShJkzldH7mncMk6zQzCywxY9PkW9as2inXK5WbJLqRyNa36At7oz TKOCDPJ6fm0NPwo1H5FVJTN00OyIJpElI3qGhQcKJTCEHhNl6hmtDxG+sz5bvKvZKEIr MvGN7bPs1CjpzZIPpbANUKPqbkX8nhrIsVFNfDJ8xhUVqlilzt0GuJTgjM6HVNaDKGkH WIdQ== 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=MG3f0Whzo3apr/Ozy+5iOfPwXocl1tPsCT+XjhaScyg=; b=nuJmFmh95m5jCBlV/g8GODh1DXO8lAnJU1snJPl5MkzfLeoU20Qu+dzHVAxYrnruo1 QrBbatNqYLZJ+vqR+A1epFEFrHsQQarpVfTY5QhJQtCUaJZZaGDXzz3b9skMmZKIASV4 V1hBwg0AFWFSfL4MYIz74Yg0XASZLR9lDe05WnM3ar/709ypm/oyvm7k+A/CH1cOWGmT uYbKStGWSc7o0p7HO9ebfc3+mZposfrt5vajl88q+0SR7yYfNvhpwArIicFrXiajna0P /s/aRApi8J9DeM0kIzXPilWa9UuYkBwxygDy+rtYmsAqoQresVuAaoqP1PsOm2au6d9Y X09A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=CL8FJ+Zk; 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 h75si3160643pfj.257.2019.01.17.17.08.38; Thu, 17 Jan 2019 17:08:54 -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=CL8FJ+Zk; 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 S1727057AbfARBHP (ORCPT + 99 others); Thu, 17 Jan 2019 20:07:15 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:33270 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbfARBHP (ORCPT ); Thu, 17 Jan 2019 20:07:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1547773632; 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=MG3f0Whzo3apr/Ozy+5iOfPwXocl1tPsCT+XjhaScyg=; b=CL8FJ+ZkQFDfCSzLbqBM8n0Z9tXCur3CbwONW/C2SE27Hn+PPv4m4nnAmoQ6r0XqEZU+Ra mMg6FUGBqWyoT3oBQFHVVFaBDN+jLTQikz+r5+zWQKHcNjXbCEjrSUlywzhKmnjwoZ/QS0 l8MCYxYXT140VBibaHy5faIS67j/D4U= From: Paul Cercueil To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Miquel Raynal , Harvey Hunt Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil Subject: [PATCH 5/8] mtd: rawnand: jz4780: Add ooblayout for the JZ4725B Date: Thu, 17 Jan 2019 22:06:31 -0300 Message-Id: <20190118010634.27399-5-paul@crapouillou.net> In-Reply-To: <20190118010634.27399-1-paul@crapouillou.net> References: <20190118010634.27399-1-paul@crapouillou.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The boot ROM of the JZ4725B SoC expects a specific OOB layout on the NAND, so it makes sense to use this OOB layout unconditionally on this SoC. Signed-off-by: Paul Cercueil --- drivers/mtd/nand/raw/jz4780_nand.c | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/jz4780_nand.c b/drivers/mtd/nand/raw/jz4780_nand.c index cf24bf12884f..073b3da5c3f7 100644 --- a/drivers/mtd/nand/raw/jz4780_nand.c +++ b/drivers/mtd/nand/raw/jz4780_nand.c @@ -34,6 +34,7 @@ struct jz_soc_info { unsigned long data_offset; unsigned long addr_offset; unsigned long cmd_offset; + const struct mtd_ooblayout_ops *oob_layout; }; struct jz4780_nand_cs { @@ -208,7 +209,7 @@ static int jz4780_nand_attach_chip(struct nand_chip *chip) return -EINVAL; } - mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops); + mtd_set_ooblayout(mtd, nfc->soc_info->oob_layout); return 0; } @@ -398,16 +399,53 @@ static int jz4780_nand_remove(struct platform_device *pdev) return 0; } +static int jz4725b_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 = 3; + + return 0; +} + +static int jz4725b_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 - 3; + oobregion->offset = 3 + ecc->total; + + return 0; +} + +const struct mtd_ooblayout_ops jz4725b_ooblayout_ops = { + .ecc = jz4725b_ooblayout_ecc, + .free = jz4725b_ooblayout_free, +}; + static const struct jz_soc_info jz4725b_soc_info = { .data_offset = 0x00000000, .cmd_offset = 0x00008000, .addr_offset = 0x00010000, + .oob_layout = &jz4725b_ooblayout_ops, }; static const struct jz_soc_info jz4780_soc_info = { .data_offset = 0x00000000, .cmd_offset = 0x00400000, .addr_offset = 0x00800000, + .oob_layout = &nand_ooblayout_lp_ops, }; static const struct of_device_id jz4780_nand_dt_match[] = { -- 2.11.0