summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2011-09-22 03:57:26 +0200
committerScott Wood <scottwood@freescale.com>2011-10-03 18:35:12 -0500
commitce80ddc1809193bc450b4d1e104d1ab2f9ee8dd2 (patch)
tree5480eff5e27a0fd7a905a71aed2234c06a3d9e06 /common
parent17d261df18acfab96dcb5e0e078d2fe81a7d70ad (diff)
downloadu-boot-imx-ce80ddc1809193bc450b4d1e104d1ab2f9ee8dd2.zip
u-boot-imx-ce80ddc1809193bc450b4d1e104d1ab2f9ee8dd2.tar.gz
u-boot-imx-ce80ddc1809193bc450b4d1e104d1ab2f9ee8dd2.tar.bz2
NAND: Make page, erase, oob size available via cmd_nand
The "nand info" and "nand device" now set shell/environment variables: nand_writesize ... nand page size nand_oobsize ..... nand oob area size nand_erasesize ... nand erase block size Also, the "nand info" command now displays this info. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Cc: Scott Wood <scottwood@freescale.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: Detlev Zundel <dzu@denx.de> [scottwood@freescale.com: removed unnecessary memsets] Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_nand.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index c726bf9..3e2edb8 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -362,15 +362,31 @@ usage:
#endif
-static void nand_print_info(int idx)
+static void nand_print_and_set_info(int idx)
{
nand_info_t *nand = &nand_info[idx];
struct nand_chip *chip = nand->priv;
+ const int bufsz = 32;
+ char buf[bufsz];
+
printf("Device %d: ", idx);
if (chip->numchips > 1)
printf("%dx ", chip->numchips);
printf("%s, sector size %u KiB\n",
nand->name, nand->erasesize >> 10);
+ printf(" Page size %8d b\n", nand->writesize);
+ printf(" OOB size %8d b\n", nand->oobsize);
+ printf(" Erase size %8d b\n", nand->erasesize);
+
+ /* Set geometry info */
+ sprintf(buf, "%x", nand->writesize);
+ setenv("nand_writesize", buf);
+
+ sprintf(buf, "%x", nand->oobsize);
+ setenv("nand_oobsize", buf);
+
+ sprintf(buf, "%x", nand->erasesize);
+ setenv("nand_erasesize", buf);
}
int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
@@ -407,7 +423,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
putc('\n');
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
if (nand_info[i].name)
- nand_print_info(i);
+ nand_print_and_set_info(i);
}
return 0;
}
@@ -418,7 +434,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE)
puts("no devices available\n");
else
- nand_print_info(dev);
+ nand_print_and_set_info(dev);
return 0;
}