diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-05-12 17:29:16 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-05-12 17:29:16 +0000 |
commit | cbfa0304f96c7e3d30f83d9feb7b7f23a197e4b1 (patch) | |
tree | 02330874c1d4a196131a528295e89b8e458300b0 /src/flash/nand.c | |
parent | f34386ee327ee7b1419ad7fda12166b00d3f04b1 (diff) | |
download | openocd+libswd-cbfa0304f96c7e3d30f83d9feb7b7f23a197e4b1.tar.gz openocd+libswd-cbfa0304f96c7e3d30f83d9feb7b7f23a197e4b1.tar.bz2 openocd+libswd-cbfa0304f96c7e3d30f83d9feb7b7f23a197e4b1.tar.xz openocd+libswd-cbfa0304f96c7e3d30f83d9feb7b7f23a197e4b1.zip |
4-bit ECC support for Marvell Kirkwood SOC
git-svn-id: svn://svn.berlios.de/openocd/trunk@1768 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/nand.c')
-rw-r--r-- | src/flash/nand.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/flash/nand.c b/src/flash/nand.c index 8efed037..057feb7d 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -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) { |