diff mbox

[U-Boot,1/3] mtd/nand : Add function board_nand_init_tail() for some special NAND controllers

Message ID 1321952056-20281-1-git-send-email-Shengzhou.Liu@freescale.com
State Superseded
Delegated to: Scott Wood
Headers show

Commit Message

Shengzhou Liu Nov. 22, 2011, 8:54 a.m. UTC
In some NAND controllers there is a size limitation of RAM buffer(2K bytes).
To support large-page NAND chips with greater than 2K pagesize, we need a large
buffer, but we don't know pagesize before calling nand_scan_ident(), for more
flexible and to identify different cases of large-page greater than 2K bytes,
we have a board_nand_init_tail() between nand_scan_ident() and nand_scan_tail().

Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
---
based on 'master' branch of Wolfgang's tree.

 drivers/mtd/nand/nand.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

Comments

Mike Frysinger Nov. 22, 2011, 9:03 p.m. UTC | #1
On Tuesday 22 November 2011 03:54:14 Shengzhou Liu wrote:
> In some NAND controllers there is a size limitation of RAM buffer(2K
> bytes). To support large-page NAND chips with greater than 2K pagesize, we
> need a large buffer, but we don't know pagesize before calling
> nand_scan_ident(), for more flexible and to identify different cases of
> large-page greater than 2K bytes, we have a board_nand_init_tail() between
> nand_scan_ident() and nand_scan_tail().

iirc, newer Linux mtd tree handles this better by breaking up the code paths 
so individual drivers can call things in the right order.  perhaps we should 
update our mtd stack so we can do that ?
-mike
Scott Wood Nov. 22, 2011, 9:11 p.m. UTC | #2
On 11/22/2011 03:03 PM, Mike Frysinger wrote:
> On Tuesday 22 November 2011 03:54:14 Shengzhou Liu wrote:
>> In some NAND controllers there is a size limitation of RAM buffer(2K
>> bytes). To support large-page NAND chips with greater than 2K pagesize, we
>> need a large buffer, but we don't know pagesize before calling
>> nand_scan_ident(), for more flexible and to identify different cases of
>> large-page greater than 2K bytes, we have a board_nand_init_tail() between
>> nand_scan_ident() and nand_scan_tail().
> 
> iirc, newer Linux mtd tree handles this better by breaking up the code paths 
> so individual drivers can call things in the right order.  perhaps we should 
> update our mtd stack so we can do that ?

We already have that on the mtd side -- this patch uses it.  The issue
is the U-Boot glue code calling nand_scan() rather than letting the
drivers control the process.

This patch is less intrusive than changing all the drivers, but if
someone wants to actually do that (without breaking anything), or more
realistically set up a transition mechanism, that'd be great. :-)

-Scott
Mike Frysinger Nov. 23, 2011, 7:31 p.m. UTC | #3
On Tuesday 22 November 2011 16:11:20 Scott Wood wrote:
> On 11/22/2011 03:03 PM, Mike Frysinger wrote:
> > On Tuesday 22 November 2011 03:54:14 Shengzhou Liu wrote:
> >> In some NAND controllers there is a size limitation of RAM buffer(2K
> >> bytes). To support large-page NAND chips with greater than 2K pagesize,
> >> we need a large buffer, but we don't know pagesize before calling
> >> nand_scan_ident(), for more flexible and to identify different cases of
> >> large-page greater than 2K bytes, we have a board_nand_init_tail()
> >> between nand_scan_ident() and nand_scan_tail().
> > 
> > iirc, newer Linux mtd tree handles this better by breaking up the code
> > paths so individual drivers can call things in the right order.  perhaps
> > we should update our mtd stack so we can do that ?
> 
> We already have that on the mtd side -- this patch uses it.  The issue
> is the U-Boot glue code calling nand_scan() rather than letting the
> drivers control the process.
> 
> This patch is less intrusive than changing all the drivers, but if
> someone wants to actually do that (without breaking anything), or more
> realistically set up a transition mechanism, that'd be great. :-)

ok, so it is a short coming in the current u-boot mtd framework that we should 
look at migrating away from.  no, i'm not volunteering to take this on :).
-mike
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index d987f4c..2bafe47 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -39,6 +39,13 @@  static ulong base_address[CONFIG_SYS_MAX_NAND_DEVICE] = CONFIG_SYS_NAND_BASE_LIS
 static const char default_nand_name[] = "nand";
 static __attribute__((unused)) char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
 
+int __board_nand_init_tail(struct mtd_info *mtd, struct nand_chip *nand)
+{
+	/* Allow for init at tail in controller-specific file for some reason */
+}
+void board_nand_init_tail(struct mtd_info *mtd, struct nand_chip *nand)
+__attribute__((weak, alias("__board_nand_init_tail")));
+
 static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
 			   ulong base_addr)
 {
@@ -51,7 +58,12 @@  static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
 
 	nand->IO_ADDR_R = nand->IO_ADDR_W = (void  __iomem *)base_addr;
 	if (board_nand_init(nand) == 0) {
-		if (nand_scan(mtd, maxchips) == 0) {
+		if (!nand_scan_ident(mtd, maxchips, NULL)) {
+			board_nand_init_tail(mtd, nand);
+			if (nand_scan_tail(mtd)) {
+				mtd->name = NULL;
+				return;
+			}
 			if (!mtd->name)
 				mtd->name = (char *)default_nand_name;
 #ifdef CONFIG_NEEDS_MANUAL_RELOC