diff mbox

[1/2] nand: Add bad block table overrides to Davinci NAND driver

Message ID 20090918211004.GA12907@mag.az.mvista.com (mailing list archive)
State Accepted
Headers show

Commit Message

Mark A. Greer Sept. 18, 2009, 9:10 p.m. UTC
From: Mark A. Greer <mgreer@mvista.com>

The existing NAND infrastructure allows the default main and
mirror bad block tables to be overridden in nand_default_bbt().
However, the davinci_nand driver does not support this.  So,
add fields to the davinci driver's platform data so platform
code can pass in their own bbt's and make the driver honor
those overrides.

Signed-off-by: Mark A. Greer <mgreer@mvista.com>
---
This is required by the da830 evm (see following patch) which requires

Comments

s-paulraj@ti.com Sept. 18, 2009, 9:21 p.m. UTC | #1
> 
> From: Mark A. Greer <mgreer@mvista.com>
> 
> The existing NAND infrastructure allows the default main and
> mirror bad block tables to be overridden in nand_default_bbt().
> However, the davinci_nand driver does not support this.  So,
> add fields to the davinci driver's platform data so platform
> code can pass in their own bbt's and make the driver honor
> those overrides.
> 
> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
> ---
> This is required by the da830 evm (see following patch) which requires
> different 'offs' and 'veroffs' values than the default.  This seemed
> like the solution that fit best with the existing infratructure.  If
> anyone has a better solution, please speak up.
> 
Mark, IIRC this feature was originally added by Andy Lowe in LSP 1.2
The same was then used in LSP 2.xx.

In the initial set of patches we were using this again but in the final iterations of the DaVinci NAND driver patch review, we have decided to go with the default patterns from the MTD NAND driver.

If you look at the Dm355/Dm365 patches for board specific NAND support we do not add this anymore. Since the EMIF on DA830 is similar to DM3xx, in my opinion we should align with DM355 and DM365.

Thanks,
Sandeep
Mark A. Greer Sept. 18, 2009, 9:56 p.m. UTC | #2
On Fri, Sep 18, 2009 at 04:21:19PM -0500, Paulraj, Sandeep wrote:
> 
> > 
> > From: Mark A. Greer <mgreer@mvista.com>
> > 
> > The existing NAND infrastructure allows the default main and
> > mirror bad block tables to be overridden in nand_default_bbt().
> > However, the davinci_nand driver does not support this.  So,
> > add fields to the davinci driver's platform data so platform
> > code can pass in their own bbt's and make the driver honor
> > those overrides.
> > 
> > Signed-off-by: Mark A. Greer <mgreer@mvista.com>
> > ---
> > This is required by the da830 evm (see following patch) which requires
> > different 'offs' and 'veroffs' values than the default.  This seemed
> > like the solution that fit best with the existing infratructure.  If
> > anyone has a better solution, please speak up.
> > 
> Mark, IIRC this feature was originally added by Andy Lowe in LSP 1.2
> The same was then used in LSP 2.xx.
> 
> In the initial set of patches we were using this again but in the final iterations of the DaVinci NAND driver patch review, we have decided to go with the default patterns from the MTD NAND driver.
> 
> If you look at the Dm355/Dm365 patches for board specific NAND support we do not add this anymore. Since the EMIF on DA830 is similar to DM3xx, in my opinion we should align with DM355 and DM365.

Hi Sandeep.

The issue is that the values for the 'offs' and 'veroffs' are wrong in
the defaults used by nand_base.c:nand_default_bbt().  The da830 evem
won't work with the default values.  So, some way to override the default
needs to be provided.  This patch seemed like the most reasonable way to
override the default since it merely implements driver functionality that
the infrastructure already allows (if not expects).

Its not optimal for the case of the da830 evm because we have to
duplicate a bunch of the data in the platform code--it would be nice to
just override those two values.  However, it still seems like the proper
solution overall.

Or...did I miss your point?

Mark
--
David Brownell Sept. 19, 2009, 6:21 a.m. UTC | #3
On Friday 18 September 2009, Mark A. Greer wrote:
> The issue is that the values for the 'offs' and 'veroffs' are wrong in
> the defaults used by nand_base.c:nand_default_bbt(). 

In what way "wrong"?
Mark A. Greer Sept. 21, 2009, 4:31 p.m. UTC | #4
On Fri, Sep 18, 2009 at 11:21:17PM -0700, David Brownell wrote:
> On Friday 18 September 2009, Mark A. Greer wrote:
> > The issue is that the values for the 'offs' and 'veroffs' are wrong in
> > the defaults used by nand_base.c:nand_default_bbt(). 
> 
> In what way "wrong"?

The default:
	.offs		= 8,
	.veroffs	= 12,

The da830 evm values:
	.offs           = 2,
	.veroffs        = 16,

With the default values, every block is flagged as bad.
This is using a small page nand flash chip.

Mark
--
Rajashekhara, Sudhakar Sept. 22, 2009, 12:40 p.m. UTC | #5
On Sat, Sep 19, 2009 at 02:40:04, Mark A. Greer wrote:
> From: Mark A. Greer <mgreer@mvista.com>
> 
> The existing NAND infrastructure allows the default main and
> mirror bad block tables to be overridden in nand_default_bbt().
> However, the davinci_nand driver does not support this.  So,
> add fields to the davinci driver's platform data so platform
> code can pass in their own bbt's and make the driver honor
> those overrides.
> 
> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
> ---
> This is required by the da830 evm (see following patch) which requires
> different 'offs' and 'veroffs' values than the default.  This seemed
> like the solution that fit best with the existing infratructure.  If
> anyone has a better solution, please speak up.
> 

Mark,

Are you trying to align with the OOB layout being followed in U-Boot?
U-Boot for da830/omap-l137 is not in mainline yet. I am planning to
start working on that shortly. We can re-visit this when da830/omap-l137
support is present in u-boot.

Regards, Sudhakar
diff mbox

Patch

different 'offs' and 'veroffs' values than the default.  This seemed
like the solution that fit best with the existing infratructure.  If
anyone has a better solution, please speak up.

 arch/arm/mach-davinci/include/mach/nand.h |    4 ++++
 drivers/mtd/nand/davinci_nand.c           |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/include/mach/nand.h b/arch/arm/mach-davinci/include/mach/nand.h
index b520c4b..b2ad809 100644
--- a/arch/arm/mach-davinci/include/mach/nand.h
+++ b/arch/arm/mach-davinci/include/mach/nand.h
@@ -79,6 +79,10 @@  struct davinci_nand_pdata {		/* platform_data */
 
 	/* e.g. NAND_BUSWIDTH_16 or NAND_USE_FLASH_BBT */
 	unsigned		options;
+
+	/* Main and mirror bbt descriptor overrides */
+	struct nand_bbt_descr	*bbt_td;
+	struct nand_bbt_descr	*bbt_md;
 };
 
 #endif	/* __ARCH_ARM_DAVINCI_NAND_H */
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 0bcfd49..31461d7 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -591,6 +591,8 @@  static int __init nand_davinci_probe(struct platform_device *pdev)
 
 	/* options such as NAND_USE_FLASH_BBT or 16-bit widths */
 	info->chip.options	= pdata->options;
+	info->chip.bbt_td	= pdata->bbt_td;
+	info->chip.bbt_md	= pdata->bbt_md;
 
 	info->ioaddr		= (uint32_t __force) vaddr;