[PATCH] mtd: rawnand: gpmi: add support for legacy-bch-geometry

Alifer Moraes alifer.m at variscite.com
Mon Mar 7 06:32:02 PST 2022


From: Pierluigi Passaro <pierluigi.p at variscite.com>

For backward compatibility, allow supporting legacy-bch-geometry as in
original NXP releases.

Signed-off-by: Pierluigi Passaro <pierluigi.p at variscite.com>
Signed-off-by: Alifer Moraes <alifer.m at variscite.com>
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 9 +++++++++
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 1b64c5a5140d..ae375115ef0a 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -517,6 +517,11 @@ static int common_nfc_set_geometry(struct gpmi_nand_data *this)
 	const struct nand_ecc_props *requirements =
 		nanddev_get_ecc_requirements(&chip->base);
 
+	if (this->legacy_bch_geometry) {
+		dev_warn(this->dev, "use legacy bch geometry\n");
+		return legacy_set_geometry(this);
+	}
+
 	if (chip->ecc.strength > 0 && chip->ecc.size > 0)
 		return set_geometry_by_ecc_info(this, chip->ecc.strength,
 						chip->ecc.size);
@@ -2072,6 +2077,10 @@ static int gpmi_nand_attach_chip(struct nand_chip *chip)
 	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
 		this->swap_block_mark ? "en" : "dis");
 
+	if (of_property_read_bool(this->dev->of_node,
+			"fsl,legacy-bch-geometry"))
+		this->legacy_bch_geometry = true;
+
 	ret = gpmi_init_last(this);
 	if (ret)
 		return ret;
diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h
index 5e1c3ddae5f8..d9926cf3d5e0 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h
@@ -151,6 +151,9 @@ struct gpmi_nand_data {
 
 	void			*raw_buffer;
 
+	/* legacy bch geometry flag */
+	bool			legacy_bch_geometry;
+
 	/* DMA channels */
 #define DMA_CHANS		8
 	struct dma_chan		*dma_chans[DMA_CHANS];
-- 
2.25.1




More information about the linux-mtd mailing list