From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH RFC] ARM: Davinci: NAND fix for large page ECC and linux compatibility
Date: Fri, 27 Jun 2008 08:44:17 +0200 [thread overview]
Message-ID: <20080627064417.GC13425@game.jcrosoft.org> (raw)
In-Reply-To: <20080627051200.GA5534@mersenne.largestprime.net>
> #endif
> +#endif
>
> static void nand_davinci_enable_hwecc(struct mtd_info *mtd, int mode)
> {
> @@ -141,12 +146,29 @@ static u_int32_t nand_davinci_readecc(st
>
> static int nand_davinci_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
> {
> +#ifdef CFG_LINUX_COMPATIBLE_ECC
> + unsigned int ecc_val = nand_davinci_readecc(mtd, 1);
> + /* squeeze 0 middle bits out so that it fits in 3 bytes */
> + unsigned int tmp = (ecc_val&0x0fff)|((ecc_val&0x0fff0000)>>4);
unsigned int tmp = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);
please and space between operator
plese use the same alignement
add an empty line
> + /* invert so that erased block ecc is correct */
> + tmp = ~tmp;
> + ecc_code[0] = (u_char)(tmp);
> + ecc_code[1] = (u_char)(tmp >> 8);
> + ecc_code[2] = (u_char)(tmp >> 16);
> +#else
> u_int32_t tmp;
> int region, n;
> struct nand_chip *this = mtd->priv;
>
> n = (this->eccmode == NAND_ECC_HW12_2048) ? 4 : 1;
>
> + u_char *read_ecc, u_char *calc_ecc)
> +{
> + struct nand_chip *chip = mtd->priv;
> + u_int32_t ecc_nand = read_ecc[0] | (read_ecc[1] << 8) |
> + (read_ecc[2] << 16);
> + u_int32_t ecc_calc = calc_ecc[0] | (calc_ecc[1] << 8) |
> + (calc_ecc[2] << 16);
> + u_int32_t diff = ecc_calc ^ ecc_nand;
> +
> + if (diff) {
> + if ((((diff>>12)^diff) & 0xfff) == 0xfff) {
please and space between operator
> + /* Correctable error */
please and space between operator
> + if ((diff>>(12+3)) < chip->eccsize) {
> + uint8_t find_bit = 1 << ((diff>>12)&7);
please and space between operator
> + uint32_t find_byte = diff>>(12+3);
uint32_t find_byte = diff >> 15;
please and space between operator
> + dat[find_byte] ^= find_bit;
> + DEBUG (MTD_DEBUG_LEVEL0, "Correcting single bit ECC error at offset: %d, bit: %d\n", find_byte, find_bit);
too long please split
> + return 1;
> + } else {
> + return -1;
> + }
> + } else if (!(diff & (diff-1))) {
please and space between operator
> + /* Single bit ECC error in the ECC itself,
> + nothing to fix */
please use this style of comment
/*
*
*/
> + DEBUG (MTD_DEBUG_LEVEL0, "Single bit ECC error in ECC.\n");
> + return 1;
> + } else {
> + /* Uncorrectable error */
> + DEBUG (MTD_DEBUG_LEVEL0, "ECC UNCORRECTED_ERROR 1\n");
> + return -1;
> /* Set address of hardware control function */
> nand->hwcontrol = nand_davinci_hwcontrol;
> Index: u-boot-1.3.3/include/configs/davinci_dvevm.h
> ===================================================================
> --- u-boot-1.3.3.orig/include/configs/davinci_dvevm.h 2008-05-19 18:47:11.000000000 +0800
> +++ u-boot-1.3.3/include/configs/davinci_dvevm.h 2008-06-27 13:04:07.000000000 +0800
> @@ -46,6 +46,18 @@
> #define CONFIG_NOR_UART_BOOT
> */
>
> +/*
> + * Previous versions of u-boot (1.3.3 and prior) and Montavista Linux kernels
> + * generated bogus ECCs on large-page NAND. Both large and small page NAND ECCs
> + * were incompatible with the Linux davinci git tree (since NAND was integrated
> + * in 2.6.24).
> + * Don't turn this on if you want backwards compatibility.
> + * Do turn this on if you want u-boot to be able to read and write NAND
> + * that can be written or read by the Linux davinci git kernel.
> + *
> +#define CFG_LINUX_COMPATIBLE_ECC
> + */
please move this in README.davinci
> +
Best Regards,
J.
next prev parent reply other threads:[~2008-06-27 6:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-27 5:12 [U-Boot-Users] [PATCH RFC] ARM: Davinci: NAND fix for large page ECC and linux compatibility Bernard Blackham
2008-06-27 6:44 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2008-08-30 21:06 ` [U-Boot] [PATCH] ARM DaVinci: Fix broken HW ECC for large page NAND Hugo Villeneuve
2008-08-30 22:27 ` ksi at koi8.net
2008-08-31 2:21 ` Bernard Blackham
2008-09-08 17:48 ` Scott Wood
[not found] <20080627141723.GA29627@mersenne.largestprime.net>
[not found] ` <48651D80.2010506@freescale.com>
2008-06-28 3:31 ` [U-Boot-Users] [PATCH RFC] ARM: Davinci: NAND fix for large page ECC and linux compatibility Bernard Blackham
2008-06-28 22:11 ` Troy Kisky
2008-06-30 15:26 ` 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=20080627064417.GC13425@game.jcrosoft.org \
--to=plagnioj@jcrosoft.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