Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4123897ybi; Mon, 3 Jun 2019 06:09:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8zXuaKfUud2cUHa6SEydNs28TegX2N0eXtTCTURxLCEJ85l9HKEQmfgECZbuNTM8hMeCt X-Received: by 2002:a17:902:f216:: with SMTP id gn22mr13407620plb.118.1559567362589; Mon, 03 Jun 2019 06:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559567362; cv=none; d=google.com; s=arc-20160816; b=FxPyZ2Lm0gUf18i2UZq75CQ90PfwNdbe7JE6duhVgS40nJbGBnuPK5QdGk8JLPsmBa MNoKZPTgm1vzjLyyxFHGanJAkJqgC7Qrlfpm1rLejT8JTNdKRCG1B4ASAXBa+STPIIR3 0ASsZ0rLR4SqW5F5FE0qIquTfczvSTIJtTKReBBiipJuFZir+MjG+sWWNESZ0IYbo0d7 2c2Mnv5QCiAPFVQyxieDecmS8pIJiiAEoO6DNy14SF8zltwDnUFq5kTsuPrNR6KInk5D zCIbtWiedR5xHRH+C1p0Ali1ejwEN/159oV2khHtRoiXwKPhtGB+aUbTkxy4AAZB7dnd cYPA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=D8yd8iQICMhLVr6gLKzA3zI5XLYvSM7htXAsP2DOxnE=; b=tonCAo2ACq/6GFAIGGYOR+xbg62bI8zut0Gk5xzY7LOQtRPLv5/vfIus9z1PhZs1Zx 0pf5Z91v+480O5KLhOqiJR/SIedDBBuqPeX9bFB94wezqY/zn7W1sSTKLoJjr63zBOaK yjpAVB9366lZ4BulpfcdvGlTrbPmDQbCrtrr+Ih6yTLGO6/fGWkodzvAKw/EiBQGKPoU 9hJv8jisoz651xIHapavxvReCFbIFow4BsjykGe8HmotEl18Z+Ub8GSrRL3wgGn9x/yQ q1M6o5TJYKk2WKxfZWP1CDSVVSH9nlYwc6TrbKMP0cos5yNIgl0uHjkh9Oi8obQ4uBIj SVIQ== ARC-Authentication-Results: i=1; mx.google.com; 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d29si1464333pgd.490.2019.06.03.06.09.04; Mon, 03 Jun 2019 06:09:22 -0700 (PDT) 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; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728259AbfFCNFm (ORCPT + 99 others); Mon, 3 Jun 2019 09:05:42 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33496 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727846AbfFCNFm (ORCPT ); Mon, 3 Jun 2019 09:05:42 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id BDC3D285189; Mon, 3 Jun 2019 14:05:39 +0100 (BST) Date: Mon, 3 Jun 2019 15:05:37 +0200 From: Boris Brezillon To: "Shivamurthy Shastri (sshivamurthy)" Cc: Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Vignesh Raghavendra , Boris Brezillon , Yixun Lan , Lucas Stach , Anders Roxell , Stefan Agner , Marcel Ziswiler , "Bean Huo (beanhuo)" , Paul Cercueil , Frieder Schrempf , Chuanhong Guo , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 04/12] mtd: rawnand: introduce struct onfi_helper Message-ID: <20190603150537.3ca5ca8a@collabora.com> In-Reply-To: References: Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-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 Hi Shivamurthy, On Mon, 3 Jun 2019 12:43:28 +0000 "Shivamurthy Shastri (sshivamurthy)" wrote: > Create onfi_helper object. This is base to turn ONFI code to generic. > > Signed-off-by: Shivamurthy Shastri > --- > include/linux/mtd/nand.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h > index 3cdf06cae8b6..645dde4c5797 100644 > --- a/include/linux/mtd/nand.h > +++ b/include/linux/mtd/nand.h > @@ -11,6 +11,7 @@ > #define __LINUX_MTD_NAND_H > > #include > +#include > > /** > * struct nand_memory_organization - Memory organization structure > @@ -157,6 +158,24 @@ struct nand_ops { > bool (*isbad)(struct nand_device *nand, const struct nand_pos *pos); > }; > > +/** > + * struct onfi_helper - ONFI helper functions that should be implemented by > + * specialized layers (raw NAND, SPI NAND, etc.) > + * @page: Page number for ONFI parameter table > + * @check_revision: Check ONFI revision number > + * @parameter_page_read: Function to read parameter pages > + * @init_intf_data: Initialize interface specific data or fixups > + */ > +struct onfi_helper { > + u8 page; > + int (*check_revision)(struct nand_device *base, > + struct nand_onfi_params *p, int *onfi_version); > + int (*parameter_page_read)(struct nand_device *base, u8 page, > + void *buf, unsigned int len); > + int (*init_intf_data)(struct nand_device *base, > + struct nand_onfi_params *p); > +}; > + > /** > * struct nand_device - NAND device > * @mtd: MTD instance attached to the NAND device > @@ -165,6 +184,7 @@ struct nand_ops { > * @rowconv: position to row address converter > * @bbt: bad block table info > * @ops: NAND operations attached to the NAND device > + * @helper: Helper functions to detect and initialize ONFI NAND > * > * Generic NAND object. Specialized NAND layers (raw NAND, SPI NAND, OneNAND) > * should declare their own NAND object embedding a nand_device struct (that's > @@ -183,6 +203,7 @@ struct nand_device { > struct nand_row_converter rowconv; > struct nand_bbt bbt; > const struct nand_ops *ops; > + struct onfi_helper helper; Sorry, but I don't think that's the right solution. When I said we should have ONFI code shared I was thinking about the code that parses the ONFI struct/data to extract nand_memory_organization bits or other generic info, not something that would abstract how to retrieve the ONFI param page. Clearly, the generic NAND layer is not supposed to handle such protocol/low-level details. Regards, Boris