mtd: spi-nor: Introduce spi_nor_init_fixup_flags()

Group NOR flags initialization. Introduce a dedicated function for
setting the fixup_flags and emphasise when those flash_info flags
should be set: when the SNOR_F_4B_OPCODES/SNOR_F_IO_MODE_EN_VOLATILE
setttings can not be discovered by SFDP for this particular flash
because the SFDP table that indicates this support is not defined
in the flash.
In case the table for his support is defined but has wrong values,
one should instead use a post_sfdp() hook to set the SNOR_F equivalent
flag.

No functional change intended in this patch.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-9-tudor.ambarus@microchip.com
This commit is contained in:
Tudor Ambarus 2021-12-07 16:02:48 +02:00
parent 5429300db9
commit a1ede1cce4
1 changed files with 20 additions and 8 deletions

View File

@ -2692,6 +2692,25 @@ static void spi_nor_init_flags(struct spi_nor *nor)
nor->flags |= SNOR_F_READY_XSR_RDY;
}
/**
* spi_nor_init_fixup_flags() - Initialize NOR flags for settings that can not
* be discovered by SFDP for this particular flash because the SFDP table that
* indicates this support is not defined in the flash. In case the table for
* this support is defined but has wrong values, one should instead use a
* post_sfdp() hook to set the SNOR_F equivalent flag.
* @nor: pointer to a 'struct spi_nor'
*/
static void spi_nor_init_fixup_flags(struct spi_nor *nor)
{
const u8 fixup_flags = nor->info->fixup_flags;
if (fixup_flags & SPI_NOR_4B_OPCODES)
nor->flags |= SNOR_F_4B_OPCODES;
if (fixup_flags & SPI_NOR_IO_MODE_EN_VOLATILE)
nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
}
/**
* spi_nor_late_init_params() - Late initialization of default flash parameters.
* @nor: pointer to a 'struct spi_nor'
@ -2710,6 +2729,7 @@ static void spi_nor_late_init_params(struct spi_nor *nor)
nor->info->fixups->late_init(nor);
spi_nor_init_flags(nor);
spi_nor_init_fixup_flags(nor);
/*
* NOR protection support. When locking_ops are not provided, we pick
@ -3147,7 +3167,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
struct mtd_info *mtd = &nor->mtd;
int ret;
int i;
u8 fixup_flags;
ret = spi_nor_check(nor);
if (ret)
@ -3197,13 +3216,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
if (ret)
return ret;
fixup_flags = info->fixup_flags;
if (fixup_flags & SPI_NOR_4B_OPCODES)
nor->flags |= SNOR_F_4B_OPCODES;
if (fixup_flags & SPI_NOR_IO_MODE_EN_VOLATILE)
nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
ret = spi_nor_set_addr_width(nor);
if (ret)
return ret;