public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/4] nand: Add support for unlock.invert
Date: Mon, 17 Sep 2012 17:35:34 -0500	[thread overview]
Message-ID: <20120917223534.GA26052@buserror.net> (raw)
In-Reply-To: <1345672185-8398-1-git-send-email-joe.hershberger@ni.com>

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).

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

  parent reply	other threads:[~2012-09-17 22:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17 20:31 [U-Boot] [PATCH 1/3] nand: Add support for unlock.invert Joe Hershberger
2012-08-17 20:31 ` [U-Boot] [PATCH 2/3] nand: consolidate duplicated constants Joe Hershberger
2012-08-17 20:31 ` [U-Boot] [PATCH 3/3] nand: Make NAND lock status compatible with Micron Joe Hershberger
2012-08-17 21:00   ` Scott Wood
2012-08-17 20:53 ` [U-Boot] [PATCH 1/3] nand: Add support for unlock.invert Scott Wood
2012-08-22 20:34   ` Joe Hershberger
2012-08-23  1:38     ` Scott Wood
2012-08-23 15:41       ` Joe Hershberger
2012-08-22 21:49 ` [U-Boot] [PATCH v2 1/4] " Joe Hershberger
2012-08-22 21:49   ` [U-Boot] [PATCH v2 2/4] nand: Change ulong to loff_t and size_t Joe Hershberger
2012-09-17 22:35     ` Scott Wood
2012-08-22 21:49   ` [U-Boot] [PATCH v2 3/4] nand: consolidate duplicated constants Joe Hershberger
2012-09-17 22:36     ` Scott Wood
2012-08-22 21:49   ` [U-Boot] [PATCH v2 4/4] nand: Make NAND lock status compatible with Micron Joe Hershberger
2012-09-17 22:36     ` Scott Wood
2012-09-17 22:35   ` Scott Wood [this message]
2012-09-18 19:22     ` [U-Boot] [PATCH v2 1/4] nand: Add support for unlock.invert Joe Hershberger

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=20120917223534.GA26052@buserror.net \
    --to=scottwood@freescale.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