[U-Boot] [PATCH v2 2/3] Fix 2k page size NAND for iMX27

Eric Benard eric at eukrea.com
Wed Jul 15 17:18:40 CEST 2009


Signed-off-by: Eric Benard <eric at eukrea.com>
---
 drivers/nand/nand_imx.c             |   20 +++++++++++++++++---
 include/asm-arm/arch-imx/imx-nand.h |    3 ++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index cbff7ce..ecfb649 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -874,7 +874,7 @@ static void imx_nand_command(struct mtd_info *mtd, unsigned command,
 
 		if (host->pagesize_2k) {
 			send_addr(host, (page_addr >> 8) & 0xFF);
-			if (mtd->size >= 0x40000000) {
+			if (mtd->size >= 0x10000000) {
 				send_addr(host, (page_addr >> 16) & 0xff);
 			}
 		} else {
@@ -961,6 +961,15 @@ static void imx_low_erase(struct mtd_info *mtd)
  *
  * @return  The function always returns 0.
  */
+static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
+
+static struct nand_bbt_descr smallpage_memorybased = {
+	.options = NAND_BBT_SCAN2NDPAGE,
+	.offs = 5,
+	.len = 1,
+	.pattern = scan_ff_pattern
+};
+
 static int __init imxnd_probe(struct device_d *dev)
 {
 	struct nand_chip *this;
@@ -969,7 +978,7 @@ static int __init imxnd_probe(struct device_d *dev)
 	struct imx_nand_host *host;
 	u16 tmp;
 	int err = 0;
-#ifdef CONFIG_ARCH_MX27
+#ifdef CONFIG_ARCH_IMX27
 	PCCR1 |= PCCR1_NFC_BAUDEN;
 #endif
 	/* Allocate memory for MTD device structure and private data */
@@ -1050,7 +1059,12 @@ static int __init imxnd_probe(struct device_d *dev)
 		this->ecc.layout = &nand_hw_eccoob_16;
 	}
 
-	host->pagesize_2k = 0;
+	if (pdata->is2k) {
+		host->pagesize_2k = 1;
+		NFMS |= (1 << NFMS_BIT);
+		this->badblock_pattern = &smallpage_memorybased;
+	} else 
+		host->pagesize_2k = 0;
 
 	/* Scan to find existence of the device */
 	if (nand_scan(mtd, 1)) {
diff --git a/include/asm-arm/arch-imx/imx-nand.h b/include/asm-arm/arch-imx/imx-nand.h
index 5ebe0be..500bb1a 100644
--- a/include/asm-arm/arch-imx/imx-nand.h
+++ b/include/asm-arm/arch-imx/imx-nand.h
@@ -8,6 +8,7 @@ void imx_nand_load_image(void *dest, int size, int pagesize, int blocksize);
 struct imx_nand_platform_data {
 	int width;
 	int hw_ecc;
-};
+	int is2k;
+	};
 #endif /* __ASM_ARCH_NAND_H */
 
-- 
1.6.0.4



More information about the U-Boot mailing list