Skip to contentSkip to conversation

mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings()

PATCH In review Stefan Roese 4 participants 4 messages Aug 28, 2015 – Sep 9, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: sunxi_nand.c: 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.

Cc Boris Brezillon <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Roy Spliet <[email protected]>
Cc Brian Norris <[email protected]>
---
 drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/nand/sunxi_nand.c +11 -5
index f97a58d..6e7941b 100644
@@ -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,
-						ONFI_FEATURE_ADDR_TIMING_MODE,
-						feature);
-		if (ret)
-			return ret;
+		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);
+			chip->nand.select_chip(&chip->mtd, -1);
+			if (ret)
+				return ret;
+		}
 	}
 
 	timings = onfi_async_timing_mode_to_sdr_timings(mode);
Signature · 1 line
2.5.0
#1 lore raw

Hi Stefan,

Quoted 9 lines · Stefan Roese

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.

Quoted 6 lines
Cc Boris Brezillon <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Roy Spliet <[email protected]>
Cc Brian Norris <[email protected]>

This one has some whitespace errors, so you may want todo a v2:

[hans@shalem linux]$ git am ~/1.eml
Applying: mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings() /home/hans/projects/sunxi/linux/.git/rebase-apply/patch:29: space before tab in indent.
ONFI_FEATURE_ADDR_TIMING_MODE,
/home/hans/projects/sunxi/linux/.git/rebase-apply/patch:30: space before tab in indent.
feature);
warning: 2 lines add whitespace errors.

Regards,

Hans

Quoted 38 lines
---
  drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
  1 file changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/nand/sunxi_nand.c +11 -5
index f97a58d..6e7941b 100644
@@ -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,
-						ONFI_FEATURE_ADDR_TIMING_MODE,
-						feature);
-		if (ret)
-			return ret;
+		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);
+			chip->nand.select_chip(&chip->mtd, -1);
+			if (ret)
+				return ret;
+		}
  	}
 
  	timings = onfi_async_timing_mode_to_sdr_timings(mode);
Acked-by on v1 1/1
#3 lore raw
In reply to Stefan Roese

Hi Stephan,

Quoted 8 lines · On Fri, 28 Aug 2015 14:45:21 +0200 Stefan Roese <[email protected]> wrote:

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.

Thanks for the fix.

Quoted 44 lines
Cc Boris Brezillon <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Roy Spliet <[email protected]>
Cc Brian Norris <[email protected]>
---
 drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/nand/sunxi_nand.c +11 -5
index f97a58d..6e7941b 100644
@@ -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,
-						ONFI_FEATURE_ADDR_TIMING_MODE,
-						feature);
-		if (ret)
-			return ret;
+		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);
+			chip->nand.select_chip(&chip->mtd, -1);
+			if (ret)
+				return ret;
+		}
 	}
 
 	timings = onfi_async_timing_mode_to_sdr_timings(mode);
Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw
In reply to Hans de Goede
Quoted 21 lines · Hans de Goede

Hi Stefan,

Quoted 9 lines · Stefan Roese

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.

Quoted 6 lines
Cc Boris Brezillon <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Roy Spliet <[email protected]>
Cc Brian Norris <[email protected]>

This one has some whitespace errors, so you may want todo a v2:

Quoted 7 lines

[hans@shalem linux]$ git am ~/1.eml
Applying: mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings() /home/hans/projects/sunxi/linux/.git/rebase-apply/patch:29: space before tab in indent.
ONFI_FEATURE_ADDR_TIMING_MODE,
/home/hans/projects/sunxi/linux/.git/rebase-apply/patch:30: space before tab in indent.
feature);
warning: 2 lines add whitespace errors.

Fixed the whitespace myself and applied to l2-mtd.git/next