summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Riedmueller <s.riedmueller@phytec.de>2021-03-30 08:50:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-04-01 10:24:14 +0200
commit0e18518c1548f22602a9a9e1a2a3d2ee1cb47724 (patch)
tree2dba4f0423419b440e2b76412740ee62be4c93e2
parent60d0fbde61ee5a19eb443a057027a004d07a3a29 (diff)
downloadbarebox-0e18518c1548f22602a9a9e1a2a3d2ee1cb47724.tar.gz
barebox-0e18518c1548f22602a9a9e1a2a3d2ee1cb47724.tar.xz
mtd: nand_msx: Implement ooblayout ops
The default ooblayout ops do not work on nand_mxs devices and can lead to an unresponsible system when doing a 'nand -i' on that device. Thus implement the ooblayout ops for the nand_mxs driver separately. Since writing the oob area is not supported simply return the whole oob area as ecc. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/mtd/nand/nand_mxs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 96ae71364e..285ae3c121 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -269,6 +269,33 @@ static void mxs_nand_return_dma_descs(struct mxs_nand_info *info)
info->desc_index = 0;
}
+/*
+ * We don't support writing the oob area so simply return the whole oob
+ * as ECC.
+ */
+static int mxs_nand_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ if (section)
+ return -ERANGE;
+
+ oobregion->offset = 0;
+ oobregion->length = mtd->oobsize;
+
+ return 0;
+}
+
+static int mxs_nand_ooblayout_free(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ return -ERANGE;
+}
+
+static const struct mtd_ooblayout_ops mxs_nand_ooblayout_ops = {
+ .ecc = mxs_nand_ooblayout_ecc,
+ .free = mxs_nand_ooblayout_free,
+};
+
static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
{
return page_data_size / MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
@@ -2218,6 +2245,8 @@ static int mxs_nand_probe(struct device_d *dev)
if (err)
goto err2;
+ mtd_set_ooblayout(mtd, &mxs_nand_ooblayout_ops);
+
mxs_nand_scan_bbt(chip);
err = add_mtd_nand_device(mtd, "nand");