From: Bill Pringlemeir <bpringlemeir@nbsps.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/4] mtd: nand: add Freescale NFC driver
Date: Thu, 14 Aug 2014 14:34:41 -0400 [thread overview]
Message-ID: <87tx5ekji6.fsf@nbsps.com> (raw)
In-Reply-To: <70dc426d4c612b10f760337ffdb5f79aff173a8f.1408031213.git.stefan@agner.ch> (Stefan Agner's message of "Thu, 14 Aug 2014 18:30:35 +0200")
On 14 Aug 2014, stefan at agner.ch wrote:
> This adds initial support for Freescale NFC (NAND Flash Controller)
> found in ARM Vybrid SoC's, Power Architecture MPC5125 and others.
> However, this driver is only tested on Vybrid.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> drivers/mtd/nand/Makefile | 1 +
> drivers/mtd/nand/vf610_nfc.c | 706
> ++++++++++++++++++++++++++++++++++++++++++> +
> 2 files changed, 707 insertions(+)
> create mode 100644 drivers/mtd/nand/vf610_nfc.c
>
> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> new file mode 100644
> index 0000000..3150ac1
> --- /dev/null
> +++ b/drivers/mtd/nand/vf610_nfc.c
> @@ -0,0 +1,706 @@
> +/*
> + * Copyright 2009-2014 Freescale Semiconductor, Inc. and others
> + *
[snip]
> +/* Count the number of 0's in buff upto max_bits */
> +static inline int count_written_bits(uint8_t *buff, int size, int max_bits)
> +{
> + uint32_t *buff32 = (uint32_t *)buff;
> + int k, written_bits = 0;
> +
> + for (k = 0; k < (size / 4); k++) {
> + written_bits += hweight32(~buff32[k]);
> + if (written_bits > max_bits)
> + break;
> + }
> +
> + return written_bits;
> +}
That is a nice change.
> +static inline int vf610_nfc_correct_data(struct mtd_info *mtd, u_char *dat)
> +{
> + struct vf610_nfc *nfc = mtd_to_nfc(mtd);
> + u8 ecc_status;
> + u8 ecc_count;
> + int flip;
> +
> + ecc_status = __raw_readb(nfc->regs + ECC_SRAM_ADDR * 8 + ECC_OFFSET);
> + ecc_count = ecc_status & ECC_ERR_COUNT;
> + if (!(ecc_status & ECC_STATUS_MASK))
> + return ecc_count;
> +
> + /* If 'ecc_count' zero or less then buffer is all 0xff or erased. */
> + flip = count_written_bits(dat, nfc->chip.ecc.size, ecc_count);
> +
> + /* ECC failed. */
> + if (flip > ecc_count)
> + return -1;
Sorry, I missed this in version one of the patch. The original had,
< if (flip > ecc_count) {
< nfc->page = -1;
---
> if (flip > ecc_count)
522d508
< }
I can see why you removed this (nfc->page = -1). However, I think that
higher layers may want to re-read on an error in case of un-stable bits?
It is very little code to ensure a re-read in case of ECC failure. The
2nd physical read may pass whereas the first failed. This path is rare,
but maybe important? A higher layer may migrate the data in this case;
just as with a corrected bits. But maybe U-Boot will never do this?
> +
> + /* Erased page. */
> + memset(dat, 0xff, nfc->chip.ecc.size);
> + return 0;
> +}
Regards,
Bill Pringlemeir.
next prev parent reply other threads:[~2014-08-14 18:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 16:30 [U-Boot] [PATCH v2 0/4] arm: vf610: add NAND flash support Stefan Agner
2014-08-14 16:30 ` [U-Boot] [PATCH v2 1/4] arm: vf610: add NFC pin mux Stefan Agner
2014-08-14 16:30 ` [U-Boot] [PATCH v2 2/4] arm: vf610: add NFC clock support Stefan Agner
2014-08-14 16:30 ` [U-Boot] [PATCH v2 3/4] mtd: nand: add Freescale NFC driver Stefan Agner
2014-08-14 18:34 ` Bill Pringlemeir [this message]
2014-08-14 19:49 ` Scott Wood
2014-08-14 21:12 ` Bill Pringlemeir
2014-08-18 9:41 ` Stefan Agner
2014-08-18 16:38 ` Bill Pringlemeir
2014-08-19 17:00 ` Stefan Agner
2014-08-21 21:15 ` [U-Boot] [PATCH v3 3/4] mtd: nand: add Freescale vf610_nfc driver Bill Pringlemeir
2014-09-11 9:37 ` Stefano Babic
2014-08-14 16:30 ` [U-Boot] [PATCH v2 4/4] arm: vf610: add NAND support for vf610twr Stefan Agner
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=87tx5ekji6.fsf@nbsps.com \
--to=bpringlemeir@nbsps.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