diff mbox

mtd: Nand Atmel: add On Flash BBT support

Message ID 72795ccb0905250844w13ed9798me95d70614050f676@mail.gmail.com
State New, archived
Headers show

Commit Message

simon polette May 25, 2009, 3:44 p.m. UTC
Hi,

Here is a patch which add support for On Flash Bad Block Table on AT91 and
AVR32 devices.

Signed-off-by: Simon Polette <spolette@adetelgroup.com>
---
 drivers/mtd/nand/Kconfig      |    9 +++++++++
 drivers/mtd/nand/atmel_nand.c |    3 +++
 2 files changed, 12 insertions(+), 0 deletions(-)

 	if (nand_scan_ident(mtd, 1)) {

Comments

Artem Bityutskiy May 26, 2009, 7:32 a.m. UTC | #1
On Mon, 2009-05-25 at 17:44 +0200, simon polette wrote:
> +config	MTD_NAND_ATMEL_FLASH_BBT
> +	bool "Use On-Flash Bad Block Table"
> +	depends on MTD_NAND_ATMEL
> +	help
> +	  This enables the On-Flash BBT, which mean that the bad blocks
> +	  will be scanned one time then the BBT will be stored
> +	  in flash, so scanning Nand flash for bad blocks will be no more
> +	  necessary for the next boots.
> +

I do not think you need a config option for this. It should be
a module parameter instead.
simon polette May 26, 2009, 9:40 a.m. UTC | #2
2009/5/26 Artem Bityutskiy <dedekind@infradead.org>:
> On Mon, 2009-05-25 at 17:44 +0200, simon polette wrote:
>> +config       MTD_NAND_ATMEL_FLASH_BBT
>> +     bool "Use On-Flash Bad Block Table"
>> +     depends on MTD_NAND_ATMEL
>> +     help
>> +       This enables the On-Flash BBT, which mean that the bad blocks
>> +       will be scanned one time then the BBT will be stored
>> +       in flash, so scanning Nand flash for bad blocks will be no more
>> +       necessary for the next boots.
>> +
>
> I do not think you need a config option for this. It should be
> a module parameter instead.
>
> --
> Best regards,
> Artem Bityutskiy (Битюцкий Артём)
>
>

Yes, good idea, but do you think that I can keep a config option to
define the default state of that param, it means doing something like
:
#ifdef CONFIG_MTD_NAND_ATMEL_FLASH_BBT
static int use_on_flash_bbt = 1;
#else
static int use_on_flash_bbt = 0;
#endif
module_param(use_on_flash_bbt, int, 0);


Best regards,

Simon Polette
Adeneo - Adetelgroup
Artem Bityutskiy May 26, 2009, 9:43 a.m. UTC | #3
On Tue, 2009-05-26 at 11:40 +0200, simon polette wrote:
> 2009/5/26 Artem Bityutskiy <dedekind@infradead.org>:
> > On Mon, 2009-05-25 at 17:44 +0200, simon polette wrote:
> >> +config       MTD_NAND_ATMEL_FLASH_BBT
> >> +     bool "Use On-Flash Bad Block Table"
> >> +     depends on MTD_NAND_ATMEL
> >> +     help
> >> +       This enables the On-Flash BBT, which mean that the bad blocks
> >> +       will be scanned one time then the BBT will be stored
> >> +       in flash, so scanning Nand flash for bad blocks will be no more
> >> +       necessary for the next boots.
> >> +
> >
> > I do not think you need a config option for this. It should be
> > a module parameter instead.
> >
> > --
> > Best regards,
> > Artem Bityutskiy (Битюцкий Артём)
> >
> >
> 
> Yes, good idea, but do you think that I can keep a config option to
> define the default state of that param, it means doing something like
> :
> #ifdef CONFIG_MTD_NAND_ATMEL_FLASH_BBT
> static int use_on_flash_bbt = 1;
> #else
> static int use_on_flash_bbt = 0;
> #endif
> module_param(use_on_flash_bbt, int, 0);

I think it is generally bad idea if each nand driver will
introduce a separate config option for this kind of stuff.

You may always boot your kernel with something like
atmel_nand.on_flash_bbt=1 in the kernel parameters.
simon polette May 26, 2009, 9:47 a.m. UTC | #4
2009/5/26 Artem Bityutskiy <dedekind@infradead.org>:
> On Tue, 2009-05-26 at 11:40 +0200, simon polette wrote:
>> 2009/5/26 Artem Bityutskiy <dedekind@infradead.org>:
>> > On Mon, 2009-05-25 at 17:44 +0200, simon polette wrote:
>> >> +config       MTD_NAND_ATMEL_FLASH_BBT
>> >> +     bool "Use On-Flash Bad Block Table"
>> >> +     depends on MTD_NAND_ATMEL
>> >> +     help
>> >> +       This enables the On-Flash BBT, which mean that the bad blocks
>> >> +       will be scanned one time then the BBT will be stored
>> >> +       in flash, so scanning Nand flash for bad blocks will be no more
>> >> +       necessary for the next boots.
>> >> +
>> >
>> > I do not think you need a config option for this. It should be
>> > a module parameter instead.
>> >
>> > --
>> > Best regards,
>> > Artem Bityutskiy (Битюцкий Артём)
>> >
>> >
>>
>> Yes, good idea, but do you think that I can keep a config option to
>> define the default state of that param, it means doing something like
>> :
>> #ifdef CONFIG_MTD_NAND_ATMEL_FLASH_BBT
>> static int use_on_flash_bbt = 1;
>> #else
>> static int use_on_flash_bbt = 0;
>> #endif
>> module_param(use_on_flash_bbt, int, 0);
>
> I think it is generally bad idea if each nand driver will
> introduce a separate config option for this kind of stuff.
>
> You may always boot your kernel with something like
> atmel_nand.on_flash_bbt=1 in the kernel parameters.
>
> --
> Best regards,
> Artem Bityutskiy (Битюцкий Артём)
>
>

Ok, I asked this question cause it's what have been done in the nand
diskonchip driver.
I'll send you a new patch soon.

Best regards,

Simon Polette
Adeneo - Adetelgroup
diff mbox

Patch

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 890936d..c860688 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -333,6 +333,15 @@  config MTD_NAND_ATMEL_ECC_NONE

 endchoice

+config	MTD_NAND_ATMEL_FLASH_BBT
+	bool "Use On-Flash Bad Block Table"
+	depends on MTD_NAND_ATMEL
+	help
+	  This enables the On-Flash BBT, which mean that the bad blocks
+	  will be scanned one time then the BBT will be stored
+	  in flash, so scanning Nand flash for bad blocks will be no more
+	  necessary for the next boots.
+
 config MTD_NAND_PXA3xx
 	tristate "Support for NAND flash devices on PXA3xx"
 	depends on MTD_NAND && PXA3xx
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 47a33ce..dca19dd 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -464,6 +464,9 @@  static int __init atmel_nand_probe(struct
platform_device *pdev)
 			goto err_no_card;
 		}
 	}
+#ifdef CONFIG_MTD_NAND_ATMEL_FLASH_BBT
+	nand_chip->options |= NAND_USE_FLASH_BBT;
+#endif

 	/* first scan to find the device and get the page size */