wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Driver for NAND support, Rick Bronson |
| 3 | * borrowed heavily from: |
| 4 | * (c) 1999 Machine Vision Holdings, Inc. |
| 5 | * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> |
wdenk | 6d3c6d1 | 2005-04-03 22:35:21 +0000 | [diff] [blame] | 6 | * |
| 7 | * Added 16-bit nand support |
| 8 | * (C) 2004 Texas Instruments |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 12 | |
| 13 | |
Jean-Christophe PLAGNIOL-VILLARD | 719bb5f | 2008-08-13 01:40:43 +0200 | [diff] [blame] | 14 | #ifndef CONFIG_NAND_LEGACY |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 15 | /* |
| 16 | * |
| 17 | * New NAND support |
| 18 | * |
| 19 | */ |
| 20 | #include <common.h> |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 21 | #include <linux/mtd/mtd.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 22 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 23 | #if defined(CONFIG_CMD_NAND) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 24 | |
| 25 | #include <command.h> |
| 26 | #include <watchdog.h> |
| 27 | #include <malloc.h> |
| 28 | #include <asm/byteorder.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 29 | #include <jffs2/jffs2.h> |
| 30 | #include <nand.h> |
| 31 | |
Ladislav Michl | 9d0928d | 2009-04-21 02:26:31 +0200 | [diff] [blame] | 32 | #if defined(CONFIG_CMD_MTDPARTS) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 33 | |
| 34 | /* parition handling routines */ |
| 35 | int mtdparts_init(void); |
| 36 | int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); |
| 37 | int find_dev_and_part(const char *id, struct mtd_device **dev, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 38 | u8 *part_num, struct part_info **part); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 41 | static int nand_dump(nand_info_t *nand, ulong off, int only_oob) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 42 | { |
| 43 | int i; |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 44 | u_char *datbuf, *oobbuf, *p; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 45 | |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 46 | datbuf = malloc(nand->writesize + nand->oobsize); |
| 47 | oobbuf = malloc(nand->oobsize); |
| 48 | if (!datbuf || !oobbuf) { |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 49 | puts("No memory for page buffer\n"); |
| 50 | return 1; |
| 51 | } |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 52 | off &= ~(nand->writesize - 1); |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 53 | loff_t addr = (loff_t) off; |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 54 | struct mtd_oob_ops ops; |
| 55 | memset(&ops, 0, sizeof(ops)); |
| 56 | ops.datbuf = datbuf; |
| 57 | ops.oobbuf = oobbuf; /* must exist, but oob data will be appended to ops.datbuf */ |
| 58 | ops.len = nand->writesize; |
| 59 | ops.ooblen = nand->oobsize; |
| 60 | ops.mode = MTD_OOB_RAW; |
| 61 | i = nand->read_oob(nand, addr, &ops); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 62 | if (i < 0) { |
Stefan Roese | 3167d07 | 2008-07-10 10:10:54 +0200 | [diff] [blame] | 63 | printf("Error (%d) reading page %08lx\n", i, off); |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 64 | free(datbuf); |
| 65 | free(oobbuf); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 66 | return 1; |
| 67 | } |
Stefan Roese | 3167d07 | 2008-07-10 10:10:54 +0200 | [diff] [blame] | 68 | printf("Page %08lx dump:\n", off); |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 69 | i = nand->writesize >> 4; |
| 70 | p = datbuf; |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 71 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 72 | while (i--) { |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 73 | if (!only_oob) |
| 74 | printf("\t%02x %02x %02x %02x %02x %02x %02x %02x" |
| 75 | " %02x %02x %02x %02x %02x %02x %02x %02x\n", |
| 76 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], |
Scott Wood | cc5f339 | 2008-06-12 13:20:16 -0500 | [diff] [blame] | 77 | p[8], p[9], p[10], p[11], p[12], p[13], p[14], |
| 78 | p[15]); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 79 | p += 16; |
| 80 | } |
| 81 | puts("OOB:\n"); |
| 82 | i = nand->oobsize >> 3; |
| 83 | while (i--) { |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 84 | printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n", |
| 85 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 86 | p += 8; |
| 87 | } |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 88 | free(datbuf); |
| 89 | free(oobbuf); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | /* ------------------------------------------------------------------------- */ |
| 95 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 96 | static inline int str2long(char *p, ulong *num) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 97 | { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 98 | char *endptr; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 99 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 100 | *num = simple_strtoul(p, &endptr, 16); |
| 101 | return (*p != '\0' && *endptr == '\0') ? 1 : 0; |
| 102 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 103 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 104 | static int |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 105 | arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, size_t *size) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 106 | { |
| 107 | int idx = nand_curr_device; |
Ladislav Michl | 9d0928d | 2009-04-21 02:26:31 +0200 | [diff] [blame] | 108 | #if defined(CONFIG_CMD_MTDPARTS) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 109 | struct mtd_device *dev; |
| 110 | struct part_info *part; |
| 111 | u8 pnum; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 112 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 113 | if (argc >= 1 && !(str2long(argv[0], off))) { |
| 114 | if ((mtdparts_init() == 0) && |
| 115 | (find_dev_and_part(argv[0], &dev, &pnum, &part) == 0)) { |
| 116 | if (dev->id->type != MTD_DEV_TYPE_NAND) { |
| 117 | puts("not a NAND device\n"); |
| 118 | return -1; |
| 119 | } |
| 120 | *off = part->offset; |
| 121 | if (argc >= 2) { |
Wolfgang Denk | 7f79454 | 2008-04-30 17:46:26 +0200 | [diff] [blame] | 122 | if (!(str2long(argv[1], (ulong *)size))) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 123 | printf("'%s' is not a number\n", argv[1]); |
| 124 | return -1; |
| 125 | } |
| 126 | if (*size > part->size) |
| 127 | *size = part->size; |
| 128 | } else { |
| 129 | *size = part->size; |
| 130 | } |
| 131 | idx = dev->id->num; |
| 132 | *nand = nand_info[idx]; |
| 133 | goto out; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 134 | } |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 135 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 136 | #endif |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 137 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 138 | if (argc >= 1) { |
| 139 | if (!(str2long(argv[0], off))) { |
| 140 | printf("'%s' is not a number\n", argv[0]); |
| 141 | return -1; |
| 142 | } |
| 143 | } else { |
| 144 | *off = 0; |
| 145 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 146 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 147 | if (argc >= 2) { |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 148 | if (!(str2long(argv[1], (ulong *)size))) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 149 | printf("'%s' is not a number\n", argv[1]); |
| 150 | return -1; |
| 151 | } |
| 152 | } else { |
| 153 | *size = nand->size - *off; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Ladislav Michl | 9d0928d | 2009-04-21 02:26:31 +0200 | [diff] [blame] | 156 | #if defined(CONFIG_CMD_MTDPARTS) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 157 | out: |
| 158 | #endif |
| 159 | printf("device %d ", idx); |
| 160 | if (*size == nand->size) |
| 161 | puts("whole chip\n"); |
| 162 | else |
Mike Frysinger | d38f4a6 | 2009-01-18 19:46:06 -0500 | [diff] [blame] | 163 | printf("offset 0x%lx, size 0x%zx\n", *off, *size); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 164 | return 0; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 165 | } |
| 166 | |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 167 | #ifdef CONFIG_CMD_NAND_LOCK_UNLOCK |
| 168 | static void print_status(ulong start, ulong end, ulong erasesize, int status) |
| 169 | { |
| 170 | printf("%08lx - %08lx: %08lx blocks %s%s%s\n", |
| 171 | start, |
| 172 | end - 1, |
| 173 | (end - start) / erasesize, |
| 174 | ((status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""), |
| 175 | ((status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""), |
| 176 | ((status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : "")); |
| 177 | } |
| 178 | |
| 179 | static void do_nand_status(nand_info_t *nand) |
| 180 | { |
| 181 | ulong block_start = 0; |
| 182 | ulong off; |
| 183 | int last_status = -1; |
| 184 | |
| 185 | struct nand_chip *nand_chip = nand->priv; |
| 186 | /* check the WP bit */ |
| 187 | nand_chip->cmdfunc(nand, NAND_CMD_STATUS, -1, -1); |
| 188 | printf("device is %swrite protected\n", |
| 189 | (nand_chip->read_byte(nand) & 0x80 ? |
| 190 | "NOT " : "")); |
| 191 | |
| 192 | for (off = 0; off < nand->size; off += nand->erasesize) { |
| 193 | int s = nand_get_lock_status(nand, off); |
| 194 | |
| 195 | /* print message only if status has changed */ |
| 196 | if (s != last_status && off != 0) { |
| 197 | print_status(block_start, off, nand->erasesize, |
| 198 | last_status); |
| 199 | block_start = off; |
| 200 | } |
| 201 | last_status = s; |
| 202 | } |
| 203 | /* Print the last block info */ |
| 204 | print_status(block_start, off, nand->erasesize, last_status); |
| 205 | } |
| 206 | #endif |
| 207 | |
Wolfgang Grandegger | b325d7e | 2009-02-11 18:38:20 +0100 | [diff] [blame] | 208 | static void nand_print_info(int idx) |
| 209 | { |
| 210 | nand_info_t *nand = &nand_info[idx]; |
| 211 | struct nand_chip *chip = nand->priv; |
| 212 | printf("Device %d: ", idx); |
| 213 | if (chip->numchips > 1) |
| 214 | printf("%dx ", chip->numchips); |
| 215 | printf("%s, sector size %u KiB\n", |
| 216 | nand->name, nand->erasesize >> 10); |
| 217 | } |
| 218 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 219 | int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 220 | { |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 221 | int i, dev, ret = 0; |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 222 | ulong addr, off; |
| 223 | size_t size; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 224 | char *cmd, *s; |
| 225 | nand_info_t *nand; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 226 | #ifdef CONFIG_SYS_NAND_QUIET |
| 227 | int quiet = CONFIG_SYS_NAND_QUIET; |
Matthias Fuchs | d42fff2 | 2007-09-12 12:36:53 +0200 | [diff] [blame] | 228 | #else |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 229 | int quiet = 0; |
Matthias Fuchs | d42fff2 | 2007-09-12 12:36:53 +0200 | [diff] [blame] | 230 | #endif |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 231 | const char *quiet_str = getenv("quiet"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 232 | |
| 233 | /* at least two arguments please */ |
| 234 | if (argc < 2) |
| 235 | goto usage; |
| 236 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 237 | if (quiet_str) |
| 238 | quiet = simple_strtoul(quiet_str, NULL, 0) != 0; |
| 239 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 240 | cmd = argv[1]; |
| 241 | |
| 242 | if (strcmp(cmd, "info") == 0) { |
| 243 | |
| 244 | putc('\n'); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 245 | for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 246 | if (nand_info[i].name) |
Wolfgang Grandegger | b325d7e | 2009-02-11 18:38:20 +0100 | [diff] [blame] | 247 | nand_print_info(i); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 248 | } |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | if (strcmp(cmd, "device") == 0) { |
| 253 | |
| 254 | if (argc < 3) { |
Wolfgang Grandegger | b325d7e | 2009-02-11 18:38:20 +0100 | [diff] [blame] | 255 | putc('\n'); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 256 | if ((nand_curr_device < 0) || |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 257 | (nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) |
Wolfgang Grandegger | b325d7e | 2009-02-11 18:38:20 +0100 | [diff] [blame] | 258 | puts("no devices available\n"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 259 | else |
Wolfgang Grandegger | b325d7e | 2009-02-11 18:38:20 +0100 | [diff] [blame] | 260 | nand_print_info(nand_curr_device); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 261 | return 0; |
| 262 | } |
| 263 | dev = (int)simple_strtoul(argv[2], NULL, 10); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 264 | if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev].name) { |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 265 | puts("No such device\n"); |
| 266 | return 1; |
| 267 | } |
| 268 | printf("Device %d: %s", dev, nand_info[dev].name); |
| 269 | puts("... is now current device\n"); |
| 270 | nand_curr_device = dev; |
Stefan Roese | 3cdd3fd | 2006-10-20 14:28:52 +0200 | [diff] [blame] | 271 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 272 | #ifdef CONFIG_SYS_NAND_SELECT_DEVICE |
Stefan Roese | 3cdd3fd | 2006-10-20 14:28:52 +0200 | [diff] [blame] | 273 | /* |
| 274 | * Select the chip in the board/cpu specific driver |
| 275 | */ |
| 276 | board_nand_select_device(nand_info[dev].priv, dev); |
| 277 | #endif |
| 278 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 279 | return 0; |
| 280 | } |
| 281 | |
| 282 | if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 && |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 283 | strncmp(cmd, "dump", 4) != 0 && |
| 284 | strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 && |
| 285 | strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 && |
| 286 | strcmp(cmd, "biterr") != 0 && |
| 287 | strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 ) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 288 | goto usage; |
| 289 | |
| 290 | /* the following commands operate on the current device */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 291 | if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 292 | !nand_info[nand_curr_device].name) { |
| 293 | puts("\nno devices available\n"); |
| 294 | return 1; |
| 295 | } |
| 296 | nand = &nand_info[nand_curr_device]; |
| 297 | |
| 298 | if (strcmp(cmd, "bad") == 0) { |
| 299 | printf("\nDevice %d bad blocks:\n", nand_curr_device); |
| 300 | for (off = 0; off < nand->size; off += nand->erasesize) |
| 301 | if (nand_block_isbad(nand, off)) |
Stefan Roese | 3167d07 | 2008-07-10 10:10:54 +0200 | [diff] [blame] | 302 | printf(" %08lx\n", off); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 306 | /* |
| 307 | * Syntax is: |
| 308 | * 0 1 2 3 4 |
| 309 | * nand erase [clean] [off size] |
| 310 | */ |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 311 | if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) { |
| 312 | nand_erase_options_t opts; |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 313 | /* "clean" at index 2 means request to write cleanmarker */ |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 314 | int clean = argc > 2 && !strcmp("clean", argv[2]); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 315 | int o = clean ? 3 : 2; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 316 | int scrub = !strcmp(cmd, "scrub"); |
| 317 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 318 | printf("\nNAND %s: ", scrub ? "scrub" : "erase"); |
| 319 | /* skip first two or three arguments, look for offset and size */ |
| 320 | if (arg_off_size(argc - o, argv + o, nand, &off, &size) != 0) |
| 321 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 322 | |
| 323 | memset(&opts, 0, sizeof(opts)); |
| 324 | opts.offset = off; |
| 325 | opts.length = size; |
| 326 | opts.jffs2 = clean; |
| 327 | opts.quiet = quiet; |
| 328 | |
| 329 | if (scrub) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 330 | puts("Warning: " |
| 331 | "scrub option will erase all factory set " |
| 332 | "bad blocks!\n" |
| 333 | " " |
| 334 | "There is no reliable way to recover them.\n" |
| 335 | " " |
| 336 | "Use this command only for testing purposes " |
| 337 | "if you\n" |
| 338 | " " |
| 339 | "are sure of what you are doing!\n" |
| 340 | "\nReally scrub this NAND flash? <y/N>\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 341 | |
| 342 | if (getc() == 'y' && getc() == '\r') { |
| 343 | opts.scrub = 1; |
| 344 | } else { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 345 | puts("scrub aborted\n"); |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 346 | return -1; |
| 347 | } |
| 348 | } |
| 349 | ret = nand_erase_opts(nand, &opts); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 350 | printf("%s\n", ret ? "ERROR" : "OK"); |
| 351 | |
| 352 | return ret == 0 ? 0 : 1; |
| 353 | } |
| 354 | |
| 355 | if (strncmp(cmd, "dump", 4) == 0) { |
| 356 | if (argc < 3) |
| 357 | goto usage; |
| 358 | |
| 359 | s = strchr(cmd, '.'); |
| 360 | off = (int)simple_strtoul(argv[2], NULL, 16); |
| 361 | |
| 362 | if (s != NULL && strcmp(s, ".oob") == 0) |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 363 | ret = nand_dump(nand, off, 1); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 364 | else |
William Juul | e7ebe6e | 2007-12-14 16:33:45 +0100 | [diff] [blame] | 365 | ret = nand_dump(nand, off, 0); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 366 | |
| 367 | return ret == 0 ? 1 : 0; |
| 368 | |
| 369 | } |
| 370 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 371 | if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) { |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 372 | int read; |
| 373 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 374 | if (argc < 4) |
| 375 | goto usage; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 376 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 377 | addr = (ulong)simple_strtoul(argv[2], NULL, 16); |
| 378 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 379 | read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 380 | printf("\nNAND %s: ", read ? "read" : "write"); |
| 381 | if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0) |
| 382 | return 1; |
William Juul | b76ec38 | 2007-11-08 10:39:53 +0100 | [diff] [blame] | 383 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 384 | s = strchr(cmd, '.'); |
Scott Wood | 12b1c95 | 2008-06-12 13:13:23 -0500 | [diff] [blame] | 385 | if (!s || !strcmp(s, ".jffs2") || |
| 386 | !strcmp(s, ".e") || !strcmp(s, ".i")) { |
Scott Wood | cc5f339 | 2008-06-12 13:20:16 -0500 | [diff] [blame] | 387 | if (read) |
| 388 | ret = nand_read_skip_bad(nand, off, &size, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 389 | (u_char *)addr); |
Scott Wood | cc5f339 | 2008-06-12 13:20:16 -0500 | [diff] [blame] | 390 | else |
| 391 | ret = nand_write_skip_bad(nand, off, &size, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 392 | (u_char *)addr); |
Mike Frysinger | 9a2cbb9 | 2009-04-12 22:29:20 -0400 | [diff] [blame] | 393 | } else if (!strcmp(s, ".oob")) { |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 394 | /* out-of-band data */ |
| 395 | mtd_oob_ops_t ops = { |
| 396 | .oobbuf = (u8 *)addr, |
| 397 | .ooblen = size, |
| 398 | .mode = MTD_OOB_RAW |
| 399 | }; |
| 400 | |
Harald Welte | 5a39510 | 2007-12-19 14:12:53 +0100 | [diff] [blame] | 401 | if (read) |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 402 | ret = nand->read_oob(nand, off, &ops); |
Harald Welte | 5a39510 | 2007-12-19 14:12:53 +0100 | [diff] [blame] | 403 | else |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 404 | ret = nand->write_oob(nand, off, &ops); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 405 | } else { |
Scott Wood | 12b1c95 | 2008-06-12 13:13:23 -0500 | [diff] [blame] | 406 | printf("Unknown nand command suffix '%s'.\n", s); |
| 407 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 408 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 409 | |
Mike Frysinger | d38f4a6 | 2009-01-18 19:46:06 -0500 | [diff] [blame] | 410 | printf(" %zu bytes %s: %s\n", size, |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 411 | read ? "read" : "written", ret ? "ERROR" : "OK"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 412 | |
| 413 | return ret == 0 ? 0 : 1; |
| 414 | } |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 415 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 416 | if (strcmp(cmd, "markbad") == 0) { |
| 417 | addr = (ulong)simple_strtoul(argv[2], NULL, 16); |
| 418 | |
| 419 | int ret = nand->block_markbad(nand, addr); |
| 420 | if (ret == 0) { |
| 421 | printf("block 0x%08lx successfully marked as bad\n", |
| 422 | (ulong) addr); |
| 423 | return 0; |
| 424 | } else { |
| 425 | printf("block 0x%08lx NOT marked as bad! ERROR %d\n", |
| 426 | (ulong) addr, ret); |
| 427 | } |
| 428 | return 1; |
| 429 | } |
Scott Wood | cc5f339 | 2008-06-12 13:20:16 -0500 | [diff] [blame] | 430 | |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 431 | if (strcmp(cmd, "biterr") == 0) { |
| 432 | /* todo */ |
| 433 | return 1; |
| 434 | } |
| 435 | |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 436 | #ifdef CONFIG_CMD_NAND_LOCK_UNLOCK |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 437 | if (strcmp(cmd, "lock") == 0) { |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 438 | int tight = 0; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 439 | int status = 0; |
| 440 | if (argc == 3) { |
| 441 | if (!strcmp("tight", argv[2])) |
| 442 | tight = 1; |
| 443 | if (!strcmp("status", argv[2])) |
| 444 | status = 1; |
| 445 | } |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 446 | if (status) { |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 447 | do_nand_status(nand); |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 448 | } else { |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 449 | if (!nand_lock(nand, tight)) { |
| 450 | puts("NAND flash successfully locked\n"); |
| 451 | } else { |
| 452 | puts("Error locking NAND flash\n"); |
| 453 | return 1; |
| 454 | } |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 455 | } |
| 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | if (strcmp(cmd, "unlock") == 0) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 460 | if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0) |
| 461 | return 1; |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 462 | |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 463 | if (!nand_unlock(nand, off, size)) { |
| 464 | puts("NAND flash successfully unlocked\n"); |
| 465 | } else { |
| 466 | puts("Error unlocking NAND flash, " |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 467 | "write and erase will probably fail\n"); |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 468 | return 1; |
| 469 | } |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 470 | return 0; |
| 471 | } |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 472 | #endif |
Stefan Roese | d351b2b | 2006-10-10 12:36:02 +0200 | [diff] [blame] | 473 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 474 | usage: |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 475 | cmd_usage(cmdtp); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 476 | return 1; |
| 477 | } |
| 478 | |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 479 | U_BOOT_CMD(nand, CONFIG_SYS_MAXARGS, 1, do_nand, |
| 480 | "NAND sub-system", |
| 481 | "info - show available NAND devices\n" |
| 482 | "nand device [dev] - show or set current device\n" |
| 483 | "nand read - addr off|partition size\n" |
| 484 | "nand write - addr off|partition size\n" |
| 485 | " read/write 'size' bytes starting at offset 'off'\n" |
| 486 | " to/from memory address 'addr', skipping bad blocks.\n" |
| 487 | "nand erase [clean] [off size] - erase 'size' bytes from\n" |
| 488 | " offset 'off' (entire device if not specified)\n" |
| 489 | "nand bad - show bad blocks\n" |
| 490 | "nand dump[.oob] off - dump page\n" |
| 491 | "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n" |
| 492 | "nand markbad off [...] - mark bad block(s) at offset (UNSAFE)\n" |
| 493 | "nand biterr off - make a bit error at offset (UNSAFE)" |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 494 | #ifdef CONFIG_CMD_NAND_LOCK_UNLOCK |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 495 | "\n" |
| 496 | "nand lock [tight] [status]\n" |
| 497 | " bring nand to lock state or display locked pages\n" |
| 498 | "nand unlock [offset] [size] - unlock section" |
Nishanth Menon | b20f840 | 2008-12-13 09:43:06 -0600 | [diff] [blame] | 499 | #endif |
| 500 | ); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 501 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 502 | static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 503 | ulong offset, ulong addr, char *cmd) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 504 | { |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 505 | int r; |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 506 | char *ep, *s; |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 507 | size_t cnt; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 508 | image_header_t *hdr; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 509 | #if defined(CONFIG_FIT) |
Marian Balakowicz | cefb402 | 2008-06-06 23:07:40 +0200 | [diff] [blame] | 510 | const void *fit_hdr = NULL; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 511 | #endif |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 512 | |
| 513 | s = strchr(cmd, '.'); |
| 514 | if (s != NULL && |
Scott Wood | d1c1f9c | 2009-03-17 12:06:04 -0500 | [diff] [blame] | 515 | (strcmp(s, ".jffs2") && strcmp(s, ".e") && strcmp(s, ".i"))) { |
Scott Wood | 12b1c95 | 2008-06-12 13:13:23 -0500 | [diff] [blame] | 516 | printf("Unknown nand load suffix '%s'\n", s); |
| 517 | show_boot_progress(-53); |
| 518 | return 1; |
| 519 | } |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 520 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 521 | printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 522 | |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 523 | cnt = nand->writesize; |
Ladislav Michl | aaee2a3 | 2009-03-13 14:38:19 +0100 | [diff] [blame] | 524 | r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 525 | if (r) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 526 | puts("** Read error\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 527 | show_boot_progress (-56); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 528 | return 1; |
| 529 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 530 | show_boot_progress (56); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 531 | |
Marian Balakowicz | d7c88a4 | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 532 | switch (genimg_get_format ((void *)addr)) { |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 533 | case IMAGE_FORMAT_LEGACY: |
| 534 | hdr = (image_header_t *)addr; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 535 | |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 536 | show_boot_progress (57); |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 537 | image_print_contents (hdr); |
| 538 | |
| 539 | cnt = image_get_image_size (hdr); |
| 540 | break; |
| 541 | #if defined(CONFIG_FIT) |
| 542 | case IMAGE_FORMAT_FIT: |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 543 | fit_hdr = (const void *)addr; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 544 | puts ("Fit image detected...\n"); |
| 545 | |
| 546 | cnt = fit_get_size (fit_hdr); |
| 547 | break; |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 548 | #endif |
| 549 | default: |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 550 | show_boot_progress (-57); |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 551 | puts ("** Unknown image type\n"); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 552 | return 1; |
| 553 | } |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 554 | show_boot_progress (57); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 555 | |
Ladislav Michl | aaee2a3 | 2009-03-13 14:38:19 +0100 | [diff] [blame] | 556 | r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 557 | if (r) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 558 | puts("** Read error\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 559 | show_boot_progress (-58); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 560 | return 1; |
| 561 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 562 | show_boot_progress (58); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 563 | |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 564 | #if defined(CONFIG_FIT) |
| 565 | /* This cannot be done earlier, we need complete FIT image in RAM first */ |
Marian Balakowicz | cefb402 | 2008-06-06 23:07:40 +0200 | [diff] [blame] | 566 | if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { |
| 567 | if (!fit_check_format (fit_hdr)) { |
| 568 | show_boot_progress (-150); |
| 569 | puts ("** Bad FIT image format\n"); |
| 570 | return 1; |
| 571 | } |
| 572 | show_boot_progress (151); |
| 573 | fit_print_contents (fit_hdr); |
| 574 | } |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 575 | #endif |
| 576 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 577 | /* Loading ok, update default load address */ |
| 578 | |
| 579 | load_addr = addr; |
| 580 | |
| 581 | /* Check if we should attempt an auto-start */ |
| 582 | if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) { |
| 583 | char *local_args[2]; |
| 584 | extern int do_bootm(cmd_tbl_t *, int, int, char *[]); |
| 585 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 586 | local_args[0] = cmd; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 587 | local_args[1] = NULL; |
| 588 | |
| 589 | printf("Automatic boot of image at addr 0x%08lx ...\n", addr); |
| 590 | |
| 591 | do_bootm(cmdtp, 0, 1, local_args); |
| 592 | return 1; |
| 593 | } |
| 594 | return 0; |
| 595 | } |
| 596 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 597 | int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 598 | { |
| 599 | char *boot_device = NULL; |
| 600 | int idx; |
| 601 | ulong addr, offset = 0; |
Ladislav Michl | 9d0928d | 2009-04-21 02:26:31 +0200 | [diff] [blame] | 602 | #if defined(CONFIG_CMD_MTDPARTS) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 603 | struct mtd_device *dev; |
| 604 | struct part_info *part; |
| 605 | u8 pnum; |
| 606 | |
| 607 | if (argc >= 2) { |
| 608 | char *p = (argc == 2) ? argv[1] : argv[2]; |
| 609 | if (!(str2long(p, &addr)) && (mtdparts_init() == 0) && |
| 610 | (find_dev_and_part(p, &dev, &pnum, &part) == 0)) { |
| 611 | if (dev->id->type != MTD_DEV_TYPE_NAND) { |
| 612 | puts("Not a NAND device\n"); |
| 613 | return 1; |
| 614 | } |
| 615 | if (argc > 3) |
| 616 | goto usage; |
| 617 | if (argc == 3) |
Thomas Knobloch | e84b777 | 2007-07-06 14:58:39 +0200 | [diff] [blame] | 618 | addr = simple_strtoul(argv[1], NULL, 16); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 619 | else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 620 | addr = CONFIG_SYS_LOAD_ADDR; |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 621 | return nand_load_image(cmdtp, &nand_info[dev->id->num], |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 622 | part->offset, addr, argv[0]); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 623 | } |
| 624 | } |
| 625 | #endif |
| 626 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 627 | show_boot_progress(52); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 628 | switch (argc) { |
| 629 | case 1: |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 630 | addr = CONFIG_SYS_LOAD_ADDR; |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 631 | boot_device = getenv("bootdevice"); |
| 632 | break; |
| 633 | case 2: |
| 634 | addr = simple_strtoul(argv[1], NULL, 16); |
| 635 | boot_device = getenv("bootdevice"); |
| 636 | break; |
| 637 | case 3: |
| 638 | addr = simple_strtoul(argv[1], NULL, 16); |
| 639 | boot_device = argv[2]; |
| 640 | break; |
| 641 | case 4: |
| 642 | addr = simple_strtoul(argv[1], NULL, 16); |
| 643 | boot_device = argv[2]; |
| 644 | offset = simple_strtoul(argv[3], NULL, 16); |
| 645 | break; |
| 646 | default: |
Ladislav Michl | 9d0928d | 2009-04-21 02:26:31 +0200 | [diff] [blame] | 647 | #if defined(CONFIG_CMD_MTDPARTS) |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 648 | usage: |
| 649 | #endif |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 650 | cmd_usage(cmdtp); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 651 | show_boot_progress(-53); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 652 | return 1; |
| 653 | } |
| 654 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 655 | show_boot_progress(53); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 656 | if (!boot_device) { |
| 657 | puts("\n** No boot device **\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 658 | show_boot_progress(-54); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 659 | return 1; |
| 660 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 661 | show_boot_progress(54); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 662 | |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 663 | idx = simple_strtoul(boot_device, NULL, 16); |
| 664 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 665 | if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx].name) { |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 666 | printf("\n** Device %d not available\n", idx); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 667 | show_boot_progress(-55); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 668 | return 1; |
| 669 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 670 | show_boot_progress(55); |
Stefan Roese | 198b23e | 2006-10-28 15:55:52 +0200 | [diff] [blame] | 671 | |
| 672 | return nand_load_image(cmdtp, &nand_info[idx], offset, addr, argv[0]); |
| 673 | } |
| 674 | |
| 675 | U_BOOT_CMD(nboot, 4, 1, do_nandboot, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 676 | "boot from NAND device", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 677 | "[partition] | [[[loadAddr] dev] offset]" |
| 678 | ); |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 679 | #endif |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 680 | |
Jean-Christophe PLAGNIOL-VILLARD | 719bb5f | 2008-08-13 01:40:43 +0200 | [diff] [blame] | 681 | #else /* CONFIG_NAND_LEGACY */ |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 682 | /* |
| 683 | * |
| 684 | * Legacy NAND support - to be phased out |
| 685 | * |
| 686 | */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 687 | #include <command.h> |
| 688 | #include <malloc.h> |
| 689 | #include <asm/io.h> |
wdenk | 145d2c1 | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 690 | #include <watchdog.h> |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 691 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 692 | #ifdef CONFIG_show_boot_progress |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 693 | # include <status_led.h> |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 694 | # define show_boot_progress(arg) show_boot_progress(arg) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 695 | #else |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 696 | # define show_boot_progress(arg) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 697 | #endif |
| 698 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 699 | #if defined(CONFIG_CMD_NAND) |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 700 | #include <linux/mtd/nand_legacy.h> |
| 701 | #if 0 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 702 | #include <linux/mtd/nand_ids.h> |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 703 | #include <jffs2/jffs2.h> |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 704 | #endif |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 705 | |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 706 | #ifdef CONFIG_OMAP1510 |
| 707 | void archflashwp(void *archdata, int wp); |
| 708 | #endif |
| 709 | |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 710 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 711 | |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 712 | #undef NAND_DEBUG |
| 713 | #undef PSYCHO_DEBUG |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 714 | |
| 715 | /* ****************** WARNING ********************* |
| 716 | * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will |
| 717 | * erase (or at least attempt to erase) blocks that are marked |
| 718 | * bad. This can be very handy if you are _sure_ that the block |
| 719 | * is OK, say because you marked a good block bad to test bad |
| 720 | * block handling and you are done testing, or if you have |
| 721 | * accidentally marked blocks bad. |
| 722 | * |
| 723 | * Erasing factory marked bad blocks is a _bad_ idea. If the |
| 724 | * erase succeeds there is no reliable way to find them again, |
| 725 | * and attempting to program or erase bad blocks can affect |
| 726 | * the data in _other_ (good) blocks. |
| 727 | */ |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 728 | #define ALLOW_ERASE_BAD_DEBUG 0 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 729 | |
| 730 | #define CONFIG_MTD_NAND_ECC /* enable ECC */ |
wdenk | e58b0dc | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 731 | #define CONFIG_MTD_NAND_ECC_JFFS2 |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 732 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 733 | /* bits for nand_legacy_rw() `cmd'; or together as needed */ |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 734 | #define NANDRW_READ 0x01 |
| 735 | #define NANDRW_WRITE 0x00 |
| 736 | #define NANDRW_JFFS2 0x02 |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 737 | #define NANDRW_JFFS2_SKIP 0x04 |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 738 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 739 | /* |
| 740 | * Imports from nand_legacy.c |
| 741 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 742 | extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE]; |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 743 | extern int curr_device; |
| 744 | extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 745 | size_t len, int clean); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 746 | extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start, |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 747 | size_t len, size_t *retlen, u_char *buf); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 748 | extern void nand_print(struct nand_chip *nand); |
| 749 | extern void nand_print_bad(struct nand_chip *nand); |
| 750 | extern int nand_read_oob(struct nand_chip *nand, size_t ofs, |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 751 | size_t len, size_t *retlen, u_char *buf); |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 752 | extern int nand_write_oob(struct nand_chip *nand, size_t ofs, |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 753 | size_t len, size_t *retlen, const u_char *buf); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 754 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 755 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 756 | int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 757 | { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 758 | int rcode = 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 759 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 760 | switch (argc) { |
| 761 | case 0: |
| 762 | case 1: |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 763 | cmd_usage(cmdtp); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 764 | return 1; |
| 765 | case 2: |
| 766 | if (strcmp (argv[1], "info") == 0) { |
| 767 | int i; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 768 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 769 | putc ('\n'); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 770 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 771 | for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; ++i) { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 772 | if (nand_dev_desc[i].ChipID == |
| 773 | NAND_ChipID_UNKNOWN) |
| 774 | continue; /* list only known devices */ |
| 775 | printf ("Device %d: ", i); |
| 776 | nand_print (&nand_dev_desc[i]); |
| 777 | } |
| 778 | return 0; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 779 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 780 | } else if (strcmp (argv[1], "device") == 0) { |
| 781 | if ((curr_device < 0) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 782 | || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 783 | puts ("\nno devices available\n"); |
| 784 | return 1; |
| 785 | } |
| 786 | printf ("\nDevice %d: ", curr_device); |
| 787 | nand_print (&nand_dev_desc[curr_device]); |
| 788 | return 0; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 789 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 790 | } else if (strcmp (argv[1], "bad") == 0) { |
| 791 | if ((curr_device < 0) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 792 | || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 793 | puts ("\nno devices available\n"); |
| 794 | return 1; |
| 795 | } |
| 796 | printf ("\nDevice %d bad blocks:\n", curr_device); |
| 797 | nand_print_bad (&nand_dev_desc[curr_device]); |
| 798 | return 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 799 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 800 | } |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 801 | cmd_usage(cmdtp); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 802 | return 1; |
| 803 | case 3: |
| 804 | if (strcmp (argv[1], "device") == 0) { |
| 805 | int dev = (int) simple_strtoul (argv[2], NULL, 10); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 806 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 807 | printf ("\nDevice %d: ", dev); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 808 | if (dev >= CONFIG_SYS_MAX_NAND_DEVICE) { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 809 | puts ("unknown device\n"); |
| 810 | return 1; |
| 811 | } |
| 812 | nand_print (&nand_dev_desc[dev]); |
| 813 | /*nand_print (dev); */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 814 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 815 | if (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN) { |
| 816 | return 1; |
| 817 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 818 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 819 | curr_device = dev; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 820 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 821 | puts ("... is now current device\n"); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 822 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 823 | return 0; |
| 824 | } else if (strcmp (argv[1], "erase") == 0 |
| 825 | && strcmp (argv[2], "clean") == 0) { |
| 826 | struct nand_chip *nand = &nand_dev_desc[curr_device]; |
| 827 | ulong off = 0; |
| 828 | ulong size = nand->totlen; |
| 829 | int ret; |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 830 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 831 | printf ("\nNAND erase: device %d offset %ld, size %ld ... ", curr_device, off, size); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 832 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 833 | ret = nand_legacy_erase (nand, off, size, 1); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 834 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 835 | printf ("%s\n", ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 836 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 837 | return ret; |
| 838 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 839 | |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 840 | cmd_usage(cmdtp); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 841 | return 1; |
| 842 | default: |
| 843 | /* at least 4 args */ |
| 844 | |
| 845 | if (strncmp (argv[1], "read", 4) == 0 || |
| 846 | strncmp (argv[1], "write", 5) == 0) { |
William Juul | 9e9c2c1 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 847 | ulong addr = simple_strtoul (argv[2], NULL, 16); |
| 848 | off_t off = simple_strtoul (argv[3], NULL, 16); |
| 849 | size_t size = simple_strtoul (argv[4], NULL, 16); |
| 850 | int cmd = (strncmp (argv[1], "read", 4) == 0) ? |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 851 | NANDRW_READ : NANDRW_WRITE; |
Wolfgang Denk | 885e86f | 2008-04-28 14:55:12 +0200 | [diff] [blame] | 852 | size_t total; |
| 853 | int ret; |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 854 | char *cmdtail = strchr (argv[1], '.'); |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 855 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 856 | if (cmdtail && !strncmp (cmdtail, ".oob", 2)) { |
| 857 | /* read out-of-band data */ |
| 858 | if (cmd & NANDRW_READ) { |
| 859 | ret = nand_read_oob (nand_dev_desc + curr_device, |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 860 | off, size, &total, |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 861 | (u_char *) addr); |
| 862 | } else { |
| 863 | ret = nand_write_oob (nand_dev_desc + curr_device, |
Wolfgang Denk | 9a11ccd | 2008-04-28 12:08:18 +0200 | [diff] [blame] | 864 | off, size, &total, |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 865 | (u_char *) addr); |
| 866 | } |
| 867 | return ret; |
Schlaegl Manfred jun | 1fd5551 | 2009-01-20 16:57:55 +0100 | [diff] [blame] | 868 | } else if (cmdtail && !strncmp (cmdtail, ".jffs2s", 7)) { |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 869 | cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */ |
| 870 | if (cmd & NANDRW_READ) |
| 871 | cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */ |
Schlaegl Manfred jun | 1fd5551 | 2009-01-20 16:57:55 +0100 | [diff] [blame] | 872 | } else if (cmdtail && !strncmp (cmdtail, ".jffs2", 2)) |
| 873 | cmd |= NANDRW_JFFS2; /* skip bad blocks */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 874 | #ifdef SXNI855T |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 875 | /* need ".e" same as ".j" for compatibility with older units */ |
| 876 | else if (cmdtail && !strcmp (cmdtail, ".e")) |
| 877 | cmd |= NANDRW_JFFS2; /* skip bad blocks */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 878 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 879 | #ifdef CONFIG_SYS_NAND_SKIP_BAD_DOT_I |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 880 | /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */ |
| 881 | /* ".i" for image -> read skips bad block (no 0xff) */ |
| 882 | else if (cmdtail && !strcmp (cmdtail, ".i")) { |
| 883 | cmd |= NANDRW_JFFS2; /* skip bad blocks (on read too) */ |
| 884 | if (cmd & NANDRW_READ) |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 885 | cmd |= NANDRW_JFFS2_SKIP; /* skip bad blocks (on read too) */ |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 886 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 887 | #endif /* CONFIG_SYS_NAND_SKIP_BAD_DOT_I */ |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 888 | else if (cmdtail) { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 889 | cmd_usage(cmdtp); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 890 | return 1; |
| 891 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 892 | |
Wolfgang Denk | 12cec0a | 2008-07-11 01:16:00 +0200 | [diff] [blame] | 893 | printf ("\nNAND %s: device %d offset %ld, size %lu ...\n", |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 894 | (cmd & NANDRW_READ) ? "read" : "write", |
Wolfgang Denk | 12cec0a | 2008-07-11 01:16:00 +0200 | [diff] [blame] | 895 | curr_device, off, (ulong)size); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 896 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 897 | ret = nand_legacy_rw (nand_dev_desc + curr_device, |
| 898 | cmd, off, size, |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 899 | &total, (u_char *) addr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 900 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 901 | printf (" %d bytes %s: %s\n", total, |
| 902 | (cmd & NANDRW_READ) ? "read" : "written", |
| 903 | ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 904 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 905 | return ret; |
| 906 | } else if (strcmp (argv[1], "erase") == 0 && |
| 907 | (argc == 4 || strcmp ("clean", argv[2]) == 0)) { |
| 908 | int clean = argc == 5; |
| 909 | ulong off = |
| 910 | simple_strtoul (argv[2 + clean], NULL, 16); |
| 911 | ulong size = |
| 912 | simple_strtoul (argv[3 + clean], NULL, 16); |
| 913 | int ret; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 914 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 915 | printf ("\nNAND erase: device %d offset %ld, size %ld ...\n", |
| 916 | curr_device, off, size); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 917 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 918 | ret = nand_legacy_erase (nand_dev_desc + curr_device, |
| 919 | off, size, clean); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 920 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 921 | printf ("%s\n", ret ? "ERROR" : "OK"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 922 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 923 | return ret; |
| 924 | } else { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 925 | cmd_usage(cmdtp); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 926 | rcode = 1; |
| 927 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 928 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 929 | return rcode; |
| 930 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 931 | } |
| 932 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 933 | U_BOOT_CMD( |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 934 | nand, 5, 1, do_nand, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 935 | "legacy NAND sub-system", |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 936 | "info - show available NAND devices\n" |
| 937 | "nand device [dev] - show or set current device\n" |
wdenk | 145d2c1 | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 938 | "nand read[.jffs2[s]] addr off size\n" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 939 | "nand write[.jffs2] addr off size - read/write `size' bytes starting\n" |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 940 | " at offset `off' to/from memory address `addr'\n" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 941 | "nand erase [clean] [off size] - erase `size' bytes from\n" |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 942 | " offset `off' (entire device if not specified)\n" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 943 | "nand bad - show bad blocks\n" |
| 944 | "nand read.oob addr off size - read out-of-band data\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 945 | "nand write.oob addr off size - read out-of-band data" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 946 | ); |
| 947 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 948 | int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 949 | { |
| 950 | char *boot_device = NULL; |
| 951 | char *ep; |
| 952 | int dev; |
| 953 | ulong cnt; |
| 954 | ulong addr; |
| 955 | ulong offset = 0; |
| 956 | image_header_t *hdr; |
| 957 | int rcode = 0; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 958 | #if defined(CONFIG_FIT) |
Marian Balakowicz | cefb402 | 2008-06-06 23:07:40 +0200 | [diff] [blame] | 959 | const void *fit_hdr = NULL; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 960 | #endif |
| 961 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 962 | show_boot_progress (52); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 963 | switch (argc) { |
| 964 | case 1: |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 965 | addr = CONFIG_SYS_LOAD_ADDR; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 966 | boot_device = getenv ("bootdevice"); |
| 967 | break; |
| 968 | case 2: |
| 969 | addr = simple_strtoul(argv[1], NULL, 16); |
| 970 | boot_device = getenv ("bootdevice"); |
| 971 | break; |
| 972 | case 3: |
| 973 | addr = simple_strtoul(argv[1], NULL, 16); |
| 974 | boot_device = argv[2]; |
| 975 | break; |
| 976 | case 4: |
| 977 | addr = simple_strtoul(argv[1], NULL, 16); |
| 978 | boot_device = argv[2]; |
| 979 | offset = simple_strtoul(argv[3], NULL, 16); |
| 980 | break; |
| 981 | default: |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 982 | cmd_usage(cmdtp); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 983 | show_boot_progress (-53); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 984 | return 1; |
| 985 | } |
| 986 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 987 | show_boot_progress (53); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 988 | if (!boot_device) { |
| 989 | puts ("\n** No boot device **\n"); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 990 | show_boot_progress (-54); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 991 | return 1; |
| 992 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 993 | show_boot_progress (54); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 994 | |
| 995 | dev = simple_strtoul(boot_device, &ep, 16); |
| 996 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 997 | if ((dev >= CONFIG_SYS_MAX_NAND_DEVICE) || |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 998 | (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) { |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 999 | printf ("\n** Device %d not available\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1000 | show_boot_progress (-55); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1001 | return 1; |
| 1002 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1003 | show_boot_progress (55); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1004 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 1005 | printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n", |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 1006 | dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR, |
| 1007 | offset); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1008 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 1009 | if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 1010 | SECTORSIZE, NULL, (u_char *)addr)) { |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1011 | printf ("** Read error on %d\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1012 | show_boot_progress (-56); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1013 | return 1; |
| 1014 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1015 | show_boot_progress (56); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1016 | |
Marian Balakowicz | d7c88a4 | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 1017 | switch (genimg_get_format ((void *)addr)) { |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1018 | case IMAGE_FORMAT_LEGACY: |
| 1019 | hdr = (image_header_t *)addr; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1020 | image_print_contents (hdr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1021 | |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1022 | cnt = image_get_image_size (hdr); |
| 1023 | cnt -= SECTORSIZE; |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1024 | break; |
| 1025 | #if defined(CONFIG_FIT) |
| 1026 | case IMAGE_FORMAT_FIT: |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1027 | fit_hdr = (const void *)addr; |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1028 | puts ("Fit image detected...\n"); |
| 1029 | |
| 1030 | cnt = fit_get_size (fit_hdr); |
| 1031 | break; |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1032 | #endif |
| 1033 | default: |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1034 | show_boot_progress (-57); |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1035 | puts ("** Unknown image type\n"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1036 | return 1; |
| 1037 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1038 | show_boot_progress (57); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1039 | |
Bartlomiej Sieka | 582f1a3 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 1040 | if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, |
Wolfgang Denk | 74e0dde | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 1041 | offset + SECTORSIZE, cnt, NULL, |
| 1042 | (u_char *)(addr+SECTORSIZE))) { |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1043 | printf ("** Read error on %d\n", dev); |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1044 | show_boot_progress (-58); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1045 | return 1; |
| 1046 | } |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 1047 | show_boot_progress (58); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1048 | |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1049 | #if defined(CONFIG_FIT) |
| 1050 | /* This cannot be done earlier, we need complete FIT image in RAM first */ |
Marian Balakowicz | cefb402 | 2008-06-06 23:07:40 +0200 | [diff] [blame] | 1051 | if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { |
| 1052 | if (!fit_check_format (fit_hdr)) { |
| 1053 | show_boot_progress (-150); |
| 1054 | puts ("** Bad FIT image format\n"); |
| 1055 | return 1; |
| 1056 | } |
| 1057 | show_boot_progress (151); |
| 1058 | fit_print_contents (fit_hdr); |
| 1059 | } |
Marian Balakowicz | e6bdd34 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 1060 | #endif |
| 1061 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1062 | /* Loading ok, update default load address */ |
| 1063 | |
| 1064 | load_addr = addr; |
| 1065 | |
| 1066 | /* Check if we should attempt an auto-start */ |
| 1067 | if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) { |
| 1068 | char *local_args[2]; |
| 1069 | extern int do_bootm (cmd_tbl_t *, int, int, char *[]); |
| 1070 | |
| 1071 | local_args[0] = argv[0]; |
| 1072 | local_args[1] = NULL; |
| 1073 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 1074 | printf ("Automatic boot of image at addr 0x%08lx ...\n", addr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1075 | |
| 1076 | do_bootm (cmdtp, 0, 1, local_args); |
| 1077 | rcode = 1; |
| 1078 | } |
| 1079 | return rcode; |
| 1080 | } |
| 1081 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1082 | U_BOOT_CMD( |
William Juul | bfb8332 | 2007-11-14 14:28:11 +0100 | [diff] [blame] | 1083 | nboot, 4, 1, do_nandboot, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1084 | "boot from NAND device", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1085 | "loadAddr dev" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 1086 | ); |
| 1087 | |
Jon Loeliger | d76b5c1 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 1088 | #endif |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1089 | |
Jean-Christophe PLAGNIOL-VILLARD | 719bb5f | 2008-08-13 01:40:43 +0200 | [diff] [blame] | 1090 | #endif /* CONFIG_NAND_LEGACY */ |