Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2875214imu; Fri, 18 Jan 2019 00:31:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7juZav+wgQScUJIEQ0XQWC1GgaleZyhmqPliriwklMM8mButDs9RJpKV5g/ABri1cRkjdj X-Received: by 2002:a63:5455:: with SMTP id e21mr16827049pgm.316.1547800282315; Fri, 18 Jan 2019 00:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547800282; cv=none; d=google.com; s=arc-20160816; b=foFLTFxx0aSMc2IVz6g8u8Z4Yz/TKH1qQ0TeL3CsHt/ZAURxlVXF28QJbuHvYAn7m9 w/6L93Sfc4xWwcFnGevVeNhvw/mEsreRE5X+p5dLUhHijiI9QQgsqYbL2ETHrwhJtV+x PsOVjeV1qgkIgE54K+26POYYPj3qiBZWxWMBJ+J90Na2o01SHDcpEejuN1pvxUdqGGOO akvoGO0XlQNVg7XoDB4beS53nhcY6qFQUFcUsGrW6T//ncPY+ou0C3WWhU6wQMIds9v3 OhRoRU/b5x9cdZve0FfBeeI/GK1M36ymzoiU/2E7wWefTLZyXh+Z6v6F6+qdG1ZjtfYs FVgQ== 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=8p4s653yhQQsC8jnZC0g1fUDBGYtELM97zOob86Vow0=; b=QCU1HoWb/8vn3OC9mJulK8XMBWBXP9cDaAsvueb1wMxSn1CRVNezQSignboLUgfv4A nmxb10Q6VFtMBbWSUihyR0jxbMLBrBC8bG214uOQNUBUw2TKfbIA/PNcWzUVwqtNl+Ej Gs4gqQfw8Na5nxvzNA6e8QvvFev3FhnE0ko26KXF4qV7Znr8j+lKl7H8FfSWYsRvj112 1K4oDyH7pXu+BR5S42TPDRFuf5iKYxIRRfmQd4+Vwg+/V67itfhWJ8xo6D2r5To1/4BB BJeLNrGEV5rTI6E2Vhsv8HtXZ9WXE4SbyU15f+oY0ACIAikPZbgIa+qXmI1ZL0Jmbmtb 4HOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GN01m9ZN; 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 a35si4014384pla.226.2019.01.18.00.31.06; Fri, 18 Jan 2019 00:31:22 -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=GN01m9ZN; 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 S1727476AbfARI37 (ORCPT + 99 others); Fri, 18 Jan 2019 03:29:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:46134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbfARI36 (ORCPT ); Fri, 18 Jan 2019 03:29:58 -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 2377D20823; Fri, 18 Jan 2019 08:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547800197; bh=GgTgbns2eBfbuAhJFW8BVh1if6T7NrQ/79Ib8cLi7Jc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GN01m9ZNdfnMopO3lxIGSmJv7xE2mcBPox0kH63eosGeQFT+u56fB6vk0Uwfivyam MF8RoX2BORZW2M7lX3TM1ycmc+5tznUBB6RCoKlzix7UuaLE8gcGMTNnH9+tMIxIpB BhaVyuJemC3BK++4JKW+f7cP4DAJbxISUCro3wAI= Date: Fri, 18 Jan 2019 09:29:45 +0100 From: Boris Brezillon To: Paul Cercueil Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Miquel Raynal , Harvey Hunt , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: Re: [PATCH 5/8] mtd: rawnand: jz4780: Add ooblayout for the JZ4725B Message-ID: <20190118092945.4ca0fef2@bbrezillon> In-Reply-To: <20190118010634.27399-5-paul@crapouillou.net> References: <20190118010634.27399-1-paul@crapouillou.net> <20190118010634.27399-5-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 Thu, 17 Jan 2019 22:06:31 -0300 Paul Cercueil wrote: > 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 Reviewed-by: Boris Brezillon > --- > 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[] = {