[U-Boot] [PATCH v2 4/4] Flex-OneNAND boundary setting command
Rohit Hagargundgi
h.rohit at samsung.com
Thu Dec 11 15:27:53 CET 2008
Add command for changing Flex-OneNAND SLC / MLC boundary.
Signed-off-by: Rohit Hagargundgi <h.rohit at samsung.com>
---
common/cmd_onenand.c | 65 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 56 insertions(+), 9 deletions(-)
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index 8d87b78..2caae45 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -21,8 +21,35 @@
extern struct mtd_info onenand_mtd;
extern struct onenand_chip onenand_chip;
+/**
+ * do_set_boundary - [Flex-OneNAND] Set boundary of Flex-OneNAND
+ * @param mtd mtd information structure
+ * @param die die of device for which boundary will be set
+ * @param bdry new boundary value ie last SLC block of die
+ *
+ * Set boundary of Flex-OneNAND
+ */
+int do_set_boundary(struct mtd_info *mtd, unsigned die, unsigned bdry, int lock)
+{
+ struct onenand_chip *this = mtd->priv;
+
+ if (!FLEXONENAND(this)) {
+ printf("Flex-OneNAND not found.\n");
+ return -1;
+ }
+
+ if (die >= this->dies) {
+ printf("Invalid die index\n");
+ return -1;
+ }
+
+ return flexonenand_set_boundary(mtd, die, bdry, lock);
+}
+
int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
+ struct mtd_info *mtd = &onenand_mtd;
+ struct onenand_chip *this = mtd->priv;
int ret = 0;
switch (argc) {
@@ -57,10 +84,11 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
start = simple_strtoul(argv[2], NULL, 10);
end = simple_strtoul(argv[3], NULL, 10);
- start >>= onenand_chip.erase_shift;
- end >>= onenand_chip.erase_shift;
+ start = onenand_get_block(this, start, NULL);
+ end = onenand_get_block(this, end, NULL);
/* Don't include the end block */
- end--;
+ if (end > 0)
+ end--;
}
if (!end || end < 0)
@@ -69,8 +97,13 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
printf("Erase block from %lu to %lu\n", start, end);
for (block = start; block <= end; block++) {
- instr.addr = block << onenand_chip.erase_shift;
- instr.len = 1 << onenand_chip.erase_shift;
+ instr.addr = onenand_get_addr(this, block);
+ if (mtd->numeraseregions > 1) {
+ int i = flexonenand_region(mtd, instr.addr);
+ instr.len = mtd->eraseregions[i].erasesize;
+ } else
+ instr.len = mtd->erasesize;
+
ret = onenand_erase(&onenand_mtd, &instr);
if (ret) {
printf("erase failed %lu\n", block);
@@ -134,15 +167,15 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
ops.mode = MTD_OOB_PLACE;
- ofs = block << onenand_chip.erase_shift;
+ ofs = onenand_get_addr(this, block);
if (page)
ofs += page << onenand_chip.page_shift;
if (!len) {
if (oob)
- ops.ooblen = 64;
+ ops.ooblen = FLEXONENAND(this) ? 128 : 64;
else
- ops.len = 512;
+ ops.len = FLEXONENAND(this) ? 4096 : 512;
}
if (oob) {
@@ -158,6 +191,18 @@ int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 0;
}
+ if (strncmp(argv[1], "setboundary", 11) == 0) {
+ unsigned die = simple_strtoul(argv[2], NULL, 0);
+ unsigned bdry = simple_strtoul(argv[3], NULL, 0);
+ int lock = 0;
+
+ if (argc == 5 && strncmp(argv[4], "LOCK", 4) == 0)
+ lock = 1;
+
+ do_set_boundary(mtd, die, bdry, lock);
+ return 0;
+ }
+
break;
}
@@ -172,5 +217,7 @@ U_BOOT_CMD(
"onenand write addr ofs len - write data at ofs with len from addr\n"
"onenand erase saddr eaddr - erase block start addr to end addr\n"
"onenand block[.oob] addr block [page] [len] - "
- "read data with (block [, page]) to addr"
+ "read data with (block [, page]) to addr\n"
+ "onenand setboundary DIE BOUNDARY [LOCK] - "
+ "Change SLC boundary of Flex-OneNAND\n"
);
--
1.5.4.3
More information about the U-Boot
mailing list