linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings()
@ 2015-08-28 12:45 Stefan Roese
  2015-08-28 13:18 ` Hans de Goede
  2015-08-28 13:19 ` Boris Brezillon
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Roese @ 2015-08-28 12:45 UTC (permalink / raw)
  To: linux-mtd
  Cc: Boris Brezillon, Hans de Goede, Maxime Ripard, Roy Spliet,
	Brian Norris

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@denx.de>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Roy Spliet <r.spliet@ultimaker.com>
Cc: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f97a58d..6e7941b 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,
-						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);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings()
  2015-08-28 12:45 [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings() Stefan Roese
@ 2015-08-28 13:18 ` Hans de Goede
  2015-09-09 23:53   ` Brian Norris
  2015-08-28 13:19 ` Boris Brezillon
  1 sibling, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2015-08-28 13:18 UTC (permalink / raw)
  To: Stefan Roese, linux-mtd
  Cc: Boris Brezillon, Maxime Ripard, Roy Spliet, Brian Norris

Hi Stefan,

On 28-08-15 14:45, Stefan Roese 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.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Cc: Roy Spliet <r.spliet@ultimaker.com>
> Cc: Brian Norris <computersforpeace@gmail.com>

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


> ---
>   drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f97a58d..6e7941b 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,
> -						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);
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings()
  2015-08-28 12:45 [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings() Stefan Roese
  2015-08-28 13:18 ` Hans de Goede
@ 2015-08-28 13:19 ` Boris Brezillon
  1 sibling, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2015-08-28 13:19 UTC (permalink / raw)
  To: Stefan Roese
  Cc: linux-mtd, Hans de Goede, Maxime Ripard, Roy Spliet, Brian Norris

Hi Stephan,

On Fri, 28 Aug 2015 14:45:21 +0200
Stefan Roese <sr@denx.de> 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.

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Cc: Roy Spliet <r.spliet@ultimaker.com>
> Cc: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/nand/sunxi_nand.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f97a58d..6e7941b 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,
> -						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);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings()
  2015-08-28 13:18 ` Hans de Goede
@ 2015-09-09 23:53   ` Brian Norris
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2015-09-09 23:53 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Stefan Roese, linux-mtd, Boris Brezillon, Maxime Ripard,
	Roy Spliet

On Fri, Aug 28, 2015 at 03:18:11PM +0200, Hans de Goede wrote:
> Hi Stefan,
> 
> On 28-08-15 14:45, Stefan Roese 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.
> >
> >Signed-off-by: Stefan Roese <sr@denx.de>
> >Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
> >Cc: Hans de Goede <hdegoede@redhat.com>
> >Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> >Cc: Roy Spliet <r.spliet@ultimaker.com>
> >Cc: Brian Norris <computersforpeace@gmail.com>
> 
> 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-09 23:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-28 12:45 [PATCH] mtd: nand: sunxi_nand.c: Select the chip in sunxi_nand_chip_init_timings() Stefan Roese
2015-08-28 13:18 ` Hans de Goede
2015-09-09 23:53   ` Brian Norris
2015-08-28 13:19 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).