mtd: sunxi_nand: Select the chip in sunxi_nand_chip_init_timings()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 6 10:59:02 PST 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=7eadd47fd708df2028877558d085f47dc9086459
Commit:     7eadd47fd708df2028877558d085f47dc9086459
Parent:     a9cadf72bfb7185a680eb7599b9bda65d1515b9f
Author:     Stefan Roese <sr at denx.de>
AuthorDate: Fri Aug 28 14:45:21 2015 +0200
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed Sep 9 16:51:47 2015 -0700

    mtd: sunxi_nand: Select the chip in sunxi_nand_chip_init_timings()
    
    nand_scan_ident() leaves the chip deselected. So just issuing some commands
    from the sunxi driver does not work. We need to select the chip before
    writing the commands to the NAND device. This patch takes care of this.
    
    Set the new timing on all dies implemented as suggested by Boris.
    
    This was detected on the in-circuit ICnova-A20 SoM equipped with the
    Micron MT29F32G08CBACAWP (4GiB) ONFI NAND device.
    
    Signed-off-by: Stefan Roese <sr at denx.de>
    Cc: Hans de Goede <hdegoede at redhat.com>
    Cc: Maxime Ripard <maxime.ripard at free-electrons.com>
    Cc: Roy Spliet <r.spliet at ultimaker.com>
    Acked-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    [Brian: fixup whitespace]
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/sunxi_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f97a58d..4e586bc 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -978,17 +978,23 @@ static int sunxi_nand_chip_init_timings(struct sunxi_nand_chip *chip,
 		mode = chip->nand.onfi_timing_mode_default;
 	} else {
 		uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {};
+		int i;
 
 		mode = fls(mode) - 1;
 		if (mode < 0)
 			mode = 0;
 
 		feature[0] = mode;
-		ret = chip->nand.onfi_set_features(&chip->mtd, &chip->nand,
+		for (i = 0; i < chip->nsels; i++) {
+			chip->nand.select_chip(&chip->mtd, i);
+			ret = chip->nand.onfi_set_features(&chip->mtd,
+						&chip->nand,
 						ONFI_FEATURE_ADDR_TIMING_MODE,
 						feature);
-		if (ret)
-			return ret;
+			chip->nand.select_chip(&chip->mtd, -1);
+			if (ret)
+				return ret;
+		}
 	}
 
 	timings = onfi_async_timing_mode_to_sdr_timings(mode);



More information about the linux-mtd-cvs mailing list