mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/5] nand: omap: Fix BCH16 read
Date: Fri, 11 Dec 2020 09:15:30 +0100	[thread overview]
Message-ID: <20201211081533.7372-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20201211081533.7372-1-s.hauer@pengutronix.de>

When reading in BCH16 mode the ECC for the first 512 byte fails. I am
pretty sure this must have worked once and I can't see why it doesn't
now. Change reading in BCH16 mode to the same way as the kernel driver
does: Instead of using wrap mode 4 to skip ECC when reading the first
OOB bytes, just use wrap mode 1 and skip reading the first OOB bytes.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index e3d36a1cf4..1d81500bce 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -91,6 +91,8 @@
 
 #define BCH8_MAX_ERROR	8	/* upto 8 bit correctable */
 
+#define BADBLOCK_MARKER_LENGTH 2
+
 static const uint8_t bch8_vector[] = {0xf3, 0xdb, 0x14, 0x16, 0x8b, 0xd2,
 		0xbe, 0xcc, 0xac, 0x6b, 0xff, 0x99, 0x7b};
 static u_char bch16_vector[] = {0xf5, 0x24, 0x1c, 0xd0, 0x61, 0xb3, 0xf1, 0x55,
@@ -497,9 +499,9 @@ static void omap_enable_hwecc(struct nand_chip *nand, int mode)
 	case OMAP_ECC_BCH16_CODE_HW:
 		bch_mod = 2;
 		if (mode == NAND_ECC_READ) {
-			bch_wrapmode = 4;
-			eccsize0 = 4; /* ECC bits in nibbles per sector */
-			eccsize1 = 52;  /* non-ECC bits in nibbles per sector */
+			bch_wrapmode = 1;
+			eccsize0 = 52; /* ECC bits in nibbles per sector */
+			eccsize1 = 0;  /* non-ECC bits in nibbles per sector */
 		} else {
 			bch_wrapmode = 4;
 			eccsize0 = 4;  /* extra bits in nibbles per sector */
@@ -964,7 +966,12 @@ static int gpmc_read_page_hwecc_elm(struct nand_chip *chip, uint8_t *buf,
 	nand_read_page_op(chip, page, 0, NULL, 0);
 
 	chip->legacy.read_buf(chip, buf, mtd->writesize);
-	chip->legacy.read_buf(chip, chip->oob_poi, mtd->oobsize);
+
+	/* Read oob bytes */
+	nand_change_read_column_op(chip,
+				mtd->writesize + BADBLOCK_MARKER_LENGTH,
+				chip->oob_poi + BADBLOCK_MARKER_LENGTH,
+				chip->ecc.total, false);
 
 	ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
                                   chip->ecc.total);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-12-11  8:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11  8:15 [PATCH 1/5] mtd: nand: Allow non page aligned length writes Sascha Hauer
2020-12-11  8:15 ` Sascha Hauer [this message]
2020-12-11  8:15 ` [PATCH 3/5] mtd: nand: omap: print error when ELM config failed Sascha Hauer
2020-12-11  8:15 ` [PATCH 4/5] mtd: nand: omap: Bail out when omap_gpmc_eccmode() fails Sascha Hauer
2020-12-11  8:15 ` [PATCH 5/5] mtd: nand: Make write support optional Sascha Hauer

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=20201211081533.7372-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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