summaryrefslogtreecommitdiff
path: root/nand_spl
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2011-10-04 22:20:25 +0200
committerWolfgang Denk <wd@denx.de>2011-10-04 22:20:25 +0200
commit4f7549d2dc00023c5f33d1adc7fee0a77575fcb2 (patch)
treef87d6f02fe74f832d18ab8c11feb0978da53014a /nand_spl
parent1fed668b3fb9c35932f58af00ff5539239fa4e1d (diff)
parent169de9059f24f50c4c7ac794ded060b2c133a29c (diff)
downloadu-boot-imx-4f7549d2dc00023c5f33d1adc7fee0a77575fcb2.zip
u-boot-imx-4f7549d2dc00023c5f33d1adc7fee0a77575fcb2.tar.gz
u-boot-imx-4f7549d2dc00023c5f33d1adc7fee0a77575fcb2.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-nand-flash
* 'master' of git://git.denx.de/u-boot-nand-flash: PPC: Fix socrates NAND problem PPC: Fix fsl_upm.c by renaming nand handling functions NAND: Make page, erase, oob size available via cmd_nand mtd: eLBC NAND: remove elbc_fcm_ctrl->oob_poi NAND: Add -y option to nand scrub command NAND: Add nand read.raw and write.raw commands NAND: Really ignore bad blocks when scrubbing spl, nand: add 4bit HW ecc oob first nand_read_page function mxc_nand: fix a problem writing more than 32MB mxc_nand: fixed some typos (cosmetic) nand: increase chip_delay in mv kirkwood nand driver
Diffstat (limited to 'nand_spl')
-rw-r--r--nand_spl/nand_boot.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
index 4683c7c..615ef25 100644
--- a/nand_spl/nand_boot.c
+++ b/nand_spl/nand_boot.c
@@ -135,6 +135,47 @@ static int nand_is_bad_block(struct mtd_info *mtd, int block)
return 0;
}
+#if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST)
+static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
+{
+ struct nand_chip *this = mtd->priv;
+ u_char *ecc_calc;
+ u_char *ecc_code;
+ u_char *oob_data;
+ int i;
+ int eccsize = CONFIG_SYS_NAND_ECCSIZE;
+ int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
+ int eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+ uint8_t *p = dst;
+ int stat;
+
+ /*
+ * No malloc available for now, just use some temporary locations
+ * in SDRAM
+ */
+ ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
+ ecc_code = ecc_calc + 0x100;
+ oob_data = ecc_calc + 0x200;
+
+ nand_command(mtd, block, page, 0, NAND_CMD_READOOB);
+ this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
+ nand_command(mtd, block, page, 0, NAND_CMD_READ0);
+
+ /* Pick the ECC bytes out of the oob data */
+ for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
+ ecc_code[i] = oob_data[nand_ecc_pos[i]];
+
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+ this->ecc.hwctl(mtd, NAND_ECC_READ);
+ this->read_buf(mtd, p, eccsize);
+ this->ecc.calculate(mtd, p, &ecc_calc[i]);
+ stat = this->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
+ }
+
+ return 0;
+}
+#else
static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
{
struct nand_chip *this = mtd->priv;
@@ -181,6 +222,7 @@ static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
return 0;
}
+#endif /* #if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST) */
static int nand_load(struct mtd_info *mtd, unsigned int offs,
unsigned int uboot_size, uchar *dst)