diff mbox

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

Message ID 20120917223534.GA26052@buserror.net
State Not Applicable
Delegated to: Scott Wood
Headers show

Commit Message

Scott Wood Sept. 17, 2012, 10:35 p.m. UTC
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@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).


-Scott

Comments

Joe Hershberger Sept. 18, 2012, 7:22 p.m. UTC | #1
Hi Scott,

On Mon, Sep 17, 2012 at 5:35 PM, Scott Wood <scottwood@freescale.com> wrote:
> 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@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).

I'm not aware of a part that supports lock and not the invert
functionality.  I'm also not aware of a way to detect at runtime if it
is supported.

Thanks,
-Joe
diff mbox

Patch

--- 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 */