From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
barebox@lists.infradead.org,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Subject: [PATCH 12/17] mtd: nand_mrvl_nfc: Add support for 4bit BCH HW ECC
Date: Fri, 9 Oct 2015 00:06:14 +0200 [thread overview]
Message-ID: <1444341979-19157-13-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1444341979-19157-1-git-send-email-sebastian.hesselbarth@gmail.com>
Add support for 4bit HW ECC modes supported by later IP versions.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: barebox@lists.infradead.org
---
drivers/mtd/nand/nand_mrvl_nfc.c | 65 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/drivers/mtd/nand/nand_mrvl_nfc.c b/drivers/mtd/nand/nand_mrvl_nfc.c
index 8a05fc88824b..2fb9823d1497 100644
--- a/drivers/mtd/nand/nand_mrvl_nfc.c
+++ b/drivers/mtd/nand/nand_mrvl_nfc.c
@@ -222,6 +222,31 @@ static struct nand_ecclayout ecc_layout_2KB_hwecc = {
.oobfree = { {0, 40} }
};
+static struct nand_ecclayout ecc_layout_2KB_bch4bit = {
+ .eccbytes = 32,
+ .eccpos = {
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63},
+ .oobfree = { {2, 30} }
+};
+
+static struct nand_ecclayout ecc_layout_4KB_bch4bit = {
+ .eccbytes = 64,
+ .eccpos = {
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63,
+ 96, 97, 98, 99, 100, 101, 102, 103,
+ 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127},
+ /* Bootrom looks in bytes 0 & 5 for bad blocks */
+ .oobfree = { {1, 4}, {6, 26}, {64, 32} }
+};
+
#define NDTR0_tCH(c) (min((c), 7) << 19)
#define NDTR0_tCS(c) (min((c), 7) << 16)
#define NDTR0_tWH(c) (min((c), 7) << 11)
@@ -859,6 +884,43 @@ static int pxa_ecc_strength1(struct mrvl_nand_host *host,
return -ENODEV;
}
+static int pxa_ecc_strength4(struct mrvl_nand_host *host,
+ struct nand_ecc_ctrl *ecc, int ecc_stepsize, int page_size)
+{
+ if (!(host->hwflags & HWFLAGS_ECC_BCH))
+ return -ENODEV;
+
+ /*
+ * Required ECC: 4-bit correction per 512 bytes
+ * Select: 16-bit correction per 2048 bytes
+ */
+ if (ecc_stepsize == 512 && page_size == 2048) {
+ host->chunk_size = 2048;
+ host->spare_size = 32;
+ host->ecc_size = 32;
+ host->ecc_bch = 1;
+ ecc->mode = NAND_ECC_HW;
+ ecc->size = 2048;
+ ecc->layout = &ecc_layout_2KB_bch4bit;
+ ecc->strength = 16;
+ return 0;
+ }
+
+ if (ecc_stepsize == 512 && page_size == 4096) {
+ host->chunk_size = 2048;
+ host->spare_size = 32;
+ host->ecc_size = 32;
+ host->ecc_bch = 1;
+ ecc->mode = NAND_ECC_HW;
+ ecc->size = 2048;
+ ecc->layout = &ecc_layout_4KB_bch4bit;
+ ecc->strength = 16;
+ 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)
@@ -869,6 +931,9 @@ static int pxa_ecc_init(struct mrvl_nand_host *host,
case 1:
ret = pxa_ecc_strength1(host, ecc, ecc_stepsize, page_size);
break;
+ case 4:
+ ret = pxa_ecc_strength4(host, ecc, ecc_stepsize, page_size);
+ break;
}
if (ret) {
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-10-08 22:06 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 22:06 [PATCH 00/17] Armada 370/XP NAND driver Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 01/17] arm: pxa: Prepare for NAND clkdev lookup on PXA3xx Sebastian Hesselbarth
2015-10-09 19:11 ` Robert Jarzmik
2015-10-09 19:13 ` Robert Jarzmik
2015-10-10 8:34 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 02/17] mtd: nand_mrvl_nfc: Use common clock for core clock Sebastian Hesselbarth
2015-10-10 8:35 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 03/17] mtd: nand: Clarify Marvell Orion Kconfig prompt Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 04/17] arm: pxa: Remove pxa_get_nandclk() Sebastian Hesselbarth
2015-10-10 8:35 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 05/17] mtd: nand_mrvl_nfc: Remove keep_config Sebastian Hesselbarth
2015-10-09 19:16 ` Robert Jarzmik
2015-10-09 19:32 ` Sebastian Hesselbarth
2015-10-09 21:14 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 06/17] mtd: nand_mrvl_nfc: Clear OOB data with 0xff instead of 0x00 Sebastian Hesselbarth
2015-10-10 8:38 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 07/17] mtd: nand_mrvl_nfc: Use Auto Read Status on program/erase Sebastian Hesselbarth
2015-10-10 8:44 ` Robert Jarzmik
2015-10-10 9:36 ` Sebastian Hesselbarth
2015-10-10 9:49 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 08/17] mtd: nand_mrvl_nfc: Fix num-cs property parsing Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 09/17] mtd: nand_mrvl_nfc: Get ecc parameters from DT Sebastian Hesselbarth
2015-10-11 20:39 ` Robert Jarzmik
2015-10-12 6:28 ` Sascha Hauer
2015-10-12 7:32 ` Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 10/17] mtd: nand_mrvl_nfc: Prepare for different HW ECC strengths Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 11/17] mtd: nand_mrvl_nfc: Add hwflags to distinguish different HW versions Sebastian Hesselbarth
2015-10-12 6:33 ` Sascha Hauer
2015-10-08 22:06 ` Sebastian Hesselbarth [this message]
2015-10-08 22:06 ` [PATCH 13/17] mtd: nand_mrvl_nfc: Add support for 8bit BCH HW ECC Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 14/17] mtd: nand_mrvl_nfc: Add support for HW BCH ECC Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 15/17] mtd: nand_mrvl_nfc: Add support for NDCB3 register Sebastian Hesselbarth
2015-10-10 8:48 ` Robert Jarzmik
2015-10-10 17:17 ` Sebastian Hesselbarth
2015-10-08 22:06 ` [PATCH 16/17] mtd: nand_mrvl_nfc: Add support for Marvell Armada 370/XP Sebastian Hesselbarth
2015-10-10 8:48 ` Robert Jarzmik
2015-10-08 22:06 ` [PATCH 17/17] mtd: nand_mrvl_nfc: Add optimized timings for Samsung K9K8G08U Sebastian Hesselbarth
2015-10-12 10:38 ` [PATCH 00/17] Armada 370/XP NAND driver Robert Jarzmik
2015-10-12 18:41 ` Sebastian Hesselbarth
2015-10-12 19:16 ` Robert Jarzmik
2015-10-12 19:59 ` Sebastian Hesselbarth
2015-10-13 9:35 ` Robert Jarzmik
2015-10-13 9:53 ` Sebastian Hesselbarth
2015-10-13 10:27 ` Sascha Hauer
2015-10-13 10:38 ` Robert Jarzmik
2015-10-13 10:54 ` Sascha Hauer
2015-10-15 21:17 ` Sebastian Hesselbarth
2015-10-16 18:40 ` Robert Jarzmik
2015-10-16 19:32 ` Sebastian Hesselbarth
2015-10-20 19:25 ` Robert Jarzmik
2015-11-19 23:16 ` Sebastian Hesselbarth
2015-11-20 7:18 ` Robert Jarzmik
2015-10-12 17:55 ` [PATCH] of: mtd: Import of_get_nand_ecc_{step_size, strength} from Linux Sebastian Hesselbarth
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=1444341979-19157-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