diff mbox series

[14/14] nand: enable the Randomizer module for i.mx7 and i.mx8

Message ID 20200504140903.23602-15-peng.fan@nxp.com
State New
Headers show
Series mtd: nand: i.MX update | expand

Commit Message

Peng Fan May 4, 2020, 2:09 p.m. UTC
From: Alice Guo <alice.guo at nxp.com>

To enable the Randomizer module, set GPMI_ECCCTRL[RANDOMIZER_ENABLE] to
1, then set GPMI_ECCCOUNT[RANDOMIZER_PAGE] to select randomizer page
number needed to be randomized.

Signed-off-by: Alice Guo <alice.guo at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/mtd/nand/raw/mxs_nand.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Stefano Babic May 11, 2020, 10:16 a.m. UTC | #1
> From: Alice Guo <alice.guo at nxp.com>
> To enable the Randomizer module, set GPMI_ECCCTRL[RANDOMIZER_ENABLE] to
> 1, then set GPMI_ECCCOUNT[RANDOMIZER_PAGE] to select randomizer page
> number needed to be randomized.
> Signed-off-by: Alice Guo <alice.guo at nxp.com>
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c
index 3fd21e51f2..c3191feca8 100644
--- a/drivers/mtd/nand/raw/mxs_nand.c
+++ b/drivers/mtd/nand/raw/mxs_nand.c
@@ -710,6 +710,12 @@  static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand,
 	d->cmd.pio_words[4] = (dma_addr_t)nand_info->data_buf;
 	d->cmd.pio_words[5] = (dma_addr_t)nand_info->oob_buf;
 
+	if ((is_mx7() || is_imx8m()) && nand_info->en_randomizer) {
+		d->cmd.pio_words[2] |= GPMI_ECCCTRL_RANDOMIZER_ENABLE |
+				       GPMI_ECCCTRL_RANDOMIZER_TYPE2;
+		d->cmd.pio_words[3] |= (page % 256) << 16;
+	}
+
 	mxs_dma_desc_append(channel, d);
 
 	/* Compile the DMA descriptor - disable the BCH block. */
@@ -871,7 +877,7 @@  static int mxs_nand_ecc_write_page(struct mtd_info *mtd,
 		 * The value is between 0-255. For additional details
 		 * check 9.6.6.4 of i.MX7D Applications Processor reference
 		 */
-		d->cmd.pio_words[3] |= (page % 255) << 16;
+		d->cmd.pio_words[3] |= (page % 256) << 16;
 	}
 
 	mxs_dma_desc_append(channel, d);