mtd: nand: Remove nand_info_t typedef

This typedef serves no purpose other than causing confusion with
struct nand_chip.

Signed-off-by: Scott Wood <oss@buserror.net>
This commit is contained in:
Scott Wood 2016-05-30 13:57:54 -05:00
parent ea7d1eec66
commit 151c06ec61
15 changed files with 251 additions and 249 deletions

View file

@ -372,8 +372,8 @@ next_bank: ;
#endif #endif
#if defined(CONFIG_CMD_IMLS_NAND) #if defined(CONFIG_CMD_IMLS_NAND)
static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off, static int nand_imls_legacyimage(struct mtd_info *mtd, int nand_dev,
size_t len) loff_t off, size_t len)
{ {
void *imgdata; void *imgdata;
int ret; int ret;
@ -386,8 +386,7 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
return -ENOMEM; return -ENOMEM;
} }
ret = nand_read_skip_bad(nand, off, &len, ret = nand_read_skip_bad(mtd, off, &len, imgdata);
imgdata);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && ret != -EUCLEAN) {
free(imgdata); free(imgdata);
return ret; return ret;
@ -413,8 +412,8 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
return 0; return 0;
} }
static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off, static int nand_imls_fitimage(struct mtd_info *mtd, int nand_dev, loff_t off,
size_t len) size_t len)
{ {
void *imgdata; void *imgdata;
int ret; int ret;
@ -427,8 +426,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
return -ENOMEM; return -ENOMEM;
} }
ret = nand_read_skip_bad(nand, off, &len, ret = nand_read_skip_bad(mtd, off, &len, imgdata);
imgdata);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && ret != -EUCLEAN) {
free(imgdata); free(imgdata);
return ret; return ret;
@ -449,7 +447,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
static int do_imls_nand(void) static int do_imls_nand(void)
{ {
nand_info_t *nand; struct mtd_info *mtd;
int nand_dev = nand_curr_device; int nand_dev = nand_curr_device;
size_t len; size_t len;
loff_t off; loff_t off;
@ -463,20 +461,20 @@ static int do_imls_nand(void)
printf("\n"); printf("\n");
for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) { for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
nand = &nand_info[nand_dev]; mtd = &nand_info[nand_dev];
if (!nand->name || !nand->size) if (!mtd->name || !mtd->size)
continue; continue;
for (off = 0; off < nand->size; off += nand->erasesize) { for (off = 0; off < mtd->size; off += mtd->erasesize) {
const image_header_t *header; const image_header_t *header;
int ret; int ret;
if (nand_block_isbad(nand, off)) if (nand_block_isbad(mtd, off))
continue; continue;
len = sizeof(buffer); len = sizeof(buffer);
ret = nand_read(nand, off, &len, (u8 *)buffer); ret = nand_read(mtd, off, &len, (u8 *)buffer);
if (ret < 0 && ret != -EUCLEAN) { if (ret < 0 && ret != -EUCLEAN) {
printf("NAND read error %d at offset %08llX\n", printf("NAND read error %d at offset %08llX\n",
ret, off); ret, off);
@ -489,13 +487,13 @@ static int do_imls_nand(void)
header = (const image_header_t *)buffer; header = (const image_header_t *)buffer;
len = image_get_image_size(header); len = image_get_image_size(header);
nand_imls_legacyimage(nand, nand_dev, off, len); nand_imls_legacyimage(mtd, nand_dev, off, len);
break; break;
#endif #endif
#if defined(CONFIG_FIT) #if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT: case IMAGE_FORMAT_FIT:
len = fit_get_size(buffer); len = fit_get_size(buffer);
nand_imls_fitimage(nand, nand_dev, off, len); nand_imls_fitimage(mtd, nand_dev, off, len);
break; break;
#endif #endif
} }

View file

@ -242,11 +242,11 @@ static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *d
static inline u32 get_part_sector_size_nand(struct mtdids *id) static inline u32 get_part_sector_size_nand(struct mtdids *id)
{ {
#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
nand_info_t *nand; struct mtd_info *mtd;
nand = &nand_info[id->num]; mtd = &nand_info[id->num];
return nand->erasesize; return mtd->erasesize;
#else #else
BUG(); BUG();
return 0; return 0;

View file

@ -38,7 +38,8 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
u8 *part_num, struct part_info **part); u8 *part_num, struct part_info **part);
#endif #endif
static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat) static int nand_dump(struct mtd_info *mtd, ulong off, int only_oob,
int repeat)
{ {
int i; int i;
u_char *datbuf, *oobbuf, *p; u_char *datbuf, *oobbuf, *p;
@ -46,32 +47,32 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
int ret = 0; int ret = 0;
if (repeat) if (repeat)
off = last + nand->writesize; off = last + mtd->writesize;
last = off; last = off;
datbuf = memalign(ARCH_DMA_MINALIGN, nand->writesize); datbuf = memalign(ARCH_DMA_MINALIGN, mtd->writesize);
if (!datbuf) { if (!datbuf) {
puts("No memory for page buffer\n"); puts("No memory for page buffer\n");
return 1; return 1;
} }
oobbuf = memalign(ARCH_DMA_MINALIGN, nand->oobsize); oobbuf = memalign(ARCH_DMA_MINALIGN, mtd->oobsize);
if (!oobbuf) { if (!oobbuf) {
puts("No memory for page buffer\n"); puts("No memory for page buffer\n");
ret = 1; ret = 1;
goto free_dat; goto free_dat;
} }
off &= ~(nand->writesize - 1); off &= ~(mtd->writesize - 1);
loff_t addr = (loff_t) off; loff_t addr = (loff_t) off;
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
memset(&ops, 0, sizeof(ops)); memset(&ops, 0, sizeof(ops));
ops.datbuf = datbuf; ops.datbuf = datbuf;
ops.oobbuf = oobbuf; ops.oobbuf = oobbuf;
ops.len = nand->writesize; ops.len = mtd->writesize;
ops.ooblen = nand->oobsize; ops.ooblen = mtd->oobsize;
ops.mode = MTD_OPS_RAW; ops.mode = MTD_OPS_RAW;
i = mtd_read_oob(nand, addr, &ops); i = mtd_read_oob(mtd, addr, &ops);
if (i < 0) { if (i < 0) {
printf("Error (%d) reading page %08lx\n", i, off); printf("Error (%d) reading page %08lx\n", i, off);
ret = 1; ret = 1;
@ -80,7 +81,7 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
printf("Page %08lx dump:\n", off); printf("Page %08lx dump:\n", off);
if (!only_oob) { if (!only_oob) {
i = nand->writesize >> 4; i = mtd->writesize >> 4;
p = datbuf; p = datbuf;
while (i--) { while (i--) {
@ -94,7 +95,7 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
} }
puts("OOB:\n"); puts("OOB:\n");
i = nand->oobsize >> 3; i = mtd->oobsize >> 3;
p = oobbuf; p = oobbuf;
while (i--) { while (i--) {
printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n", printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n",
@ -152,32 +153,32 @@ static void print_status(ulong start, ulong end, ulong erasesize, int status)
((status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : "")); ((status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
} }
static void do_nand_status(nand_info_t *nand) static void do_nand_status(struct mtd_info *mtd)
{ {
ulong block_start = 0; ulong block_start = 0;
ulong off; ulong off;
int last_status = -1; int last_status = -1;
struct nand_chip *nand_chip = nand->priv; struct nand_chip *nand_chip = mtd->priv;
/* check the WP bit */ /* check the WP bit */
nand_chip->cmdfunc(nand, NAND_CMD_STATUS, -1, -1); nand_chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
printf("device is %swrite protected\n", printf("device is %swrite protected\n",
(nand_chip->read_byte(nand) & 0x80 ? (nand_chip->read_byte(mtd) & 0x80 ?
"NOT " : "")); "NOT " : ""));
for (off = 0; off < nand->size; off += nand->erasesize) { for (off = 0; off < mtd->size; off += mtd->erasesize) {
int s = nand_get_lock_status(nand, off); int s = nand_get_lock_status(mtd, off);
/* print message only if status has changed */ /* print message only if status has changed */
if (s != last_status && off != 0) { if (s != last_status && off != 0) {
print_status(block_start, off, nand->erasesize, print_status(block_start, off, mtd->erasesize,
last_status); last_status);
block_start = off; block_start = off;
} }
last_status = s; last_status = s;
} }
/* Print the last block info */ /* Print the last block info */
print_status(block_start, off, nand->erasesize, last_status); print_status(block_start, off, mtd->erasesize, last_status);
} }
#endif #endif
@ -188,10 +189,10 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
{ {
int ret; int ret;
uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)]; uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)];
nand_info_t *nand = &nand_info[0]; struct mtd_info *mtd = &nand_info[0];
char *cmd = argv[1]; char *cmd = argv[1];
if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !nand->name) { if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !mtd->name) {
puts("no devices available\n"); puts("no devices available\n");
return 1; return 1;
} }
@ -199,7 +200,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
set_dev(0); set_dev(0);
if (!strcmp(cmd, "get")) { if (!strcmp(cmd, "get")) {
ret = get_nand_env_oob(nand, &nand_env_oob_offset); ret = get_nand_env_oob(mtd, &nand_env_oob_offset);
if (ret) if (ret)
return 1; return 1;
@ -229,15 +230,15 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
return 1; return 1;
} }
if (nand->oobavail < ENV_OFFSET_SIZE) { if (mtd->oobavail < ENV_OFFSET_SIZE) {
printf("Insufficient available OOB bytes:\n" printf("Insufficient available OOB bytes:\n"
"%d OOB bytes available but %d required for " "%d OOB bytes available but %d required for "
"env.oob support\n", "env.oob support\n",
nand->oobavail, ENV_OFFSET_SIZE); mtd->oobavail, ENV_OFFSET_SIZE);
return 1; return 1;
} }
if ((addr & (nand->erasesize - 1)) != 0) { if ((addr & (mtd->erasesize - 1)) != 0) {
printf("Environment offset must be block-aligned\n"); printf("Environment offset must be block-aligned\n");
return 1; return 1;
} }
@ -249,15 +250,15 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[])
ops.oobbuf = (void *) oob_buf; ops.oobbuf = (void *) oob_buf;
oob_buf[0] = ENV_OOB_MARKER; oob_buf[0] = ENV_OOB_MARKER;
oob_buf[1] = addr / nand->erasesize; oob_buf[1] = addr / mtd->erasesize;
ret = nand->write_oob(nand, ENV_OFFSET_SIZE, &ops); ret = mtd->write_oob(mtd, ENV_OFFSET_SIZE, &ops);
if (ret) { if (ret) {
printf("Error writing OOB block 0\n"); printf("Error writing OOB block 0\n");
return ret; return ret;
} }
ret = get_nand_env_oob(nand, &nand_env_oob_offset); ret = get_nand_env_oob(mtd, &nand_env_oob_offset);
if (ret) { if (ret) {
printf("Error reading env offset in OOB\n"); printf("Error reading env offset in OOB\n");
return ret; return ret;
@ -283,29 +284,29 @@ usage:
static void nand_print_and_set_info(int idx) static void nand_print_and_set_info(int idx)
{ {
nand_info_t *nand = &nand_info[idx]; struct mtd_info *mtd = &nand_info[idx];
struct nand_chip *chip = nand->priv; struct nand_chip *chip = mtd->priv;
printf("Device %d: ", idx); printf("Device %d: ", idx);
if (chip->numchips > 1) if (chip->numchips > 1)
printf("%dx ", chip->numchips); printf("%dx ", chip->numchips);
printf("%s, sector size %u KiB\n", printf("%s, sector size %u KiB\n",
nand->name, nand->erasesize >> 10); mtd->name, mtd->erasesize >> 10);
printf(" Page size %8d b\n", nand->writesize); printf(" Page size %8d b\n", mtd->writesize);
printf(" OOB size %8d b\n", nand->oobsize); printf(" OOB size %8d b\n", mtd->oobsize);
printf(" Erase size %8d b\n", nand->erasesize); printf(" Erase size %8d b\n", mtd->erasesize);
printf(" subpagesize %8d b\n", chip->subpagesize); printf(" subpagesize %8d b\n", chip->subpagesize);
printf(" options 0x%8x\n", chip->options); printf(" options 0x%8x\n", chip->options);
printf(" bbt options 0x%8x\n", chip->bbt_options); printf(" bbt options 0x%8x\n", chip->bbt_options);
/* Set geometry info */ /* Set geometry info */
setenv_hex("nand_writesize", nand->writesize); setenv_hex("nand_writesize", mtd->writesize);
setenv_hex("nand_oobsize", nand->oobsize); setenv_hex("nand_oobsize", mtd->oobsize);
setenv_hex("nand_erasesize", nand->erasesize); setenv_hex("nand_erasesize", mtd->erasesize);
} }
static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count, static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
int read) ulong count, int read)
{ {
int ret = 0; int ret = 0;
@ -313,18 +314,18 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
/* Raw access */ /* Raw access */
mtd_oob_ops_t ops = { mtd_oob_ops_t ops = {
.datbuf = (u8 *)addr, .datbuf = (u8 *)addr,
.oobbuf = ((u8 *)addr) + nand->writesize, .oobbuf = ((u8 *)addr) + mtd->writesize,
.len = nand->writesize, .len = mtd->writesize,
.ooblen = nand->oobsize, .ooblen = mtd->oobsize,
.mode = MTD_OPS_RAW .mode = MTD_OPS_RAW
}; };
if (read) { if (read) {
ret = mtd_read_oob(nand, off, &ops); ret = mtd_read_oob(mtd, off, &ops);
} else { } else {
ret = mtd_write_oob(nand, off, &ops); ret = mtd_write_oob(mtd, off, &ops);
if (!ret) if (!ret)
ret = nand_verify_page_oob(nand, &ops, off); ret = nand_verify_page_oob(mtd, &ops, off);
} }
if (ret) { if (ret) {
@ -333,8 +334,8 @@ static int raw_access(nand_info_t *nand, ulong addr, loff_t off, ulong count,
break; break;
} }
addr += nand->writesize + nand->oobsize; addr += mtd->writesize + mtd->oobsize;
off += nand->writesize; off += mtd->writesize;
} }
return ret; return ret;
@ -348,18 +349,18 @@ static void adjust_size_for_badblocks(loff_t *size, loff_t offset, int dev)
/* We grab the nand info object here fresh because this is usually /* We grab the nand info object here fresh because this is usually
* called after arg_off_size() which can change the value of dev. * called after arg_off_size() which can change the value of dev.
*/ */
nand_info_t *nand = &nand_info[dev]; struct mtd_info *mtd = &nand_info[dev];
loff_t maxoffset = offset + *size; loff_t maxoffset = offset + *size;
int badblocks = 0; int badblocks = 0;
/* count badblocks in NAND from offset to offset + size */ /* count badblocks in NAND from offset to offset + size */
for (; offset < maxoffset; offset += nand->erasesize) { for (; offset < maxoffset; offset += mtd->erasesize) {
if (nand_block_isbad(nand, offset)) if (nand_block_isbad(mtd, offset))
badblocks++; badblocks++;
} }
/* adjust size if any bad blocks found */ /* adjust size if any bad blocks found */
if (badblocks) { if (badblocks) {
*size -= badblocks * nand->erasesize; *size -= badblocks * mtd->erasesize;
printf("size adjusted to 0x%llx (%d bad blocks)\n", printf("size adjusted to 0x%llx (%d bad blocks)\n",
(unsigned long long)*size, badblocks); (unsigned long long)*size, badblocks);
} }
@ -371,7 +372,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong addr; ulong addr;
loff_t off, size, maxsize; loff_t off, size, maxsize;
char *cmd, *s; char *cmd, *s;
nand_info_t *nand; struct mtd_info *mtd;
#ifdef CONFIG_SYS_NAND_QUIET #ifdef CONFIG_SYS_NAND_QUIET
int quiet = CONFIG_SYS_NAND_QUIET; int quiet = CONFIG_SYS_NAND_QUIET;
#else #else
@ -437,12 +438,12 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
puts("\nno devices available\n"); puts("\nno devices available\n");
return 1; return 1;
} }
nand = &nand_info[dev]; mtd = &nand_info[dev];
if (strcmp(cmd, "bad") == 0) { if (strcmp(cmd, "bad") == 0) {
printf("\nDevice %d bad blocks:\n", dev); printf("\nDevice %d bad blocks:\n", dev);
for (off = 0; off < nand->size; off += nand->erasesize) for (off = 0; off < mtd->size; off += mtd->erasesize)
if (nand_block_isbad(nand, off)) if (nand_block_isbad(mtd, off))
printf(" %08llx\n", (unsigned long long)off); printf(" %08llx\n", (unsigned long long)off);
return 0; return 0;
} }
@ -502,7 +503,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (set_dev(dev)) if (set_dev(dev))
return 1; return 1;
nand = &nand_info[dev]; mtd = &nand_info[dev];
memset(&opts, 0, sizeof(opts)); memset(&opts, 0, sizeof(opts));
opts.offset = off; opts.offset = off;
@ -524,7 +525,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} }
} }
} }
ret = nand_erase_opts(nand, &opts); ret = nand_erase_opts(mtd, &opts);
printf("%s\n", ret ? "ERROR" : "OK"); printf("%s\n", ret ? "ERROR" : "OK");
return ret == 0 ? 0 : 1; return ret == 0 ? 0 : 1;
@ -535,7 +536,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
goto usage; goto usage;
off = (int)simple_strtoul(argv[2], NULL, 16); off = (int)simple_strtoul(argv[2], NULL, 16);
ret = nand_dump(nand, off, !strcmp(&cmd[4], ".oob"), repeat); ret = nand_dump(mtd, off, !strcmp(&cmd[4], ".oob"), repeat);
return ret == 0 ? 1 : 0; return ret == 0 ? 1 : 0;
} }
@ -567,19 +568,19 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (set_dev(dev)) if (set_dev(dev))
return 1; return 1;
nand = &nand_info[dev]; mtd = &nand_info[dev];
if (argc > 4 && !str2long(argv[4], &pagecount)) { if (argc > 4 && !str2long(argv[4], &pagecount)) {
printf("'%s' is not a number\n", argv[4]); printf("'%s' is not a number\n", argv[4]);
return 1; return 1;
} }
if (pagecount * nand->writesize > size) { if (pagecount * mtd->writesize > size) {
puts("Size exceeds partition or device limit\n"); puts("Size exceeds partition or device limit\n");
return -1; return -1;
} }
rwsize = pagecount * (nand->writesize + nand->oobsize); rwsize = pagecount * (mtd->writesize + mtd->oobsize);
} else { } else {
if (mtd_arg_off_size(argc - 3, argv + 3, &dev, &off, if (mtd_arg_off_size(argc - 3, argv + 3, &dev, &off,
&size, &maxsize, &size, &maxsize,
@ -596,16 +597,16 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
rwsize = size; rwsize = size;
} }
nand = &nand_info[dev]; mtd = &nand_info[dev];
if (!s || !strcmp(s, ".jffs2") || if (!s || !strcmp(s, ".jffs2") ||
!strcmp(s, ".e") || !strcmp(s, ".i")) { !strcmp(s, ".e") || !strcmp(s, ".i")) {
if (read) if (read)
ret = nand_read_skip_bad(nand, off, &rwsize, ret = nand_read_skip_bad(mtd, off, &rwsize,
NULL, maxsize, NULL, maxsize,
(u_char *)addr); (u_char *)addr);
else else
ret = nand_write_skip_bad(nand, off, &rwsize, ret = nand_write_skip_bad(mtd, off, &rwsize,
NULL, maxsize, NULL, maxsize,
(u_char *)addr, (u_char *)addr,
WITH_WR_VERIFY); WITH_WR_VERIFY);
@ -615,7 +616,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("Unknown nand command suffix '%s'\n", s); printf("Unknown nand command suffix '%s'\n", s);
return 1; return 1;
} }
ret = nand_write_skip_bad(nand, off, &rwsize, NULL, ret = nand_write_skip_bad(mtd, off, &rwsize, NULL,
maxsize, (u_char *)addr, maxsize, (u_char *)addr,
WITH_DROP_FFS | WITH_WR_VERIFY); WITH_DROP_FFS | WITH_WR_VERIFY);
#endif #endif
@ -628,11 +629,11 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}; };
if (read) if (read)
ret = mtd_read_oob(nand, off, &ops); ret = mtd_read_oob(mtd, off, &ops);
else else
ret = mtd_write_oob(nand, off, &ops); ret = mtd_write_oob(mtd, off, &ops);
} else if (raw) { } else if (raw) {
ret = raw_access(nand, addr, off, pagecount, read); ret = raw_access(mtd, addr, off, pagecount, read);
} else { } else {
printf("Unknown nand command suffix '%s'.\n", s); printf("Unknown nand command suffix '%s'.\n", s);
return 1; return 1;
@ -655,8 +656,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} }
printf("\nNAND torture: device %d offset 0x%llx size 0x%x\n", printf("\nNAND torture: device %d offset 0x%llx size 0x%x\n",
dev, off, nand->erasesize); dev, off, mtd->erasesize);
ret = nand_torture(nand, off); ret = nand_torture(mtd, off);
printf(" %s\n", ret ? "Failed" : "Passed"); printf(" %s\n", ret ? "Failed" : "Passed");
return ret == 0 ? 0 : 1; return ret == 0 ? 0 : 1;
@ -673,7 +674,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
while (argc > 0) { while (argc > 0) {
addr = simple_strtoul(*argv, NULL, 16); addr = simple_strtoul(*argv, NULL, 16);
if (mtd_block_markbad(nand, addr)) { if (mtd_block_markbad(mtd, addr)) {
printf("block 0x%08lx NOT marked " printf("block 0x%08lx NOT marked "
"as bad! ERROR %d\n", "as bad! ERROR %d\n",
addr, ret); addr, ret);
@ -705,9 +706,9 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
status = 1; status = 1;
} }
if (status) { if (status) {
do_nand_status(nand); do_nand_status(mtd);
} else { } else {
if (!nand_lock(nand, tight)) { if (!nand_lock(mtd, tight)) {
puts("NAND flash successfully locked\n"); puts("NAND flash successfully locked\n");
} else { } else {
puts("Error locking NAND flash\n"); puts("Error locking NAND flash\n");
@ -801,7 +802,7 @@ U_BOOT_CMD(
"NAND sub-system", nand_help_text "NAND sub-system", nand_help_text
); );
static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, static int nand_load_image(cmd_tbl_t *cmdtp, struct mtd_info *mtd,
ulong offset, ulong addr, char *cmd) ulong offset, ulong addr, char *cmd)
{ {
int r; int r;
@ -822,11 +823,11 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
return 1; return 1;
} }
printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset); printf("\nLoading from %s, offset 0x%lx\n", mtd->name, offset);
cnt = nand->writesize; cnt = mtd->writesize;
r = nand_read_skip_bad(nand, offset, &cnt, NULL, nand->size, r = nand_read_skip_bad(mtd, offset, &cnt, NULL, mtd->size,
(u_char *)addr); (u_char *)addr);
if (r) { if (r) {
puts("** Read error\n"); puts("** Read error\n");
bootstage_error(BOOTSTAGE_ID_NAND_HDR_READ); bootstage_error(BOOTSTAGE_ID_NAND_HDR_READ);
@ -860,8 +861,8 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
} }
bootstage_mark(BOOTSTAGE_ID_NAND_TYPE); bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
r = nand_read_skip_bad(nand, offset, &cnt, NULL, nand->size, r = nand_read_skip_bad(mtd, offset, &cnt, NULL, mtd->size,
(u_char *)addr); (u_char *)addr);
if (r) { if (r) {
puts("** Read error\n"); puts("** Read error\n");
bootstage_error(BOOTSTAGE_ID_NAND_READ); bootstage_error(BOOTSTAGE_ID_NAND_READ);

View file

@ -276,7 +276,7 @@ static int readenv(size_t offset, u_char *buf)
#endif /* #if defined(CONFIG_SPL_BUILD) */ #endif /* #if defined(CONFIG_SPL_BUILD) */
#ifdef CONFIG_ENV_OFFSET_OOB #ifdef CONFIG_ENV_OFFSET_OOB
int get_nand_env_oob(nand_info_t *nand, unsigned long *result) int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result)
{ {
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
uint32_t oob_buf[ENV_OFFSET_SIZE / sizeof(uint32_t)]; uint32_t oob_buf[ENV_OFFSET_SIZE / sizeof(uint32_t)];
@ -288,14 +288,14 @@ int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
ops.ooblen = ENV_OFFSET_SIZE; ops.ooblen = ENV_OFFSET_SIZE;
ops.oobbuf = (void *)oob_buf; ops.oobbuf = (void *)oob_buf;
ret = nand->read_oob(nand, ENV_OFFSET_SIZE, &ops); ret = mtd->read_oob(mtd, ENV_OFFSET_SIZE, &ops);
if (ret) { if (ret) {
printf("error reading OOB block 0\n"); printf("error reading OOB block 0\n");
return ret; return ret;
} }
if (oob_buf[0] == ENV_OOB_MARKER) { if (oob_buf[0] == ENV_OOB_MARKER) {
*result = oob_buf[1] * nand->erasesize; *result = oob_buf[1] * mtd->erasesize;
} else if (oob_buf[0] == ENV_OOB_MARKER_OLD) { } else if (oob_buf[0] == ENV_OOB_MARKER_OLD) {
*result = oob_buf[1]; *result = oob_buf[1];
} else { } else {

View file

@ -19,7 +19,7 @@
static char *response_str; static char *response_str;
struct fb_nand_sparse { struct fb_nand_sparse {
nand_info_t *nand; struct mtd_info *nand;
struct part_info *part; struct part_info *part;
}; };
@ -34,7 +34,7 @@ __weak int board_fastboot_write_partition_setup(char *name)
} }
static int fb_nand_lookup(const char *partname, char *response, static int fb_nand_lookup(const char *partname, char *response,
nand_info_t **nand, struct mtd_info **nand,
struct part_info **part) struct part_info **part)
{ {
struct mtd_device *dev; struct mtd_device *dev;
@ -62,12 +62,12 @@ static int fb_nand_lookup(const char *partname, char *response,
return -EINVAL; return -EINVAL;
} }
*nand = &nand_info[dev->id->num]; *mtd = &nand_info[dev->id->num];
return 0; return 0;
} }
static int _fb_nand_erase(nand_info_t *nand, struct part_info *part) static int _fb_nand_erase(struct mtd_info *mtd, struct part_info *part)
{ {
nand_erase_options_t opts; nand_erase_options_t opts;
int ret; int ret;
@ -80,7 +80,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)
printf("Erasing blocks 0x%llx to 0x%llx\n", printf("Erasing blocks 0x%llx to 0x%llx\n",
part->offset, part->offset + part->size); part->offset, part->offset + part->size);
ret = nand_erase_opts(nand, &opts); ret = nand_erase_opts(mtd, &opts);
if (ret) if (ret)
return ret; return ret;
@ -90,7 +90,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)
return 0; return 0;
} }
static int _fb_nand_write(nand_info_t *nand, struct part_info *part, static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part,
void *buffer, unsigned int offset, void *buffer, unsigned int offset,
unsigned int length, size_t *written) unsigned int length, size_t *written)
{ {
@ -100,7 +100,7 @@ static int _fb_nand_write(nand_info_t *nand, struct part_info *part,
flags |= WITH_DROP_FFS; flags |= WITH_DROP_FFS;
#endif #endif
return nand_write_skip_bad(nand, offset, &length, written, return nand_write_skip_bad(mtd, offset, &length, written,
part->size - (offset - part->offset), part->size - (offset - part->offset),
buffer, flags); buffer, flags);
} }
@ -131,13 +131,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
char *response) char *response)
{ {
struct part_info *part; struct part_info *part;
nand_info_t *nand = NULL; struct mtd_info *mtd = NULL;
int ret; int ret;
/* initialize the response buffer */ /* initialize the response buffer */
response_str = response; response_str = response;
ret = fb_nand_lookup(partname, response, &nand, &part); ret = fb_nand_lookup(partname, response, &mtd, &part);
if (ret) { if (ret) {
error("invalid NAND device"); error("invalid NAND device");
fastboot_fail(response_str, "invalid NAND device"); fastboot_fail(response_str, "invalid NAND device");
@ -152,10 +152,10 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
struct fb_nand_sparse sparse_priv; struct fb_nand_sparse sparse_priv;
sparse_storage_t sparse; sparse_storage_t sparse;
sparse_priv.nand = nand; sparse_priv.nand = mtd;
sparse_priv.part = part; sparse_priv.part = part;
sparse.block_sz = nand->writesize; sparse.block_sz = mtd->writesize;
sparse.start = part->offset / sparse.block_sz; sparse.start = part->offset / sparse.block_sz;
sparse.size = part->size / sparse.block_sz; sparse.size = part->size / sparse.block_sz;
sparse.name = part->name; sparse.name = part->name;
@ -167,7 +167,7 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
printf("Flashing raw image at offset 0x%llx\n", printf("Flashing raw image at offset 0x%llx\n",
part->offset); part->offset);
ret = _fb_nand_write(nand, part, download_buffer, part->offset, ret = _fb_nand_write(mtd, part, download_buffer, part->offset,
download_bytes, NULL); download_bytes, NULL);
printf("........ wrote %u bytes to '%s'\n", printf("........ wrote %u bytes to '%s'\n",
@ -185,13 +185,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,
void fb_nand_erase(const char *partname, char *response) void fb_nand_erase(const char *partname, char *response)
{ {
struct part_info *part; struct part_info *part;
nand_info_t *nand = NULL; struct mtd_info *mtd = NULL;
int ret; int ret;
/* initialize the response buffer */ /* initialize the response buffer */
response_str = response; response_str = response;
ret = fb_nand_lookup(partname, response, &nand, &part); ret = fb_nand_lookup(partname, response, &mtd, &part);
if (ret) { if (ret) {
error("invalid NAND device"); error("invalid NAND device");
fastboot_fail(response_str, "invalid NAND device"); fastboot_fail(response_str, "invalid NAND device");
@ -202,9 +202,9 @@ void fb_nand_erase(const char *partname, char *response)
if (ret) if (ret)
return; return;
ret = _fb_nand_erase(nand, part); ret = _fb_nand_erase(mtd, part);
if (ret) { if (ret) {
error("failed erasing from device %s", nand->name); error("failed erasing from device %s", mtd->name);
fastboot_fail(response_str, "failed erasing from device"); fastboot_fail(response_str, "failed erasing from device");
return; return;
} }

View file

@ -25,7 +25,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
loff_t start, lim; loff_t start, lim;
size_t count, actual; size_t count, actual;
int ret; int ret;
nand_info_t *nand; struct mtd_info *mtd;
/* if buf == NULL return total size of the area */ /* if buf == NULL return total size of the area */
if (buf == NULL) { if (buf == NULL) {
@ -44,11 +44,11 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
return -1; return -1;
} }
nand = &nand_info[nand_curr_device]; mtd = &nand_info[nand_curr_device];
if (op == DFU_OP_READ) { if (op == DFU_OP_READ) {
ret = nand_read_skip_bad(nand, start, &count, &actual, ret = nand_read_skip_bad(mtd, start, &count, &actual,
lim, buf); lim, buf);
} else { } else {
nand_erase_options_t opts; nand_erase_options_t opts;
@ -59,12 +59,12 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
opts.quiet = 1; opts.quiet = 1;
opts.lim = lim; opts.lim = lim;
/* first erase */ /* first erase */
ret = nand_erase_opts(nand, &opts); ret = nand_erase_opts(mtd, &opts);
if (ret) if (ret)
return ret; return ret;
/* then write */ /* then write */
ret = nand_write_skip_bad(nand, start, &count, &actual, ret = nand_write_skip_bad(mtd, start, &count, &actual,
lim, buf, WITH_WR_VERIFY); lim, buf, WITH_WR_VERIFY);
} }
if (ret != 0) { if (ret != 0) {
@ -142,7 +142,7 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
/* in case of ubi partition, erase rest of the partition */ /* in case of ubi partition, erase rest of the partition */
if (dfu->data.nand.ubi) { if (dfu->data.nand.ubi) {
nand_info_t *nand; struct mtd_info *mtd;
nand_erase_options_t opts; nand_erase_options_t opts;
if (nand_curr_device < 0 || if (nand_curr_device < 0 ||
@ -152,14 +152,14 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
return -1; return -1;
} }
nand = &nand_info[nand_curr_device]; mtd = &nand_info[nand_curr_device];
memset(&opts, 0, sizeof(opts)); memset(&opts, 0, sizeof(opts));
opts.offset = dfu->data.nand.start + dfu->offset + opts.offset = dfu->data.nand.start + dfu->offset +
dfu->bad_skip; dfu->bad_skip;
opts.length = dfu->data.nand.start + opts.length = dfu->data.nand.start +
dfu->data.nand.size - opts.offset; dfu->data.nand.size - opts.offset;
ret = nand_erase_opts(nand, &opts); ret = nand_erase_opts(mtd, &opts);
if (ret != 0) if (ret != 0)
printf("Failure erase: %d\n", ret); printf("Failure erase: %d\n", ret);
} }

View file

@ -16,7 +16,7 @@
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand_ecc.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
nand_info_t nand_info[1]; struct mtd_info nand_info[1];
static struct nand_chip nand_chip; static struct nand_chip nand_chip;
#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ #define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \

View file

@ -1238,7 +1238,7 @@ static int at91_nand_ready(struct mtd_info *mtd)
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_BUILD
/* The following code is for SPL */ /* The following code is for SPL */
static nand_info_t mtd; static struct mtd_info mtd;
static struct nand_chip nand_chip; static struct nand_chip nand_chip;
static int nand_command(int block, int page, uint32_t offs, u8 cmd) static int nand_command(int block, int page, uint32_t offs, u8 cmd)

View file

@ -8,7 +8,7 @@
#include <nand.h> #include <nand.h>
#include <malloc.h> #include <malloc.h>
static nand_info_t mtd; static struct mtd_info mtd;
static struct nand_chip nand_chip; static struct nand_chip nand_chip;
static void mxs_nand_command(struct mtd_info *mtd, unsigned int command, static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,

View file

@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;
int nand_curr_device = -1; int nand_curr_device = -1;
nand_info_t nand_info[CONFIG_SYS_MAX_NAND_DEVICE]; struct mtd_info nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
#ifndef CONFIG_SYS_NAND_SELF_INIT #ifndef CONFIG_SYS_NAND_SELF_INIT
static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];

View file

@ -11,7 +11,7 @@
#include <linux/mtd/nand_ecc.h> #include <linux/mtd/nand_ecc.h>
static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
static nand_info_t mtd; static struct mtd_info mtd;
static struct nand_chip nand_chip; static struct nand_chip nand_chip;
#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ #define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \

View file

@ -42,25 +42,26 @@ typedef struct mtd_info mtd_info_t;
* nand_erase_opts: - erase NAND flash with support for various options * nand_erase_opts: - erase NAND flash with support for various options
* (jffs2 formatting) * (jffs2 formatting)
* *
* @param meminfo NAND device to erase * @param mtd nand mtd instance to erase
* @param opts options, @see struct nand_erase_options * @param opts options, @see struct nand_erase_options
* @return 0 in case of success * @return 0 in case of success
* *
* This code is ported from flash_eraseall.c from Linux mtd utils by * This code is ported from flash_eraseall.c from Linux mtd utils by
* Arcom Control System Ltd. * Arcom Control System Ltd.
*/ */
int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) int nand_erase_opts(struct mtd_info *mtd,
const nand_erase_options_t *opts)
{ {
struct jffs2_unknown_node cleanmarker; struct jffs2_unknown_node cleanmarker;
erase_info_t erase; erase_info_t erase;
unsigned long erase_length, erased_length; /* in blocks */ unsigned long erase_length, erased_length; /* in blocks */
int result; int result;
int percent_complete = -1; int percent_complete = -1;
const char *mtd_device = meminfo->name; const char *mtd_device = mtd->name;
struct mtd_oob_ops oob_opts; struct mtd_oob_ops oob_opts;
struct nand_chip *chip = meminfo->priv; struct nand_chip *chip = mtd->priv;
if ((opts->offset & (meminfo->erasesize - 1)) != 0) { if ((opts->offset & (mtd->erasesize - 1)) != 0) {
printf("Attempt to erase non block-aligned data\n"); printf("Attempt to erase non block-aligned data\n");
return -1; return -1;
} }
@ -68,11 +69,11 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
memset(&erase, 0, sizeof(erase)); memset(&erase, 0, sizeof(erase));
memset(&oob_opts, 0, sizeof(oob_opts)); memset(&oob_opts, 0, sizeof(oob_opts));
erase.mtd = meminfo; erase.mtd = mtd;
erase.len = meminfo->erasesize; erase.len = mtd->erasesize;
erase.addr = opts->offset; erase.addr = opts->offset;
erase_length = lldiv(opts->length + meminfo->erasesize - 1, erase_length = lldiv(opts->length + mtd->erasesize - 1,
meminfo->erasesize); mtd->erasesize);
cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
@ -97,7 +98,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
for (erased_length = 0; for (erased_length = 0;
erased_length < erase_length; erased_length < erase_length;
erase.addr += meminfo->erasesize) { erase.addr += mtd->erasesize) {
WATCHDOG_RESET(); WATCHDOG_RESET();
@ -106,7 +107,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
return -EFBIG; return -EFBIG;
} }
if (!opts->scrub) { if (!opts->scrub) {
int ret = mtd_block_isbad(meminfo, erase.addr); int ret = mtd_block_isbad(mtd, erase.addr);
if (ret > 0) { if (ret > 0) {
if (!opts->quiet) if (!opts->quiet)
printf("\rSkipping bad block at " printf("\rSkipping bad block at "
@ -129,7 +130,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
erased_length++; erased_length++;
result = mtd_erase(meminfo, &erase); result = mtd_erase(mtd, &erase);
if (result != 0) { if (result != 0) {
printf("\n%s: MTD Erase failure: %d\n", printf("\n%s: MTD Erase failure: %d\n",
mtd_device, result); mtd_device, result);
@ -145,9 +146,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
ops.ooboffs = 0; ops.ooboffs = 0;
ops.mode = MTD_OPS_AUTO_OOB; ops.mode = MTD_OPS_AUTO_OOB;
result = mtd_write_oob(meminfo, result = mtd_write_oob(mtd, erase.addr, &ops);
erase.addr,
&ops);
if (result != 0) { if (result != 0) {
printf("\n%s: MTD writeoob failure: %d\n", printf("\n%s: MTD writeoob failure: %d\n",
mtd_device, result); mtd_device, result);
@ -303,7 +302,7 @@ int nand_get_lock_status(struct mtd_info *mtd, loff_t offset)
* @param mtd nand mtd instance * @param mtd nand mtd instance
* @param start start byte address * @param start start byte address
* @param length number of bytes to unlock (must be a multiple of * @param length number of bytes to unlock (must be a multiple of
* page size nand->writesize) * page size mtd->writesize)
* @param allexcept if set, unlock everything not selected * @param allexcept if set, unlock everything not selected
* *
* @return 0 on success, -1 in case of error * @return 0 on success, -1 in case of error
@ -399,7 +398,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
* Check if there are any bad blocks, and whether length including bad * Check if there are any bad blocks, and whether length including bad
* blocks fits into device * blocks fits into device
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param offset offset in flash * @param offset offset in flash
* @param length image length * @param length image length
* @param used length of flash needed for the requested length * @param used length of flash needed for the requested length
@ -407,8 +406,8 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
* 1 if the image fits, but there are bad blocks * 1 if the image fits, but there are bad blocks
* -1 if the image does not fit * -1 if the image does not fit
*/ */
static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length, static int check_skip_len(struct mtd_info *mtd, loff_t offset, size_t length,
size_t *used) size_t *used)
{ {
size_t len_excl_bad = 0; size_t len_excl_bad = 0;
int ret = 0; int ret = 0;
@ -417,14 +416,14 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
size_t block_len, block_off; size_t block_len, block_off;
loff_t block_start; loff_t block_start;
if (offset >= nand->size) if (offset >= mtd->size)
return -1; return -1;
block_start = offset & ~(loff_t)(nand->erasesize - 1); block_start = offset & ~(loff_t)(mtd->erasesize - 1);
block_off = offset & (nand->erasesize - 1); block_off = offset & (mtd->erasesize - 1);
block_len = nand->erasesize - block_off; block_len = mtd->erasesize - block_off;
if (!nand_block_isbad(nand, block_start)) if (!nand_block_isbad(mtd, block_start))
len_excl_bad += block_len; len_excl_bad += block_len;
else else
ret = 1; ret = 1;
@ -441,7 +440,7 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
} }
#ifdef CONFIG_CMD_NAND_TRIMFFS #ifdef CONFIG_CMD_NAND_TRIMFFS
static size_t drop_ffs(const nand_info_t *nand, const u_char *buf, static size_t drop_ffs(const struct mtd_info *mtd, const u_char *buf,
const size_t *len) const size_t *len)
{ {
size_t l = *len; size_t l = *len;
@ -453,8 +452,8 @@ static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
/* The resulting length must be aligned to the minimum flash I/O size */ /* The resulting length must be aligned to the minimum flash I/O size */
l = i + 1; l = i + 1;
l = (l + nand->writesize - 1) / nand->writesize; l = (l + mtd->writesize - 1) / mtd->writesize;
l *= nand->writesize; l *= mtd->writesize;
/* /*
* since the input length may be unaligned, prevent access past the end * since the input length may be unaligned, prevent access past the end
@ -471,16 +470,17 @@ static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
* Reads page of NAND and verifies the contents and OOB against the * Reads page of NAND and verifies the contents and OOB against the
* values in ops. * values in ops.
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param ops MTD operations, including data to verify * @param ops MTD operations, including data to verify
* @param ofs offset in flash * @param ofs offset in flash
* @return 0 in case of success * @return 0 in case of success
*/ */
int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs) int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops,
loff_t ofs)
{ {
int rval; int rval;
struct mtd_oob_ops vops; struct mtd_oob_ops vops;
size_t verlen = nand->writesize + nand->oobsize; size_t verlen = mtd->writesize + mtd->oobsize;
memcpy(&vops, ops, sizeof(vops)); memcpy(&vops, ops, sizeof(vops));
@ -489,9 +489,9 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)
if (!vops.datbuf) if (!vops.datbuf)
return -ENOMEM; return -ENOMEM;
vops.oobbuf = vops.datbuf + nand->writesize; vops.oobbuf = vops.datbuf + mtd->writesize;
rval = mtd_read_oob(nand, ofs, &vops); rval = mtd_read_oob(mtd, ofs, &vops);
if (!rval) if (!rval)
rval = memcmp(ops->datbuf, vops.datbuf, vops.len); rval = memcmp(ops->datbuf, vops.datbuf, vops.len);
if (!rval) if (!rval)
@ -510,17 +510,17 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)
* the contents of a buffer. The offset into the NAND must be * the contents of a buffer. The offset into the NAND must be
* page-aligned, and the function doesn't handle skipping bad blocks. * page-aligned, and the function doesn't handle skipping bad blocks.
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param ofs offset in flash * @param ofs offset in flash
* @param len buffer length * @param len buffer length
* @param buf buffer to read from * @param buf buffer to read from
* @return 0 in case of success * @return 0 in case of success
*/ */
int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf) int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf)
{ {
int rval = 0; int rval = 0;
size_t verofs; size_t verofs;
size_t verlen = nand->writesize; size_t verlen = mtd->writesize;
uint8_t *verbuf = memalign(ARCH_DMA_MINALIGN, verlen); uint8_t *verbuf = memalign(ARCH_DMA_MINALIGN, verlen);
if (!verbuf) if (!verbuf)
@ -529,8 +529,8 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
/* Read the NAND back in page-size groups to limit malloc size */ /* Read the NAND back in page-size groups to limit malloc size */
for (verofs = ofs; verofs < ofs + len; for (verofs = ofs; verofs < ofs + len;
verofs += verlen, buf += verlen) { verofs += verlen, buf += verlen) {
verlen = min(nand->writesize, (uint32_t)(ofs + len - verofs)); verlen = min(mtd->writesize, (uint32_t)(ofs + len - verofs));
rval = nand_read(nand, verofs, &verlen, verbuf); rval = nand_read(mtd, verofs, &verlen, verbuf);
if (!rval || (rval == -EUCLEAN)) if (!rval || (rval == -EUCLEAN))
rval = memcmp(buf, verbuf, verlen); rval = memcmp(buf, verbuf, verlen);
@ -558,7 +558,7 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
* beyond the limit we are passed, length is set to 0 and actual is set * beyond the limit we are passed, length is set to 0 and actual is set
* to the required length. * to the required length.
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param offset offset in flash * @param offset offset in flash
* @param length buffer length * @param length buffer length
* @param actual set to size required to write length worth of * @param actual set to size required to write length worth of
@ -569,8 +569,8 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)
* @param flags flags modifying the behaviour of the write to NAND * @param flags flags modifying the behaviour of the write to NAND
* @return 0 in case of success * @return 0 in case of success
*/ */
int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
size_t *actual, loff_t lim, u_char *buffer, int flags) size_t *actual, loff_t lim, u_char *buffer, int flags)
{ {
int rval = 0, blocksize; int rval = 0, blocksize;
size_t left_to_write = *length; size_t left_to_write = *length;
@ -581,7 +581,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
if (actual) if (actual)
*actual = 0; *actual = 0;
blocksize = nand->erasesize; blocksize = mtd->erasesize;
/* /*
* nand_write() handles unaligned, partial page writes. * nand_write() handles unaligned, partial page writes.
@ -594,13 +594,13 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
* you should only start a block skipping access at a * you should only start a block skipping access at a
* partition boundary). So don't try to handle that. * partition boundary). So don't try to handle that.
*/ */
if ((offset & (nand->writesize - 1)) != 0) { if ((offset & (mtd->writesize - 1)) != 0) {
printf("Attempt to write non page-aligned data\n"); printf("Attempt to write non page-aligned data\n");
*length = 0; *length = 0;
return -EINVAL; return -EINVAL;
} }
need_skip = check_skip_len(nand, offset, *length, &used_for_write); need_skip = check_skip_len(mtd, offset, *length, &used_for_write);
if (actual) if (actual)
*actual = used_for_write; *actual = used_for_write;
@ -618,10 +618,10 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
} }
if (!need_skip && !(flags & WITH_DROP_FFS)) { if (!need_skip && !(flags & WITH_DROP_FFS)) {
rval = nand_write(nand, offset, length, buffer); rval = nand_write(mtd, offset, length, buffer);
if ((flags & WITH_WR_VERIFY) && !rval) if ((flags & WITH_WR_VERIFY) && !rval)
rval = nand_verify(nand, offset, *length, buffer); rval = nand_verify(mtd, offset, *length, buffer);
if (rval == 0) if (rval == 0)
return 0; return 0;
@ -633,15 +633,15 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
} }
while (left_to_write > 0) { while (left_to_write > 0) {
size_t block_offset = offset & (nand->erasesize - 1); size_t block_offset = offset & (mtd->erasesize - 1);
size_t write_size, truncated_write_size; size_t write_size, truncated_write_size;
WATCHDOG_RESET(); WATCHDOG_RESET();
if (nand_block_isbad(nand, offset & ~(nand->erasesize - 1))) { if (nand_block_isbad(mtd, offset & ~(mtd->erasesize - 1))) {
printf("Skip bad block 0x%08llx\n", printf("Skip bad block 0x%08llx\n",
offset & ~(nand->erasesize - 1)); offset & ~(mtd->erasesize - 1));
offset += nand->erasesize - block_offset; offset += mtd->erasesize - block_offset;
continue; continue;
} }
@ -653,15 +653,15 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
truncated_write_size = write_size; truncated_write_size = write_size;
#ifdef CONFIG_CMD_NAND_TRIMFFS #ifdef CONFIG_CMD_NAND_TRIMFFS
if (flags & WITH_DROP_FFS) if (flags & WITH_DROP_FFS)
truncated_write_size = drop_ffs(nand, p_buffer, truncated_write_size = drop_ffs(mtd, p_buffer,
&write_size); &write_size);
#endif #endif
rval = nand_write(nand, offset, &truncated_write_size, rval = nand_write(mtd, offset, &truncated_write_size,
p_buffer); p_buffer);
if ((flags & WITH_WR_VERIFY) && !rval) if ((flags & WITH_WR_VERIFY) && !rval)
rval = nand_verify(nand, offset, rval = nand_verify(mtd, offset,
truncated_write_size, p_buffer); truncated_write_size, p_buffer);
offset += write_size; offset += write_size;
@ -693,7 +693,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
* the limit we are passed, length is set to 0 and actual is set to the * the limit we are passed, length is set to 0 and actual is set to the
* required length. * required length.
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param offset offset in flash * @param offset offset in flash
* @param length buffer length, on return holds number of read bytes * @param length buffer length, on return holds number of read bytes
* @param actual set to size required to read length worth of buffer or 0 * @param actual set to size required to read length worth of buffer or 0
@ -703,8 +703,8 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
* @param buffer buffer to write to * @param buffer buffer to write to
* @return 0 in case of success * @return 0 in case of success
*/ */
int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, int nand_read_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
size_t *actual, loff_t lim, u_char *buffer) size_t *actual, loff_t lim, u_char *buffer)
{ {
int rval; int rval;
size_t left_to_read = *length; size_t left_to_read = *length;
@ -712,7 +712,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
u_char *p_buffer = buffer; u_char *p_buffer = buffer;
int need_skip; int need_skip;
if ((offset & (nand->writesize - 1)) != 0) { if ((offset & (mtd->writesize - 1)) != 0) {
printf("Attempt to read non page-aligned data\n"); printf("Attempt to read non page-aligned data\n");
*length = 0; *length = 0;
if (actual) if (actual)
@ -720,7 +720,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
return -EINVAL; return -EINVAL;
} }
need_skip = check_skip_len(nand, offset, *length, &used_for_read); need_skip = check_skip_len(mtd, offset, *length, &used_for_read);
if (actual) if (actual)
*actual = used_for_read; *actual = used_for_read;
@ -738,7 +738,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
} }
if (!need_skip) { if (!need_skip) {
rval = nand_read(nand, offset, length, buffer); rval = nand_read(mtd, offset, length, buffer);
if (!rval || rval == -EUCLEAN) if (!rval || rval == -EUCLEAN)
return 0; return 0;
@ -749,24 +749,24 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
} }
while (left_to_read > 0) { while (left_to_read > 0) {
size_t block_offset = offset & (nand->erasesize - 1); size_t block_offset = offset & (mtd->erasesize - 1);
size_t read_length; size_t read_length;
WATCHDOG_RESET(); WATCHDOG_RESET();
if (nand_block_isbad(nand, offset & ~(nand->erasesize - 1))) { if (nand_block_isbad(mtd, offset & ~(mtd->erasesize - 1))) {
printf("Skipping bad block 0x%08llx\n", printf("Skipping bad block 0x%08llx\n",
offset & ~(nand->erasesize - 1)); offset & ~(mtd->erasesize - 1));
offset += nand->erasesize - block_offset; offset += mtd->erasesize - block_offset;
continue; continue;
} }
if (left_to_read < (nand->erasesize - block_offset)) if (left_to_read < (mtd->erasesize - block_offset))
read_length = left_to_read; read_length = left_to_read;
else else
read_length = nand->erasesize - block_offset; read_length = mtd->erasesize - block_offset;
rval = nand_read(nand, offset, &read_length, p_buffer); rval = nand_read(mtd, offset, &read_length, p_buffer);
if (rval && rval != -EUCLEAN) { if (rval && rval != -EUCLEAN) {
printf("NAND read from offset %llx failed %d\n", printf("NAND read from offset %llx failed %d\n",
offset, rval); offset, rval);
@ -812,57 +812,57 @@ static int check_pattern(const u_char *buf, u_char patt, int size)
* This is useful to determine if a block that caused a write error is still * This is useful to determine if a block that caused a write error is still
* good or should be marked as bad. * good or should be marked as bad.
* *
* @param nand NAND device * @param mtd nand mtd instance
* @param offset offset in flash * @param offset offset in flash
* @return 0 if the block is still good * @return 0 if the block is still good
*/ */
int nand_torture(nand_info_t *nand, loff_t offset) int nand_torture(struct mtd_info *mtd, loff_t offset)
{ {
u_char patterns[] = {0xa5, 0x5a, 0x00}; u_char patterns[] = {0xa5, 0x5a, 0x00};
struct erase_info instr = { struct erase_info instr = {
.mtd = nand, .mtd = nand,
.addr = offset, .addr = offset,
.len = nand->erasesize, .len = mtd->erasesize,
}; };
size_t retlen; size_t retlen;
int err, ret = -1, i, patt_count; int err, ret = -1, i, patt_count;
u_char *buf; u_char *buf;
if ((offset & (nand->erasesize - 1)) != 0) { if ((offset & (mtd->erasesize - 1)) != 0) {
puts("Attempt to torture a block at a non block-aligned offset\n"); puts("Attempt to torture a block at a non block-aligned offset\n");
return -EINVAL; return -EINVAL;
} }
if (offset + nand->erasesize > nand->size) { if (offset + mtd->erasesize > mtd->size) {
puts("Attempt to torture a block outside the flash area\n"); puts("Attempt to torture a block outside the flash area\n");
return -EINVAL; return -EINVAL;
} }
patt_count = ARRAY_SIZE(patterns); patt_count = ARRAY_SIZE(patterns);
buf = malloc_cache_aligned(nand->erasesize); buf = malloc_cache_aligned(mtd->erasesize);
if (buf == NULL) { if (buf == NULL) {
puts("Out of memory for erase block buffer\n"); puts("Out of memory for erase block buffer\n");
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < patt_count; i++) { for (i = 0; i < patt_count; i++) {
err = nand->erase(nand, &instr); err = mtd->erase(mtd, &instr);
if (err) { if (err) {
printf("%s: erase() failed for block at 0x%llx: %d\n", printf("%s: erase() failed for block at 0x%llx: %d\n",
nand->name, instr.addr, err); mtd->name, instr.addr, err);
goto out; goto out;
} }
/* Make sure the block contains only 0xff bytes */ /* Make sure the block contains only 0xff bytes */
err = nand->read(nand, offset, nand->erasesize, &retlen, buf); err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
if ((err && err != -EUCLEAN) || retlen != nand->erasesize) { if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
printf("%s: read() failed for block at 0x%llx: %d\n", printf("%s: read() failed for block at 0x%llx: %d\n",
nand->name, instr.addr, err); mtd->name, instr.addr, err);
goto out; goto out;
} }
err = check_pattern(buf, 0xff, nand->erasesize); err = check_pattern(buf, 0xff, mtd->erasesize);
if (!err) { if (!err) {
printf("Erased block at 0x%llx, but a non-0xff byte was found\n", printf("Erased block at 0x%llx, but a non-0xff byte was found\n",
offset); offset);
@ -871,22 +871,22 @@ int nand_torture(nand_info_t *nand, loff_t offset)
} }
/* Write a pattern and check it */ /* Write a pattern and check it */
memset(buf, patterns[i], nand->erasesize); memset(buf, patterns[i], mtd->erasesize);
err = nand->write(nand, offset, nand->erasesize, &retlen, buf); err = mtd->write(mtd, offset, mtd->erasesize, &retlen, buf);
if (err || retlen != nand->erasesize) { if (err || retlen != mtd->erasesize) {
printf("%s: write() failed for block at 0x%llx: %d\n", printf("%s: write() failed for block at 0x%llx: %d\n",
nand->name, instr.addr, err); mtd->name, instr.addr, err);
goto out; goto out;
} }
err = nand->read(nand, offset, nand->erasesize, &retlen, buf); err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
if ((err && err != -EUCLEAN) || retlen != nand->erasesize) { if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
printf("%s: read() failed for block at 0x%llx: %d\n", printf("%s: read() failed for block at 0x%llx: %d\n",
nand->name, instr.addr, err); mtd->name, instr.addr, err);
goto out; goto out;
} }
err = check_pattern(buf, patterns[i], nand->erasesize); err = check_pattern(buf, patterns[i], mtd->erasesize);
if (!err) { if (!err) {
printf("Pattern 0x%.2x checking failed for block at " printf("Pattern 0x%.2x checking failed for block at "
"0x%llx\n", patterns[i], offset); "0x%llx\n", patterns[i], offset);

View file

@ -23,7 +23,7 @@
# define DEBUGF(fmt,args...) # define DEBUGF(fmt,args...)
#endif #endif
static nand_info_t *nand; static struct mtd_info *mtd;
/* Compression names */ /* Compression names */
static char *compr_names[] = { static char *compr_names[] = {
@ -304,7 +304,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest,
len = sizeof(struct jffs2_raw_inode); len = sizeof(struct jffs2_raw_inode);
if (dest) if (dest)
len += jNode->csize; len += jNode->csize;
nand_read(nand, jNode->offset, &len, inode); nand_read(mtd, jNode->offset, &len, inode);
/* ignore data behind latest known EOF */ /* ignore data behind latest known EOF */
if (inode->offset > totalSize) if (inode->offset > totalSize)
continue; continue;
@ -450,7 +450,7 @@ dump_inode(struct b_lists *pL, struct b_dirent *d, struct b_inode *i)
if(!d || !i) return -1; if(!d || !i) return -1;
len = d->nsize; len = d->nsize;
nand_read(nand, d->offset + sizeof(struct jffs2_raw_dirent), nand_read(mtd, d->offset + sizeof(struct jffs2_raw_dirent),
&len, &fname); &len, &fname);
fname[d->nsize] = '\0'; fname[d->nsize] = '\0';
@ -592,7 +592,9 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)
for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) { for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
if (jNode->ino == jDirFoundIno) { if (jNode->ino == jDirFoundIno) {
size_t len = jNode->csize; size_t len = jNode->csize;
nand_read(nand, jNode->offset + sizeof(struct jffs2_raw_inode), &len, &tmp); nand_read(mtd,
jNode->offset + sizeof(struct jffs2_raw_inode),
&len, &tmp);
tmp[jNode->csize] = '\0'; tmp[jNode->csize] = '\0';
break; break;
} }
@ -760,14 +762,14 @@ dump_dirents(struct b_lists *pL)
#endif #endif
static int static int
jffs2_fill_scan_buf(nand_info_t *nand, unsigned char *buf, jffs2_fill_scan_buf(struct mtd_info *mtd, unsigned char *buf,
unsigned ofs, unsigned len) unsigned ofs, unsigned len)
{ {
int ret; int ret;
unsigned olen; unsigned olen;
olen = len; olen = len;
ret = nand_read(nand, ofs, &olen, buf); ret = nand_read(mtd, ofs, &olen, buf);
if (ret) { if (ret) {
printf("nand_read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret); printf("nand_read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret);
return ret; return ret;
@ -794,7 +796,7 @@ jffs2_1pass_build_lists(struct part_info * part)
u32 counterN = 0; u32 counterN = 0;
struct mtdids *id = part->dev->id; struct mtdids *id = part->dev->id;
nand = nand_info + id->num; mtd = nand_info + id->num;
/* if we are building a list we need to refresh the cache. */ /* if we are building a list we need to refresh the cache. */
jffs_init_1pass_list(part); jffs_init_1pass_list(part);
@ -802,7 +804,7 @@ jffs2_1pass_build_lists(struct part_info * part)
pL->partOffset = part->offset; pL->partOffset = part->offset;
puts ("Scanning JFFS2 FS: "); puts ("Scanning JFFS2 FS: ");
sectorsize = nand->erasesize; sectorsize = mtd->erasesize;
nr_blocks = part->size / sectorsize; nr_blocks = part->size / sectorsize;
buf = malloc(sectorsize); buf = malloc(sectorsize);
if (!buf) if (!buf)
@ -813,10 +815,10 @@ jffs2_1pass_build_lists(struct part_info * part)
offset = part->offset + i * sectorsize; offset = part->offset + i * sectorsize;
if (nand_block_isbad(nand, offset)) if (nand_block_isbad(mtd, offset))
continue; continue;
if (jffs2_fill_scan_buf(nand, buf, offset, EMPTY_SCAN_SIZE)) if (jffs2_fill_scan_buf(mtd, buf, offset, EMPTY_SCAN_SIZE))
return 0; return 0;
ofs = 0; ofs = 0;
@ -826,7 +828,7 @@ jffs2_1pass_build_lists(struct part_info * part)
if (ofs == EMPTY_SCAN_SIZE) if (ofs == EMPTY_SCAN_SIZE)
continue; continue;
if (jffs2_fill_scan_buf(nand, buf + EMPTY_SCAN_SIZE, offset + EMPTY_SCAN_SIZE, sectorsize - EMPTY_SCAN_SIZE)) if (jffs2_fill_scan_buf(mtd, buf + EMPTY_SCAN_SIZE, offset + EMPTY_SCAN_SIZE, sectorsize - EMPTY_SCAN_SIZE))
return 0; return 0;
offset += ofs; offset += ofs;

View file

@ -141,7 +141,7 @@ static const char *yaffs_error_str(void)
} }
} }
extern nand_info_t nand_info[]; extern struct mtd_info nand_info[];
void cmd_yaffs_tracemask(unsigned set, unsigned mask) void cmd_yaffs_tracemask(unsigned set, unsigned mask)
{ {

View file

@ -40,27 +40,27 @@ int nand_register(int devnum);
extern int board_nand_init(struct nand_chip *nand); extern int board_nand_init(struct nand_chip *nand);
#endif #endif
typedef struct mtd_info nand_info_t;
extern int nand_curr_device; extern int nand_curr_device;
extern nand_info_t nand_info[]; extern struct mtd_info nand_info[];
static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf) static inline int nand_read(struct mtd_info *info, loff_t ofs, size_t *len,
u_char *buf)
{ {
return mtd_read(info, ofs, *len, (size_t *)len, buf); return mtd_read(info, ofs, *len, (size_t *)len, buf);
} }
static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf) static inline int nand_write(struct mtd_info *info, loff_t ofs, size_t *len,
u_char *buf)
{ {
return mtd_write(info, ofs, *len, (size_t *)len, buf); return mtd_write(info, ofs, *len, (size_t *)len, buf);
} }
static inline int nand_block_isbad(nand_info_t *info, loff_t ofs) static inline int nand_block_isbad(struct mtd_info *info, loff_t ofs)
{ {
return mtd_block_isbad(info, ofs); return mtd_block_isbad(info, ofs);
} }
static inline int nand_erase(nand_info_t *info, loff_t off, size_t size) static inline int nand_erase(struct mtd_info *info, loff_t off, size_t size)
{ {
struct erase_info instr; struct erase_info instr;
@ -96,27 +96,28 @@ struct nand_erase_options {
typedef struct nand_erase_options nand_erase_options_t; typedef struct nand_erase_options nand_erase_options_t;
int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, int nand_read_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
size_t *actual, loff_t lim, u_char *buffer); size_t *actual, loff_t lim, u_char *buffer);
#define WITH_DROP_FFS (1 << 0) /* drop trailing all-0xff pages */ #define WITH_DROP_FFS (1 << 0) /* drop trailing all-0xff pages */
#define WITH_WR_VERIFY (1 << 1) /* verify data was written correctly */ #define WITH_WR_VERIFY (1 << 1) /* verify data was written correctly */
int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
size_t *actual, loff_t lim, u_char *buffer, int flags); size_t *actual, loff_t lim, u_char *buffer, int flags);
int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts); int nand_erase_opts(struct mtd_info *mtd,
int nand_torture(nand_info_t *nand, loff_t offset); const nand_erase_options_t *opts);
int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, int nand_torture(struct mtd_info *mtd, loff_t offset);
loff_t ofs); int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops,
int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf); loff_t ofs);
int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf);
#define NAND_LOCK_STATUS_TIGHT 0x01 #define NAND_LOCK_STATUS_TIGHT 0x01
#define NAND_LOCK_STATUS_UNLOCK 0x04 #define NAND_LOCK_STATUS_UNLOCK 0x04
int nand_lock(nand_info_t *meminfo, int tight); int nand_lock(struct mtd_info *mtd, int tight);
int nand_unlock(nand_info_t *meminfo, loff_t start, size_t length, int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
int allexcept); int allexcept);
int nand_get_lock_status(nand_info_t *meminfo, loff_t offset); int nand_get_lock_status(struct mtd_info *mtd, loff_t offset);
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst); int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
void nand_deselect(void); void nand_deselect(void);
@ -135,6 +136,6 @@ __attribute__((noreturn)) void nand_boot(void);
#define ENV_OOB_MARKER_OLD 0x30564e45 /*"ENV0" in little-endian -- offset is #define ENV_OOB_MARKER_OLD 0x30564e45 /*"ENV0" in little-endian -- offset is
stored as byte number */ stored as byte number */
#define ENV_OFFSET_SIZE 8 #define ENV_OFFSET_SIZE 8
int get_nand_env_oob(nand_info_t *nand, unsigned long *result); int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result);
#endif #endif
int spl_nand_erase_one(int block, int page); int spl_nand_erase_one(int block, int page);