mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
mtd: spi-nor: Set the 4-Byte Address Mode method based on SFDP data
JESD216 SFDP defines in BFPT methods to enter and exit the 4-Byte Address Mode. The flash parameters and settings that are retrieved from SFDP have higher precedence than the static initialized ones, because they should be more accurate and less error prone than those initialized statically. Parse and favor the BFPT-parsed set_4byte_addr_mode methods. Some regressions may be introduced by this patch, because the params->set_4byte_addr_mode method that was set either in spi_nor_init_default_params() or later overwritten in default_init() hooks, are now be overwritten with a different value based on the BFPT data. If that's the case, the fix is to introduce a post_bfpt fixup hook where one should fix the wrong BFPT info. Link: https://lore.kernel.org/r/20230331074606.3559258-7-tudor.ambarus@linaro.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
This commit is contained in:
@@ -216,19 +216,25 @@ static const struct spi_nor_otp_ops winbond_nor_otp_ops = {
|
||||
.is_locked = spi_nor_otp_is_locked_sr2,
|
||||
};
|
||||
|
||||
static void winbond_nor_default_init(struct spi_nor *nor)
|
||||
{
|
||||
nor->params->set_4byte_addr_mode = winbond_nor_set_4byte_addr_mode;
|
||||
}
|
||||
|
||||
static void winbond_nor_late_init(struct spi_nor *nor)
|
||||
{
|
||||
if (nor->params->otp.org->n_regions)
|
||||
nor->params->otp.ops = &winbond_nor_otp_ops;
|
||||
struct spi_nor_flash_parameter *params = nor->params;
|
||||
|
||||
if (params->otp.org->n_regions)
|
||||
params->otp.ops = &winbond_nor_otp_ops;
|
||||
|
||||
/*
|
||||
* Winbond seems to require that the Extended Address Register to be set
|
||||
* to zero when exiting the 4-Byte Address Mode, at least for W25Q256FV.
|
||||
* This requirement is not described in the JESD216 SFDP standard, thus
|
||||
* it is Winbond specific. Since we do not know if other Winbond flashes
|
||||
* have the same requirement, play safe and overwrite the method parsed
|
||||
* from BFPT, if any.
|
||||
*/
|
||||
params->set_4byte_addr_mode = winbond_nor_set_4byte_addr_mode;
|
||||
}
|
||||
|
||||
static const struct spi_nor_fixups winbond_nor_fixups = {
|
||||
.default_init = winbond_nor_default_init,
|
||||
.late_init = winbond_nor_late_init,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user