summaryrefslogtreecommitdiffstats
path: root/common/cmd_onenand.c
diff options
context:
space:
mode:
authorKyungmin Park <kmpark@infradead.org>2008-03-31 10:40:19 +0900
committerWolfgang Denk <wd@denx.de>2008-04-13 23:10:39 -0700
commita9da2b41079d230db3a5641625311983f85ce1fb (patch)
treef679cbdd19f5b3e91472c105ebd520c1e56f092b /common/cmd_onenand.c
parent61525f2ffa156665a66908fda47dbf29d65ea579 (diff)
downloadu-boot-a9da2b41079d230db3a5641625311983f85ce1fb.tar.gz
u-boot-a9da2b41079d230db3a5641625311983f85ce1fb.tar.xz
u-boot-a9da2b41079d230db3a5641625311983f85ce1fb.zip
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.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index dcda099c84..aff11d15c9 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;