
On 10/26/18 03:36, Rajat Srivastava wrote:
<snip>
Spansion flashes (on our boards) support both 3-byte and 4-byte addressing modes which needs active switching. What could be added to your patch is already supported in SFDP method. SFDP also provides information about page size, flash density, read/write/erase commands, etc, in addition to getting information about address width supported by flash.
The flashes on our boards (and also other vendor's board) will not work with Stefan's patch.
My patch can handle flashes with address widths of 3-byte, 4-byte or both. It also takes a more generic path (as opposed to supporting only specific flash models) by parsing SFDP standard parameters and then deciding what address width is to be used.
I still don't see why each and every SPI controller driver needs to be extended to support this SFDP parameter reading. Can't this be handled by some generic (read common) code part in the SPI flash infrastructure?
The generic (read common) code part in the SPI flash infrastructure also lands on respective SPI drivers which ultimately sends the commands to flash. Currently every SPI driver has support for basic read command (which is called after "generic read common code") but no driver has support for SFDP reading, which is what needs to be added. Also, only the drivers that want to make use of SFDP needs to extend support for SFDP parameter reading.
I am reiterating that this is how SFDP parsing has been implemented in Linux as well and this is the generic way. Driver support is absolutely required because SPI framework cannot directly send any command to any flash.
It sounds like your difference is how to detect 4-byte addressing should be used.
Stefan's method is from the flash chip side, to check status register. The benefit is to preserve setting before U-Boot. I am not sure if it is necessary to preserve previous setting though.
Rajat's method is from the controller side, to read SFDP. It can support all flash chips I presume.
I guess Stefan's method will not determine Rajat's flash as 4-byte addressing because it indeed supports both 3- and 4-byte. To make Rajat's method work on Stefan's board, SFDP needs to be extended to the controller driver Stefan uses, is that right?
I also guess reading SFDP is controller-specific and cannot be done in a generic way. If the new feature is useful and can be gradually extended to other controllers, it sounds good to me. My guesses could wrong though.
York