All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/5 v2] mtd/nand: workaround for Freescale FCM to support 4k pagesize Nand chip
Date: Mon, 12 Dec 2011 14:14:17 -0600	[thread overview]
Message-ID: <4EE66099.3040100@freescale.com> (raw)
In-Reply-To: <1323683398-11001-5-git-send-email-Shengzhou.Liu@freescale.com>

On 12/12/2011 03:49 AM, Shengzhou Liu wrote:
> Freescale FCM controller has a 2K size limitation of buffer RAM. In order
> to support the Nand flash chip with pagesize larger than 2K bytes,
> we read/write 2k data repeatedly by issuing FIR_OP_RB/FIR_OP_WB and save
> them to a large buffer.
> 
> Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
> Signed-off-by: Liu Shuo <b35362@freescale.com>
> ---
>  drivers/mtd/nand/fsl_elbc_nand.c |  283 +++++++++++++++++++++++++++++++++----
>  1 files changed, 252 insertions(+), 31 deletions(-)

I've asked you several times what you're planning on doing for bad block
marker migration.  I am not going to let you ignore this.  NACK until
you have a migration tool, and a scheme for marking the flash as having
been migrated.

Also please mention below the --- what has changed since v1.

> @@ -393,9 +468,28 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
>  		     page_addr, column);
>  
>  		ctrl->column = column;
> -		ctrl->oob = 0;
> +		if (column >= mtd->writesize) {
> +			/* OOB area */
> +			column -= mtd->writesize;
> +			ctrl->oob = 1;
> +		} else {
> +			ctrl->oob = 0;
> +		}
[snip]
> @@ -432,12 +524,19 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
>  		}
>  
>  		out_be32(&lbc->fcr, fcr);
> -		set_addr(mtd, column, page_addr, ctrl->oob);
> +		if (column >= mtd->writesize && mtd->writesize > 2048) {

How can column >= mtd->writesize be true at this point?  You've already
subtracted it out.

>  		if (ctrl->oob || ctrl->column != 0 ||
> -		    ctrl->index != mtd->writesize + mtd->oobsize)
> -			out_be32(&lbc->fbcr, ctrl->index);
> -		else
> +				ctrl->index != mtd->writesize + mtd->oobsize) {
> +			if (ctrl->oob && mtd->writesize > 2048) {
> +				out_be32(&lbc->fbcr, 64);
> +			} else {
> +				out_be32(&lbc->fbcr, ctrl->index -
> +					ctrl->column);
> +			}
> +		} else {
>  			out_be32(&lbc->fbcr, 0);
> +		}

Again, if we're going to make an API assumption that we get either a
full page access or a full OOB access, then make the assumption fully.
Don't half-implement partial accessses.

> +int board_nand_init_tail(struct mtd_info *mtd)
> +{
> +	struct nand_chip *nand = mtd->priv;
> +	struct fsl_elbc_mtd *priv = nand->priv;
> +	struct fsl_elbc_ctrl *ctrl = priv->ctrl;
> +
> +	/* adjust Option Register and ECC to match Flash page size */
> +	if (mtd->writesize == 512) {
> +		clrbits_be32(&ctrl->regs->bank[priv->bank].or, OR_FCM_PGS);
> +	} else if (mtd->writesize >= 2048 && mtd->writesize <= 8192) {
> +		setbits_be32(&ctrl->regs->bank[priv->bank].or, OR_FCM_PGS);
> +		/* adjust ecc setup if needed */
> +		if ((in_be32(&ctrl->regs->bank[priv->bank].br) & BR_DECC) ==
> +			BR_DECC_CHK_GEN) {
> +			nand->ecc.size = 512;

Please find some way to indent the continuation line so it doesn't line
up with the if-body.

> +			nand->ecc.layout = (priv->fmr & FMR_ECCM) ?
> +			   &fsl_elbc_oob_lp_eccm1 : &fsl_elbc_oob_lp_eccm0;
> +			nand->badblock_pattern = &largepage_memorybased;

Those oob layouts won't be quite right for larger page sizes.

-Scott

  reply	other threads:[~2011-12-12 20:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12  9:49 [U-Boot] [PATCH 1/5 v2] mtd/nand: Add function board_nand_init_tail() for some special NAND controllers Shengzhou Liu
2011-12-12  9:49 ` [U-Boot] [PATCH 2/5 v2] mtd/nand: Fixup for support ONFI detect Shengzhou Liu
2011-12-12  9:49   ` [U-Boot] [PATCH 3/5 v2] mtd/nand: remove CONFIG_SYS_NAND_ONFI_DETECTION to enable ONFI detection Shengzhou Liu
2011-12-12  9:49     ` [U-Boot] [PATCH 4/5 v2] mtd/nand: Add ONFI support for FSL NAND controller Shengzhou Liu
2011-12-12  9:49       ` [U-Boot] [PATCH 5/5 v2] mtd/nand: workaround for Freescale FCM to support 4k pagesize Nand chip Shengzhou Liu
2011-12-12 20:14         ` Scott Wood [this message]
     [not found]           ` <3F453DDFF675A64A89321A1F352810216BEF66@039-SN1MPN1-005.039d.mgd.msft.net>
2011-12-14 17:54             ` Scott Wood
     [not found]               ` <3F453DDFF675A64A89321A1F352810216C4934@039-SN1MPN1-005.039d.mgd.msft.net>
2011-12-15 17:36                 ` Scott Wood
2012-01-10 23:29       ` [U-Boot] [PATCH 4/5 v2] mtd/nand: Add ONFI support for FSL NAND controller Scott Wood
2011-12-12 18:42     ` [U-Boot] [PATCH 3/5 v2] mtd/nand: remove CONFIG_SYS_NAND_ONFI_DETECTION to enable ONFI detection Scott Wood
     [not found]       ` <3F453DDFF675A64A89321A1F352810216BECF4@039-SN1MPN1-005.039d.mgd.msft.net>
2011-12-14 18:08         ` Scott Wood

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=4EE66099.3040100@freescale.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.