[U-Boot-Users] [PATCH] M18 flash (Sibley) support (attempt 2)

Hi Wolfgang,
Your patch was corrupted by your mailer which wrapped long lines. It cannot be applied.
Thank you very much for your reply. Gmail wrapped long lines. So I changed mail box. This is the second attempt.
The patch was verified on different kinds of NOR using Mainstone II platform - no issues are found on u-boot (versions 1.3.0-rc1 and 1.3.0-rc2).
Any comments and suggestions are welcome.
Thanks,
Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru Signed-off-by: Alexey Korolev akorolex@gmail.com ==================================================== --- u-boot-1.3.0-rc1.base/drivers/cfi_flash.c 2007-09-07 19:43:36.000000000 +0400 +++ u-boot-1.3.0-rc1/drivers/cfi_flash.c 2007-09-24 16:07:10.000000000 +0400 @@ -74,6 +74,7 @@ #define FLASH_CMD_PROTECT_CLEAR 0xD0 #define FLASH_CMD_CLEAR_STATUS 0x50 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8 +#define FLASH_CMD_WRITE_TO_BUFFER_EXT 0xE9 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
#define FLASH_STATUS_DONE 0x80 @@ -136,6 +137,7 @@ #define CFI_CMDSET_MITSU_STANDARD 256 #define CFI_CMDSET_MITSU_EXTENDED 257 #define CFI_CMDSET_SST 258 +#define CFI_CMDSET_INTEL_PROG_REGIONS 512
#ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */ # undef FLASH_CMD_RESET @@ -184,8 +186,8 @@ flash_info_t flash_info[CFG_MAX_FLASH_BA typedef unsigned long flash_sect_t;
static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c); -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf); -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf); +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd); static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect); static int flash_isequal (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); static int flash_isset (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); @@ -474,6 +476,7 @@ int flash_erase (flash_info_t * info, in for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd (info, sect, 0, FLASH_CMD_CLEAR_STATUS); @@ -522,6 +525,9 @@ void flash_print_info (flash_info_t * in info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: + printf ("Intel Prog Regions"); + break; case CFI_CMDSET_INTEL_STANDARD: printf ("Intel Standard"); break; @@ -771,6 +777,7 @@ static int flash_is_busy (flash_info_t * int retval;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE); @@ -825,6 +832,7 @@ static int flash_full_status_check (flas
retcode = flash_status_check (info, sector, tout, prompt); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: if ((retcode == ERR_OK) @@ -903,7 +911,7 @@ static void flash_add_byte (flash_info_t /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; uchar *cp = (uchar *) cmdbuf; @@ -913,13 +921,13 @@ static void flash_make_cmd (flash_info_t #else for (i = 1; i <= info->portwidth; i++) #endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + *cp++ = (i > info->chipwidth) ? '\0' : *((uchar *)&cmd + info->portwidth - i); }
/* * Write a proper sized command to the correct address */ -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd) +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd) {
volatile cfiptr_t addr; @@ -1090,6 +1098,7 @@ static void flash_read_jedec_ids (flash_ info->device_id2 = 0;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd(info, 0, 0, FLASH_CMD_RESET); @@ -1209,6 +1218,7 @@ ulong flash_get_size (ulong base, int ba flash_printqry (info, 0); #endif switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: default: @@ -1289,6 +1299,7 @@ ulong flash_get_size (ulong base, int ba * Only read protection status from supported devices (intel...) */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: info->protect[sect_cnt] = @@ -1377,6 +1388,7 @@ static int flash_write_cfiword (flash_in flag = disable_interrupts ();
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS); @@ -1422,15 +1434,19 @@ static int flash_write_cfibuffer (flash_ int retcode; volatile cfiptr_t src; volatile cfiptr_t dst; + uchar write_cmd;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: src.cp = cp; dst.cp = (uchar *) dest; sector = find_sector (info, dest); + write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ? + FLASH_CMD_WRITE_TO_BUFFER_EXT : FLASH_CMD_WRITE_TO_BUFFER; flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); - flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); + flash_write_cmd (info, sector, 0, write_cmd); if ((retcode = flash_status_check (info, sector, info->buffer_write_tout, "write to buffer")) == ERR_OK) { /* reduce the number of loops by the width of the port */ @@ -1451,7 +1467,7 @@ static int flash_write_cfibuffer (flash_ return ERR_INVAL; break; } - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT:

Dear Vasiliy,
in message E1IbE2e-000EEu-00.vasiliy-leonenko-mail-ru@f97.mail.ru you wrote:
Your patch was corrupted by your mailer which wrapped long lines. It cannot be applied.
Thank you very much for your reply. Gmail wrapped long lines. So I changed mail box. This is the second attempt.
The patch was verified on different kinds of NOR using Mainstone II platform - no issues are found on u-boot (versions 1.3.0-rc1 and 1.3.0-rc2).
Any comments and suggestions are welcome.
I'm a bit scared about your patch. Which tools do you use to create it?
@@ -184,8 +186,8 @@ flash_info_t flash_info[CFG_MAX_FLASH_BA typedef unsigned long flash_sect_t;
static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c); -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf); -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf); +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd); static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect); static int flash_isequal (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); static int flash_isset (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
I don't see any differences here. Why is this flagged as a change?
...
@@ -903,7 +911,7 @@ static void flash_add_byte (flash_info_t /*-----------------------------------------------------------------------
- make a proper sized command based on the port and chip widths
*/ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; uchar *cp = (uchar *) cmdbuf;
Ditto.
@@ -913,13 +921,13 @@ static void flash_make_cmd (flash_info_t
...
/*
- Write a proper sized command to the correct address
*/ -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd) +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd)
Ditto.
This smells somewhat fishy. Do you have an explanation what's going on here?
Best regards,
Wolfgang Denk

Hi Wolfgang
I'm a bit scared about your patch. Which tools do you use to create it?
Vasiliy used a "diff" tool.
@@ -184,8 +186,8 @@ flash_info_t flash_info[CFG_MAX_FLASH_BA typedef unsigned long flash_sect_t;
static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c); -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf); -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf); +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd); static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect); static int flash_isequal (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); static int flash_isset (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
I don't see any differences here. Why is this flagged as a change?
The difference is in type of "cmd" variable. ...
This smells somewhat fishy. Do you have an explanation what's going on here?
Let me explain. M18 flash is a flash with programming regions. It writes data by pages using buffered write method. According to the specification of buffered prog. for NOR chips. We should write CMD to start data write, length of buffer in words, buffer, and write confirm command. Unlike other NOR chips M18 has large programming buffer. The buffer size for M18 is 1024bytes i.e. 512 word. In existing code we transfer commands and buffer length using flash_write_cmd() and flash_make_cmd functions. The input type for cmd variable is uchar in these functions. If we want to write more than 255 words we will have write error. To avoid these issues we extended these two functions little bit to deal with larger commands.
Kind regards, Alexey

Dear Alexey,
in message 202cde0e0709280847r26684293yd0b9039c8254b75b@mail.gmail.com you wrote:
-static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf); -static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd); +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf); +static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, ulong cmd);
...
I don't see any differences here. Why is this flagged as a change?
The difference is in type of "cmd" variable.
Argh. You are right. Sorry for the noise.
Best regards,
Wolfgang Denk

