Commit 68bb8295 authored by Heiko Schocher's avatar Heiko Schocher Committed by Albert ARIBAUD
Browse files

spl, nand: add 4bit HW ecc oob first nand_read_page function

similiar to commit dc7cd8e5

, only
adapted for the new spl framework.
Signed-off-by: default avatarHeiko Schocher <hs@denx.de>
Acked-by: default avatarTom Rini <trini@ti.com>
Acked-by: default avatarScott Wood <scottwood@freescale.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
Signed-off-by: default avatarSandeep Paulraj <s-paulraj@ti.com>
parent 435199f3
...@@ -3257,6 +3257,11 @@ Low Level (hardware related) configuration options: ...@@ -3257,6 +3257,11 @@ Low Level (hardware related) configuration options:
that is executed before the actual U-Boot. E.g. when that is executed before the actual U-Boot. E.g. when
compiling a NAND SPL. compiling a NAND SPL.
- CONFIG_SYS_NAND_HW_ECC_OOBFIRST
define this, if you want to read first the oob data
and then the data. This is used for example on
davinci plattforms.
- CONFIG_USE_ARCH_MEMCPY - CONFIG_USE_ARCH_MEMCPY
CONFIG_USE_ARCH_MEMSET CONFIG_USE_ARCH_MEMSET
If these options are used a optimized version of memcpy/memset will If these options are used a optimized version of memcpy/memset will
......
...@@ -140,6 +140,47 @@ static int nand_is_bad_block(int block) ...@@ -140,6 +140,47 @@ static int nand_is_bad_block(int block)
return 0; return 0;
} }
#if defined(CONFIG_SYS_NAND_HW_ECC_OOBFIRST)
static int nand_read_page(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(block, page, 0, NAND_CMD_READOOB);
this->read_buf(&mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
nand_command(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(int block, int page, void *dst) static int nand_read_page(int block, int page, void *dst)
{ {
struct nand_chip *this = mtd.priv; struct nand_chip *this = mtd.priv;
...@@ -186,6 +227,7 @@ static int nand_read_page(int block, int page, void *dst) ...@@ -186,6 +227,7 @@ static int nand_read_page(int block, int page, void *dst)
return 0; return 0;
} }
#endif
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
{ {
...@@ -230,7 +272,6 @@ void nand_init(void) ...@@ -230,7 +272,6 @@ void nand_init(void)
mtd.priv = &nand_chip; mtd.priv = &nand_chip;
nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W =
(void __iomem *)CONFIG_SYS_NAND_BASE; (void __iomem *)CONFIG_SYS_NAND_BASE;
nand_chip.options = 0;
board_nand_init(&nand_chip); board_nand_init(&nand_chip);
if (nand_chip.select_chip) if (nand_chip.select_chip)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment