MLK-22582-1: nand: enable the Randomizer module for mx7 and mx8 when call
authorAlice Guo <alice.guo@nxp.com>
Thu, 24 Oct 2019 15:49:50 +0000 (23:49 +0800)
committerYe Li <ye.li@nxp.com>
Mon, 28 Oct 2019 08:11:52 +0000 (01:11 -0700)
the function named mxs_nand_ecc_read_page

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@nxp.com>
(cherry picked from commit e8271a1c7621cc3607d3e9c7b0a872342b5f4c95)

drivers/mtd/nand/raw/mxs_nand.c

index fc954ff..08bf7b8 100644 (file)
@@ -708,6 +708,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. */
@@ -859,7 +865,7 @@ static int mxs_nand_ecc_write_page(struct mtd_info *mtd,
        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() && nand_info->en_randomizer) || (is_imx8m() && nand_info->en_randomizer)) {
+       if ((is_mx7() || is_imx8m()) && nand_info->en_randomizer) {
                d->cmd.pio_words[2] |= GPMI_ECCCTRL_RANDOMIZER_ENABLE |
                                       GPMI_ECCCTRL_RANDOMIZER_TYPE2;
                /*
@@ -869,7 +875,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);