All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-BOOT] cfi_flash.c fails to program NOR Flash SST39LF040
Date: Mon, 6 Jul 2009 10:58:50 +0200	[thread overview]
Message-ID: <200907061058.50988.sr@denx.de> (raw)
In-Reply-To: <ec1aee9f0907030211i3c8dde33nb0a4b8dbb526c0e1@mail.gmail.com>

Hi Po-Yu Chuang,

On Friday 03 July 2009 11:11:55 Po-Yu Chuang wrote:
> > Yes, I understand your problem and it needs to get fixed. But your
> > original patch changed the unlock address not only for this "legacy"
> > FLASH type but for all AMD type FLASH chips. And I'm not sure if this is
> > correct. Meaning if the AMD/Spansion chips will accept these unlock
> > addresses.
> >
> > Perhaps you could check some data-sheets (some older and more recent
> > Spansion CFI chips) which unlock addresses should be used here.
>
> After checked the data sheets of jedec flash currently supported in u-boot
> -
>
> SST 39LF020
> AMD AM29LV040B
> SST 39LF040
> ST Micro M29W040B
> AMD AM29LV400BB
> AMD AM29LV800BB
>
> I found that the addresses to program a word of these chips are
> related to 0 (not sector base).
>
> And in flash_erase() in drivers/mtd/cfi_flash.c
>
> 			case CFI_CMDSET_AMD_STANDARD:
> 			case CFI_CMDSET_AMD_EXTENDED:
> 				flash_unlock_seq (info, sect);
> 				flash_write_cmd (info, sect,
> 						info->addr_unlock1,
> 						AMD_CMD_ERASE_START);
> 				flash_unlock_seq (info, sect);
> 				flash_write_cmd (info, sect, 0,
> 						 AMD_CMD_ERASE_SECTOR);
> 				break;
> #ifdef CONFIG_FLASH_CFI_LEGACY
> 			case CFI_CMDSET_AMD_LEGACY:
> 				flash_unlock_seq (info, 0);
> 				flash_write_cmd (info, 0, info->addr_unlock1,
> 						AMD_CMD_ERASE_START);
> 				flash_unlock_seq (info, 0);
> 				flash_write_cmd (info, sect, 0,
> 						AMD_CMD_ERASE_SECTOR);
> 				break;
> #endif
>
> It look like CFI_CMDSET_AMD_LEGACY use base 0
> CFI_CMDSET_AMD_STANDARD and CFI_CMDSET_AMD_EXTENDED use sector base
> for erase.
>
> It probably is the same case while programing a word.
>
> The following patch might be feasible.
> However, I don't have those chips for testing.

I don't have those chips either, but your patch below looks like an 
improvement to me. So I suggest that we push this patch into mainline so that 
other users with such chips can easily test it.

Could you please sent the patch below as a proper patch with a description 
your s-o-b line again to the list?

Thanks.

Best regards,
Stefan

> regards,
> Po-Yu Chuang
>
> ---
>  drivers/mtd/cfi_flash.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> index d0732f5..81ac5d3 100644
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -835,14 +835,19 @@ static int flash_write_cfiword (flash_info_t *
> info, ulong dest,
>  		break;
>  	case CFI_CMDSET_AMD_EXTENDED:
>  	case CFI_CMDSET_AMD_STANDARD:
> -#ifdef CONFIG_FLASH_CFI_LEGACY
> -	case CFI_CMDSET_AMD_LEGACY:
> -#endif
>  		sect = find_sector(info, dest);
>  		flash_unlock_seq (info, sect);
>  		flash_write_cmd (info, sect, info->addr_unlock1, AMD_CMD_WRITE);
>  		sect_found = 1;
>  		break;
> +#ifdef CONFIG_FLASH_CFI_LEGACY
> +	case CFI_CMDSET_AMD_LEGACY:
> +		sect = find_sector(info, dest);
> +		flash_unlock_seq (info, 0);
> +		flash_write_cmd (info, 0, info->addr_unlock1, AMD_CMD_WRITE);
> +		sect_found = 1;
> +		break;
> +#endif
>  	}
>
>  	switch (info->portwidth) {

Viele Gr??e,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

      reply	other threads:[~2009-07-06  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-24  2:39 [U-Boot] [U-BOOT] cfi_flash.c fails to program NOR Flash SST39LF040 Po-Yu Chuang
2009-04-27  7:31 ` Stefan Roese
2009-04-28  3:12   ` Po-Yu Chuang
2009-07-03  7:37     ` Po-Yu Chuang
2009-07-03  7:46       ` Stefan Roese
2009-07-03  9:11         ` Po-Yu Chuang
2009-07-06  8:58           ` Stefan Roese [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907061058.50988.sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.