Skip to contentSkip to conversation

Add sync at the end of flash_write_cmd for MPC86xx

PATCH New Haiying Wang 5 participants 8 messages Feb 5, 2007 – Feb 6, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Add sync at the end of flash_write_cmd for MPC86xx
to ensure write command are really finished before reading data

---
According to Tolunay's first suggestion, this patch for cfi_flash driver fixed the flash operation error on MPC8641HPCN board. Since there is not such flash error reported on 85xx, 83xx platform and as Tolunay said, there is not a PowerPC macro to define, I just use CONFIG_MPC86xx for now. I also tested his second suggestion(adding udelay directly after reset command), but flash still failed to work.

Based on my tests before (I added udelay after the flash_write_cmd() which switched flash to CFI read mode, and it worked as well) and the test with this patch, I think that most possible fix of this issue should be that we should make sure command has been fully executed before return to data read mode(as in his first suggestion). So please review this patch below:

 drivers/cfi_flash.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/cfi_flash.c +3 -0
index 696f9a4..a93e94d 100644
@@ -971,6 +971,9 @@ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset
 #endif
 		break;
 	}
+#ifdef CONFIG_MPC86xx
+	asm("sync;");
+#endif
 }
 
 static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect)
#1 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Quoted 11 lines · Haiying Wang

Add sync at the end of flash_write_cmd for MPC86xx
to ensure write command are really finished before reading data

---
According to Tolunay's first suggestion, this patch for cfi_flash driver fixed the flash operation error on MPC8641HPCN board. Since there is not such flash error reported on 85xx, 83xx platform and as Tolunay said, there is not a PowerPC macro to define, I just use CONFIG_MPC86xx for now. I also tested his second suggestion(adding udelay directly after reset command), but flash still failed to work.

Given that this is already looks to have been an issue on blackfin and now PPC (and probably some MIPS also), I would suggest it's better to define a macro in the CPU definition for your arch and blackfin and do a generic test like so:

#ifdef SYNC
    SYNC;

#endif

Maybe you can come up with a more descriptive name than SYNC :-)

I had e-mailed Tolunay about this and he concurred.

Signature · 2 lines
Hardware, n.:
        The parts of a computer system that can be kicked.
#2 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Quoted 8 lines · Andrew Dyer

Given that this is already looks to have been an issue on blackfin and now PPC (and probably some MIPS also), I would suggest it's better to define a macro in the CPU definition for your arch and blackfin and do a generic test like so:

#ifdef SYNC
    SYNC;

#endif

Better to drop the #ifdef and just add empty stubs for the arches that don't need it.

Haavard

#3 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Quoted 6 lines · Haavard Skinnemoen
Quoted 3 lines
#ifdef SYNC
    SYNC;

#endif

Better to drop the #ifdef and just add empty stubs for the arches that don't need it.

Yes, please do it this way.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
=====================================================================

#4 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Quoted 8 lines · Stefan Roese
Quoted 5 lines · Haavard Skinnemoen
Quoted 3 lines
#ifdef SYNC
    SYNC;

#endif

Better to drop the #ifdef and just add empty stubs for the arches that don't need it.

Yes, please do it this way.

I think defining the SYNC macro in architecture files is probably better but #ifdef wrapper would avoid touching architectures that does not have SYNC concept.

I guess at this moment we need a real (not a stub) SYNC for all PowerPC variants and Blackfin. I do not know if other architectures supported by U-Boot have such instructions in instruction set. So, it is probably the best time for those architecture people to speak up.

I think this patch should be independent than the cfi_flash.c patch. cfi_flash.c patch will depend on this patch applied first.

Best regards,
Tolunay

#5 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

Quoted 4 lines · Tolunay Orkun

I guess at this moment we need a real (not a stub) SYNC for all PowerPC variants and Blackfin. I do not know if other architectures supported by U-Boot have such instructions in instruction set. So, it is probably the best time for those architecture people to speak up.

AVR32 does have a sync instruction, but I don't think it's needed here. Please just add a stub and I'll patch in a real implementation later if it turns out to be necessary.

Haavard

#6 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

In reply to Andrew Dyer
Quoted 5 lines

Given that this is already looks to have been an issue on blackfin and now PPC (and probably some MIPS also), I would suggest it's better to define a macro in the CPU definition for your arch and blackfin and do a generic test like so:

Quoted 8 lines
#ifdef SYNC
    SYNC;

#endif

Maybe you can come up with a more descriptive name than SYNC :-)

I had e-mailed Tolunay about this and he concurred.

It sounds good to me:-). So, should I patch my arch after your suggested patch is applied?

Haiying

#7 lore raw

PATCH 1/1 Add sync at the end of flash_write_cmd for MPC86xx

In reply to Haiying Wang
Quoted 5 lines · Haiying Wang
drivers/cfi_flash.c +0 -0
index 696f9a4..a93e94d 100644

drivers/cfi_flash.c static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset · line 979

Quoted 9 lines
drivers/cfi_flash.c +3 -0
@@ -971,6 +971,9 @@ static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset
 #endif
 		break;
 	}
+#ifdef CONFIG_MPC86xx
+	asm("sync;");
+#endif
 }
 
 static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect)

I think for consistency of the code, you should either relocate blackfin sync instruction to the end or add MPC86xx sync instructions to each case just like blackfin does.

Having addressed that, I think this patch would be OK for me except that as you have probably seen the discussion in the list, it will be better to define SYNC macros in cpu architecture files and call SYNC; instead fo asm("sync;");

So, please create an independent patch that adds SYNC to all CPU architectures (dummy stub if architecture does not have such feature) and submit that patch first. Refer to other email for details. Right now all PowerPC variants and Blackfin needs this but more might come.

Having submitted that patch, please modify this patch about to use SYNC; and submit as well.

I know it is probably a bit more work than you wished for but we should do this the right way.

Tolunay