mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	barebox@lists.infradead.org
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Subject: [PATCH v2 12/19] mtd: nand_mrvl_nfc: Prepare for different HW ECC strengths
Date: Fri, 20 Nov 2015 20:36:05 +0100	[thread overview]
Message-ID: <1448048172-10080-13-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1448048172-10080-1-git-send-email-sebastian.hesselbarth@gmail.com>

Newer versions of Marvell PXA3xx NFC also support BCH and therefore
higher ECC strengths than 1. Prepare for different ECC strength by
factoring out ECC init into separate functions by strength. Also,
add a new host variable that indicates BCH ECC.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/mtd/nand/nand_mrvl_nfc.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/nand_mrvl_nfc.c b/drivers/mtd/nand/nand_mrvl_nfc.c
index 8dcbc3dc045e..217aacd7201a 100644
--- a/drivers/mtd/nand/nand_mrvl_nfc.c
+++ b/drivers/mtd/nand/nand_mrvl_nfc.c
@@ -156,6 +156,7 @@ struct mrvl_nand_host {
 	int			num_cs;		/* avaiable CS signals */
 	int			cs;		/* selected chip 0/1 */
 	int			use_ecc;	/* use HW ECC ? */
+	int			ecc_bch;	/* HW ECC is BCH */
 	int			use_spare;	/* use spare ? */
 	int			flash_bbt;
 
@@ -824,32 +825,53 @@ static void mrvl_nand_config_flash(struct mrvl_nand_host *host)
 	host->reg_ndcr = ndcr;
 }
 
-static int pxa_ecc_init(struct mrvl_nand_host *host,
-			struct nand_ecc_ctrl *ecc,
-			int strength, int ecc_stepsize, int page_size)
+static int pxa_ecc_strength1(struct mrvl_nand_host *host,
+		struct nand_ecc_ctrl *ecc, int ecc_stepsize, int page_size)
 {
-	if (strength == 1 && ecc_stepsize == 512 && page_size == 2048) {
+	if (ecc_stepsize == 512 && page_size == 2048) {
 		host->chunk_size = 2048;
 		host->spare_size = 40;
 		host->ecc_size = 24;
+		host->ecc_bch = 0;
 		ecc->mode = NAND_ECC_HW;
 		ecc->size = 512;
 		ecc->strength = 1;
 		ecc->layout = &ecc_layout_2KB_hwecc;
+		return 0;
+	}
 
-	} else if (strength == 1 && ecc_stepsize == 512 && page_size == 512) {
+	if (ecc_stepsize == 512 && page_size == 512) {
 		host->chunk_size = 512;
 		host->spare_size = 8;
 		host->ecc_size = 8;
+		host->ecc_bch = 0;
 		ecc->mode = NAND_ECC_HW;
 		ecc->size = 512;
 		ecc->layout = &ecc_layout_512B_hwecc;
 		ecc->strength = 1;
-	} else {
+		return 0;
+	}
+
+	return -ENODEV;
+}
+
+static int pxa_ecc_init(struct mrvl_nand_host *host,
+			struct nand_ecc_ctrl *ecc,
+			int strength, int ecc_stepsize, int page_size)
+{
+	int ret = -ENODEV;
+
+	switch (strength) {
+	case 1:
+		ret = pxa_ecc_strength1(host, ecc, ecc_stepsize, page_size);
+		break;
+	}
+
+	if (ret) {
 		dev_err(host->dev,
 			"ECC strength %d at page size %d is not supported\n",
 			strength, page_size);
-		return -ENODEV;
+		return ret;
 	}
 
 	dev_info(host->dev, "ECC strength %d, ECC step size %d\n",
-- 
2.1.4


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

  parent reply	other threads:[~2015-11-20 19:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 19:35 [PATCH v2 00/19] Armada 370/XP NAND driver Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 01/19] of: mtd: Import of_get_nand_ecc_{step_size, strength} from Linux Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 02/19] mtd: nand: Clarify Marvell Orion Kconfig prompt Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 03/19] arm: pxa: Prepare for NAND clkdev lookup on PXA3xx Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 04/19] arm: pxa: Add clock for Zylonite NFC Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 05/19] mtd: nand_mrvl_nfc: Use common clock for core clock Sebastian Hesselbarth
2015-11-20 19:35 ` [PATCH v2 06/19] arm: pxa: Remove pxa_get_nandclk() Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 07/19] mtd: nand_mrvl_nfc: Clear OOB data with 0xff instead of 0x00 Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 08/19] mtd: nand_mrvl_nfc: Use Auto Read Status on program/erase Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 09/19] mtd: nand_mrvl_nfc: Protect mrvl_nand_probe_dt Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 10/19] mtd: nand_mrvl_nfc: Fix num-cs property parsing Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 11/19] mtd: nand_mrvl_nfc: Get ecc parameters from DT Sebastian Hesselbarth
2015-11-20 19:36 ` Sebastian Hesselbarth [this message]
2015-11-20 20:38   ` [PATCH v2 12/19] mtd: nand_mrvl_nfc: Prepare for different HW ECC strengths Trent Piepho
2015-11-23  7:18     ` Sascha Hauer
2015-11-20 19:36 ` [PATCH v2 13/19] mtd: nand_mrvl_nfc: Add hwflags to distinguish different HW versions Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 14/19] mtd: nand_mrvl_nfc: Add support for 4bit BCH HW ECC Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 15/19] mtd: nand_mrvl_nfc: Add support for 8bit " Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 16/19] mtd: nand_mrvl_nfc: Add support for HW BCH ECC Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 17/19] mtd: nand_mrvl_nfc: Add support for NDCB3 register Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 18/19] mtd: nand_mrvl_nfc: Add support for Marvell Armada 370/XP Sebastian Hesselbarth
2015-11-20 19:36 ` [PATCH v2 19/19] mtd: nand_mrvl_nfc: Add optimized timings for Samsung K9K8G08U Sebastian Hesselbarth
2015-11-23  7:19 ` [PATCH v2 00/19] Armada 370/XP NAND driver 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=1448048172-10080-13-git-send-email-sebastian.hesselbarth@gmail.com \
    --to=sebastian.hesselbarth@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=thomas.petazzoni@free-electrons.com \
    /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