1 From 9a8f612ca0d6a436e6471c9bed516d34a2cc626f Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Mon, 8 Apr 2019 10:31:45 +0200
4 Subject: mtd: rawnand: marvell: Clean the controller state before each operation
6 From: Miquel Raynal <miquel.raynal@bootlin.com>
8 commit 9a8f612ca0d6a436e6471c9bed516d34a2cc626f upstream.
10 Since the migration of the driver to stop using the legacy
11 ->select_chip() hook, there is nothing deselecting the target anymore,
12 thus the selection is not forced at the next access. Ensure the ND_RUN
13 bit and the interrupts are always in a clean state.
15 Cc: Daniel Mack <daniel@zonque.org>
16 Cc: stable@vger.kernel.org
17 Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
18 Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
19 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
20 Tested-by: Daniel Mack <daniel@zonque.org>
21 Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
22 Signed-off-by: Richard Weinberger <richard@nod.at>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
27 1 file changed, 6 insertions(+), 6 deletions(-)
29 --- a/drivers/mtd/nand/raw/marvell_nand.c
30 +++ b/drivers/mtd/nand/raw/marvell_nand.c
31 @@ -722,12 +722,6 @@ static void marvell_nfc_select_target(st
32 struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
35 - if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
38 - writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
39 - writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
42 * Reset the NDCR register to a clean state for this particular chip,
43 * also clear ND_RUN bit.
44 @@ -739,6 +733,12 @@ static void marvell_nfc_select_target(st
45 /* Also reset the interrupt status register */
46 marvell_nfc_clear_int(nfc, NDCR_ALL_INT);
48 + if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
51 + writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
52 + writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
54 nfc->selected_chip = chip;
55 marvell_nand->selected_die = die_nr;