Hi Vasily,
On Friday 28 September 2007, Vasiliy Leoenenko wrote:
Your patch was corrupted by your mailer which wrapped long lines. It cannot be applied.
Thank you very much for your reply. Gmail wrapped long lines. So I changed mail box. This is the second attempt.
The patch was verified on different kinds of NOR using Mainstone II platform - no issues are found on u-boot (versions 1.3.0-rc1 and 1.3.0-rc2).
Any comments and suggestions are welcome.
Sorry, but I really forgot about this patch. Could you please resend this patch against the current tot, since it doesn't apply cleanly anymore?
Thanks.
Best regards, 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@denx.de =====================================================================

Hi, Stefan
Sorry, but I really forgot about this patch. Could you please resend this patch against the current tot, since it doesn't apply cleanly anymore?
I prepared patch for u-boot version 1.3.2. Any comments and suggestions are welcome. Code(included below) was verified on Mainstone II board with M18 flash chip. Please don't forget to include it :)
Best regards, Vasiliy
Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru Signed-off-by: Alexey Korolev akorolex@gmail.com ==================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-22 16:26:29.000000000 +0400 @@ -77,6 +77,7 @@ #define FLASH_CMD_PROTECT_CLEAR 0xD0 #define FLASH_CMD_CLEAR_STATUS 0x50 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8 +#define FLASH_CMD_WRITE_BUFFER_PROG 0xE9 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
#define FLASH_STATUS_DONE 0x80 @@ -136,6 +137,7 @@ #define CFI_CMDSET_MITSU_STANDARD 256 #define CFI_CMDSET_MITSU_EXTENDED 257 #define CFI_CMDSET_SST 258 +#define CFI_CMDSET_INTEL_PROG_REGIONS 512
#ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */ # undef FLASH_CMD_RESET @@ -298,7 +300,7 @@ static inline void flash_unmap(flash_inf /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; uchar *cp = (uchar *) cmdbuf; @@ -308,7 +310,8 @@ static void flash_make_cmd (flash_info_t #else for (i = 1; i <= info->portwidth; i++) #endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + *cp++ = (i > info->chipwidth) ? '\0' : + *((uchar *)&cmd + info->portwidth - i); }
#ifdef DEBUG @@ -422,7 +425,7 @@ static ulong flash_read_long (flash_info * Write a proper sized command to the correct address */ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, - uint offset, uchar cmd) + uint offset, ulong cmd) {
void *addr; @@ -605,6 +608,7 @@ static int flash_is_busy (flash_info_t * int retval;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE); @@ -664,6 +668,7 @@ static int flash_full_status_check (flas
retcode = flash_status_check (info, sector, tout, prompt); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: if ((retcode == ERR_OK) @@ -792,6 +797,7 @@ static int flash_write_cfiword (flash_in flag = disable_interrupts ();
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS); @@ -846,6 +852,7 @@ static int flash_write_cfibuffer (flash_ int flag = 0; uint offset = 0; unsigned int shift; + uchar write_cmd;
switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -900,10 +907,13 @@ static int flash_write_cfibuffer (flash_ sector = find_sector (info, dest);
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: + write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ? + FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER; flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); - flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); + flash_write_cmd (info, sector, 0, write_cmd); retcode = flash_status_check (info, sector, info->buffer_write_tout, "write to buffer"); @@ -911,7 +921,7 @@ static int flash_write_cfibuffer (flash_ /* reduce the number of loops by the width of * the port */ cnt = len >> shift; - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -1038,6 +1048,7 @@ int flash_erase (flash_info_t * info, in for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd (info, sect, 0, @@ -1106,6 +1117,9 @@ void flash_print_info (flash_info_t * in info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: + printf ("Intel Prog Regions"); + break; case CFI_CMDSET_INTEL_STANDARD: printf ("Intel Standard"); break; @@ -1496,6 +1510,7 @@ static void flash_read_jedec_ids (flash_ info->device_id2 = 0;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_read_jedec_ids(info); @@ -1550,6 +1565,7 @@ static int flash_detect_legacy(ulong bas }
switch(info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: info->cmd_reset = FLASH_CMD_RESET; @@ -1745,6 +1761,7 @@ ulong flash_get_size (ulong base, int ba #endif
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_init(info, &qry); @@ -1822,6 +1839,7 @@ ulong flash_get_size (ulong base, int ba * supported devices (intel...) */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: info->protect[sect_cnt] =

Hi Vasily,
On Wednesday 23 April 2008, Vasiliy Leoenenko wrote:
Sorry, but I really forgot about this patch. Could you please resend this patch against the current tot, since it doesn't apply cleanly anymore?
I prepared patch for u-boot version 1.3.2. Any comments and suggestions are welcome. Code(included below) was verified on Mainstone II board with M18 flash chip. Please don't forget to include it :)
Unfortunately this breaks CFI support for "normal" AMD/Spansion FLASH equipped boards. On Sequoia with Spansion GL512 I get this after applying your patch:
U-Boot 1.3.2-01356-g8fa1348 (Apr 24 2008 - 17:05:55)
CPU: AMCC PowerPC 440EPx Rev. A at 528 MHz (PLB=132, OPB=66, EBC=66 MHz) Security/Kasumi support Bootstrap Option H - Boot ROM Location I2C (Addr 0x52) Internal PCI arbiter enabled, PCI async ext clock used 32 kB I-Cache 32 kB D-Cache Board: Sequoia - AMCC PPC440EPx Evaluation Board, Rev. F, PCI=66 MHz I2C: ready DTT: 1 is 29 C DRAM: 256 MB FLASH: CFI: Unknown command set 0x0 *** failed *** ### ERROR ### Please RESET the board ###
:-(
Please fix this and resubmit. Best would be if you could test it on a board with Spansion CFI FLASH's too.
Thanks.
Best regards, 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@denx.de =====================================================================

Hi Stefan
Unfortunately this breaks CFI support for "normal" AMD/Spansion FLASH equipped boards. On Sequoia with Spansion GL512 I get this after applying your patch:
Please fix this and resubmit. Best would be if you could test it on a board with Spansion CFI FLASH's too.
I investigated the reproted issue and I think I've corrected it. The issue caused by my incorect conversion of cmd value in flash_make_cmd function. So we improved the procedure of conversion. I think it will be better to sent two patches: The first patch adds support of long commands and fixes conversion issues. The second patch adds M18 family command set support.
Patches were tested on Mainstone II board and two flashes: M18 portwidth=16 chipwidth=16 P30 portwidth=32 chipwidth=16 Also I tested in simulation the conversion algorithms to make sure that it works fine. Unforunately I have no abiliy to test my patch on different borads and width Spansion CFI flash.
The next two messages will contain patches.
Best regards Vasiliy

On 16:14 Tue 29 Apr , Vasiliy Leoenenko wrote:
Hi Stefan
Unfortunately this breaks CFI support for "normal" AMD/Spansion FLASH equipped boards. On Sequoia with Spansion GL512 I get this after applying your patch:
Please fix this and resubmit. Best would be if you could test it on a board with Spansion CFI FLASH's too.
I investigated the reproted issue and I think I've corrected it. The issue caused by my incorect conversion of cmd value in flash_make_cmd function. So we improved the procedure of conversion. I think it will be better to sent two patches: The first patch adds support of long commands and fixes conversion issues. The second patch adds M18 family command set support.
Patches were tested on Mainstone II board and two flashes: M18 portwidth=16 chipwidth=16 P30 portwidth=32 chipwidth=16 Also I tested in simulation the conversion algorithms to make sure that it works fine. Unforunately I have no abiliy to test my patch on different borads and width Spansion CFI flash.
You could test it on qemu_mips which use an amd cfi flash or with few modif in qemu an intel falsh
Best Regards, J.

The first patch (support of long commands):
=================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-29 15:57:51.000000000 +0400 @@ -298,17 +298,29 @@ static inline void flash_unmap(flash_inf /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; + int cpofft; uchar *cp = (uchar *) cmdbuf; + uchar cp_val;
#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) - for (i = info->portwidth; i > 0; i--) + for (i = sizeof(cfiword_t); i > 0; i--) + { + cpofft=(i-1); #else - for (i = 1; i <= info->portwidth; i++) -#endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + for (i = 1; i <= sizeof(cfiword_t); i++) + { + cpofft=(sizeof(cfiword_t)-i); +#endif + if( cpofft%info->chipwidth >= sizeof(ulong) || cpofft>=info->portwidth) + cp_val = 0x00; + else + cp_val = *((uchar*)&cmd + cpofft%info->chipwidth); + + cp[i-1] = cp_val; + } }
#ifdef DEBUG @@ -422,7 +434,7 @@ static ulong flash_read_long (flash_info * Write a proper sized command to the correct address */ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, - uint offset, uchar cmd) + uint offset, ulong cmd) {
void *addr; @@ -911,7 +923,7 @@ static int flash_write_cfibuffer (flash_ /* reduce the number of loops by the width of * the port */ cnt = len >> shift; - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT:

On Tuesday 29 April 2008, Vasiliy Leoenenko wrote:
The first patch (support of long commands):
I like the idea of splitting this patch up in two separate patches/emails. But please provide a descriptive subject and a short description that can will be added to the git repository as commit text for each patch. And don't forget your Signed-off-by line.
Please take a look at other patches on the list how this should be done. Best would be if you could use the git tools to create (and send) the patches.
Thanks.
Some further remarks below:
=================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-29 15:57:51.000000000 +0400 @@ -298,17 +298,29 @@ static inline void flash_unmap(flash_inf /*-----------------------------------------------------------------------
- make a proper sized command based on the port and chip widths
*/ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i;
- int cpofft; uchar *cp = (uchar *) cmdbuf;
- uchar cp_val;
#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
- for (i = info->portwidth; i > 0; i--)
- for (i = sizeof(cfiword_t); i > 0; i--)
- {
+ for (i = sizeof(cfiword_t); i > 0; i--) {
The code down below has some coding style issues too. Please
cpofft=(i-1);
+ cpofft = i - 1;
The code down below has some coding style issues too. Please try to be more careful here.
And the resulting code looks like this:
#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) for (i = sizeof(cfiword_t); i > 0; i--) { cpofft=(i-1); #else for (i = 1; i <= sizeof(cfiword_t); i++) { cpofft=(sizeof(cfiword_t)-i); #endif if( cpofft%info->chipwidth >= sizeof(ulong) || cpofft>=info->portwidth) cp_val = 0x00; else cp_val = *((uchar*)&cmd + cpofft%info->chipwidth); cp[i-1] = cp_val; }
Apart from the coding-style issues, this is getting quite complex and unclear. At least to me. Are you sure that this can't be written differently to make it easier to understand?
Thanks.
Best regards, 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@denx.de =====================================================================

In message E1JqokH-000IQ6-00.vasiliy-leonenko-mail-ru@f128.mail.ru you wrote:
The first patch (support of long commands):
That's not exactly a good commit message.
And your signed-off-by line is missing.
And the coding style is broken. There are trailing white spaces, and...
#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
- for (i = info->portwidth; i > 0; i--)
- for (i = sizeof(cfiword_t); i > 0; i--)
- {
... bad brace style here and elsewhere.
Best regards,
Wolfgang Denk

Hi, Wolfgang
Sorry for codding-style issues in previous sent patches. Next two messages will contain patches with corrected codding-style, descriptions and signed-off lines to commit.
Best regards Vasiliy

cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max value size of uchar. For example all M18 family chips use 0x1ff command in buffered write mode as value of program loops count.
Signed-off-by: Alexey Korolev akorolev@infradead.org Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru ====================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-29 17:29:07.000000000 +0400 @@ -298,17 +298,32 @@ static inline void flash_unmap(flash_inf /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; + int cword_offset; + int perchip_offset; uchar *cp = (uchar *) cmdbuf; + uchar val;
#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) - for (i = info->portwidth; i > 0; i--) + for (i = sizeof(cfiword_t); i > 0; i--){ + cword_offset = i - 1; #else - for (i = 1; i <= info->portwidth; i++) + for (i = 1; i <= sizeof(cfiword_t); i++){ + cword_offset = sizeof(cfiword_t) - i; #endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + perchip_offset = cword_offset % info->chipwidth; + + /* If current offset inside one chip is over command size or + current offset is over portwidth fill data by 0x00 */ + if(perchip_offset >= sizeof(ulong) || cword_offset >= info->portwidth) + val = 0x00; + else + val = *((uchar*)&cmd + perchip_offset); + + cp[i - 1] = val; + } }
#ifdef DEBUG @@ -422,7 +437,7 @@ static ulong flash_read_long (flash_info * Write a proper sized command to the correct address */ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, - uint offset, uchar cmd) + uint offset, ulong cmd) {
void *addr; @@ -911,7 +926,7 @@ static int flash_write_cfibuffer (flash_ /* reduce the number of loops by the width of * the port */ cnt = len >> shift; - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT:

Hi Vasiliy,
Vasiliy Leoenenko wrote:
cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max value size of uchar. For example all M18 family chips use 0x1ff command in buffered write mode as value of program loops count.
Unfortunately this patch still breaks CFI support on sequoia board:
U-Boot 1.3.3-rc1-00021-g0e715a7-dirty (Apr 29 2008 - 16:55:18)
CPU: AMCC PowerPC 440EPx Rev. A at 330 MHz (PLB=132, OPB=66, EBC=66 MHz) Security/Kasumi support Bootstrap Option B - Boot ROM Location EBC (16 bits) Internal PCI arbiter enabled, PCI async ext clock used 32 kB I-Cache 32 kB D-Cache Board: Sequoia - AMCC PPC440EPx Evaluation Board, Rev. F, PCI=33 MHz I2C: ready DTT: 1 is 36 C DRAM: 256 MB FLASH: CFI: Unknown command set 0x0 *** failed *** ### ERROR ### Please RESET the board ###
Best regards, Anatolij

Hi All
I corrected this issue with the help of Anatolij. I checked this patches on Mainstone II board width Intel M18 chip(16x16) and P30 chip (32x16). Next two messages will contain corrected patches.
Best Regards Vasiliy

cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max value size of uchar. For example all M18 family chips use 0x1ff command in buffered write mode as value of program loops count.
Signed-off-by: Alexey Korolev akorolev@infradead.org Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru ====================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-05-07 15:51:18.000000000 +0400 @@ -298,17 +298,25 @@ static inline void flash_unmap(flash_inf /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; + int cword_offset; + int cp_offset; + uchar val; uchar *cp = (uchar *) cmdbuf;
+ for (i = info->portwidth; i > 0; i--){ + cword_offset = (info->portwidth-i)%info->chipwidth; #if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) - for (i = info->portwidth; i > 0; i--) + cp_offset = info->portwidth - i; + val = *((uchar*)&cmd + cword_offset); #else - for (i = 1; i <= info->portwidth; i++) + cp_offset = i - 1; + val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1); #endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val; + } }
#ifdef DEBUG @@ -422,7 +430,7 @@ static ulong flash_read_long (flash_info * Write a proper sized command to the correct address */ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, - uint offset, uchar cmd) + uint offset, ulong cmd) {
void *addr; @@ -911,7 +919,7 @@ static int flash_write_cfibuffer (flash_ /* reduce the number of loops by the width of * the port */ cnt = len >> shift; - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -953,7 +961,7 @@ static int flash_write_cfibuffer (flash_ #endif flash_write_cmd(info, sector, offset, AMD_CMD_WRITE_TO_BUFFER); cnt = len >> shift; - flash_write_cmd(info, sector, offset, (uchar)cnt - 1); + flash_write_cmd(info, sector, offset, cnt - 1);
switch (info->portwidth) { case FLASH_CFI_8BIT:

On Wednesday 07 May 2008, Vasiliy Leoenenko wrote:
cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max value size of uchar. For example all M18 family chips use 0x1ff command in buffered write mode as value of program loops count.
Applied to u-boot-cfi-flash. Thanks.
Best regards, 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@denx.de =====================================================================

cfi_flash: enable M18 flash chips family support.
Added new command set ID. Buffered write command processing is changed in order to support M18 flash chips family.
Signed-off-by: Alexey Korolev akorolev@infradead.org Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru ============================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-05-07 15:51:18.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-05-07 16:35:42.000000000 +0400 @@ -76,7 +76,9 @@ #define FLASH_CMD_PROTECT_SET 0x01 #define FLASH_CMD_PROTECT_CLEAR 0xD0 #define FLASH_CMD_CLEAR_STATUS 0x50 +#define FLASH_CMD_READ_STATUS 0x70 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8 +#define FLASH_CMD_WRITE_BUFFER_PROG 0xE9 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
#define FLASH_STATUS_DONE 0x80 @@ -136,6 +138,7 @@ #define CFI_CMDSET_MITSU_STANDARD 256 #define CFI_CMDSET_MITSU_EXTENDED 257 #define CFI_CMDSET_SST 258 +#define CFI_CMDSET_INTEL_PROG_REGIONS 512
#ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */ # undef FLASH_CMD_RESET @@ -613,6 +616,7 @@ static int flash_is_busy (flash_info_t * int retval;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE); @@ -672,6 +676,7 @@ static int flash_full_status_check (flas
retcode = flash_status_check (info, sector, tout, prompt); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: if ((retcode == ERR_OK) @@ -800,6 +805,7 @@ static int flash_write_cfiword (flash_in flag = disable_interrupts ();
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS); @@ -854,6 +860,7 @@ static int flash_write_cfibuffer (flash_ int flag = 0; uint offset = 0; unsigned int shift; + uchar write_cmd;
switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -908,10 +915,14 @@ static int flash_write_cfibuffer (flash_ sector = find_sector (info, dest);
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: + write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ? + FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER; flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); - flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); + flash_write_cmd (info, sector, 0, FLASH_CMD_READ_STATUS); + flash_write_cmd (info, sector, 0, write_cmd); retcode = flash_status_check (info, sector, info->buffer_write_tout, "write to buffer"); @@ -961,7 +972,7 @@ static int flash_write_cfibuffer (flash_ #endif flash_write_cmd(info, sector, offset, AMD_CMD_WRITE_TO_BUFFER); cnt = len >> shift; - flash_write_cmd(info, sector, offset, cnt - 1); + flash_write_cmd(info, sector, offset, (uchar)cnt - 1);
switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -1046,6 +1057,7 @@ int flash_erase (flash_info_t * info, in for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd (info, sect, 0, @@ -1114,6 +1126,9 @@ void flash_print_info (flash_info_t * in info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: + printf ("Intel Prog Regions"); + break; case CFI_CMDSET_INTEL_STANDARD: printf ("Intel Standard"); break; @@ -1504,6 +1519,7 @@ static void flash_read_jedec_ids (flash_ info->device_id2 = 0;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_read_jedec_ids(info); @@ -1558,6 +1574,7 @@ static int flash_detect_legacy(ulong bas }
switch(info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: info->cmd_reset = FLASH_CMD_RESET; @@ -1753,6 +1770,7 @@ ulong flash_get_size (ulong base, int ba #endif
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_init(info, &qry); @@ -1830,6 +1848,7 @@ ulong flash_get_size (ulong base, int ba * supported devices (intel...) */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: info->protect[sect_cnt] =

On Wednesday 07 May 2008, Vasiliy Leoenenko wrote:
cfi_flash: enable M18 flash chips family support.
Added new command set ID. Buffered write command processing is changed in order to support M18 flash chips family.
Applied to u-boot-cfi-flash. Thanks.
Best regards, 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@denx.de =====================================================================

cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max value size of uchar. For example all M18 family chips use 0x1ff command in buffered write mode as value of program loops count.
Signed-off-by: Alexey Korolev akorolev@infradead.org Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru ====================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-21 02:39:38.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-05-07 15:51:18.000000000 +0400 @@ -298,17 +298,25 @@ static inline void flash_unmap(flash_inf /*----------------------------------------------------------------------- * make a proper sized command based on the port and chip widths */ -static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) +static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf) { int i; + int cword_offset; + int cp_offset; + uchar val; uchar *cp = (uchar *) cmdbuf;
+ for (i = info->portwidth; i > 0; i--){ + cword_offset = (info->portwidth-i)%info->chipwidth; #if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) - for (i = info->portwidth; i > 0; i--) + cp_offset = info->portwidth - i; + val = *((uchar*)&cmd + cword_offset); #else - for (i = 1; i <= info->portwidth; i++) + cp_offset = i - 1; + val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1); #endif - *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd; + cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val; + } }
#ifdef DEBUG @@ -422,7 +430,7 @@ static ulong flash_read_long (flash_info * Write a proper sized command to the correct address */ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, - uint offset, uchar cmd) + uint offset, ulong cmd) {
void *addr; @@ -911,7 +919,7 @@ static int flash_write_cfibuffer (flash_ /* reduce the number of loops by the width of * the port */ cnt = len >> shift; - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + flash_write_cmd (info, sector, 0, cnt - 1); while (cnt-- > 0) { switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -953,7 +961,7 @@ static int flash_write_cfibuffer (flash_ #endif flash_write_cmd(info, sector, offset, AMD_CMD_WRITE_TO_BUFFER); cnt = len >> shift; - flash_write_cmd(info, sector, offset, (uchar)cnt - 1); + flash_write_cmd(info, sector, offset, cnt - 1);
switch (info->portwidth) { case FLASH_CFI_8BIT:

Hi All
The last message with patch was sent by mistake. Correct patches were sent in two messages before.
Best Regards Vasiliy

On Monday 12 May 2008, Vasiliy Leonenko wrote:
The last message with patch was sent by mistake. Correct patches were sent in two messages before.
Understood. I'll recheck this patchset after 1.3.3 is released.
Thanks.
Best regards, 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@denx.de =====================================================================

cfi_flash: enable M18 flash chips family support.
Added new command set ID. Buffered write command processing is changed in order to support M18 flash chips family.
Signed-off-by: Alexey Korolev akorolev@infradead.org Signed-off-by: Vasiliy Leonenko vasiliy.leonenko@mail.ru ============================================================== diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-29 17:32:47.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-29 17:32:59.000000000 +0400 @@ -76,7 +76,9 @@ #define FLASH_CMD_PROTECT_SET 0x01 #define FLASH_CMD_PROTECT_CLEAR 0xD0 #define FLASH_CMD_CLEAR_STATUS 0x50 +#define FLASH_CMD_READ_STATUS 0x70 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8 +#define FLASH_CMD_WRITE_BUFFER_PROG 0xE9 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
#define FLASH_STATUS_DONE 0x80 @@ -136,6 +138,7 @@ #define CFI_CMDSET_MITSU_STANDARD 256 #define CFI_CMDSET_MITSU_EXTENDED 257 #define CFI_CMDSET_SST 258 +#define CFI_CMDSET_INTEL_PROG_REGIONS 512
#ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */ # undef FLASH_CMD_RESET @@ -620,6 +623,7 @@ static int flash_is_busy (flash_info_t * int retval;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE); @@ -679,6 +683,7 @@ static int flash_full_status_check (flas
retcode = flash_status_check (info, sector, tout, prompt); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: if ((retcode == ERR_OK) @@ -807,6 +812,7 @@ static int flash_write_cfiword (flash_in flag = disable_interrupts ();
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS); @@ -861,6 +867,7 @@ static int flash_write_cfibuffer (flash_ int flag = 0; uint offset = 0; unsigned int shift; + uchar write_cmd;
switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -915,10 +922,14 @@ static int flash_write_cfibuffer (flash_ sector = find_sector (info, dest);
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: + write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ? + FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER; flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); - flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); + flash_write_cmd (info, sector, 0, FLASH_CMD_READ_STATUS); + flash_write_cmd (info, sector, 0, write_cmd); retcode = flash_status_check (info, sector, info->buffer_write_tout, "write to buffer"); @@ -1053,6 +1064,7 @@ int flash_erase (flash_info_t * info, in for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd (info, sect, 0, @@ -1121,6 +1133,9 @@ void flash_print_info (flash_info_t * in info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: + printf ("Intel Prog Regions"); + break; case CFI_CMDSET_INTEL_STANDARD: printf ("Intel Standard"); break; @@ -1511,6 +1526,7 @@ static void flash_read_jedec_ids (flash_ info->device_id2 = 0;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_read_jedec_ids(info); @@ -1565,6 +1581,7 @@ static int flash_detect_legacy(ulong bas }
switch(info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: info->cmd_reset = FLASH_CMD_RESET; @@ -1760,6 +1777,7 @@ ulong flash_get_size (ulong base, int ba #endif
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_init(info, &qry); @@ -1837,6 +1855,7 @@ ulong flash_get_size (ulong base, int ba * supported devices (intel...) */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: info->protect[sect_cnt] =

The second patch (M18 family command set support) ================================================================ diff -aupNr a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c --- a/drivers/mtd/cfi_flash.c 2008-04-29 15:57:51.000000000 +0400 +++ b/drivers/mtd/cfi_flash.c 2008-04-29 15:59:04.000000000 +0400 @@ -76,7 +76,9 @@ #define FLASH_CMD_PROTECT_SET 0x01 #define FLASH_CMD_PROTECT_CLEAR 0xD0 #define FLASH_CMD_CLEAR_STATUS 0x50 +#define FLASH_CMD_READ_STATUS 0x70 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8 +#define FLASH_CMD_WRITE_BUFFER_PROG 0xE9 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
#define FLASH_STATUS_DONE 0x80 @@ -136,6 +138,7 @@ #define CFI_CMDSET_MITSU_STANDARD 256 #define CFI_CMDSET_MITSU_EXTENDED 257 #define CFI_CMDSET_SST 258 +#define CFI_CMDSET_INTEL_PROG_REGIONS 512
#ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */ # undef FLASH_CMD_RESET @@ -617,6 +620,7 @@ static int flash_is_busy (flash_info_t * int retval;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE); @@ -676,6 +680,7 @@ static int flash_full_status_check (flas
retcode = flash_status_check (info, sector, tout, prompt); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: if ((retcode == ERR_OK) @@ -804,6 +809,7 @@ static int flash_write_cfiword (flash_in flag = disable_interrupts ();
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS); @@ -858,6 +864,7 @@ static int flash_write_cfibuffer (flash_ int flag = 0; uint offset = 0; unsigned int shift; + uchar write_cmd;
switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -912,10 +919,14 @@ static int flash_write_cfibuffer (flash_ sector = find_sector (info, dest);
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: + write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ? + FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER; flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); - flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); + flash_write_cmd (info, sector, 0, FLASH_CMD_READ_STATUS); + flash_write_cmd (info, sector, 0, write_cmd); retcode = flash_status_check (info, sector, info->buffer_write_tout, "write to buffer"); @@ -1050,6 +1061,7 @@ int flash_erase (flash_info_t * info, in for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: flash_write_cmd (info, sect, 0, @@ -1118,6 +1130,9 @@ void flash_print_info (flash_info_t * in info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: + printf ("Intel Prog Regions"); + break; case CFI_CMDSET_INTEL_STANDARD: printf ("Intel Standard"); break; @@ -1508,6 +1523,7 @@ static void flash_read_jedec_ids (flash_ info->device_id2 = 0;
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_read_jedec_ids(info); @@ -1562,6 +1578,7 @@ static int flash_detect_legacy(ulong bas }
switch(info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: info->cmd_reset = FLASH_CMD_RESET; @@ -1757,6 +1774,7 @@ ulong flash_get_size (ulong base, int ba #endif
switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: case CFI_CMDSET_INTEL_EXTENDED: cmdset_intel_init(info, &qry); @@ -1834,6 +1852,7 @@ ulong flash_get_size (ulong base, int ba * supported devices (intel...) */ switch (info->vendor) { + case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_EXTENDED: case CFI_CMDSET_INTEL_STANDARD: info->protect[sect_cnt] =
participants (7)
-
Alexey Korolev
-
Anatolij Gustschin
-
Jean-Christophe PLAGNIOL-VILLARD
-
Stefan Roese
-
Vasiliy Leoenenko
-
Vasiliy Leonenko
-
Wolfgang Denk