4-bit ECC support for Marvell Kirkwood SOC

git-svn-id: svn://svn.berlios.de/openocd/trunk@1768 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
oharboe
2009-05-12 17:29:16 +00:00
parent f34386ee32
commit cbfa0304f9
5 changed files with 197 additions and 4 deletions

View File

@@ -1332,6 +1332,8 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
oob_format |= NAND_OOB_RAW | NAND_OOB_ONLY;
else if (!strcmp(args[i], "oob_softecc"))
oob_format |= NAND_OOB_SW_ECC;
else if (!strcmp(args[i], "oob_softecc_kw"))
oob_format |= NAND_OOB_SW_ECC_KW;
else
{
command_print(cmd_ctx, "unknown option: %s", args[i]);
@@ -1355,7 +1357,7 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
page = malloc(p->page_size);
}
if (oob_format & (NAND_OOB_RAW | NAND_OOB_SW_ECC))
if (oob_format & (NAND_OOB_RAW | NAND_OOB_SW_ECC | NAND_OOB_SW_ECC_KW))
{
if (p->page_size == 512) {
oob_size = 16;
@@ -1401,6 +1403,21 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
oob[eccpos[j++]] = ecc[1];
oob[eccpos[j++]] = ecc[2];
}
} else if (oob_format & NAND_OOB_SW_ECC_KW)
{
/*
* In this case eccpos is not used as
* the ECC data is always stored contigously
* at the end of the OOB area. It consists
* of 10 bytes per 512-byte data block.
*/
u32 i;
u8 *ecc = oob + oob_size - page_size/512 * 10;
memset(oob, 0xff, oob_size);
for (i = 0; i < page_size; i += 512) {
nand_calculate_ecc_kw(p, page+i, ecc);
ecc += 10;
}
}
else if (NULL != oob)
{