diff mbox

[U-Boot,V4,4/8] imx: nand: Support flash based BBT

Message ID 1334825735-27992-5-git-send-email-timo@exertus.fi
State Accepted
Commit a1028730b5a5f8266fc3a198cd626bf73e157e6c
Headers show

Commit Message

Timo Ketola April 19, 2012, 8:55 a.m. UTC
Signed-off-by: Timo Ketola <timo@exertus.fi>
---

Changes in v4:
- Removed blank lines inside #ifdef
- Manipulate 'this->options' with '|=' instead of '='

Changes in v3:
- Changed the subject
- Changed the BBT pattern offsets (patch 4); They are now zero as in
    Linux

Changes in v2:
- Dropped patches 2, 3 and 6 so this one changed from 7 to 4
- Rebased to u-boot-imx next

 drivers/mtd/nand/mxc_nand.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

Comments

Scott Wood April 19, 2012, 3:27 p.m. UTC | #1
On 04/19/2012 03:55 AM, Timo Ketola wrote:
> Signed-off-by: Timo Ketola <timo@exertus.fi>
> ---
> 
> Changes in v4:
> - Removed blank lines inside #ifdef
> - Manipulate 'this->options' with '|=' instead of '='
> 
> Changes in v3:
> - Changed the subject
> - Changed the BBT pattern offsets (patch 4); They are now zero as in
>     Linux
> 
> Changes in v2:
> - Dropped patches 2, 3 and 6 so this one changed from 7 to 4
> - Rebased to u-boot-imx next
> 
>  drivers/mtd/nand/mxc_nand.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)

Acked-by: Scott Wood <scottwood@freescale.com>

-Scott
Stefano Babic May 6, 2012, 5:18 p.m. UTC | #2
On 19/04/2012 10:55, Timo Ketola wrote:
> Signed-off-by: Timo Ketola <timo@exertus.fi>
> ---
> 
> Changes in v4:
> - Removed blank lines inside #ifdef
> - Manipulate 'this->options' with '|=' instead of '='
> 
> Changes in v3:
> - Changed the subject
> - Changed the BBT pattern offsets (patch 4); They are now zero as in
>     Linux
> 
> Changes in v2:
> - Dropped patches 2, 3 and 6 so this one changed from 7 to 4
> - Rebased to u-boot-imx next
> 

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 35e89a0..936186f 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1302,12 +1302,45 @@  static void mxc_setup_config1(void)
 #define mxc_setup_config1()
 #endif
 
+#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
+
+static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
+static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr bbt_main_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		   NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs =	0,
+	.len = 4,
+	.veroffs = 4,
+	.maxblocks = 4,
+	.pattern = bbt_pattern,
+};
+
+static struct nand_bbt_descr bbt_mirror_descr = {
+	.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
+		   NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs =	0,
+	.len = 4,
+	.veroffs = 4,
+	.maxblocks = 4,
+	.pattern = mirror_pattern,
+};
+
+#endif
+
 int board_nand_init(struct nand_chip *this)
 {
 	struct mtd_info *mtd;
 	uint16_t tmp;
 	int err = 0;
 
+#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
+	this->options |= NAND_USE_FLASH_BBT;
+	this->bbt_td = &bbt_main_descr;
+	this->bbt_md = &bbt_mirror_descr;
+#endif
+
 	/* structures must be linked */
 	mtd = &host->mtd;
 	mtd->priv = this;