Commit ef24f97d authored by Miquel Raynal's avatar Miquel Raynal
Browse files

mtd: rawnand: Separate the ECC engine type and the ECC byte placement



The use of "syndrome" placement should not be encoded in the ECC
engine mode/type.

Create a "placement" field in NAND chip and change all occurrences of
the NAND_ECC_HW_SYNDROME enumeration to be just NAND_ECC_HW and
possibly a placement entry like NAND_ECC_PLACEMENT_INTERLEAVED.

Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200827085208.16276-10-miquel.raynal@bootlin.com
parent a8c7ffdb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ static struct davinci_nand_pdata davinci_nand_data = {
	.mask_chipsel		= BIT(14),
	.parts			= davinci_nand_partitions,
	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),
	.ecc_mode		= NAND_ECC_HW_SYNDROME,
	.ecc_mode		= NAND_HW_ECC_ENGINE,
	.ecc_placement		= NAND_ECC_PLACEMENT_INTERLEAVED,
	.ecc_bits		= 4,
	.bbt_options		= NAND_BBT_USE_FLASH,
};
+2 −1
Original line number Diff line number Diff line
@@ -629,7 +629,8 @@ static int cafe_nand_attach_chip(struct nand_chip *chip)
		goto out_free_dma;
	}

	cafe->nand.ecc.mode = NAND_ECC_HW_SYNDROME;
	cafe->nand.ecc.mode = NAND_ECC_HW;
	cafe->nand.ecc.placement = NAND_ECC_PLACEMENT_INTERLEAVED;
	cafe->nand.ecc.size = mtd->writesize;
	cafe->nand.ecc.bytes = 14;
	cafe->nand.ecc.strength = 4;
+3 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ static int nand_davinci_correct_1bit(struct nand_chip *chip, u_char *dat,
/*
 * 4-bit hardware ECC ... context maintained over entire AEMIF
 *
 * This is a syndrome engine, but we avoid NAND_ECC_HW_SYNDROME
 * This is a syndrome engine, but we avoid NAND_ECC_PLACEMENT_INTERLEAVED
 * since that forces use of a problematic "infix OOB" layout.
 * Among other things, it trashes manufacturer bad block markers.
 * Also, and specific to this hardware, it ECC-protects the "prepad"
@@ -851,6 +851,7 @@ static int nand_davinci_probe(struct platform_device *pdev)

	/* Use board-specific ECC config */
	info->chip.ecc.mode	= pdata->ecc_mode;
	info->chip.ecc.placement = pdata->ecc_placement;

	spin_lock_irq(&davinci_nand_lock);

@@ -897,7 +898,7 @@ static int nand_davinci_remove(struct platform_device *pdev)
	int ret;

	spin_lock_irq(&davinci_nand_lock);
	if (info->chip.ecc.mode == NAND_ECC_HW_SYNDROME)
	if (info->chip.ecc.placement == NAND_ECC_PLACEMENT_INTERLEAVED)
		ecc4_busy = false;
	spin_unlock_irq(&davinci_nand_lock);

+2 −1
Original line number Diff line number Diff line
@@ -1237,7 +1237,8 @@ int denali_chip_init(struct denali_controller *denali,
	chip->bbt_options |= NAND_BBT_USE_FLASH;
	chip->bbt_options |= NAND_BBT_NO_OOB;
	chip->options |= NAND_NO_SUBPAGE_WRITE;
	chip->ecc.mode = NAND_ECC_HW_SYNDROME;
	chip->ecc.mode = NAND_ECC_HW;
	chip->ecc.placement = NAND_ECC_PLACEMENT_INTERLEAVED;
	chip->ecc.read_page = denali_read_page;
	chip->ecc.write_page = denali_write_page;
	chip->ecc.read_page_raw = denali_read_page_raw;
+2 −1
Original line number Diff line number Diff line
@@ -1456,7 +1456,8 @@ static int __init doc_probe(unsigned long physadr)
	nand->ecc.calculate	= doc200x_calculate_ecc;
	nand->ecc.correct	= doc200x_correct_data;

	nand->ecc.mode		= NAND_ECC_HW_SYNDROME;
	nand->ecc.mode		= NAND_ECC_HW;
	nand->ecc.placement	= NAND_ECC_PLACEMENT_INTERLEAVED;
	nand->ecc.size		= 512;
	nand->ecc.bytes		= 6;
	nand->ecc.strength	= 2;
Loading