[U-Boot] [PATCH v2 1/4] nand: Add support for unlock.invert

Scott Wood scottwood at freescale.com
Tue Sep 18 00:35:34 CEST 2012


On Wed, Aug 22, 2012 at 04:49:42PM -0500, Joe Hershberger wrote:
> NAND unlock command allows an invert bit to be set to unlock all but
> the selected page range.
> 
> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
> ---
> Changes in v2:
> - Changed invert to allexcept
> - Changed unlock printf to debug print
> - Dropped cast in unlock debug print
> 
>  common/cmd_nand.c            | 13 ++++++++++---
>  drivers/mtd/nand/nand_util.c | 10 +++++++---
>  include/nand.h               |  4 ++--
>  3 files changed, 19 insertions(+), 8 deletions(-)

Applied to u-boot-nand-flash with the diff below.  Do you know if all
chips that support locking support the invert bit?  If not, we should at
least update the documentation to mention this (though runtime detection
would be good if practical).

--- a/doc/README.nand
+++ b/doc/README.nand
@@ -228,6 +228,8 @@ NAND locking command (for chips with active LOCKPRE pin)
   "nand unlock [offset] [size]"
   unlock consecutive area (can be called multiple times for different areas)
 
+  "nand unlock.allexcept [offset] [size]"
+  unlock all except specified consecutive area
 
 I have tested the code with board containing 128MiB NAND large page chips
 and 32MiB small page chips.
diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index 21a011c..c66eeef 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -370,8 +370,15 @@ int nand_unlock(struct mtd_info *mtd, ulong start, ulong length, int allexcept)
 
 	/* submit ADDRESS of LAST page to unlock */
 	page += (int)(length >> chip->page_shift);
+
+	/*
+	 * Page addresses for unlocking are supposed to be block-aligned.
+	 * At least some NAND chips use the low bit to indicate that the
+	 * page range should be inverted.
+	 */
 	if (allexcept)
 		page |= 1;
+
 	chip->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1, page & chip->pagemask);
 
 	/* call wait ready function */

-Scott



More information about the U-Boot mailing list