mtd: rawnand: marvell: Clean the controller state before each operation [Linux 5.1]

mtd: rawnand: marvell: Clean the controller state before each operation [Linux 5.1]

This Linux kernel change "mtd: rawnand: marvell: Clean the controller state before each operation" is included in the Linux 5.1 release. This change is authored by Miquel Raynal <miquel.raynal [at] bootlin.com> on Mon Apr 8 10:31:45 2019 +0200. The commit for this change in Linux stable tree is 9a8f612 (patch).

mtd: rawnand: marvell: Clean the controller state before each operation

Since the migration of the driver to stop using the legacy
->select_chip() hook, there is nothing deselecting the target anymore,
thus the selection is not forced at the next access. Ensure the ND_RUN
bit and the interrupts are always in a clean state.

Cc: Daniel Mack <[email protected]>
Cc: [email protected]
Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
Suggested-by: Boris Brezillon <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Tested-by: Daniel Mack <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>

There are 12 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index f38e5c1..d984538 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -722,12 +722,6 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
    struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
    u32 ndcr_generic;

-   if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
-       return;
-
-   writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
-   writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
-
    /*
     * Reset the NDCR register to a clean state for this particular chip,
     * also clear ND_RUN bit.
@@ -739,6 +733,12 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
    /* Also reset the interrupt status register */
    marvell_nfc_clear_int(nfc, NDCR_ALL_INT);

+   if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
+       return;
+
+   writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
+   writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
+
    nfc->selected_chip = chip;
    marvell_nand->selected_die = die_nr;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *