Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2458675ima; Sat, 2 Feb 2019 23:30:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6AzoP20g/FPZtHo5CzckNbhmNTn2F9rzN3yuGjKriMiooPy9UiQts7gLYDa3p9CtVHHV3q X-Received: by 2002:a62:3adc:: with SMTP id v89mr45496356pfj.109.1549179042405; Sat, 02 Feb 2019 23:30:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549179042; cv=none; d=google.com; s=arc-20160816; b=MQOaAKf9/7lRNbOdAdvHkp5ebxUhU5amNgh+oqKHztnfK5oyP5d8kahnLRNVE3Tdbo VqczkMbLTAW+AAufOq6yMR5sNfIlmU97fLnIQ2vmam3PFmadQ0PIdHzSafaYiLMU4pNv RKwsTJbgxDBqCOs3jo8T4gs9ehBGjWe97sRnvkRP5qPjRXzWKoUYB10tQ5jkzF2ruYWW pSsf0Tth5cbnSgtnt43fp7uIIy8m9tiV/KlqHWYVa6XX0xmh3tcKUu3wBYg5V6e7J+Xt i9JC4aHHTioMlZb3omWAUPTEsUc/m2cH34uSFXFN9gZz9sbgVSrBS2zdqcbi444E4OV9 JjsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=IboxpcQuHEJyJI36rUTLeuvgKE5GRQm38aDQX1tuBZE=; b=fdM2jj/izGNnK4EoJai7kJlLO+78kjnOg5xNOvUlNWbbiVxndIwJKISCigU/5T7UCn PNTLZqBK3XvUnVBZTRrAGfwQ0uu23Jmpczg/Wu6/tSK1+mC3PQmpcFs7bLoG8WYeG5CC Sn1kX33fEaS3xkxIrkNtprdTaI8SGICFFAFGkKhib2/5LpDOkaTOqt4LdxEccFce0ks0 /iPRL837x4FxTYswCUxw0O1MHR4FWCEOpOX/hgr/312zW21aA01loGhddLnK4IoYt8mO 5xAj9CMnfoHtOVvQddnoPERRzjlLGXwHgJlg8FN/PG8MsmvDYJaILarU/2Ak8IWcaxCL DfBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vt6nDFvj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si11746899pgb.192.2019.02.02.23.30.23; Sat, 02 Feb 2019 23:30:42 -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=pass header.i=@kernel.org header.s=default header.b=vt6nDFvj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbfBCHaT (ORCPT + 99 others); Sun, 3 Feb 2019 02:30:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:57688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfBCHaT (ORCPT ); Sun, 3 Feb 2019 02:30:19 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 145EA2082E; Sun, 3 Feb 2019 07:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549179017; bh=ks2ipiHZO/uli19qRFyFeK4eQsVOw+M0yb9vwKcyKyU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vt6nDFvjM/1AJfkvoon46cXaIwEVMxEnXrDG4pAFEWPjSR1B+cTUWDpYRVjo7yMQ1 GdpWKGgJ99PR4RCuyQ4X5Zi5zLQA5nn9wwYbFLT3g0z0hNLhmuf2a3D5o7g119EGtA +9x3wLZYs7w0t8RR2rR85VEG4X6tsqSkNiFrJIT4= Date: Sun, 3 Feb 2019 08:30:04 +0100 From: Boris Brezillon To: Paul Cercueil Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Miquel Raynal , Harvey Hunt , Mathieu Malaterre , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/9] mtd: rawnand: jz4780: Add ooblayout for the Qi Ben Nanonote Message-ID: <20190203083004.390b96be@bbrezillon> In-Reply-To: <20190202231926.2444-7-paul@crapouillou.net> References: <20190202231926.2444-1-paul@crapouillou.net> <20190202231926.2444-7-paul@crapouillou.net> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2 Feb 2019 20:19:23 -0300 Paul Cercueil wrote: > 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. I'm really not a big fan of this ingenic,oob-layout property, it encourages people to use new custom layouts which is just a pain to maintain. I understand that we don't have the choice for this board as it's already upstream, but maybe we can avoid adding this prop and check the root compat (which should contain the board name). > > 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;