summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorIlya Yanok <yanok@emcraft.com>2011-11-28 06:37:37 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2011-12-06 23:59:36 +0100
commit1df308e5be76ec42ade8fb21f623f36ba09217bd (patch)
tree19ea8959f104971e98015ba79f03c94b0ad655d1 /drivers/mtd
parentad2a7909a1430321224ea25c808494b4df8d1140 (diff)
downloadu-boot-imx-1df308e5be76ec42ade8fb21f623f36ba09217bd.zip
u-boot-imx-1df308e5be76ec42ade8fb21f623f36ba09217bd.tar.gz
u-boot-imx-1df308e5be76ec42ade8fb21f623f36ba09217bd.tar.bz2
nand_spl_simple: add support for software ECC
This patch adds support for software ECC to the nand_spl_simple driver. To enable this one have to define CONFIG_SPL_NAND_SOFTECC. Tested on OMAP3. Signed-off-by: Ilya Yanok <yanok@emcraft.com> Acked-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_ecc.c2
-rw-r--r--drivers/mtd/nand/nand_spl_simple.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index 52bc916..81f0e08 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -50,7 +50,7 @@
* only nand_correct_data() is needed
*/
-#ifndef CONFIG_NAND_SPL
+#if !defined(CONFIG_NAND_SPL) || defined(CONFIG_SPL_NAND_SOFTECC)
/*
* Pre-calculated 256-way 1 byte column parity
*/
diff --git a/drivers/mtd/nand/nand_spl_simple.c b/drivers/mtd/nand/nand_spl_simple.c
index e5003e6..ed821f2 100644
--- a/drivers/mtd/nand/nand_spl_simple.c
+++ b/drivers/mtd/nand/nand_spl_simple.c
@@ -21,6 +21,7 @@
#include <common.h>
#include <nand.h>
#include <asm/io.h>
+#include <linux/mtd/nand_ecc.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
static nand_info_t mtd;
@@ -204,7 +205,8 @@ static int nand_read_page(int block, int page, void *dst)
oob_data = ecc_calc + 0x200;
for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
- this->ecc.hwctl(&mtd, NAND_ECC_READ);
+ if (this->ecc.mode != NAND_ECC_SOFT)
+ this->ecc.hwctl(&mtd, NAND_ECC_READ);
this->read_buf(&mtd, p, eccsize);
this->ecc.calculate(&mtd, p, &ecc_calc[i]);
}
@@ -274,6 +276,13 @@ void nand_init(void)
(void __iomem *)CONFIG_SYS_NAND_BASE;
board_nand_init(&nand_chip);
+#ifdef CONFIG_SPL_NAND_SOFTECC
+ if (nand_chip.ecc.mode == NAND_ECC_SOFT) {
+ nand_chip.ecc.calculate = nand_calculate_ecc;
+ nand_chip.ecc.correct = nand_correct_data;
+ }
+#endif
+
if (nand_chip.select_chip)
nand_chip.select_chip(&mtd, 0);
}