diff options
author | Kyungmin Park <kmpark@infradead.org> | 2008-03-31 10:40:19 +0900 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-04-13 23:10:39 -0700 |
commit | a9da2b41079d230db3a5641625311983f85ce1fb (patch) | |
tree | f679cbdd19f5b3e91472c105ebd520c1e56f092b /common/cmd_onenand.c | |
parent | 61525f2ffa156665a66908fda47dbf29d65ea579 (diff) | |
download | u-boot-imx-a9da2b41079d230db3a5641625311983f85ce1fb.zip u-boot-imx-a9da2b41079d230db3a5641625311983f85ce1fb.tar.gz u-boot-imx-a9da2b41079d230db3a5641625311983f85ce1fb.tar.bz2 |
Fix OneNAND erase command
It mis-calculates the block address.
Also fix DECLARE_GLOBAL_DATA_PTR in env_onenand.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'common/cmd_onenand.c')
-rw-r--r-- | common/cmd_onenand.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index dcda099..aff11d1 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -44,14 +44,28 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) default: /* At least 4 args */ if (strncmp(argv[1], "erase", 5) == 0) { - struct erase_info instr; + struct erase_info instr = { + .callback = NULL, + }; ulong start, end; ulong block; - - start = simple_strtoul(argv[2], NULL, 10); - end = simple_strtoul(argv[3], NULL, 10); - start -= (unsigned long)onenand_chip.base; - end -= (unsigned long)onenand_chip.base; + char *endtail; + + if (strncmp(argv[2], "block", 5) == 0) { + start = simple_strtoul(argv[3], NULL, 10); + endtail = strchr(argv[3], '-'); + end = simple_strtoul(endtail + 1, NULL, 10); + } else { + start = simple_strtoul(argv[2], NULL, 10); + end = simple_strtoul(argv[3], NULL, 10); + start -= (unsigned long)onenand_chip.base; + end -= (unsigned long)onenand_chip.base; + + start >>= onenand_chip.erase_shift; + end >>= onenand_chip.erase_shift; + /* Don't include the end block */ + end--; + } if (!end || end < 0) end = start; |