Patchwork [U-Boot,2/5] NAND: Add nand read.raw and write.raw commands

login
register
mail settings
Submitter Marek Vasut
Date Sept. 8, 2011, 8:39 p.m.
Message ID <1315514380-19089-3-git-send-email-marek.vasut@gmail.com>
Download mbox | patch
Permalink /patch/113948/
State Superseded
Headers show

Comments

Marek Vasut - Sept. 8, 2011, 8:39 p.m.
These commands should work around various "hardware" ECC and BCH methods.

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>
---
 common/cmd_nand.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

Patch

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 66e06a5..a1c8dfd 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -606,6 +606,20 @@  int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 				ret = nand->read_oob(nand, off, &ops);
 			else
 				ret = nand->write_oob(nand, off, &ops);
+		} else if (!strcmp(s, ".raw")) {
+			/* Raw access */
+			mtd_oob_ops_t ops = {
+				.datbuf = (u8 *)addr,
+				.oobbuf = ((u8 *)addr) + nand->writesize,
+				.len = nand->writesize,
+				.ooblen = nand->oobsize,
+				.mode = MTD_OOB_RAW
+			};
+
+			if (read)
+				ret = nand->read_oob(nand, off, &ops);
+			else
+				ret = nand->write_oob(nand, off, &ops);
 		} else {
 			printf("Unknown nand command suffix '%s'.\n", s);
 			return 1;