mtd: spi-nor: Add default_init() hook to tweak flash parameters
authorTudor Ambarus <tudor.ambarus@microchip.com>
Sat, 24 Aug 2019 12:00:37 +0000 (12:00 +0000)
committerTudor Ambarus <tudor.ambarus@microchip.com>
Wed, 28 Aug 2019 09:40:27 +0000 (12:40 +0300)
commitce0b6f3f3c43271f4486c7255656277cc5996f6e
tree179b3f33d06d672ae8c25a301e454ad86c9a8de2
parentc46872170a54c902425c8580fd0a75a56ac1d147
mtd: spi-nor: Add default_init() hook to tweak flash parameters

As of now, the flash parameters initialization logic is as following:

a/ default flash parameters init in spi_nor_init_params()
b/ manufacturer specific flash parameters updates, split across entire
   spi-nor core code
c/ flash parameters updates based on SFDP tables
d/ post BFPT flash parameter updates

In the quest of removing the manufacturer specific code from the spi-nor
core, we want to impose a timeline/priority on how the flash parameters
are updated. The following sequence of calls is pursued:

1/ spi-nor core parameters init based on 'flash_info' struct:
spi_nor_info_init_params()

which can be overwritten by:
2/ MFR-based manufacturer flash parameters init:
nor->manufacturer->fixups->default_init()

which can be overwritten by:
3/ specific flash_info tweeks done when decisions can not be done just on
   MFR:
nor->info->fixups->default_init()

which can be overwritten by:
4/ SFDP tables flash parameters init - SFDP knows better:
spi_nor_sfdp_init_params()

which can be overwritten by:
5/ post SFDP tables flash parameters updates - in case manufacturers get
   the serial flash tables wrong or incomplete.
nor->info->fixups->post_sfdp()
   The later can be extended to nor->manufacturer->fixups->post_sfdp() if
   needed.

This patch opens doors for steps 2/ and 3/.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
drivers/mtd/spi-nor/spi-nor.c