[PATCH 3/6] mtd: nand: Allow to set a per-device ECC layout

Ezequiel Garcia ezequiel.garcia at imgtec.com
Tue Dec 2 04:58:53 PST 2014


Until now, the ECC was handled either by Linux (i.e. software ECC) or by the
NAND controller (i.e. hardware ECC). In each of these, the ECC layout is
defined by the controller of the NAND device, not by the NAND device itself.

However, devices with on-die ECC support have their own ECC layout so we need
a way to specify a per-device ECC layout.

This commit adds a new field to the nand_flash_dev structure, to allow devices
to specify its own ECC layout.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia at imgtec.com>
---
 drivers/mtd/nand/nand_base.c | 1 +
 include/linux/mtd/nand.h     | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index a4c9cee..10f5ac9 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3595,6 +3595,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
 		chip->options |= type->options;
 		chip->ecc_strength_ds = NAND_ECC_STRENGTH(type);
 		chip->ecc_step_ds = NAND_ECC_STEP(type);
+		chip->ecc.layout = type->ecc.layout;
 		chip->onfi_timing_mode_default =
 					type->onfi_timing_mode_default;
 
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index a36fff1..a36d628 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -780,6 +780,7 @@ struct nand_chip {
  *               @ecc_step_ds in nand_chip{}, also from the datasheet.
  *               For example, the "4bit ECC for each 512Byte" can be set with
  *               NAND_ECC_INFO(4, 512).
+ * @ecc.layout: If the device has on-die ECC, it can provide its own ECC layout.
  * @onfi_timing_mode_default: the default ONFI timing mode entered after a NAND
  *			      reset. Should be deduced from timings described
  *			      in the datasheet.
@@ -803,6 +804,7 @@ struct nand_flash_dev {
 	struct {
 		uint16_t strength_ds;
 		uint16_t step_ds;
+		struct nand_ecclayout *layout;
 	} ecc;
 	int onfi_timing_mode_default;
 };
-- 
2.1.0




More information about the linux-mtd mailing list