public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Rohit Hagargundgi <h.rohit@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot]  [PATCH v2 4/4] Flex-OneNAND boundary setting command
Date: Thu, 11 Dec 2008 19:57:53 +0530	[thread overview]
Message-ID: <49412369.6010707@samsung.com> (raw)

Add command for changing Flex-OneNAND SLC / MLC boundary.

Signed-off-by: Rohit Hagargundgi <h.rohit@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@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

             reply	other threads:[~2008-12-11 14:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 14:27 Rohit Hagargundgi [this message]
2009-03-08  6:47 ` [U-Boot] [PATCH v2 4/4] Flex-OneNAND boundary setting command Rohit Hagargundgi
2009-03-09 21:38   ` Scott Wood
2009-03-23  7:06     ` Amul Kumar Saha
2009-03-23 20:17       ` Scott Wood
2009-03-25 15:14     ` Amul Kumar Saha
2009-03-25 17:23       ` Scott Wood
2009-03-26 12:21         ` Amul Kumar Saha
2009-03-26 12:35         ` Amul Kumar Saha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49412369.6010707@samsung.com \
    --to=h.rohit@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox