diff options
author | Kyungmin Park <kmpark@infradead.org> | 2008-08-19 08:42:53 +0900 |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2008-08-21 13:50:20 -0500 |
commit | bfd7f38614e21f745b6d6845fcc616ebc5e4d36f (patch) | |
tree | f72c120c39a8a6b51e57d22d600571e29aaa976e /common | |
parent | 8d765456c1d33f2010d2717ee58de7647fdc6346 (diff) | |
download | u-boot-imx-bfd7f38614e21f745b6d6845fcc616ebc5e4d36f.zip u-boot-imx-bfd7f38614e21f745b6d6845fcc616ebc5e4d36f.tar.gz u-boot-imx-bfd7f38614e21f745b6d6845fcc616ebc5e4d36f.tar.bz2 |
Fix OneNAND read_oob/write_oob functions compatability
Also sync with kernel OneNAND codes
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_onenand.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index 5e2062b..8d87b78 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -85,15 +85,25 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ulong addr = simple_strtoul(argv[2], NULL, 16); ulong ofs = simple_strtoul(argv[3], NULL, 16); size_t len = simple_strtoul(argv[4], NULL, 16); - size_t retlen = 0; int oob = strncmp(argv[1], "read.oob", 8) ? 0 : 1; + struct mtd_oob_ops ops; + + ops.mode = MTD_OOB_PLACE; + + if (oob) { + ops.len = 0; + ops.datbuf = NULL; + ops.ooblen = len; + ops.oobbuf = (u_char *) addr; + } else { + ops.len = len; + ops.datbuf = (u_char *) addr; + ops.ooblen = 0; + ops.oobbuf = NULL; + } + ops.retlen = ops.oobretlen = 0; - if (oob) - onenand_read_oob(&onenand_mtd, ofs, len, - &retlen, (u_char *) addr); - else - onenand_read(&onenand_mtd, ofs, len, &retlen, - (u_char *) addr); + onenand_mtd.read_oob(&onenand_mtd, ofs, &ops); printf("Done\n"); return 0; @@ -117,9 +127,12 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ulong block = simple_strtoul(argv[3], NULL, 10); ulong page = simple_strtoul(argv[4], NULL, 10); size_t len = simple_strtol(argv[5], NULL, 10); - size_t retlen = 0; ulong ofs; int oob = strncmp(argv[1], "block.oob", 9) ? 0 : 1; + struct mtd_oob_ops ops; + + ops.mode = MTD_OOB_PLACE; + ofs = block << onenand_chip.erase_shift; if (page) @@ -127,17 +140,21 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) if (!len) { if (oob) - len = 64; + ops.ooblen = 64; else - len = 512; + ops.len = 512; + } + + if (oob) { + ops.datbuf = NULL; + ops.oobbuf = (u_char *) addr; + } else { + ops.datbuf = (u_char *) addr; + ops.oobbuf = NULL; } + ops.retlen = ops.oobretlen = 0; - if (oob) - onenand_read_oob(&onenand_mtd, ofs, len, - &retlen, (u_char *) addr); - else - onenand_read(&onenand_mtd, ofs, len, &retlen, - (u_char *) addr); + onenand_read_oob(&onenand_mtd, ofs, &ops); return 0; } |