
Hi Wolfgang Denk,
On Sun, 25 Dec 2005 11:19:20 +0100, Wolfgang Denk wd@denx.de wrote:
In message 20051225120433.F3F6.LARK@linux.net.cn you wrote:
After reading many board/*/flash.c and writing customer board driver for one of my customer, I think the current flash interface can be improved.
Did you have a look at the cfi_flash driver? This is supposed to replace the custom board/*/flash.c in most cses (i. e. whenever memory footprint requirements are not too limiting).
I have tested cfi_flash.c for a while. Unfortuanately, it fails for Spansion S29AL016M. The chip can be recognized, chip information is all correct, but the erase and write routines fail.
The symptom is erase and write routine complete and seem to succeed, but content remains unchanged.
The datasheet I download from Spansion (S29AL016M_00_A5_E.pdf) says:
― CFI (Common Flash Interface) compliant: allows host system to identify and accommodate multiple flash devices
Carefully read cfi_flash.c and datasheet, I think S29AL016M doesn't support the cfi_flash.c's command sequence for erasing and writing.
I suggest adding a subdir $(TOPDIR)/include/flash/ and putting flash chip information here. When you use some kinds of flash chips, just include relevant header files.
I think we should use the cfi_driver instead.
And BTW - a comment on the suggested code:
If we go further, many information in $(TOPDIR)/include/flash.h can be put into these header files.
...
The following is an example of AMD Spansion S29AL016M chip.
...
int FLASH_S29AL016M_T_BYTE_SA[] = { 0x000000, 0x010000, 0x020000, 0x030000, 0x040000, 0x050000, 0x060000, 0x070000,
...
All-capital-names should be reserved for preprocessor variables. It is not acceptable to use these for other variables or function names. It is also not a good idea to have such initializations in a header file which might get included more than once.
The code I give are JUST example, so uppper or lower case is not a problem in this sense.
I did worry about such initializations in header file, but given the fact that only flash.c will include it, I think it is not a real problem. And even it is included by multiple files, we can make these variables static. Or we can use better solution, but the idea itself is still reasonable.