Message ID | 20211029172633.886453-6-tudor.ambarus@microchip.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mtd: spi-nor: Clean params init | expand |
Am 2021-10-29 19:26, schrieb Tudor Ambarus: > Flash parameters init is done in a spaghetti way right now. > There is the init based on the flash_info data, then there is the > default_init() hook, then SFDP init, an intermediary post_bft(), > then post_sfdp() and a spi_nor_late_init_params(). Each method can > overwrite previuosly initialized parameters. > > We want to separate what is SFDP and non-SFDP specific. late_init() > will replace the default_init() hook and will be used only to > initialize > flash parameters that are not declared in the JESD216 SFDP standard, or > where SFDP tables are not defined at all. > We cut a member in the chain of initializing parameters by getting rid > of the default_init() hook, and we make it clear that everything that > is > in late_init() is not covered by the SFDP tables defined by the flash. > > Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Michael Walle <michael@walle.cc>
On 29/10/21 08:26PM, Tudor Ambarus wrote: > Flash parameters init is done in a spaghetti way right now. > There is the init based on the flash_info data, then there is the > default_init() hook, then SFDP init, an intermediary post_bft(), > then post_sfdp() and a spi_nor_late_init_params(). Each method can > overwrite previuosly initialized parameters. > > We want to separate what is SFDP and non-SFDP specific. late_init() > will replace the default_init() hook and will be used only to initialize > flash parameters that are not declared in the JESD216 SFDP standard, or > where SFDP tables are not defined at all. > We cut a member in the chain of initializing parameters by getting rid > of the default_init() hook, and we make it clear that everything that is > in late_init() is not covered by the SFDP tables defined by the flash. > > Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 13515ad12bf1..4679298c5301 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2666,11 +2666,19 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) * spi_nor_late_init_params() - Late initialization of default flash parameters. * @nor: pointer to a 'struct spi_nor' * - * Used to set default flash parameters and settings when the ->default_init() - * hook or the SFDP parser let voids. + * Used to initialize flash parameters that are not declared in the JESD216 + * SFDP standard, or where SFDP tables are not defined at all. + * Will replace the spi_nor_manufacturer_init_params() method. */ static void spi_nor_late_init_params(struct spi_nor *nor) { + if (nor->manufacturer && nor->manufacturer->fixups && + nor->manufacturer->fixups->late_init) + nor->manufacturer->fixups->late_init(nor); + + if (nor->info->fixups && nor->info->fixups->late_init) + nor->info->fixups->late_init(nor); + /* * NOR protection support. When locking_ops are not provided, we pick * the default ones. @@ -2712,8 +2720,9 @@ static void spi_nor_late_init_params(struct spi_nor *nor) * wrong). * spi_nor_post_sfdp_fixups() * - * 5/ Late default flash parameters initialization, used when the - * ->default_init() hook or the SFDP parser do not set specific params. + * 5/ Late flash parameters initialization, used to initialize flash + * parameters that are not declared in the JESD216 SFDP standard, or where SFDP + * tables are not defined at all. * spi_nor_late_init_params() */ static int spi_nor_init_params(struct spi_nor *nor) diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 48f26d3f1b3c..f6c4b6f4743b 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -297,6 +297,9 @@ struct spi_nor_flash_parameter { * parameters that could not be extracted by other means (i.e. * when information provided by the SFDP/flash_info tables are * incomplete or wrong). + * @late_init: used to initialize flash parameters that are not declared in the + * JESD216 SFDP standard, or where SFDP tables not defined at all. + * Will replace the default_init() hook. * * Those hooks can be used to tweak the SPI NOR configuration when the SFDP * table is broken or not available. @@ -307,6 +310,7 @@ struct spi_nor_fixups { const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt); void (*post_sfdp)(struct spi_nor *nor); + void (*late_init)(struct spi_nor *nor); }; struct flash_info {
Flash parameters init is done in a spaghetti way right now. There is the init based on the flash_info data, then there is the default_init() hook, then SFDP init, an intermediary post_bft(), then post_sfdp() and a spi_nor_late_init_params(). Each method can overwrite previuosly initialized parameters. We want to separate what is SFDP and non-SFDP specific. late_init() will replace the default_init() hook and will be used only to initialize flash parameters that are not declared in the JESD216 SFDP standard, or where SFDP tables are not defined at all. We cut a member in the chain of initializing parameters by getting rid of the default_init() hook, and we make it clear that everything that is in late_init() is not covered by the SFDP tables defined by the flash. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/mtd/spi-nor/core.c | 17 +++++++++++++---- drivers/mtd/spi-nor/core.h | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-)