mtd: spi-nor: Clean params init
Subsystems (4)
v3 cover mtd: spi-nor: Clean params init
Clean spi_nor_scan() and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.
This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.
Changes in v3:
- move late_init() in struct spi_nor_fixups and update patches accordingly. R-b tags were dropped.
- new patch "mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag" moves manufacturer specific flag out of the core.
- update methods description to make it clear who sets when
- introduce flash_info flag masks to make it clear when one should be set.
- rework "parse SFDP first idea".
Tudor Ambarus (25):
mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description
mtd: spi-nor: core: Use container_of to get the pointer to struct
spi_nor
mtd: spi-nor: Introduce spi_nor_set_mtd_info()
mtd: spi-nor: Get rid of nor->page_size
mtd: spi-nor: core: Introduce the late_init() hook
mtd: spi-nor: atmel: Use flash late_init() for locking
mtd: spi-nor: sst: Use flash late_init() for locking
mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops
mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method
mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
mtd: spi-nor: spansion: Use manufacturer late_init()
mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only when SFDP is
defined
mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
mtd: spi-nor: Introduce flash_info flags masks
mtd: spi-nor: Introduce spi_nor_nonsfdp_init_flags()
mtd: spi-nor: Introduce spi_nor_init_fixup_flags()
mtd: spi-nor: core: Introduce SPI_NOR_PARSE_SFDP
mtd: spi-nor: core: Init flash params based on SFDP first for new
flash additions
mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup()
mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
mtd: spi-nor: winbond: w25q256jvm: Init flash based on SFDP
mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing
mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP
mtd: spi-nor: issi: is25lp256: Init flash based on SFDP
mtd: spi-nor: macronix: mx25l25635e: Init flash based on SFDP
drivers/mtd/spi-nor/atmel.c | 8 +- drivers/mtd/spi-nor/core.c | 480 +++++++++++++++++-------------- drivers/mtd/spi-nor/core.h | 106 ++++--- drivers/mtd/spi-nor/gigadevice.c | 7 +- drivers/mtd/spi-nor/issi.c | 6 +- drivers/mtd/spi-nor/macronix.c | 15 +- drivers/mtd/spi-nor/micron-st.c | 20 +- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/spansion.c | 15 +- drivers/mtd/spi-nor/sst.c | 105 ++++--- drivers/mtd/spi-nor/swp.c | 2 +- drivers/mtd/spi-nor/winbond.c | 7 +- drivers/mtd/spi-nor/xilinx.c | 21 +- include/linux/mtd/spi-nor.h | 2 - 14 files changed, 460 insertions(+), 336 deletions(-)
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 1/25 mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description
Update the description of the otp member of the
struct spi_nor_flash_parameter.
--- drivers/mtd/spi-nor/core.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/spi-nor/core.h +1 -2
@@ -250,7 +250,7 @@ struct spi_nor_otp {* higher index in the array, the higher priority. * @erase_map: the erase map parsed from the SFDP Sector Map Parameter * Table. -* @otp_info: describes the OTP regions. +* @otp: SPI NOR OTP info. * @octal_dtr_enable: enables SPI NOR octal DTR mode. * @quad_enable: enables SPI NOR quad mode. * @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode.
@@ -262,7 +262,6 @@ struct spi_nor_otp {* e.g. different opcodes, specific address calculation, * page size, etc. * @locking_ops: SPI NOR locking methods. -* @otp: SPI NOR OTP methods. */ struct spi_nor_flash_parameter {u64 size;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 01/25] mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
Update the description of the otp member of the
structspi_nor_flash_parameter.Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Pratyush Yadav <[email protected]>---
You've forgot to add my former tag here. Anyway:
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 2/25 mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor
In reply to Tudor Ambarus"struct mtd_info mtd" is member of "struct spi_nor", there's no need to use "mtd->priv". Get the pointer to the containing struct spi_nor by using container_of. While here, make the function inline and get rid of the __maybe_unused.
--- drivers/mtd/spi-nor/core.c | 1 - drivers/mtd/spi-nor/core.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/core.c +0 -1
@@ -3134,7 +3134,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (!mtd->name) mtd->name =dev_name (dev); - mtd->priv = nor; mtd->type =MTD_NORFLASH ; mtd->writesize = nor->params->writesize; mtd->flags =MTD_CAP_NORFLASH ;
drivers/mtd/spi-nor/core.h +2 -2
@@ -551,9 +551,9 @@ void spi_nor_try_unlock_all(struct spi_nor *nor);void spi_nor_register_locking_ops (struct spi_nor *nor);void spi_nor_otp_init (struct spi_nor *nor); -static struct spi_nor __maybe_unused *mtd_to_spi_nor (struct mtd_info *mtd) +static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) { -return mtd->priv; + return container_of(mtd, struct spi_nor, mtd); }#endif /* __LINUX_MTD_SPI_NOR_INTERNAL_H */
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 02/25] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
"struct
mtd_infomtd" is member of "structspi_nor", there's no need to use "mtd->priv". Get the pointer to the containing structspi_norby usingcontainer_of. While here, make the function inline and get rid of the__maybe_unused.Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 02/25] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor
In reply to Tudor AmbarusQuoted 6 lines · Tudor Ambarus
"struct
mtd_infomtd" is member of "structspi_nor", there's no need to use "mtd->priv". Get the pointer to the containing structspi_norby usingcontainer_of. While here, make the function inline and get rid of the__maybe_unused.Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 3/25 mtd: spi-nor: Introduce spi_nor_set_mtd_info()
In reply to Tudor AmbarusUsed to init all the mtd_info fields. Move the mtd_info init the last thing in the spi_nor_scan(), so that we avoid superfluous initialization of the mtd_info fields in case of errors.
While here use common naming scheme for functions that are setting mtd_info fields:
s/spi_nor_register_locking_ops/spi_nor_set_mtd_locking_ops s/spi_nor_otp_init/spi_nor_set_mtd_otp_ops
The functions names are self explanatory, get rid of the comment for the OTP function.
--- drivers/mtd/spi-nor/core.c | 54 +++++++++++++++++++++----------------- drivers/mtd/spi-nor/core.h | 4 +-- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/swp.c | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-)
drivers/mtd/spi-nor/core.c +30 -24
@@ -3071,6 +3071,35 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,return info; } +static void spi_nor_set_mtd_info (struct spi_nor *nor) +{ +struct mtd_info *mtd = &nor->mtd; +struct device *dev = nor->dev; + +spi_nor_set_mtd_locking_ops (nor); +spi_nor_set_mtd_otp_ops (nor); + + mtd->dev.parent = dev; +if (!mtd->name) + mtd->name =dev_name (dev); + mtd->type =MTD_NORFLASH ; + mtd->flags =MTD_CAP_NORFLASH ; +if (nor->info->flags &SPI_NOR_NO_ERASE ) + mtd->flags |=MTD_NO_ERASE ; + mtd->writesize = nor->params->writesize; + mtd->writebufsize = nor->page_size; + mtd->size = nor->params->size; + mtd->_erase = spi_nor_erase; + mtd->_read = spi_nor_read; +/* Might be already set by some SST flashes. */ +if (!mtd->_write) + mtd->_write = spi_nor_write; + mtd->_suspend = spi_nor_suspend; + mtd->_resume = spi_nor_resume; + mtd->_get_device = spi_nor_get_device; + mtd->_put_device = spi_nor_put_device; +} +int spi_nor_scan (struct spi_nor *nor,const char *name,const struct spi_nor_hwcaps *hwcaps) {
@@ -3125,26 +3154,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (info->flags &SPI_NOR_HAS_LOCK ) nor->flags |=SNOR_F_HAS_LOCK ; - mtd->_write = spi_nor_write; -/* Init flash parameters based on flash_info struct and SFDP */ ret =spi_nor_init_params (nor);if (ret)return ret; -if (!mtd->name) - mtd->name =dev_name (dev); - mtd->type =MTD_NORFLASH ; - mtd->writesize = nor->params->writesize; - mtd->flags =MTD_CAP_NORFLASH ; - mtd->size = nor->params->size; - mtd->_erase = spi_nor_erase; - mtd->_read = spi_nor_read; - mtd->_suspend = spi_nor_suspend; - mtd->_resume = spi_nor_resume; - mtd->_get_device = spi_nor_get_device; - mtd->_put_device = spi_nor_put_device; -if (info->flags &USE_FSR ) nor->flags |=SNOR_F_USE_FSR ;if (info->flags &SPI_NOR_HAS_TB ) {
@@ -3166,12 +3180,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (info->flags &SPI_NOR_NO_ERASE ) - mtd->flags |=MTD_NO_ERASE ; - - mtd->dev.parent = dev; nor->page_size = nor->params->page_size; - mtd->writebufsize = nor->page_size;if (of_property_read_bool (np,"broken-flash-reset" )) nor->flags |=SNOR_F_BROKEN_RESET ;
@@ -3196,15 +3205,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (ret)return ret; -spi_nor_register_locking_ops (nor); -/* Send all the required SPI flash commands to initialize device */ ret =spi_nor_init (nor);if (ret)return ret; -/* Configure OTP parameters and ops */ -spi_nor_otp_init (nor); +spi_nor_set_mtd_info (nor);dev_info (dev,"%s (%lld Kbytes)\n" , info->name, (long long )mtd->size >>10 );
drivers/mtd/spi-nor/core.h +2 -2
@@ -548,8 +548,8 @@ int spi_nor_post_bfpt_fixups(struct spi_nor *nor,void spi_nor_init_default_locking_ops (struct spi_nor *nor);void spi_nor_try_unlock_all (struct spi_nor *nor); -void spi_nor_register_locking_ops (struct spi_nor *nor); -void spi_nor_otp_init (struct spi_nor *nor); +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor); +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor);static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) {
drivers/mtd/spi-nor/otp.c +1 -1
@@ -480,7 +480,7 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)return ret; } -void spi_nor_otp_init (struct spi_nor *nor) +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;
drivers/mtd/spi-nor/swp.c +1 -1
@@ -414,7 +414,7 @@ void spi_nor_try_unlock_all(struct spi_nor *nor)dev_dbg (nor->dev,"Failed to unlock the entire flash memory array\n" ); } -void spi_nor_register_locking_ops (struct spi_nor *nor) +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 4 lines
Used to init all the
mtd_infofields. Move themtd_infoinit the last thing in thespi_nor_scan(), so that we avoid superfluous initialization of themtd_infofields in case of errors.
Quoted 8 lines
While here use common naming scheme for functions that are setting
mtd_infofields:
s/spi_nor_register_locking_ops/spi_nor_set_mtd_locking_ops s/spi_nor_otp_init/spi_nor_set_mtd_otp_ops
The functions names are self explanatory, get rid of the comment for the OTP function.Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
In reply to Tudor AmbarusQuoted 44 lines · Tudor Ambarus
Used to init all the
mtd_infofields. Move themtd_infoinit the last thing in thespi_nor_scan(), so that we avoid superfluous initialization of themtd_infofields in case of errors.While here use common naming scheme for functions that are setting
mtd_infofields:
s/spi_nor_register_locking_ops/spi_nor_set_mtd_locking_ops s/spi_nor_otp_init/spi_nor_set_mtd_otp_ops
The functions names are self explanatory, get rid of the comment for the OTP function.Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 54 +++++++++++++++++++++----------------- drivers/mtd/spi-nor/core.h | 4 +-- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/swp.c | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-)drivers/mtd/spi-nor/core.c +17
-0@@ -3071,6 +3071,35 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,return info; } +static void spi_nor_set_mtd_info (struct spi_nor *nor) +{ +struct mtd_info *mtd = &nor->mtd; +struct device *dev = nor->dev; + +spi_nor_set_mtd_locking_ops (nor); +spi_nor_set_mtd_otp_ops (nor); + + mtd->dev.parent = dev; +if (!mtd->name) + mtd->name =dev_name (dev); + mtd->type =MTD_NORFLASH ; + mtd->flags =MTD_CAP_NORFLASH ; +if (nor->info->flags &SPI_NOR_NO_ERASE ) + mtd->flags |=MTD_NO_ERASE ; + mtd->writesize = nor->params->writesize; + mtd->writebufsize = nor->page_size;
drivers/mtd/spi-nor/core.c static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, · line 3100
Quoted 10 lines
drivers/mtd/spi-nor/core.c +10
-0+ mtd->size = nor->params->size; + mtd->_erase = spi_nor_erase; + mtd->_read = spi_nor_read; +/* Might be already set by some SST flashes. */ +if (!mtd->_write) + mtd->_write = spi_nor_write; + mtd->_suspend = spi_nor_suspend; + mtd->_resume = spi_nor_resume; + mtd->_get_device = spi_nor_get_device; + mtd->_put_device = spi_nor_put_device;
You should also merge in spi_nor_debugfs_init() in here which initializes mtd->dbg.
Quoted 49 lines
drivers/mtd/spi-nor/core.c +2
-20+} +int spi_nor_scan (struct spi_nor *nor,const char *name,const struct spi_nor_hwcaps *hwcaps) {@@ -3125,26 +3154,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (info->flags &SPI_NOR_HAS_LOCK ) nor->flags |=SNOR_F_HAS_LOCK ; - mtd->_write = spi_nor_write; -/* Init flash parameters based on flash_info struct and SFDP */ ret =spi_nor_init_params (nor);if (ret)return ret; -if (!mtd->name) - mtd->name =dev_name (dev); - mtd->type =MTD_NORFLASH ; - mtd->writesize = nor->params->writesize; - mtd->flags =MTD_CAP_NORFLASH ; - mtd->size = nor->params->size; - mtd->_erase = spi_nor_erase; - mtd->_read = spi_nor_read; - mtd->_suspend = spi_nor_suspend; - mtd->_resume = spi_nor_resume; - mtd->_get_device = spi_nor_get_device; - mtd->_put_device = spi_nor_put_device; -if (info->flags &USE_FSR ) nor->flags |=SNOR_F_USE_FSR ;if (info->flags &SPI_NOR_HAS_TB ) {@@ -3166,12 +3180,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (info->flags &SPI_NOR_NO_ERASE ) - mtd->flags |=MTD_NO_ERASE ; - - mtd->dev.parent = dev; nor->page_size = nor->params->page_size; - mtd->writebufsize = nor->page_size;if (of_property_read_bool (np,"broken-flash-reset" )) nor->flags |=SNOR_F_BROKEN_RESET ;@@ -3196,15 +3205,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (ret)return ret;
drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3213
Quoted 10 lines
drivers/mtd/spi-nor/core.c +1
-4-spi_nor_register_locking_ops (nor); -/* Send all the required SPI flash commands to initialize device */ ret =spi_nor_init (nor);if (ret)return ret; -/* Configure OTP parameters and ops */ -spi_nor_otp_init (nor); +spi_nor_set_mtd_info (nor);
This will break multiple things.
- spi_nor_set_addr_width(), which is called by spi_nor-setup(). It checks for nor->mtd.size which has not been set yet.
- spi_nor_spimem_check_op(), which is called (indirectly) by spi_nor_default_setup(). It check for nor->mtd.size.
- spi_nor_try_unlock_all(), which is called by spi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.
Quoted 47 lines
drivers/mtd/spi-nor/core.c +0
-0dev_info (dev,"%s (%lld Kbytes)\n" , info->name, (long long )mtd->size >>10 );drivers/mtd/spi-nor/core.h +2
-2@@ -548,8 +548,8 @@ int spi_nor_post_bfpt_fixups(struct spi_nor *nor,void spi_nor_init_default_locking_ops (struct spi_nor *nor);void spi_nor_try_unlock_all (struct spi_nor *nor); -void spi_nor_register_locking_ops (struct spi_nor *nor); -void spi_nor_otp_init (struct spi_nor *nor); +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor); +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor);static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) {drivers/mtd/spi-nor/otp.c +1
-1@@ -480,7 +480,7 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)return ret; } -void spi_nor_otp_init (struct spi_nor *nor) +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;drivers/mtd/spi-nor/swp.c +1
-1@@ -414,7 +414,7 @@ void spi_nor_try_unlock_all(struct spi_nor *nor)dev_dbg (nor->dev,"Failed to unlock the entire flash memory array\n" ); } -void spi_nor_register_locking_ops (struct spi_nor *nor) +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;Signature · 1 line
2.25.1
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Quoted 52 lines · Pratyush Yadav
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 49 lines · Tudor Ambarus
Used to init all the
mtd_infofields. Move themtd_infoinit the last thing in thespi_nor_scan(), so that we avoid superfluous initialization of themtd_infofields in case of errors.While here use common naming scheme for functions that are setting
mtd_infofields:
s/spi_nor_register_locking_ops/spi_nor_set_mtd_locking_ops s/spi_nor_otp_init/spi_nor_set_mtd_otp_ops
The functions names are self explanatory, get rid of the comment for the OTP function.Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 54 +++++++++++++++++++++----------------- drivers/mtd/spi-nor/core.h | 4 +-- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/swp.c | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-)drivers/mtd/spi-nor/core.c +22
-0@@ -3071,6 +3071,35 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,return info; } +static void spi_nor_set_mtd_info (struct spi_nor *nor) +{ +struct mtd_info *mtd = &nor->mtd; +struct device *dev = nor->dev; + +spi_nor_set_mtd_locking_ops (nor); +spi_nor_set_mtd_otp_ops (nor); + + mtd->dev.parent = dev; +if (!mtd->name) + mtd->name =dev_name (dev); + mtd->type =MTD_NORFLASH ; + mtd->flags =MTD_CAP_NORFLASH ; +if (nor->info->flags &SPI_NOR_NO_ERASE ) + mtd->flags |=MTD_NO_ERASE ; + mtd->writesize = nor->params->writesize; + mtd->writebufsize = nor->page_size; + mtd->size = nor->params->size; + mtd->_erase = spi_nor_erase; + mtd->_read = spi_nor_read; +/* Might be already set by some SST flashes. */ +if (!mtd->_write)
Quoted 9 lines
drivers/mtd/spi-nor/core.c static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, · line 3100
Quoted 5 lines
drivers/mtd/spi-nor/core.c +5
-0+ mtd->_write = spi_nor_write; + mtd->_suspend = spi_nor_suspend; + mtd->_resume = spi_nor_resume; + mtd->_get_device = spi_nor_get_device; + mtd->_put_device = spi_nor_put_device;You should also merge in
spi_nor_debugfs_init()in here which initializesmtd->dbg.
I was thinking of getting rid of debugfs entries since they duplicate those on sysfs.
Quoted 56 lines
Quoted 56 lines
drivers/mtd/spi-nor/core.c +2
-22+} +int spi_nor_scan (struct spi_nor *nor,const char *name,const struct spi_nor_hwcaps *hwcaps) {@@ -3125,26 +3154,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (info->flags &SPI_NOR_HAS_LOCK ) nor->flags |=SNOR_F_HAS_LOCK ; - mtd->_write = spi_nor_write; -/* Init flash parameters based on flash_info struct and SFDP */ ret =spi_nor_init_params (nor);if (ret)return ret; -if (!mtd->name) - mtd->name =dev_name (dev); - mtd->type =MTD_NORFLASH ; - mtd->writesize = nor->params->writesize; - mtd->flags =MTD_CAP_NORFLASH ; - mtd->size = nor->params->size; - mtd->_erase = spi_nor_erase; - mtd->_read = spi_nor_read; - mtd->_suspend = spi_nor_suspend; - mtd->_resume = spi_nor_resume; - mtd->_get_device = spi_nor_get_device; - mtd->_put_device = spi_nor_put_device; -if (info->flags &USE_FSR ) nor->flags |=SNOR_F_USE_FSR ;if (info->flags &SPI_NOR_HAS_TB ) {@@ -3166,12 +3180,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (info->flags &SPI_NOR_NO_ERASE ) - mtd->flags |=MTD_NO_ERASE ; - - mtd->dev.parent = dev; nor->page_size = nor->params->page_size; - mtd->writebufsize = nor->page_size;if (of_property_read_bool (np,"broken-flash-reset" )) nor->flags |=SNOR_F_BROKEN_RESET ;@@ -3196,15 +3205,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (ret)return ret; -spi_nor_register_locking_ops (nor); -/* Send all the required SPI flash commands to initialize device */ ret =spi_nor_init (nor);if (ret)return ret;
Quoted 5 lines
drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3213
Quoted 3 lines
drivers/mtd/spi-nor/core.c +1
-2-/* Configure OTP parameters and ops */ -spi_nor_otp_init (nor); +spi_nor_set_mtd_info (nor);This will break multiple things.
this is gold :), thanks
Quoted 4 lines
-
spi_nor_set_addr_width(), which is called by spi_nor-setup(). It
checks fornor->mtd.sizewhich has not been set yet.> -spi_nor_spimem_check_op(), which is called (indirectly) byspi_nor_default_setup(). It check fornor->mtd.size.
Let's use NOR parameters in SPI NOR core, thus nor->params->size instead, and let the mtd fields for mtd. This will spare us of these problems. And it's cleaner too.
Quoted 3 lines
-
spi_nor_try_unlock_all(), which is called byspi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.
we are safe here, the pointer to mtd is used just to get the pointer to nor.
Thanks again.
ta
Quoted 45 lines
Quoted 45 lines
drivers/mtd/spi-nor/core.c +0
-0dev_info (dev,"%s (%lld Kbytes)\n" , info->name, (long long )mtd->size >>10 );drivers/mtd/spi-nor/core.h +2
-2@@ -548,8 +548,8 @@ int spi_nor_post_bfpt_fixups(struct spi_nor *nor,void spi_nor_init_default_locking_ops (struct spi_nor *nor);void spi_nor_try_unlock_all (struct spi_nor *nor); -void spi_nor_register_locking_ops (struct spi_nor *nor); -void spi_nor_otp_init (struct spi_nor *nor); +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor); +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor);static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) {drivers/mtd/spi-nor/otp.c +1
-1@@ -480,7 +480,7 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)return ret; } -void spi_nor_otp_init (struct spi_nor *nor) +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;drivers/mtd/spi-nor/swp.c +1
-1@@ -414,7 +414,7 @@ void spi_nor_try_unlock_all(struct spi_nor *nor)dev_dbg (nor->dev,"Failed to unlock the entire flash memory array\n" ); } -void spi_nor_register_locking_ops (struct spi_nor *nor) +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;
Quoted 9 lines
Quoted 3 lines
--
2.25.1--
Regards,
Pratyush Yadav
Texas Instruments Inc.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Quoted 63 lines · On 16/11/21 02:25PM, [email protected] wrote:
Quoted 52 lines · Pratyush Yadav
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 49 lines · Tudor Ambarus
Used to init all the
mtd_infofields. Move themtd_infoinit the last thing in thespi_nor_scan(), so that we avoid superfluous initialization of themtd_infofields in case of errors.While here use common naming scheme for functions that are setting
mtd_infofields:
s/spi_nor_register_locking_ops/spi_nor_set_mtd_locking_ops s/spi_nor_otp_init/spi_nor_set_mtd_otp_ops
The functions names are self explanatory, get rid of the comment for the OTP function.Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 54 +++++++++++++++++++++----------------- drivers/mtd/spi-nor/core.h | 4 +-- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/swp.c | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-)drivers/mtd/spi-nor/core.c +22
-0@@ -3071,6 +3071,35 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,return info; } +static void spi_nor_set_mtd_info (struct spi_nor *nor) +{ +struct mtd_info *mtd = &nor->mtd; +struct device *dev = nor->dev; + +spi_nor_set_mtd_locking_ops (nor); +spi_nor_set_mtd_otp_ops (nor); + + mtd->dev.parent = dev; +if (!mtd->name) + mtd->name =dev_name (dev); + mtd->type =MTD_NORFLASH ; + mtd->flags =MTD_CAP_NORFLASH ; +if (nor->info->flags &SPI_NOR_NO_ERASE ) + mtd->flags |=MTD_NO_ERASE ; + mtd->writesize = nor->params->writesize; + mtd->writebufsize = nor->page_size; + mtd->size = nor->params->size; + mtd->_erase = spi_nor_erase; + mtd->_read = spi_nor_read; +/* Might be already set by some SST flashes. */ +if (!mtd->_write)Quoted 9 lines
drivers/mtd/spi-nor/core.c static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, · line 3100
Quoted 5 lines
drivers/mtd/spi-nor/core.c +5
-0+ mtd->_write = spi_nor_write; + mtd->_suspend = spi_nor_suspend; + mtd->_resume = spi_nor_resume; + mtd->_get_device = spi_nor_get_device; + mtd->_put_device = spi_nor_put_device;You should also merge in
spi_nor_debugfs_init()in here which initializesmtd->dbg.
Quoted 2 lines
I was thinking of getting rid of debugfs entries since they duplicate those on sysfs.
Okay. Fine by me either way.
Quoted 65 lines
Quoted 57 lines
Quoted 57 lines
drivers/mtd/spi-nor/core.c +2
-22+} +int spi_nor_scan (struct spi_nor *nor,const char *name,const struct spi_nor_hwcaps *hwcaps) {@@ -3125,26 +3154,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (info->flags &SPI_NOR_HAS_LOCK ) nor->flags |=SNOR_F_HAS_LOCK ; - mtd->_write = spi_nor_write; -/* Init flash parameters based on flash_info struct and SFDP */ ret =spi_nor_init_params (nor);if (ret)return ret; -if (!mtd->name) - mtd->name =dev_name (dev); - mtd->type =MTD_NORFLASH ; - mtd->writesize = nor->params->writesize; - mtd->flags =MTD_CAP_NORFLASH ; - mtd->size = nor->params->size; - mtd->_erase = spi_nor_erase; - mtd->_read = spi_nor_read; - mtd->_suspend = spi_nor_suspend; - mtd->_resume = spi_nor_resume; - mtd->_get_device = spi_nor_get_device; - mtd->_put_device = spi_nor_put_device; -if (info->flags &USE_FSR ) nor->flags |=SNOR_F_USE_FSR ;if (info->flags &SPI_NOR_HAS_TB ) {@@ -3166,12 +3180,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } -if (info->flags &SPI_NOR_NO_ERASE ) - mtd->flags |=MTD_NO_ERASE ; - - mtd->dev.parent = dev; nor->page_size = nor->params->page_size; - mtd->writebufsize = nor->page_size;if (of_property_read_bool (np,"broken-flash-reset" )) nor->flags |=SNOR_F_BROKEN_RESET ;@@ -3196,15 +3205,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (ret)return ret; -spi_nor_register_locking_ops (nor); -/* Send all the required SPI flash commands to initialize device */ ret =spi_nor_init (nor);if (ret)return ret;Quoted 5 lines
drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3213
Quoted 3 lines
drivers/mtd/spi-nor/core.c +1
-2-/* Configure OTP parameters and ops */ -spi_nor_otp_init (nor); +spi_nor_set_mtd_info (nor);This will break multiple things.
this is gold :), thanks
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
-
spi_nor_set_addr_width(), which is called by spi_nor-setup(). It
checks fornor->mtd.sizewhich has not been set yet.> -spi_nor_spimem_check_op(), which is called (indirectly) byspi_nor_default_setup(). It check fornor->mtd.size.Let's use NOR parameters in SPI NOR core, thus
nor->params->sizeinstead, and let the mtd fields for mtd. This will spare us of these problems. And it's cleaner too.
I agree.
Quoted 7 lines
Quoted 4 lines
-
spi_nor_try_unlock_all(), which is called byspi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.we are safe here, the pointer to mtd is used just to get the pointer to nor.
Yeah, but who knows if that might change some time later. I would prefer we don't use a member we haven't initialized yet.
Quoted 59 lines
Thanks again.
taQuoted 54 lines
Quoted 46 lines
drivers/mtd/spi-nor/core.c +0
-0dev_info (dev,"%s (%lld Kbytes)\n" , info->name, (long long )mtd->size >>10 );drivers/mtd/spi-nor/core.h +2
-2@@ -548,8 +548,8 @@ int spi_nor_post_bfpt_fixups(struct spi_nor *nor,void spi_nor_init_default_locking_ops (struct spi_nor *nor);void spi_nor_try_unlock_all (struct spi_nor *nor); -void spi_nor_register_locking_ops (struct spi_nor *nor); -void spi_nor_otp_init (struct spi_nor *nor); +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor); +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor);static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) {drivers/mtd/spi-nor/otp.c +1
-1@@ -480,7 +480,7 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)return ret; } -void spi_nor_otp_init (struct spi_nor *nor) +void spi_nor_set_mtd_otp_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd;drivers/mtd/spi-nor/swp.c +1
-2@@ -414,7 +414,7 @@ void spi_nor_try_unlock_all(struct spi_nor *nor)dev_dbg (nor->dev,"Failed to unlock the entire flash memory array\n" ); } -void spi_nor_register_locking_ops (struct spi_nor *nor) +void spi_nor_set_mtd_locking_ops (struct spi_nor *nor) {struct mtd_info *mtd = &nor->mtd; --Quoted 2 lines
2.25.1
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Quoted 10 lines · Pratyush Yadav
Quoted 7 lines
Quoted 4 lines
-
spi_nor_try_unlock_all(), which is called byspi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.we are safe here, the pointer to mtd is used just to get the pointer to nor.
Yeah, but who knows if that might change some time later. I would prefer we don't use a member we haven't initialized yet.
If it weren't for the SPI NOR controller drivers that use spi_nor_scan(), I would put the spi_nor_set_mtd_info() just above the mtd_device_register(). It will indicate that no mtd_info field is used up to that point, less things to worry about. spi_nor_try_unlock_all() calls
spi_nor_unlock(&nor->mtd, 0, nor->params->size);
I can't see for now if we will ever need some specific mtd_info parameter. I would say that we won't, we're just unlocking the full flash, every info we would need we can obtain from NOR. The discussion would be different if it were about mtd partitions, but it isn't, we're dealing with the entire flash.
Would you accept the place where I put spi_nor_set_mtd_info() if I add a comment before calling it? Something like:
/* No mtd_info fields are used up to this point. */ spi_nor_set_mtd_info();
Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Quoted 25 lines · On 17/11/21 02:36PM, [email protected] wrote:
Quoted 10 lines · Pratyush Yadav
Quoted 7 lines
Quoted 4 lines
-
spi_nor_try_unlock_all(), which is called byspi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.we are safe here, the pointer to mtd is used just to get the pointer to nor.
Yeah, but who knows if that might change some time later. I would prefer we don't use a member we haven't initialized yet.
If it weren't for the SPI NOR controller drivers that use
spi_nor_scan(), I would put thespi_nor_set_mtd_info()just above themtd_device_register(). It will indicate that nomtd_infofield is used up to that point, less things to worry about.spi_nor_try_unlock_all()callsspi_nor_unlock(&nor->mtd, 0, nor->params->size);I can't see for now if we will ever need some specific
mtd_infoparameter. I would say that we won't, we're just unlocking the full flash, every info we would need we can obtain from NOR. The discussion would be different if it were about mtd partitions, but it isn't, we're dealing with the entire flash.
Quoted 4 lines
Would you accept the place where I put
spi_nor_set_mtd_info()if I add a comment before calling it? Something like:
/* Nomtd_infofields are used up to this point. */spi_nor_set_mtd_info();
I see that everything that spi_nor_set_mtd_info() needs is set by the time spi_nor_init_params() is finished. Everything after that is concerned about selecting the protocol and sending the init commands to the flash. So why can't you call it right after spi_nor_init_params()? That and updating spi_nor_spimem_check_op() and spi_nor_set_addr_width() to use nor->params->size instead of nor->mtd.size should do the trick.
I think that it is implied that mtd_info fields are not being used until they are initialized so I don't think the comment itself is of much use, but I don't care much about it either way.
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()
Hi, Pratyush,
Quoted 33 lines · Pratyush Yadav
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 25 lines · On 17/11/21 02:36PM, [email protected] wrote:
Quoted 10 lines · Pratyush Yadav
Quoted 7 lines
Quoted 4 lines
-
spi_nor_try_unlock_all(), which is called byspi_nor_init(). I don't think it actually uses any values you initialize here but still worth pointing out.we are safe here, the pointer to mtd is used just to get the pointer to nor.
Yeah, but who knows if that might change some time later. I would prefer we don't use a member we haven't initialized yet.
If it weren't for the SPI NOR controller drivers that use
spi_nor_scan(), I would put thespi_nor_set_mtd_info()just above themtd_device_register(). It will indicate that nomtd_infofield is used up to that point, less things to worry about.spi_nor_try_unlock_all()callsspi_nor_unlock(&nor->mtd, 0, nor->params->size);I can't see for now if we will ever need some specific
mtd_infoparameter. I would say that we won't, we're just unlocking the full flash, every info we would need we can obtain from NOR. The discussion would be different if it were about mtd partitions, but it isn't, we're dealing with the entire flash.Quoted 4 lines
Would you accept the place where I put
spi_nor_set_mtd_info()if I add a comment before calling it? Something like:
/* Nomtd_infofields are used up to this point. */spi_nor_set_mtd_info();
Quoted 4 lines
I see that everything that
spi_nor_set_mtd_info()needs is set by the timespi_nor_init_params()is finished. Everything after that is concerned about selecting the protocol and sending the init commands to the flash. So why can't you call it right afterspi_nor_init_params()?
Because I would like to move it just above mtd_device_register() in the future. If unlock_all() will need some mtd fields in the future, we can introduce a spi_nor_prepare_mtd_for_unlock_all(). I don't want the mtd fields init to be scattered through the SPI NOR core. They shouldn't be used in the NOR's probe sequence of calls anyway, keeping them closer to mtd_device_register() makes the code easier to grasp I think.
I will respin the series soon and wanted to let you know why I kept spi_nor_set_mtd_info() where it is in this patch set.
Cheers,
ta
Quoted 12 lines
That and updating
spi_nor_spimem_check_op()andspi_nor_set_addr_width()to usenor->params->sizeinstead ofnor->mtd.sizeshould do the trick.I think that it is implied that
mtd_infofields are not being used until they are initialized so I don't think the comment itself is of much use, but I don't care much about it either way.--
Regards,
Pratyush Yadav
Texas Instruments Inc.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 4/25 mtd: spi-nor: Get rid of nor->page_size
In reply to Tudor Ambarusnor->page_size duplicated what nor->params->page_size indicates for no good reason. page_size is a flash parameter of fixed value and it is better suited to be found in nor->params->page_size.
--- drivers/mtd/spi-nor/core.c | 20 +++++++++----------- drivers/mtd/spi-nor/xilinx.c | 17 ++++++++++------- include/linux/mtd/spi-nor.h | 2 -- 3 files changed, 19 insertions(+), 20 deletions(-)
drivers/mtd/spi-nor/core.c +9 -11
@@ -1952,6 +1952,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,struct spi_nor *nor =mtd_to_spi_nor (mtd);size_t page_offset, page_remain, i;ssize_t ret; +u32 page_size = nor->params->page_size;dev_dbg (nor->dev,"to 0x%08x, len %zd\n" , (u32 )to, len);
@@ -1968,16 +1969,15 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,* calculated with an AND operation. On the other cases we * need to do a modulus operation (more expensive). */ -if (is_power_of_2 (nor->page_size)) { - page_offset = addr & (nor->page_size -1 ); +if (is_power_of_2 (page_size)) { + page_offset = addr & (page_size -1 ); }else {uint64_t aux = addr; - page_offset =do_div (aux, nor->page_size); + page_offset =do_div (aux, page_size); }/* the size of data remaining on the first page */ - page_remain =min_t (size_t, - nor->page_size - page_offset, len - i); + page_remain =min_t (size_t, page_size - page_offset, len - i); addr =spi_nor_convert_addr (nor, addr);
@@ -3087,7 +3087,7 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)if (nor->info->flags &SPI_NOR_NO_ERASE ) mtd->flags |=MTD_NO_ERASE ; mtd->writesize = nor->params->writesize; - mtd->writebufsize = nor->page_size; + mtd->writebufsize = nor->params->page_size; mtd->size = nor->params->size; mtd->_erase = spi_nor_erase; mtd->_read = spi_nor_read;
@@ -3123,7 +3123,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,* We need the bounce buffer early to read/write registers when going * through the spi-mem layer (buffers have to be DMA-able). * For spi-mem drivers, we'll reallocate a new buffer if -* nor->page_size turns out to be greater than PAGE_SIZE (which +* nor->params->page_size turns out to be greater than PAGE_SIZE (which * shouldn't happen before long since NOR pages are usually less * than 1KB) after spi_nor_scan() returns. */
@@ -3180,8 +3180,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; } - nor->page_size = nor->params->page_size; -if (of_property_read_bool (np,"broken-flash-reset" )) nor->flags |=SNOR_F_BROKEN_RESET ;
@@ -3346,8 +3344,8 @@ static int spi_nor_probe(struct spi_mem *spimem)* and add this logic so that if anyone ever adds support for such * a NOR we don't end up with buffer overflows. */ -if (nor->page_size >PAGE_SIZE ) { - nor->bouncebuf_size = nor->page_size; +if (nor->params->page_size >PAGE_SIZE ) { + nor->bouncebuf_size = nor->params->page_size;devm_kfree (nor->dev, nor->bouncebuf); nor->bouncebuf = devm_kmalloc(nor->dev, nor->bouncebuf_size,
drivers/mtd/spi-nor/xilinx.c +10 -7
@@ -28,11 +28,12 @@ static const struct flash_info xilinx_parts[] = {*/ static u32 s3an_convert_addr (struct spi_nor *nor,u32 addr) { +u32 page_size = nor->params->page_size;u32 offset, page; - offset = addr % nor->page_size; - page = addr / nor->page_size; - page <<= (nor->page_size >512 ) ?10 :9 ; + offset = addr % page_size; + page = addr / page_size; + page <<= (page_size >512 ) ?10 :9 ;return page | offset; }
@@ -40,6 +41,7 @@ static u32 s3an_convert_addr(struct spi_nor *nor, u32 addr)static int xilinx_nor_setup (struct spi_nor *nor,const struct spi_nor_hwcaps *hwcaps) { +u32 page_size;int ret; ret =spi_nor_xread_sr (nor, nor->bouncebuf);
@@ -64,10 +66,11 @@ static int xilinx_nor_setup(struct spi_nor *nor,*/ if (nor->bouncebuf[0 ] &XSR_PAGESIZE ) {/* Flash in Power of 2 mode */ - nor->page_size = (nor->page_size ==264 ) ?256 :512 ; - nor->mtd.writebufsize = nor->page_size; - nor->mtd.size =8 * nor->page_size * nor->info->n_sectors; - nor->mtd.erasesize =8 * nor->page_size; + page_size = (nor->params->page_size ==264 ) ?256 :512 ; + nor->params->page_size = page_size; + nor->mtd.writebufsize = page_size; + nor->mtd.size =8 * page_size * nor->info->n_sectors; + nor->mtd.erasesize =8 * page_size; }else {/* Flash in Default addressing mode */ nor->params->convert_addr = s3an_convert_addr;
include/linux/mtd/spi-nor.h +0 -2
@@ -371,7 +371,6 @@ struct spi_nor_flash_parameter;* @bouncebuf_size: size of the bounce buffer * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer -* @page_size: the page size of the SPI NOR * @addr_width: number of address bytes * @erase_opcode: the opcode for erasing a sector * @read_opcode: the read opcode
@@ -401,7 +400,6 @@ struct spi_nor {size_t bouncebuf_size;const struct flash_info *info;const struct spi_nor_manufacturer *manufacturer; -u32 page_size;u8 addr_width;u8 erase_opcode;u8 read_opcode;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 04/25] mtd: spi-nor: Get rid of nor->page_size
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
nor->page_sizeduplicated whatnor->params->page_sizeindicates for no good reason.page_sizeis a flash parameter of fixed value and it is better suited to be found innor->params->page_size.Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Pratyush Yadav <[email protected]>
IIRC this patch already had my:
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 04/25] mtd: spi-nor: Get rid of nor->page_size
Quoted 11 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
nor->page_sizeduplicated whatnor->params->page_sizeindicates for no good reason.page_sizeis a flash parameter of fixed value and it is better suited to be found innor->params->page_size.Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Pratyush Yadav <[email protected]>IIRC this patch already had my:
You're right, sorry. Next time I'll download the patches from ml, to get the tags automatically.
Quoted 1 line
Reviewed-by Michael Walle <[email protected]>
Thanks,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 5/25 mtd: spi-nor: core: Introduce the late_init() hook
In reply to Tudor AmbarusFlash 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.
--- drivers/mtd/spi-nor/core.c | 17 +++++++++++++---- drivers/mtd/spi-nor/core.h | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/core.c +13 -4
@@ -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)
drivers/mtd/spi-nor/core.h +4 -0
@@ -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 {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 05/25] mtd: spi-nor: core: Introduce the late_init() hook
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 14 lines
Flash parameters init is done in a spaghetti way right now. There is the init based on the
flash_infodata, then there is thedefault_init()hook, then SFDP init, an intermediarypost_bft(), thenpost_sfdp()and aspi_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 thedefault_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 thedefault_init()hook, and we make it clear that everything that is inlate_init()is not covered by the SFDP tables defined by the flash.
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 05/25] mtd: spi-nor: core: Introduce the late_init() hook
In reply to Tudor AmbarusQuoted 14 lines · Tudor Ambarus
Flash parameters init is done in a spaghetti way right now. There is the init based on the
flash_infodata, then there is thedefault_init()hook, then SFDP init, an intermediarypost_bft(), thenpost_sfdp()and aspi_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 thedefault_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 thedefault_init()hook, and we make it clear that everything that is inlate_init()is not covered by the SFDP tables defined by the flash.
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 6/25 mtd: spi-nor: atmel: Use flash late_init() for locking
In reply to Tudor AmbarusLocking is not described in JESD216 SFDP standard, place the locking init in late_init().
--- drivers/mtd/spi-nor/atmel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/atmel.c +4 -4
@@ -48,13 +48,13 @@ static const struct spi_nor_locking_ops atmel_at25fs_locking_ops = { .is_locked = atmel_at25fs_is_locked, }; -static void atmel_at25fs_default_init (struct spi_nor *nor) +static void atmel_at25fs_late_init (struct spi_nor *nor) { nor->params->locking_ops = &atmel_at25fs_locking_ops; }static const struct spi_nor_fixups atmel_at25fs_fixups = { - .default_init = atmel_at25fs_default_init, + .late_init = atmel_at25fs_late_init, };/**
@@ -146,13 +146,13 @@ static const struct spi_nor_locking_ops atmel_global_protection_ops = { .is_locked = atmel_is_global_protected, }; -static void atmel_global_protection_default_init (struct spi_nor *nor) +static void atmel_global_protection_late_init (struct spi_nor *nor) { nor->params->locking_ops = &atmel_global_protection_ops; }static const struct spi_nor_fixups atmel_global_protection_fixups = { - .default_init = atmel_global_protection_default_init, + .late_init = atmel_global_protection_late_init, };static const struct flash_info atmel_parts[] = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 06/25] mtd: spi-nor: atmel: Use flash late_init() for locking
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 4 lines
Locking is not described in JESD216 SFDP standard, place the locking init in
late_init().Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 06/25] mtd: spi-nor: atmel: Use flash late_init() for locking
In reply to Tudor AmbarusQuoted 4 lines · Tudor Ambarus
Locking is not described in JESD216 SFDP standard, place the locking init in
late_init().Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 7/25 mtd: spi-nor: sst: Use flash late_init() for locking
In reply to Tudor AmbarusLocking is not described in JESD216 SFDP standard, place the locking init in late_init().
--- drivers/mtd/spi-nor/sst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/sst.c +2 -2
@@ -46,13 +46,13 @@ static const struct spi_nor_locking_ops sst26vf_locking_ops = { .is_locked = sst26vf_is_locked, }; -static void sst26vf_default_init (struct spi_nor *nor) +static void sst26vf_late_init (struct spi_nor *nor) { nor->params->locking_ops = &sst26vf_locking_ops; }static const struct spi_nor_fixups sst26vf_fixups = { - .default_init = sst26vf_default_init, + .late_init = sst26vf_late_init, };static const struct flash_info sst_parts[] = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 07/25] mtd: spi-nor: sst: Use flash late_init() for locking
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 4 lines
Locking is not described in JESD216 SFDP standard, place the locking init in
late_init().Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 07/25] mtd: spi-nor: sst: Use flash late_init() for locking
In reply to Tudor AmbarusQuoted 4 lines · Tudor Ambarus
Locking is not described in JESD216 SFDP standard, place the locking init in
late_init().Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 8/25 mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops
In reply to Tudor AmbarusOTP is not described in the JESD216 SFDP standard, place the OTP ops init in late_init().
We can't get rid of the default_init() hook for winbond, as the 4byte_addr_mode is SFDP specific and will require to have all flashes at hand, in order to check which has the SFDP tables defined, in which case there's nothing to do if the SFDP tables are corect, and which of the flashes do not define the SFDP tables in which case each flash should declare a late_init() fixup.
--- drivers/mtd/spi-nor/winbond.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/winbond.c +5 -0
@@ -147,12 +147,17 @@ static const struct spi_nor_otp_ops winbond_otp_ops = {static void winbond_default_init (struct spi_nor *nor) { nor->params->set_4byte_addr_mode = winbond_set_4byte_addr_mode; +} + +static void winbond_late_init (struct spi_nor *nor) +{if (nor->params->otp.org->n_regions) nor->params->otp.ops = &winbond_otp_ops; }static const struct spi_nor_fixups winbond_fixups = { .default_init = winbond_default_init, + .late_init = winbond_late_init, };const struct spi_nor_manufacturer spi_nor_winbond = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 08/25] mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 11 lines
OTP is not described in the JESD216 SFDP standard, place the OTP ops init in
late_init().We can't get rid of the
default_init()hook for winbond, as the 4byte_addr_mode is SFDP specific and will require to have all flashes at hand, in order to check which has the SFDP tables defined, in which case there's nothing to do if the SFDP tables are corect, and which of the flashes do not define the SFDP tables in which case each flash should declare alate_init()fixup.Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 08/25] mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops
In reply to Tudor AmbarusQuoted 11 lines · Tudor Ambarus
OTP is not described in the JESD216 SFDP standard, place the OTP ops init in
late_init().We can't get rid of the
default_init()hook for winbond, as the 4byte_addr_mode is SFDP specific and will require to have all flashes at hand, in order to check which has the SFDP tables defined, in which case there's nothing to do if the SFDP tables are corect, and which of the flashes do not define the SFDP tables in which case each flash should declare alate_init()fixup.Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 9/25 mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method
In reply to Tudor Ambaruspost_sfdp was misleading in this case, as SFDP is not supported by xilinx. Plus, there's no fixup here, just setting the correct setup method, as required by xilinx parts.
--- drivers/mtd/spi-nor/xilinx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/xilinx.c +2 -2
@@ -80,13 +80,13 @@ static int xilinx_nor_setup(struct spi_nor *nor,return 0 ; } -static void xilinx_post_sfdp_fixups (struct spi_nor *nor) +static void xilinx_late_init (struct spi_nor *nor) { nor->params->setup = xilinx_nor_setup; }static const struct spi_nor_fixups xilinx_fixups = { - .post_sfdp = xilinx_post_sfdp_fixups, + .late_init = xilinx_late_init, };const struct spi_nor_manufacturer spi_nor_xilinx = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 09/25] mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 5 lines
post_sfdpwas misleading in this case, as SFDP is not supported by xilinx. Plus, there's no fixup here, just setting the correct setup method, as required by xilinx parts.Signed-off-by Tudor Ambarus <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 09/25] mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method
In reply to Tudor AmbarusQuoted 5 lines · Tudor Ambarus
post_sfdpwas misleading in this case, as SFDP is not supported by xilinx. Plus, there's no fixup here, just setting the correct setup method, as required by xilinx parts.Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 10/25 mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
In reply to Tudor AmbarusSetting the correct nor->mtd._write in a fixup hook was misleading, since this is not a fixup, just a specific setting for SST, that differs from the SPI NOR core default init.
--- drivers/mtd/spi-nor/sst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/sst.c +2 -2
@@ -177,14 +177,14 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,return ret; } -static void sst_post_sfdp_fixups (struct spi_nor *nor) +static void sst_late_init (struct spi_nor *nor) {if (nor->info->flags &SST_WRITE ) nor->mtd._write = sst_write; }static const struct spi_nor_fixups sst_fixups = { - .post_sfdp = sst_post_sfdp_fixups, + .late_init = sst_late_init, };const struct spi_nor_manufacturer spi_nor_sst = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 5 lines
Setting the correct
nor->mtd._writein a fixup hook was misleading, since this is not a fixup, just a specific setting for SST, that differs from the SPI NOR core default init.Signed-off-by Tudor Ambarus <[email protected]>
Just a comment below.
Quoted 9 lines
--- drivers/mtd/spi-nor/sst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mtd/spi-nor/sst.c +0
-0
drivers/mtd/spi-nor/sst.c static int sst_write(struct mtd_info *mtd, · line 183
Quoted 8 lines
drivers/mtd/spi-nor/sst.c +1
-1@@ -177,14 +177,14 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, return ret; } -static void sst_post_sfdp_fixups (struct spi_nor *nor) +static void sst_late_init (struct spi_nor *nor) {if (nor->info->flags &SST_WRITE )
SST_WRITE is only used during to set this. Shouldn't this be a fixup per flash so we don't need that flag.
Quoted 9 lines
drivers/mtd/spi-nor/sst.c +1
-1nor->mtd._write = sst_write; }static const struct spi_nor_fixups sst_fixups = { - .post_sfdp = sst_post_sfdp_fixups, + .late_init = sst_late_init, };const struct
spi_nor_manufacturerspi_nor_sst= {
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
Quoted 27 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
Setting the correct
nor->mtd._writein a fixup hook was misleading, since this is not a fixup, just a specific setting for SST, that differs
from the SPI NOR core default init.Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Michael Walle <[email protected]>Just a comment below.
Quoted 13 lines
---
drivers/mtd/spi-nor/sst.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/mtd/spi-nor/sst.c +0
-0@@ -177,14 +177,14 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, return ret; }
Quoted 7 lines
drivers/mtd/spi-nor/sst.c static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, · line 182
Quoted 4 lines
drivers/mtd/spi-nor/sst.c +1
-1-static void sst_post_sfdp_fixups (struct spi_nor *nor) +static void sst_late_init (struct spi_nor *nor) { if (nor->info->flags & SST_WRITE)
SST_WRITEis only used during to set this. Shouldn't this be a fixup per flash so we don't need that flag.
We should get rid of the SST_WRITE indeed. Do you want me to handle this or do you want to take care of it yourself?
As a side note, I find the manufacturer fixup hooks and generic settings not scalable. We may consider to remove the per manufacturer settings in the future.
Cheers,
ta
Quoted 4 lines
Quoted 4 lines
drivers/mtd/spi-nor/sst.c +0
-0nor->mtd._write = sst_write; }
Quoted 8 lines
Quoted 6 lines
drivers/mtd/spi-nor/sst.c +1
-1static const struct spi_nor_fixups sst_fixups = { - .post_sfdp = sst_post_sfdp_fixups, + .late_init = sst_late_init, };const struct
spi_nor_manufacturerspi_nor_sst= {-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
Quoted 1 line · Tudor Ambarus
On 11/9/21 11:47 AM, Michael Walle wrote:
cut
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
drivers/mtd/spi-nor/sst.c +1
-1-static void sst_post_sfdp_fixups (struct spi_nor *nor) +static void sst_late_init (struct spi_nor *nor){
if (nor->info->flags&SST_WRITE)
SST_WRITEis only used during to set this. Shouldn't this be a fixup per flash so we don't need that flag.We should get rid of the
SST_WRITEindeed. Do you want me to handle this or do you want to take care of it yourself?
oh, I forgot, I have already took care of it, check:
[PATCH v3 13/25] mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
In reply to [email protected]Quoted 5 lines
Quoted 2 lines
SST_WRITEis only used during to set this. Shouldn't this be a fixup per flash so we don't need that flag.We should get rid of the
SST_WRITEindeed. Do you want me to handle this or do you want to take care of it yourself?
Well you already got a patch (in this series) which will do exactly this ;) But I didn't notice, because its later in this series.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write()
In reply to Tudor AmbarusQuoted 5 lines · Tudor Ambarus
Setting the correct
nor->mtd._writein a fixup hook was misleading, since this is not a fixup, just a specific setting for SST, that differs from the SPI NOR core default init.Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 11/25 mtd: spi-nor: spansion: Use manufacturer late_init()
In reply to Tudor Ambarusspansion_post_sfdp_fixups() was called regardless if the flash defined SFDP tables or not. A better place for this kind of parameters init is in manufacturer's late_init() hook. post_sfdp() should be called only when SFDP is defined. No functional change in this patch.
Instead of doing the 4b opcodes settings at manufacturer level, thus also for every flash that will be introduced, this should be done just where it is needed, per flash. I'll let this for other patch.
--- drivers/mtd/spi-nor/spansion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/spansion.c +2 -2
@@ -276,7 +276,7 @@ static const struct flash_info spansion_parts[] = { }, }; -static void spansion_post_sfdp_fixups (struct spi_nor *nor) +static void spansion_late_init (struct spi_nor *nor) {if (nor->params->size <=SZ_16M )return ;
@@ -288,7 +288,7 @@ static void spansion_post_sfdp_fixups(struct spi_nor *nor) }static const struct spi_nor_fixups spansion_fixups = { - .post_sfdp = spansion_post_sfdp_fixups, + .late_init = spansion_late_init, };const struct spi_nor_manufacturer spi_nor_spansion = {
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 11/25] mtd: spi-nor: spansion: Use manufacturer late_init()
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 10 lines
spansion_post_sfdp_fixups()was called regardless if the flash defined SFDP tables or not. A better place for this kind of parameters init is in manufacturer'slate_init()hook.post_sfdp()should be called only when SFDP is defined. No functional change in this patch.Instead of doing the 4b opcodes settings at manufacturer level, thus also for every flash that will be introduced, this should be done just where it is needed, per flash. I'll let this for other patch.
Signed-off-by Tudor Ambarus <[email protected]>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 11/25] mtd: spi-nor: spansion: Use manufacturer late_init()
In reply to Tudor AmbarusQuoted 10 lines · Tudor Ambarus
spansion_post_sfdp_fixups()was called regardless if the flash defined SFDP tables or not. A better place for this kind of parameters init is in manufacturer'slate_init()hook.post_sfdp()should be called only when SFDP is defined. No functional change in this patch.Instead of doing the 4b opcodes settings at manufacturer level, thus also for every flash that will be introduced, this should be done just where it is needed, per flash. I'll let this for other patch.
Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 12/25 mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only when SFDP is defined
In reply to Tudor Ambarusspi_nor_post_sfdp_fixups() was called even when there were no SFDP tables defined. late_init() should be instead used for flashes that do not define SFDP tables.
Use spi_nor_post_sfdp_fixups() just to fix SFDP data. post_sfdp() hook is as of now used just by s28hs512t, mt35xu512aba, and both support SFDP, there's no functional change with this patch.
--- drivers/mtd/spi-nor/core.c | 56 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 30 deletions(-)
drivers/mtd/spi-nor/core.c +26 -30
@@ -2508,6 +2508,25 @@ static void spi_nor_manufacturer_init_params(struct spi_nor *nor) nor->info->fixups->default_init (nor); } +/** +* spi_nor_post_sfdp_fixups() - Updates the flash's parameters and settings +* after SFDP has been parsed. Called only for flashes that define JESD216 SFDP +* tables. +* @nor: pointer to a 'struct spi_nor' +* +* Used to tweak various flash parameters when information provided by the SFDP +* tables are wrong. +*/ +static void spi_nor_post_sfdp_fixups (struct spi_nor *nor) +{ +if (nor->manufacturer && nor->manufacturer->fixups && + nor->manufacturer->fixups->post_sfdp) + nor->manufacturer->fixups->post_sfdp (nor); + +if (nor->info->fixups && nor->info->fixups->post_sfdp) + nor->info->fixups->post_sfdp (nor); +} +/** * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings * based on JESD216 SFDP standard.
@@ -2522,7 +2541,9 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor)memcpy (&sfdp_params, nor->params,sizeof (sfdp_params)); -if (spi_nor_parse_sfdp (nor)) { +if (!spi_nor_parse_sfdp (nor)) { +spi_nor_post_sfdp_fixups (nor); + }else {memcpy (nor->params, &sfdp_params,sizeof (*nor->params)); nor->addr_width =0 ; nor->flags &= ~SNOR_F_4B_OPCODES ;
@@ -2642,26 +2663,6 @@ static void spi_nor_info_init_params(struct spi_nor *nor)spi_nor_init_uniform_erase_map (map, erase_mask, params->size); } -/** -* spi_nor_post_sfdp_fixups() - Updates the flash's parameters and settings -* after SFDP has been parsed (is also called for SPI NORs that do not -* support RDSFDP). -* @nor: pointer to a 'struct spi_nor' -* -* Typically used to tweak various parameters that could not be extracted by -* other means (i.e. when information provided by the SFDP/flash_info tables -* are incomplete or wrong). -*/ -static void spi_nor_post_sfdp_fixups (struct spi_nor *nor) -{ -if (nor->manufacturer && nor->manufacturer->fixups && - nor->manufacturer->fixups->post_sfdp) - nor->manufacturer->fixups->post_sfdp (nor); - -if (nor->info->fixups && nor->info->fixups->post_sfdp) - nor->info->fixups->post_sfdp (nor); -} -/** * spi_nor_late_init_params() - Late initialization of default flash parameters. * @nor: pointer to a 'struct spi_nor'
@@ -2712,15 +2713,12 @@ static void spi_nor_late_init_params(struct spi_nor *nor)* Please note that there is a ->post_bfpt() fixup hook that can overwrite * the flash parameters and settings immediately after parsing the Basic * Flash Parameter Table. +* spi_nor_post_sfdp_fixups() is called after the SFDP tables are parsed. +* It is used to tweak various flash parameters when information provided +* by the SFDP tables are wrong. * * which can be overwritten by: -* 4/ Post SFDP flash parameters initialization. Used to tweak various -* parameters that could not be extracted by other means (i.e. when -* information provided by the SFDP/flash_info tables are incomplete or -* wrong). -* spi_nor_post_sfdp_fixups() -* -* 5/ Late flash parameters initialization, used to initialize flash +* 4/ 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()
@@ -2740,8 +2738,6 @@ static int spi_nor_init_params(struct spi_nor *nor) !(nor->info->flags & SPI_NOR_SKIP_SFDP))spi_nor_sfdp_init_params (nor); -spi_nor_post_sfdp_fixups (nor); -spi_nor_late_init_params (nor);return 0 ;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 12/25] mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only when SFDP is defined
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 49 lines
spi_nor_post_sfdp_fixups()was called even when there were no SFDP tables defined.late_init()should be instead used for flashes that do not define SFDP tables.Use
spi_nor_post_sfdp_fixups()just to fix SFDP data.post_sfdp()hook is as of now used just by s28hs512t, mt35xu512aba, and both support SFDP, there's no functional change with this patch.Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 56 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 30 deletions(-)drivers/mtd/spi-nor/core.c +2
-0@@ -2508,6 +2508,25 @@ static void spi_nor_manufacturer_init_params(struct spi_nor *nor) nor->info->fixups->default_init(nor); } +/** +* spi_nor_post_sfdp_fixups() - Updates the flash's parameters and settings
+ * after SFDP has been parsed. Called only for flashes that define JESD216 SFDP
+ * tables.
+ * @nor: pointer to a 'structspi_nor'
+ *
+ * Used to tweak various flash parameters when information provided by the SFDP
+ * tables are wrong.
+ */drivers/mtd/spi-nor/core.c +10
-0+static void spi_nor_post_sfdp_fixups (struct spi_nor *nor) +{ +if (nor->manufacturer && nor->manufacturer->fixups && + nor->manufacturer->fixups->post_sfdp) + nor->manufacturer->fixups->post_sfdp (nor); + +if (nor->info->fixups && nor->info->fixups->post_sfdp) + nor->info->fixups->post_sfdp (nor); +} +/** * spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings
* based on JESD216 SFDP standard.
drivers/mtd/spi-nor/core.c static void spi_nor_sfdp_init_params(struct · line 2546
Quoted 7 lines
drivers/mtd/spi-nor/core.c +2
-1@@ -2522,7 +2541,9 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor) memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); -if (spi_nor_parse_sfdp (nor)) { +if (!spi_nor_parse_sfdp (nor)) { +spi_nor_post_sfdp_fixups (nor);
I find this function particulary confusing. Why is it copying the params around? I know the function doc says rollback, but can't we make this better?
Either make spi_nor_parse_sfdp() commit the nor->params update atomically, or pass a second parameter sfdp_params, which are copied to nor->params here if spi_nor_parse_sfdp() was successful.
Also the control flow could be better.
ret = spi_nor_parse_sfdp(nor, &sfdp_params);
if (!ret) {
/* clever comment, why is addr_width = 0 here */
nor->addr_width = 0;
nor->flags &= ~SNOR_F_4B_OPCODES;
return 0;
}memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); spi_nor_post_sfdp_fixups(nor);
Having an even closer look, addr_width is set to 0 because spi_nor_parse_sfdp() is also changing that. nor->flags is also changed and not only the SNOR_F_4B_OPCODES bit. But only that one is cleared?!
I think this deserves another cleanup series. Having the rollback here makes no sense. You'd have to keep both in sync.
IMHO best would be a second parameter and make sure all code in sfdp.c don't change anything else. Which would probably mean that addr_width and flags will move to nor->params.
Anyway, for now:
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 13/25 mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
In reply to Tudor AmbarusThe flash_info flags should be generic and not manufacturer specific. Get rid of the manufacturer specific flag and use the late_init() fixup hook instead.
Please note that sst_write is now set at flash level and not globally, per manufacturer. Manufacturer hooks are generally a bad idea, because it affects settings for all the flashes and we might end up with fixups for "manufacturer settings".
--- drivers/mtd/spi-nor/core.h | 1 - drivers/mtd/spi-nor/sst.c | 100 +++++++++++++++++++++---------------- 2 files changed, 58 insertions(+), 43 deletions(-)
drivers/mtd/spi-nor/core.h +0 -1
@@ -336,7 +336,6 @@ struct flash_info {u32 flags;#define SECT_4K BIT(0)/* SPINOR_OP_BE_4K works uniformly */ #define SPI_NOR_NO_ERASE BIT(1)/* No erase command needed */ -#define SST_WRITE BIT(2)/* use SST byte programming */ #define SPI_NOR_NO_FR BIT(3)/* Can't do fastread */ #define SECT_4K_PMC BIT(4)/* SPINOR_OP_BE_4K_PMC works uniformly */ #define SPI_NOR_DUAL_READ BIT(5)/* Flash supports Dual Read */
drivers/mtd/spi-nor/sst.c +58 -42
119 lines not on this page · raw message
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 13/25] mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 9 lines
The
flash_infoflags should be generic and not manufacturer specific. Get rid of the manufacturer specific flag and use thelate_init()fixup hook instead.
Please note thatsst_writeis now set at flash level and not globally, per manufacturer. Manufacturer hooks are generally a bad idea, because it affects settings for all the flashes and we might end up with fixups for "manufacturer settings".Signed-off-by Tudor Ambarus <[email protected]>
I'm still not sure, if having a just one fixup function will scale with different flashes. What do you think about having an additional (opaque to the core) (bit)field for the manufacturer and flash fixups functions? In this case, you can reuse the same function - and then a manufacturer will make more sense (addressing Pratyush comment about a common manufacturer fixup here).
I.e. the SST_WRITE flag would go into these flags, set per flash device and the fixup can still remain in the manufacturer fixup.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 13/25] mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
Quoted 11 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 8 lines
The
flash_infoflags should be generic and not manufacturer specific. Get rid of the manufacturer specific flag and use thelate_init()fixup hook instead.
Please note thatsst_writeis now set at flash level and not globally, per manufacturer. Manufacturer hooks are generally a bad idea, because it affects settings for all the flashes and we might end up with fixups for "manufacturer settings".
Quoted 7 lines
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Michael Walle <[email protected]>I'm still not sure, if having a just one fixup function will scale with different flashes. What do you think about having an additional (opaque to the core) (bit)field for the manufacturer and flash fixups functions?
Sounds fine. I can reserve few bits to manufacturers and introduce a MANUF_FLAGS genmask for the flash_info flags. Each specific manufacturer flag will be visible just for that manufacturer. Please check patch 14/25, I can extend the idea from there.
Quoted 7 lines
In this case, you can reuse the same function - and then a manufacturer will make more sense (addressing Pratyush comment about a common manufacturer fixup here).
I.e. the
SST_WRITEflag would go into these flags, set per flash device and the fixup can still remain in the manufacturer fixup.
Right. Let me know if a MANUF_FLAGS genmask is better than this patch.
Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 13/25] mtd: spi-nor: sst: Get rid of SST_WRITE flash_info flag
Am 2021-11-09 13:31, schrieb [email protected]:
Quoted 30 lines · Michael Walle
Quoted 11 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 8 lines
The
flash_infoflags should be generic and not manufacturer specific. Get rid of the manufacturer specific flag and use thelate_init()fixup hook instead.
Please note thatsst_writeis now set at flash level and not globally, per manufacturer. Manufacturer hooks are generally a bad idea, because it affects settings for all the flashes and we might end up with fixups for "manufacturer settings".Quoted 7 lines
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Michael Walle <[email protected]>I'm still not sure, if having a just one fixup function will scale with different flashes. What do you think about having an additional (opaque to the core) (bit)field for the manufacturer and flash fixups functions?
Sounds fine. I can reserve few bits to manufacturers and introduce a
MANUF_FLAGSgenmask for theflash_infoflags. Each specific manufacturer flag will be visible just for that manufacturer. Please check patch 14/25, I can extend the idea from there.Quoted 4 lines
In this case, you can reuse the same function - and then a manufacturer will make more sense (addressing Pratyush comment about a common manufacturer fixup here).
Quoted 5 lines
Quoted 3 lines
I.e. the
SST_WRITEflag would go into these flags, set per flash device and the fixup can still remain in the manufacturer fixup.Right. Let me know if a
MANUF_FLAGSgenmask is better than this patch.
Yes, I think so.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 14/25 mtd: spi-nor: Introduce flash_info flags masks
In reply to Tudor AmbarusClarify for what the flash_info flags are used for. Split them in three categories:
1/ NON_SFDP_FLAGS: flags that indicate support that is not defined
by the JESD216 standard in its SFDP tables.
2/ SFDP_FLAGS: flags that indicate support that can be discovered
via SFDP. These flags are used when the flash does not define the SFDP tables. Used together with SPI_NOR_SKIP_SFDP flag.
3/ FIXUP_FLAGS: flags that indicate support that can be discovered
via SFDP ideally, but can not be discovered for this particular flash because the SFDP table that indicates this support is not defined by 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.
Manufacturer specific flags like USE_CLSR, USE_FSR, SPI_NOR_XSR_RDY, will be removed in a future series.
BIT(0) was kept for SPI_NOR_PARSE_SFDP (will be introduced in a further patch).
--- drivers/mtd/spi-nor/core.h | 89 ++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 32 deletions(-)
drivers/mtd/spi-nor/core.h +57 -32
@@ -334,56 +334,81 @@ struct flash_info {u16 addr_width;u32 flags; -#define SECT_4K BIT(0)/* SPINOR_OP_BE_4K works uniformly */ -#define SPI_NOR_NO_ERASE BIT(1)/* No erase command needed */ -#define SPI_NOR_NO_FR BIT(3)/* Can't do fastread */ -#define SECT_4K_PMC BIT(4)/* SPINOR_OP_BE_4K_PMC works uniformly */ -#define SPI_NOR_DUAL_READ BIT(5)/* Flash supports Dual Read */ -#define SPI_NOR_QUAD_READ BIT(6)/* Flash supports Quad Read */ -#define USE_FSR BIT(7)/* use flag status register */ -#define SPI_NOR_HAS_LOCK BIT(8)/* Flash supports lock/unlock via SR */ -#define SPI_NOR_HAS_TB BIT(9)/* +#define SPI_NOR_SKIP_SFDP BIT(1)/* Skip parsing of SFDP tables */ + +/* +* Flags that indicate support that is not defined by the JESD216 standard in +* its SFDP tables. +*/ +#define NON_SFDP_FLAGS_MASK GENMASK(15, 2) +#define NON_SFDP_FLAGS (x) ((x) & NON_SFDP_FLAGS_MASK) +#define SPI_NOR_HAS_LOCK BIT(2)/* Flash supports lock/unlock via SR */ +#define SPI_NOR_HAS_TB BIT(3)/* * Flash SR has Top/Bottom (TB) protect * bit. Must be used with * SPI_NOR_HAS_LOCK. */ -#define SPI_NOR_XSR_RDY BIT(10)/* -* S3AN flashes have specific opcode to -* read the status register. -*/ -#define SPI_NOR_4B_OPCODES BIT(11)/* -* Use dedicated 4byte address op codes -* to support memory size above 128Mib. -*/ -#define NO_CHIP_ERASE BIT(12)/* Chip does not support chip erase */ -#define SPI_NOR_SKIP_SFDP BIT(13)/* Skip parsing of SFDP tables */ -#define USE_CLSR BIT(14)/* use CLSR command */ -#define SPI_NOR_OCTAL_READ BIT(15)/* Flash supports Octal Read */ -#define SPI_NOR_TB_SR_BIT6 BIT(16)/* +#define SPI_NOR_TB_SR_BIT6 BIT(4)/* * Top/Bottom (TB) is bit 6 of * status register. Must be used with * SPI_NOR_HAS_TB. */ -#define SPI_NOR_4BIT_BP BIT(17)/* +#define SPI_NOR_4BIT_BP BIT(5)/* * Flash SR has 4 bit fields (BP0-3) * for block protection. */ -#define SPI_NOR_BP3_SR_BIT6 BIT(18)/* +#define SPI_NOR_BP3_SR_BIT6 BIT(6)/* * BP3 is bit 6 of status register. * Must be used with SPI_NOR_4BIT_BP. */ -#define SPI_NOR_OCTAL_DTR_READ BIT(19)/* Flash supports octal DTR Read. */ -#define SPI_NOR_OCTAL_DTR_PP BIT(20)/* Flash supports Octal DTR Page Program */ -#define SPI_NOR_IO_MODE_EN_VOLATILE BIT(21)/* -* Flash enables the best -* available I/O mode via a -* volatile bit. -*/ -#define SPI_NOR_SWP_IS_VOLATILE BIT(22)/* +#define SPI_NOR_SWP_IS_VOLATILE BIT(7)/* * Flash has volatile software write * protection bits. Usually these will * power-up in a write-protected state. */ +#define SPI_NOR_NO_ERASE BIT(8)/* No erase command needed */ +#define NO_CHIP_ERASE BIT(9)/* Chip does not support chip erase */ +#define SPI_NOR_NO_FR BIT(10)/* Can't do fastread */ +#define USE_CLSR BIT(11)/* use CLSR command */ +#define USE_FSR BIT(12)/* use flag status register */ +#define SPI_NOR_XSR_RDY BIT(13)/* +* S3AN flashes have specific opcode to +* read the status register. +*/ + +/* +* Flags that indicate support that can be discovered via SFDP. Used when SFDP +* tables are not defined in the flash. These flags are used together with the +* SPI_NOR_SKIP_SFDP flag. +*/ +#define SFDP_FLAGS_MASK GENMASK(23, 16) +#define SFDP_FLAGS (x) ((x) & SFDP_FLAGS_MASK) +#define SECT_4K BIT(16)/* SPINOR_OP_BE_4K works uniformly */ +#define SECT_4K_PMC BIT(17)/* SPINOR_OP_BE_4K_PMC works uniformly */ +#define SPI_NOR_DUAL_READ BIT(18)/* Flash supports Dual Read */ +#define SPI_NOR_QUAD_READ BIT(19)/* Flash supports Quad Read */ +#define SPI_NOR_OCTAL_READ BIT(20)/* Flash supports Octal Read */ +#define SPI_NOR_OCTAL_DTR_READ BIT(21)/* Flash supports octal DTR Read. */ +#define SPI_NOR_OCTAL_DTR_PP BIT(22)/* Flash supports Octal DTR Page Program */ + +/* +* Flags that indicate support that can be discovered via SFDP ideally, but can +* not be discovered for this particular flash because the SFDP table that +* indicates this support is not defined by 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. +*/ +#define FIXUP_FLAGS_MASK GENMASK(31, 24) +#define FIXUP_FLAGS (x) ((x) & FIXUP_FLAGS_MASK) +#define SPI_NOR_4B_OPCODES BIT(24)/* +* Use dedicated 4byte address op codes +* to support memory size above 128Mib. +*/ +#define SPI_NOR_IO_MODE_EN_VOLATILE BIT(25)/* +* Flash enables the best +* available I/O mode via a +* volatile bit. +*/ const struct spi_nor_otp_organization otp_org;
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 14/25] mtd: spi-nor: Introduce flash_info flags masks
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 16 lines
Clarify for what the
flash_infoflags are used for. Split them in three categories:
1/NON_SFDP_FLAGS: flags that indicate support that is not defined
by the JESD216 standard in its SFDP tables.
2/SFDP_FLAGS: flags that indicate support that can be discovered
via SFDP. These flags are used when the flash does not define the SFDP tables. Used together withSPI_NOR_SKIP_SFDPflag.
3/FIXUP_FLAGS: flags that indicate support that can be discovered
via SFDP ideally, but can not be discovered for this particular
flash
because the SFDP table that indicates this support is not defined by the flash. In case the table for this support is defined but has
wrong
values, one should instead use apost_sfdp()hook to set theSNOR_Fequivalent flag.
Quoted 2 lines
Manufacturer specific flags like
USE_CLSR,USE_FSR,SPI_NOR_XSR_RDY, will be removed in a future series.
While i like the partitioning of the flags, I don't really like that masks etc. Why don't you just use different members, like non_sfdp_flags sfdp_flags and fixup_flags?
This will make sure, the flags won't get mixed up. Also I'm not sure about your intention of the
info_flags = nor->info->flags & SOME_MASK;
pattern in the subsequent patches. But if you have different members you don't have to do that (although its superfluous anyway).
The flags of each group can start with BIT(0) and reorganizations of the flags won't affect other groups and will then make these patches smaller and easier to review.
If your concern is memory, then you can also use bitfields, no? To populate the flash_info structure, you already introduced a new macro. This can then just use the new member instead of ".flags".
Quoted 138 lines
BIT(0) was kept for
SPI_NOR_PARSE_SFDP(will be introduced in a further patch).Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.h | 89 ++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 32 deletions(-)drivers/mtd/spi-nor/core.h +4
-9@@ -334,56 +334,81 @@ struct flash_info {u16 addr_width; u32 flags; -#define SECT_4K BIT(0)/* SPINOR_OP_BE_4K works uniformly */ -#define SPI_NOR_NO_ERASE BIT(1)/* No erase command needed */ -#define SPI_NOR_NO_FR BIT(3)/* Can't do fastread */ -#define SECT_4K_PMC BIT(4)/* SPINOR_OP_BE_4K_PMC works uniformly */ -#define SPI_NOR_DUAL_READ BIT(5)/* Flash supports Dual Read */ -#define SPI_NOR_QUAD_READ BIT(6)/* Flash supports Quad Read */ -#define USE_FSR BIT(7)/* use flag status register */ -#define SPI_NOR_HAS_LOCK BIT(8)/* Flash supports lock/unlock via SR */ -#define SPI_NOR_HAS_TB BIT(9)/* +#define SPI_NOR_SKIP_SFDP BIT(1)/* Skip parsing of SFDP tables */ + +/* +* Flags that indicate support that is not defined by the JESD216 standard in
+ * its SFDP tables.
+ */drivers/mtd/spi-nor/core.h +3
-0+#define NON_SFDP_FLAGS_MASK GENMASK(15, 2) +#define NON_SFDP_FLAGS (x) ((x) & NON_SFDP_FLAGS_MASK) +#define SPI_NOR_HAS_LOCK BIT(2)/* Flash supports lock/unlock via SR */
drivers/mtd/spi-nor/core.h +4
-16+#define SPI_NOR_HAS_TB BIT(3)/* * Flash SR has Top/Bottom (TB) protect * bit. Must be used with * SPI_NOR_HAS_LOCK. */ -#define SPI_NOR_XSR_RDY BIT(10)/* -* S3AN flashes have specific opcode to -* read the status register. -*/ -#define SPI_NOR_4B_OPCODES BIT(11)/* -* Use dedicated 4byte address op codes -* to support memory size above 128Mib. -*/ -#define NO_CHIP_ERASE BIT(12)/* Chip does not support chip erase */ -#define SPI_NOR_SKIP_SFDP BIT(13)/* Skip parsing of SFDP tables */ -#define USE_CLSR BIT(14)/* use CLSR command */ -#define SPI_NOR_OCTAL_READ BIT(15)/* Flash supports Octal Read */ -#define SPI_NOR_TB_SR_BIT6 BIT(16)/* +#define SPI_NOR_TB_SR_BIT6 BIT(4)/* * Top/Bottom (TB) is bit 6 of * status register. Must be used with * SPI_NOR_HAS_TB. */ -#define SPI_NOR_4BIT_BP BIT(17)/* +#define SPI_NOR_4BIT_BP BIT(5)/* * Flash SR has 4 bit fields (BP0-3) * for block protection. */ -#define SPI_NOR_BP3_SR_BIT6 BIT(18)/* +#define SPI_NOR_BP3_SR_BIT6 BIT(6)/* * BP3 is bit 6 of status register. * Must be used with SPI_NOR_4BIT_BP. */ -#define SPI_NOR_OCTAL_DTR_READ BIT(19)/* Flash supports octal DTR Read. */
-#defineSPI_NOR_OCTAL_DTR_PPBIT(20) /* Flash supports Octal DTR Page
Program */drivers/mtd/spi-nor/core.h +13
-6-#define SPI_NOR_IO_MODE_EN_VOLATILE BIT(21)/* -* Flash enables the best -* available I/O mode via a -* volatile bit. -*/ -#define SPI_NOR_SWP_IS_VOLATILE BIT(22)/* +#define SPI_NOR_SWP_IS_VOLATILE BIT(7)/* * Flash has volatile software write * protection bits. Usually these will * power-up in a write-protected state. */ +#define SPI_NOR_NO_ERASE BIT(8)/* No erase command needed */ +#define NO_CHIP_ERASE BIT(9)/* Chip does not support chip erase */ +#define SPI_NOR_NO_FR BIT(10)/* Can't do fastread */ +#define USE_CLSR BIT(11)/* use CLSR command */ +#define USE_FSR BIT(12)/* use flag status register */ +#define SPI_NOR_XSR_RDY BIT(13)/* +* S3AN flashes have specific opcode to +* read the status register. +*/ + +/* +* Flags that indicate support that can be discovered via SFDP. Used when SFDP
+ * tables are not defined in the flash. These flags are used together with the
+ *SPI_NOR_SKIP_SFDPflag.
+ */drivers/mtd/spi-nor/core.h +8
-0+#define SFDP_FLAGS_MASK GENMASK(23, 16) +#define SFDP_FLAGS (x) ((x) & SFDP_FLAGS_MASK) +#define SECT_4K BIT(16)/* SPINOR_OP_BE_4K works uniformly */ +#define SECT_4K_PMC BIT(17)/* SPINOR_OP_BE_4K_PMC works uniformly */ +#define SPI_NOR_DUAL_READ BIT(18)/* Flash supports Dual Read */ +#define SPI_NOR_QUAD_READ BIT(19)/* Flash supports Quad Read */ +#define SPI_NOR_OCTAL_READ BIT(20)/* Flash supports Octal Read */ +#define SPI_NOR_OCTAL_DTR_READ BIT(21)/* Flash supports octal DTR Read. */
+#defineSPI_NOR_OCTAL_DTR_PPBIT(22) /* Flash supports Octal DTR Page
Program */drivers/mtd/spi-nor/core.h +3
-0+ +/* +* Flags that indicate support that can be discovered via SFDP ideally, but can
+ * not be discovered for this particular flash because the SFDP table that
+ * indicates this support is not defined by 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 theSNOR_Fequivalent flag.
+ */drivers/mtd/spi-nor/core.h +11
-0+#define FIXUP_FLAGS_MASK GENMASK(31, 24) +#define FIXUP_FLAGS (x) ((x) & FIXUP_FLAGS_MASK) +#define SPI_NOR_4B_OPCODES BIT(24)/* +* Use dedicated 4byte address op codes +* to support memory size above 128Mib. +*/ +#define SPI_NOR_IO_MODE_EN_VOLATILE BIT(25)/* +* Flash enables the best +* available I/O mode via a +* volatile bit. +*/ const struct spi_nor_otp_organization otp_org;
Signature · 5 lines
-michael ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 14/25] mtd: spi-nor: Introduce flash_info flags masks
Quoted 19 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 16 lines
Clarify for what the
flash_infoflags are used for. Split them in three categories:
1/NON_SFDP_FLAGS: flags that indicate support that is not defined by the JESD216 standard in its SFDP tables.
2/SFDP_FLAGS: flags that indicate support that can be discovered via SFDP. These flags are used when the flash does not define the SFDP tables. Used together withSPI_NOR_SKIP_SFDPflag. 3/FIXUP_FLAGS: flags that indicate support that can be discovered via SFDP ideally, but can not be discovered for this particular flash
because the SFDP table that indicates this support is not defined by the flash. In case the table for this support is defined but has wrong
values, one should instead use apost_sfdp()hook to set theSNOR_Fequivalent flag.
Quoted 6 lines
Quoted 2 lines
Manufacturer specific flags like
USE_CLSR,USE_FSR,SPI_NOR_XSR_RDY, will be removed in a future series.While i like the partitioning of the flags, I don't really like that masks etc. Why don't you just use different members, like
non_sfdp_flagssfdp_flagsandfixup_flags?
because of memory concerns. But I think I can substitute the u32 flags with u16 and u8 equivalents, so will end with the same memory footprint. Will implement this, thanks.
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 15/25 mtd: spi-nor: Introduce spi_nor_nonsfdp_init_flags()
In reply to Tudor AmbarusUsed to initialize the NOR flags for settings that are not defined in the JESD216 SFDP standard, thus can not be retrieved when parsing SFDP.
This moves the setting of SNOR_F_READY_XSR_RDY and SNOR_F_HAS_LOCK late in the init call, without any functional change expected. The rest of the flags were already set after the spi_nor_init_params().
--- drivers/mtd/spi-nor/core.c | 88 ++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 36 deletions(-)
drivers/mtd/spi-nor/core.c +52 -36
@@ -2663,6 +2663,56 @@ static void spi_nor_info_init_params(struct spi_nor *nor)spi_nor_init_uniform_erase_map (map, erase_mask, params->size); } +/** +* spi_nor_nonsfdp_init_flags() - Initialize NOR flags for settings that are not +* defined in the JESD216 SFDP standard, thus can not be retrieved when parsing +* SFDP. +* @nor: pointer to a 'struct spi_nor' +*/ +static void spi_nor_nonsfdp_init_flags (struct spi_nor *nor) +{ +struct device_node *np =spi_nor_get_flash_node (nor); +const u32 info_flags = nor->info->flags &NON_SFDP_FLAGS_MASK ; + +if (of_property_read_bool (np,"broken-flash-reset" )) + nor->flags |=SNOR_F_BROKEN_RESET ; + +if (info_flags &SPI_NOR_SWP_IS_VOLATILE ) + nor->flags |=SNOR_F_SWP_IS_VOLATILE ; + +if (info_flags &SPI_NOR_HAS_LOCK ) + nor->flags |=SNOR_F_HAS_LOCK ; + +if (info_flags &SPI_NOR_HAS_TB ) { + nor->flags |=SNOR_F_HAS_SR_TB ; +if (info_flags &SPI_NOR_TB_SR_BIT6 ) + nor->flags |=SNOR_F_HAS_SR_TB_BIT6 ; + } + +if (info_flags &SPI_NOR_4BIT_BP ) { + nor->flags |=SNOR_F_HAS_4BIT_BP ; +if (info_flags &SPI_NOR_BP3_SR_BIT6 ) + nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; + } + +if (info_flags &NO_CHIP_ERASE ) + nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ; + +if (info_flags &USE_CLSR ) + nor->flags |=SNOR_F_USE_CLSR ; + +if (info_flags &USE_FSR ) + nor->flags |=SNOR_F_USE_FSR ; + +/* +* Make sure the XSR_RDY flag is set before calling +* spi_nor_wait_till_ready(). Xilinx S3AN share MFR +* with Atmel SPI NOR. +*/ +if (info_flags &SPI_NOR_XSR_RDY ) + nor->flags |=SNOR_F_READY_XSR_RDY ; +} +/** * spi_nor_late_init_params() - Late initialization of default flash parameters. * @nor: pointer to a 'struct spi_nor'
@@ -2680,6 +2730,8 @@ static void spi_nor_late_init_params(struct spi_nor *nor)if (nor->info->fixups && nor->info->fixups->late_init) nor->info->fixups->late_init (nor); +spi_nor_nonsfdp_init_flags (nor); +/* * NOR protection support. When locking_ops are not provided, we pick * the default ones.
@@ -3111,7 +3163,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,const struct flash_info *info;struct device *dev = nor->dev;struct mtd_info *mtd = &nor->mtd; -struct device_node *np =spi_nor_get_flash_node (nor);int ret;int i;
@@ -3148,46 +3199,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,mutex_init (&nor->lock); -/* -* Make sure the XSR_RDY flag is set before calling -* spi_nor_wait_till_ready(). Xilinx S3AN share MFR -* with Atmel SPI NOR. -*/ -if (info->flags &SPI_NOR_XSR_RDY ) - nor->flags |=SNOR_F_READY_XSR_RDY ; - -if (info->flags &SPI_NOR_HAS_LOCK ) - nor->flags |=SNOR_F_HAS_LOCK ; -/* Init flash parameters based on flash_info struct and SFDP */ ret =spi_nor_init_params (nor);if (ret)return ret; -if (info->flags &USE_FSR ) - nor->flags |=SNOR_F_USE_FSR ; -if (info->flags &SPI_NOR_HAS_TB ) { - nor->flags |=SNOR_F_HAS_SR_TB ; -if (info->flags &SPI_NOR_TB_SR_BIT6 ) - nor->flags |=SNOR_F_HAS_SR_TB_BIT6 ; - } - -if (info->flags &NO_CHIP_ERASE ) - nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ; -if (info->flags &USE_CLSR ) - nor->flags |=SNOR_F_USE_CLSR ; -if (info->flags &SPI_NOR_SWP_IS_VOLATILE ) - nor->flags |=SNOR_F_SWP_IS_VOLATILE ; - -if (info->flags &SPI_NOR_4BIT_BP ) { - nor->flags |=SNOR_F_HAS_4BIT_BP ; -if (info->flags &SPI_NOR_BP3_SR_BIT6 ) - nor->flags |=SNOR_F_HAS_SR_BP3_BIT6 ; - } - -if (of_property_read_bool (np,"broken-flash-reset" )) - nor->flags |=SNOR_F_BROKEN_RESET ; -/* * Configure the SPI memory: * - select op codes for (Fast) Read, Page Program and Sector Erase.
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 15/25] mtd: spi-nor: Introduce spi_nor_nonsfdp_init_flags()
Quoted 8 lines · Tudor Ambarus
Used to initialize the NOR flags for settings that are not defined in the JESD216 SFDP standard, thus can not be retrieved when parsing SFDP.
This moves the setting ofSNOR_F_READY_XSR_RDYandSNOR_F_HAS_LOCKlate in the init call, without any functional change expected. The rest of the flags were already set after thespi_nor_init_params().Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 16/25 mtd: spi-nor: Introduce spi_nor_init_fixup_flags()
In reply to Tudor AmbarusInitialize 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 his support is defined but has wrong values, one should instead use a post_sfdp() hook to set the SNOR_F equivalent flag.
Update all flash_info entries that use SPI_NOR_4B_OPCODES or SPI_NOR_IO_MODE_EN_VOLATILE to also use the FIXUP_FLAGS() macro. This should highlight to developers that those flags should be used only as fixups, where flashes miss to define the SFDP tables that describe those settings.
No functional change intended in this patch.
--- drivers/mtd/spi-nor/core.c | 26 ++++++++++++++++++++------ drivers/mtd/spi-nor/gigadevice.c | 5 +++-- drivers/mtd/spi-nor/issi.c | 4 ++-- drivers/mtd/spi-nor/macronix.c | 13 ++++++++----- drivers/mtd/spi-nor/micron-st.c | 20 ++++++++++++-------- drivers/mtd/spi-nor/spansion.c | 6 +++--- 6 files changed, 48 insertions(+), 26 deletions(-)
drivers/mtd/spi-nor/core.c +20 -6
@@ -2713,6 +2713,25 @@ static void spi_nor_nonsfdp_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 u32 info_flags = nor->info->flags &FIXUP_FLAGS_MASK ; + +if (info_flags &SPI_NOR_4B_OPCODES ) + nor->flags |=SNOR_F_4B_OPCODES ; + +if (info_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'
@@ -2731,6 +2750,7 @@ static void spi_nor_late_init_params(struct spi_nor *nor) nor->info->fixups->late_init (nor);spi_nor_nonsfdp_init_flags (nor); +spi_nor_init_fixup_flags (nor);/* * NOR protection support. When locking_ops are not provided, we pick
@@ -3214,12 +3234,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (ret)return ret; -if (info->flags &SPI_NOR_4B_OPCODES ) - nor->flags |=SNOR_F_4B_OPCODES ; - -if (info->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;
drivers/mtd/spi-nor/gigadevice.c +3 -2
@@ -47,8 +47,9 @@ static const struct flash_info gigadevice_parts[] = { SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, {"gd25q256" ,INFO (0xc84019 ,0 ,64 *1024 ,512 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_4B_OPCODES |SPI_NOR_HAS_LOCK | -SPI_NOR_HAS_TB |SPI_NOR_TB_SR_BIT6 ) +SPI_NOR_HAS_LOCK |SPI_NOR_HAS_TB | +SPI_NOR_TB_SR_BIT6 | +FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) .fixups = &gd25q256_fixups }, };
drivers/mtd/spi-nor/issi.c +2 -2
@@ -46,7 +46,7 @@ static const struct flash_info issi_parts[] = { SECT_4K | SPI_NOR_DUAL_READ) }, {"is25lp256" ,INFO (0x9d6019 ,0 ,64 *1024 ,512 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_4B_OPCODES ) +FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) .fixups = &is25lp256_fixups }, { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
@@ -56,7 +56,7 @@ static const struct flash_info issi_parts[] = { SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, {"is25wp256" ,INFO (0x9d7019 ,0 ,64 *1024 ,512 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_4B_OPCODES ) +FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) .fixups = &is25lp256_fixups },/* PMC */
drivers/mtd/spi-nor/macronix.c +8 -5
@@ -65,20 +65,22 @@ static const struct flash_info macronix_parts[] = { SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) .fixups = &mx25l25635_fixups }, {"mx25u25635f" ,INFO (0xc22539 ,0 ,64 *1024 ,512 , - SECT_4K | SPI_NOR_4B_OPCODES) }, + SECT_4K | FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024,SECT_4K |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "mx25v8035f", INFO(0xc22314, 0, 64 * 1024, 16,SECT_4K |SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, { "mx66l51235f", INFO(0xc2201a, 0, 64 * 1024, 1024,SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024,SECT_4K |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "mx66l1g45g", INFO(0xc2201b, 0, 64 * 1024, 2048,SECT_4K |SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
@@ -86,7 +88,8 @@ static const struct flash_info macronix_parts[] = { SPI_NOR_QUAD_READ) }, {"mx66u2g45g" ,INFO (0xc2253c ,0 ,64 *1024 ,4096 ,SECT_4K |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, };static void macronix_default_init (struct spi_nor *nor)
drivers/mtd/spi-nor/micron-st.c +12 -8
@@ -121,13 +121,13 @@ static struct spi_nor_fixups mt35xu512aba_fixups = {static const struct flash_info micron_parts[] = { {"mt35xu512aba" ,INFO (0x2c5b1a ,0 ,128 *1024 ,512 ,SECT_4K |USE_FSR |SPI_NOR_OCTAL_READ | -SPI_NOR_4B_OPCODES |SPI_NOR_OCTAL_DTR_READ | -SPI_NOR_OCTAL_DTR_PP | -SPI_NOR_IO_MODE_EN_VOLATILE ) +SPI_NOR_OCTAL_DTR_READ |SPI_NOR_OCTAL_DTR_PP | +FIXUP_FLAGS (SPI_NOR_4B_OPCODES | +SPI_NOR_IO_MODE_EN_VOLATILE )) .fixups = &mt35xu512aba_fixups}, {"mt35xu02g" ,INFO (0x2c5b1c ,0 ,128 *1024 ,2048 ,SECT_4K |USE_FSR |SPI_NOR_OCTAL_READ | -SPI_NOR_4B_OPCODES ) }, +FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) }, };static const struct flash_info st_parts[] = {
@@ -151,25 +151,29 @@ static const struct flash_info st_parts[] = { SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6) }, {"mt25ql256a" ,INFO6 (0x20ba19 ,0x104400 ,64 *1024 ,512 ,SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "mt25qu256a", INFO6(0x20bb19, 0x104400, 64 * 1024, 512,SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, { "mt25ql512a", INFO6(0x20ba20, 0x104400, 64 * 1024, 1024,SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024,SECT_4K |USE_FSR |SPI_NOR_QUAD_READ |SPI_NOR_HAS_LOCK |SPI_NOR_HAS_TB | SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6) }, { "mt25qu512a", INFO6(0x20bb20, 0x104400, 64 * 1024, 1024,SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | - SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, +SPI_NOR_QUAD_READ | + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB |
drivers/mtd/spi-nor/spansion.c +3 -3
@@ -260,13 +260,13 @@ static const struct flash_info spansion_parts[] = { SECT_4K | SPI_NOR_DUAL_READ) }, {"s25fl064l" ,INFO (0x016017 ,0 ,64 *1024 ,128 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "s25fl128l", INFO(0x016018, 0, 64 * 1024, 256,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "s25fl256l", INFO(0x016019, 0, 64 * 1024, 512,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, + FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) }, { "cy15x104q", INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1, SPI_NOR_NO_ERASE) }, { "s28hs512t", INFO(0x345b1a, 0, 256 * 1024, 256,
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 16/25] mtd: spi-nor: Introduce spi_nor_init_fixup_flags()
Quoted 12 lines · Tudor Ambarus
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 his support is defined but has wrong values, one should instead use a
post_sfdp()hook to set theSNOR_Fequivalent flag.
Update allflash_infoentries that useSPI_NOR_4B_OPCODESorSPI_NOR_IO_MODE_EN_VOLATILEto also use theFIXUP_FLAGS()macro. This should highlight to developers that those flags should be used only as fixups, where flashes miss to define the SFDP tables that describe those settings.
No functional change intended in this patch.
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 17/25 mtd: spi-nor: core: Introduce SPI_NOR_PARSE_SFDP
In reply to Tudor AmbarusSPI NOR flashes that statically declare one of the SPI_NOR_{DUAL, QUAD, OCTAL, OCTAL_DTR}_READ flags and do not support the RDSFDP command are gratuiously receiving the RDSFDP command in the attempt of parsing the SFDP tables. It is not desirable to issue commands that are not supported, so introduce a flag to help on this situation.
New flash additions that support the SFDP standard should be declared using SPI_NOR_PARSE_SFDP. Support that can be discovered when parsing SFDP should not be duplicated by explicit flags at flash declaration. All the flash parameters will be discovered when parsing SFDP. Sometimes manufacturers wrongly define some fields in the SFDP tables. If that's the case, SFDP data can be amended with the fixups() hooks. It is not common, but if the SFDP tables are entirely wrong, and it does not worth the hassle to tweak the SFDP parameters by using the fixups hooks, or if the flash does not define the SFDP tables at all, then statically init the flash with the SPI_NOR_SKIP_SFDP flag and specify the rest of flash capabilities with the flash info flags.
With time, we want to convert all flashes to SPI_NOR_PARSE_SFDP and stop triggering the SFDP parsing with the
SPI_NOR_{DUAL, QUAD, OCTAL*}_READ flags. Getting rid of the SPI_NOR_{OCTAL, OCTAL_DTR}_READ trigger is easily achievable, the rest are a long term goal.
--- drivers/mtd/spi-nor/core.c | 3 ++- drivers/mtd/spi-nor/core.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
@@ -2805,7 +2805,8 @@ static int spi_nor_init_params(struct spi_nor *nor)spi_nor_manufacturer_init_params (nor); -if ((nor->info->flags & (SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | +if ((nor->info->flags & (SPI_NOR_PARSE_SFDP | +SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ |SPI_NOR_OCTAL_READ |SPI_NOR_OCTAL_DTR_READ )) && !(nor->info->flags &SPI_NOR_SKIP_SFDP ))spi_nor_sfdp_init_params (nor);
drivers/mtd/spi-nor/core.h +1 -0
@@ -334,6 +334,7 @@ struct flash_info {u16 addr_width;u32 flags; +#define SPI_NOR_PARSE_SFDP BIT(0)/* Flash initialized based on SFDP. */ #define SPI_NOR_SKIP_SFDP BIT(1)/* Skip parsing of SFDP tables */ /*
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 18/25 mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions
In reply to Tudor AmbarusNew flash additions that support SFDP should be declared with SPI_NOR_PARSE_SFDP and with all the other flags that are not SFDP discoverable.
Keep the old way of initializing the flash, until all the flashes are converted to use either SPI_NOR_PARSE_SFDP or SPI_NOR_SKIP_SFDP. Since we want to get rid of the default_init() hook, the rollback mechanism for flashes that use SPI_NOR_PARSE_SFDP does not call spi_nor_manufacturer_init_params().
Split spi_nor_info_init_params() in spi_nor_init_default_params() and spi_nor_skip_sfdp_init_params(). spi_nor_init_default_params() is called for all the flashes regardless if they support SFDP or not. spi_nor_skip_sfdp_init_params() is called just for the flashes that do not define SFDP and initializes parameters and setting solely based on flash_info data.
--- drivers/mtd/spi-nor/core.c | 187 +++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 82 deletions(-)
drivers/mtd/spi-nor/core.c +105 -82
@@ -2493,6 +2493,56 @@ static int spi_nor_setup(struct spi_nor *nor,return nor->params->setup (nor, hwcaps); } +/** +* spi_nor_init_default_params() - Default initialization of flash parameters +* and settings. Done for all flashes, regardless is they define SFDP tables +* or not. +* @nor: pointer to a 'struct spi_nor'. +*/ +static void spi_nor_init_default_params (struct spi_nor *nor) +{ +struct spi_nor_flash_parameter *params = nor->params; +const struct flash_info *info = nor->info; +struct device_node *np =spi_nor_get_flash_node (nor); + + params->quad_enable = spi_nor_sr2_bit1_quad_enable; + params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; + params->setup = spi_nor_default_setup; + params->otp.org = &info->otp_org; + +/* Default to 16-bit Write Status (01h) Command */ + nor->flags |=SNOR_F_HAS_16BIT_SR ; + +/* Set SPI NOR sizes. */ + params->writesize =1 ; + params->size = (u64 )info->sector_size * info->n_sectors; + params->page_size = info->page_size; + +if (!(info->flags &SPI_NOR_NO_FR )) { +/* Default to Fast Read for DT and non-DT platform devices. */ + params->hwcaps.mask |=SNOR_HWCAPS_READ_FAST ; + +/* Mask out Fast Read if not requested at DT instantiation. */ +if (np && !of_property_read_bool (np,"m25p,fast-read" )) + params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST ; + } + +/* (Fast) Read settings. */ + params->hwcaps.mask |=SNOR_HWCAPS_READ ; +spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ ], +0 ,0 ,SPINOR_OP_READ , +SNOR_PROTO_1_1_1 ); + +if (params->hwcaps.mask &SNOR_HWCAPS_READ_FAST ) +spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_FAST ], +0 ,8 ,SPINOR_OP_READ_FAST , +SNOR_PROTO_1_1_1 ); +/* Page Program settings. */ + params->hwcaps.mask |=SNOR_HWCAPS_PP ; +spi_nor_set_pp_settings (¶ms->page_programs[SNOR_CMD_PP ], +SPINOR_OP_PP ,SNOR_PROTO_1_1_1 ); +} +/** * spi_nor_manufacturer_init_params() - Initialize the flash's parameters and * settings based on MFR register and ->default_init() hook.
@@ -2528,109 +2578,46 @@ static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) }/** -* spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings -* based on JESD216 SFDP standard. -* @nor: pointer to a 'struct spi_nor'. -* -* The method has a roll-back mechanism: in case the SFDP parsing fails, the -* legacy flash parameters and settings will be restored. -*/ -static void spi_nor_sfdp_init_params (struct spi_nor *nor) -{ -struct spi_nor_flash_parameter sfdp_params; - -memcpy (&sfdp_params, nor->params,sizeof (sfdp_params)); - -if (!spi_nor_parse_sfdp (nor)) { -spi_nor_post_sfdp_fixups (nor); - }else { -memcpy (nor->params, &sfdp_params,sizeof (*nor->params)); - nor->addr_width =0 ; - nor->flags &= ~SNOR_F_4B_OPCODES ; - } -} - -/** -* spi_nor_info_init_params() - Initialize the flash's parameters and settings -* based on nor->info data. +* spi_nor_skip_sfdp_init_params() - Initialize the flash's parameters and +* settings based on nor->info data. * @nor: pointer to a 'struct spi_nor'. */ -static void spi_nor_info_init_params (struct spi_nor *nor) +static void spi_nor_skip_sfdp_init_params (struct spi_nor *nor) {struct spi_nor_flash_parameter *params = nor->params;struct spi_nor_erase_map *map = ¶ms->erase_map; -const struct flash_info *info = nor->info; -struct device_node *np =spi_nor_get_flash_node (nor); +const u32 info_flags = nor->info->flags &SFDP_FLAGS_MASK ;u8 i, erase_mask; -/* Initialize default flash parameters and settings. */ - params->quad_enable = spi_nor_sr2_bit1_quad_enable; - params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; - params->setup = spi_nor_default_setup; - params->otp.org = &info->otp_org; - -/* Default to 16-bit Write Status (01h) Command */ - nor->flags |=SNOR_F_HAS_16BIT_SR ; - -/* Set SPI NOR sizes. */ - params->writesize =1 ; - params->size = (u64 )info->sector_size * info->n_sectors; - params->page_size = info->page_size; - -if (!(info->flags &SPI_NOR_NO_FR )) { -/* Default to Fast Read for DT and non-DT platform devices. */ - params->hwcaps.mask |=SNOR_HWCAPS_READ_FAST ; - -/* Mask out Fast Read if not requested at DT instantiation. */ -if (np && !of_property_read_bool (np,"m25p,fast-read" )) - params->hwcaps.mask &= ~SNOR_HWCAPS_READ_FAST ; - } - -/* (Fast) Read settings. */ - params->hwcaps.mask |=SNOR_HWCAPS_READ ; -spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ ], -0 ,0 ,SPINOR_OP_READ , -SNOR_PROTO_1_1_1 ); - -if (params->hwcaps.mask &SNOR_HWCAPS_READ_FAST ) -spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_FAST ], -0 ,8 ,SPINOR_OP_READ_FAST , -SNOR_PROTO_1_1_1 ); - -if (info->flags &SPI_NOR_DUAL_READ ) { +if (info_flags &SPI_NOR_DUAL_READ ) { params->hwcaps.mask |=SNOR_HWCAPS_READ_1_1_2 ;spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_1_1_2 ],0 ,8 ,SPINOR_OP_READ_1_1_2 ,SNOR_PROTO_1_1_2 ); } -if (info->flags &SPI_NOR_QUAD_READ ) { +if (info_flags &SPI_NOR_QUAD_READ ) { params->hwcaps.mask |=SNOR_HWCAPS_READ_1_1_4 ;spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_1_1_4 ],0 ,8 ,SPINOR_OP_READ_1_1_4 ,SNOR_PROTO_1_1_4 ); } -if (info->flags &SPI_NOR_OCTAL_READ ) { +if (info_flags &SPI_NOR_OCTAL_READ ) { params->hwcaps.mask |=SNOR_HWCAPS_READ_1_1_8 ;spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_1_1_8 ],0 ,8 ,SPINOR_OP_READ_1_1_8 ,SNOR_PROTO_1_1_8 ); } -if (info->flags &SPI_NOR_OCTAL_DTR_READ ) { +if (info_flags &SPI_NOR_OCTAL_DTR_READ ) { params->hwcaps.mask |=SNOR_HWCAPS_READ_8_8_8_DTR ;spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_8_8_8_DTR ],0 ,20 ,SPINOR_OP_READ_FAST ,SNOR_PROTO_8_8_8_DTR ); } -/* Page Program settings. */ - params->hwcaps.mask |=SNOR_HWCAPS_PP ; -spi_nor_set_pp_settings (¶ms->page_programs[SNOR_CMD_PP ], -SPINOR_OP_PP ,SNOR_PROTO_1_1_1 ); - -if (info->flags &SPI_NOR_OCTAL_DTR_PP ) { +if (info_flags &SPI_NOR_OCTAL_DTR_PP ) { params->hwcaps.mask |=SNOR_HWCAPS_PP_8_8_8_DTR ;/* * Since xSPI Page Program opcode is backward compatible with
@@ -2646,23 +2633,49 @@ static void spi_nor_info_init_params(struct spi_nor *nor)*/ erase_mask =0 ; i =0 ; -if (info->flags &SECT_4K_PMC ) { +if (info_flags &SECT_4K_PMC ) { erase_mask |=BIT (i);spi_nor_set_erase_type (&map->erase_type[i],4096u ,SPINOR_OP_BE_4K_PMC ); i++; - }else if (info->flags &SECT_4K ) { + }else if (info_flags &SECT_4K ) { erase_mask |=BIT (i);spi_nor_set_erase_type (&map->erase_type[i],4096u ,SPINOR_OP_BE_4K ); i++; } erase_mask |=BIT (i); -spi_nor_set_erase_type (&map->erase_type[i], info->sector_size, +spi_nor_set_erase_type (&map->erase_type[i], nor->info->sector_size,SPINOR_OP_SE );spi_nor_init_uniform_erase_map (map, erase_mask, params->size); } +/** +* spi_nor_sfdp_init_params() - Initialize the flash's parameters and settings +* based on JESD216 SFDP standard. +* @nor: pointer to a 'struct spi_nor'. +* +* The method has a roll-back mechanism: in case the SFDP parsing fails, the +* legacy flash parameters and settings will be restored. +*/ +static void spi_nor_sfdp_init_params (struct spi_nor *nor) +{ +struct spi_nor_flash_parameter sfdp_params; + +memcpy (&sfdp_params, nor->params,sizeof (sfdp_params)); + +if (!spi_nor_parse_sfdp (nor)) { +spi_nor_post_sfdp_fixups (nor); + }else { +memcpy (nor->params, &sfdp_params,sizeof (*nor->params)); + nor->addr_width =0 ; + nor->flags &= ~SNOR_F_4B_OPCODES ; + +if (nor->info->flags &SPI_NOR_PARSE_SFDP ) +spi_nor_skip_sfdp_init_params (nor); + } +} +/** * spi_nor_nonsfdp_init_flags() - Initialize NOR flags for settings that are not * defined in the JESD216 SFDP standard, thus can not be retrieved when parsing
@@ -2760,6 +2773,19 @@ static void spi_nor_late_init_params(struct spi_nor *nor)spi_nor_init_default_locking_ops (nor); } +static void spi_nor_init_params_deprecated (struct spi_nor *nor) +{ +spi_nor_skip_sfdp_init_params (nor); + +spi_nor_manufacturer_init_params (nor); + +if ((nor->info->flags & (SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | +SPI_NOR_OCTAL_READ | +SPI_NOR_OCTAL_DTR_READ )) && + !(nor->info->flags &SPI_NOR_SKIP_SFDP )) +spi_nor_sfdp_init_params (nor); +} +/** * spi_nor_init_params() - Initialize the flash's parameters and settings. * @nor: pointer to a 'struct spi_nor'.
@@ -2801,15 +2827,12 @@ static int spi_nor_init_params(struct spi_nor *nor)if (!nor->params)return -ENOMEM ; -spi_nor_info_init_params (nor); +spi_nor_init_default_params (nor); -spi_nor_manufacturer_init_params (nor); - -if ((nor->info->flags & (SPI_NOR_PARSE_SFDP | -SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_OCTAL_READ |SPI_NOR_OCTAL_DTR_READ )) && - !(nor->info->flags &SPI_NOR_SKIP_SFDP )) +if (nor->info->flags &SPI_NOR_PARSE_SFDP )spi_nor_sfdp_init_params (nor); +else +spi_nor_init_params_deprecated (nor);spi_nor_late_init_params (nor);
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 18/25] mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions
Quoted 15 lines · Tudor Ambarus
New flash additions that support SFDP should be declared with
SPI_NOR_PARSE_SFDPand with all the other flags that are not SFDP discoverable.
Keep the old way of initializing the flash, until all the flashes are converted to use eitherSPI_NOR_PARSE_SFDPorSPI_NOR_SKIP_SFDP. Since we want to get rid of thedefault_init()hook, the rollback mechanism for flashes that useSPI_NOR_PARSE_SFDPdoes not callspi_nor_manufacturer_init_params().
Splitspi_nor_info_init_params()inspi_nor_init_default_params()andspi_nor_skip_sfdp_init_params().spi_nor_init_default_params()is called for all the flashes regardless if they support SFDP or not.spi_nor_skip_sfdp_init_params()is called just for the flashes that do not define SFDP and initializes parameters and setting solely based onflash_infodata.
Quoted 1 line
Signed-off-by Tudor Ambarus <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 19/25 mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup()
In reply to Tudor Ambarusspi_nor_setup() configures the SPI NOR memory. Setting the addr width is too a configuration, hence we can move the spi_nor_set_addr_width() in spi_nor_setup().
--- drivers/mtd/spi-nor/core.c | 102 +++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 50 deletions(-)
drivers/mtd/spi-nor/core.c +52 -50
@@ -2484,13 +2484,61 @@ static int spi_nor_default_setup(struct spi_nor *nor,return 0 ; } +static int spi_nor_set_addr_width (struct spi_nor *nor) +{ +if (nor->addr_width) { +/* already configured from SFDP */ + }else if (nor->read_proto ==SNOR_PROTO_8_8_8_DTR ) { +/* +* In 8D-8D-8D mode, one byte takes half a cycle to transfer. So +* in this protocol an odd address width cannot be used because +* then the address phase would only span a cycle and a half. +* Half a cycle would be left over. We would then have to start +* the dummy phase in the middle of a cycle and so too the data +* phase, and we will end the transaction with half a cycle left +* over. +* +* Force all 8D-8D-8D flashes to use an address width of 4 to +* avoid this situation. +*/ + nor->addr_width =4 ; + }else if (nor->info->addr_width) { + nor->addr_width = nor->info->addr_width; + }else { + nor->addr_width =3 ; + } + +if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) { +/* enable 4-byte addressing if the device exceeds 16MiB */ + nor->addr_width =4 ; + } + +if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) { +dev_dbg (nor->dev,"address width is too large: %u\n" , + nor->addr_width); +return -EINVAL ; + } + +/* Set 4byte opcodes when possible. */ +if (nor->addr_width ==4 && nor->flags &SNOR_F_4B_OPCODES && + !(nor->flags &SNOR_F_HAS_4BAIT )) +spi_nor_set_4byte_opcodes (nor); + +return 0 ; +} +static int spi_nor_setup (struct spi_nor *nor,const struct spi_nor_hwcaps *hwcaps) { -if (!nor->params->setup) -return 0 ; +int ret; -return nor->params->setup (nor, hwcaps); +if (nor->params->setup) { + ret = nor->params->setup (nor, hwcaps); +if (ret) +return ret; + } + +return spi_nor_set_addr_width (nor); }/**
@@ -3079,49 +3127,6 @@ static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,return NULL ; } -static int spi_nor_set_addr_width (struct spi_nor *nor) -{ -if (nor->addr_width) { -/* already configured from SFDP */ - }else if (nor->read_proto ==SNOR_PROTO_8_8_8_DTR ) { -/* -* In 8D-8D-8D mode, one byte takes half a cycle to transfer. So -* in this protocol an odd address width cannot be used because -* then the address phase would only span a cycle and a half. -* Half a cycle would be left over. We would then have to start -* the dummy phase in the middle of a cycle and so too the data -* phase, and we will end the transaction with half a cycle left -* over. -* -* Force all 8D-8D-8D flashes to use an address width of 4 to -* avoid this situation. -*/ - nor->addr_width =4 ; - }else if (nor->info->addr_width) { - nor->addr_width = nor->info->addr_width; - }else { - nor->addr_width =3 ; - } - -if (nor->addr_width ==3 && nor->mtd.size >0x1000000 ) { -/* enable 4-byte addressing if the device exceeds 16MiB */ - nor->addr_width =4 ; - } - -if (nor->addr_width >SPI_NOR_MAX_ADDR_WIDTH ) { -dev_dbg (nor->dev,"address width is too large: %u\n" , - nor->addr_width); -return -EINVAL ; - } - -/* Set 4byte opcodes when possible. */ -if (nor->addr_width ==4 && nor->flags &SNOR_F_4B_OPCODES && - !(nor->flags &SNOR_F_HAS_4BAIT )) -spi_nor_set_4byte_opcodes (nor); - -return 0 ; -} -static void spi_nor_debugfs_init (struct spi_nor *nor,const struct flash_info *info) {
@@ -3253,15 +3258,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,* - select op codes for (Fast) Read, Page Program and Sector Erase. * - set the number of dummy cycles (mode cycles + wait states). * - set the SPI protocols for register and memory accesses. +* - set the address width. */ ret =spi_nor_setup (nor, hwcaps);if (ret)return ret; - ret =spi_nor_set_addr_width (nor); -if (ret) -return ret; -/* Send all the required SPI flash commands to initialize device */ ret =spi_nor_init (nor);if (ret)
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 19/25] mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup()
Am 2021-10-29 19:26, schrieb Tudor Ambarus:
Quoted 6 lines
spi_nor_setup()configures the SPI NOR memory. Setting the addr width is too a configuration, hence we can move thespi_nor_set_addr_width()inspi_nor_setup().Signed-off-by Tudor Ambarus <[email protected]>Reviewed-by Pratyush Yadav <[email protected]>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 20/25 mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
In reply to Tudor AmbarusGet rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4 0xeb, for erases SPINOR_OP_BE_4K 0x20, and for writes SPINOR_OP_PP 0x02.
--- drivers/mtd/spi-nor/sst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/sst.c +3 -2
@@ -199,8 +199,9 @@ static const struct flash_info sst_parts[] = { {"sst26vf016b" ,INFO (0xbf2641 ,0 ,64 *1024 ,32 , SECT_4K | SPI_NOR_DUAL_READ) }, { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128, -SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_HAS_LOCK |SPI_NOR_SWP_IS_VOLATILE ) +SPI_NOR_PARSE_SFDP | +NON_SFDP_FLAGS (SPI_NOR_HAS_LOCK | +SPI_NOR_SWP_IS_VOLATILE )) .fixups = &sst26vf_fixups }, };
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 20/25] mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
Quoted 8 lines · Tudor Ambarus
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_40xeb, for erasesSPINOR_OP_BE_4K0x20, and for writesSPINOR_OP_PP0x02.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id bf2643 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer sst root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname sst26vf064b root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > sst26vf064b-sfdp root@sama5d2-xplained:~# hexdump sst26vf064b-sfdp 0000000 4653 5044 0106 ff02 0600 1001 0030 ff00 0000010 0081 0601 0100 ff00 00bf 1801 0200 0100 0000020 ffff ffff ffff ffff ffff ffff ffff ffff 0000030 20fd fff1 ffff 03ff eb44 6b08 3b08 bb80 0000040 fffe ffff ffff ff00 ffff 0b44 200c d80d 0000050 d80f d810 9120 2448 6f80 811d 0fed 3877 0000060 b030 b030 fff7 ffff c229 ff5c 30f0 80c0 0000070 ffff ffff ffff ffff ffff ffff ffff ffff * 0000100 00ff ff04 7ff3 0000 7ff5 0000 fff9 007d 0000110 7ff5 0000 7ff3 0000 ffff ffff ffff ffff 0000120 ffff ffff ffff ffff ffff ffff ffff ffff * 0000200 26bf ff43 5fb9 fffd f230 f360 ff32 120a 0000210 4623 0fff 3219 190f ff19 ffff ffff ffff 0000220 6600 3899 05ff 3501 0406 3202 30b0 4272 0000230 e88d 8898 85a5 9fc0 5aaf ffff ec06 0c06 0000240 0300 0b08 ffff ffff 07ff ffff 0202 06ff 0000250 0003 fdfd 0704 fc00 0003 fefe 0202 0e07 0000260
Quoted 2 lines
drivers/mtd/spi-nor/sst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 20/25] mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
Am 2021-10-29 19:31, schrieb [email protected]:
Quoted 21 lines · Tudor Ambarus
Quoted 8 lines
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_40xeb, for erasesSPINOR_OP_BE_4K0x20, and for writesSPINOR_OP_PP0x02.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id bf2643 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer sst root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname sst26vf064b root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp
Quoted 2 lines
Quoted 1 line
sst26vf064b-sfdp
root@sama5d2-xplained:~# hexdump sst26vf064b-sfdp
xxd please, and md5sum or sha256sum or really any
checksum is missing.
same goes for the other flashes.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 20/25] mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
Quoted 24 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2021-10-29 19:31, schrieb [email protected]:
Quoted 21 lines · Tudor Ambarus
Quoted 8 lines
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_40xeb, for erasesSPINOR_OP_BE_4K0x20, and for writesSPINOR_OP_PP0x02.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id bf2643 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer sst root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname sst26vf064b root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
sst26vf064b-sfdp
root@sama5d2-xplained:~# hexdump sst26vf064b-sfdpxxd please, and md5sum or sha256sum or really any
checksum is missing.
right, I forgot the checksum.
Just curious, why do you prefer xxd over hexdump? Does it matter which tool we use?
Quoted 1 line
same goes for the other flashes.
ok, will do.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 20/25] mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
Am 2021-11-09 13:33, schrieb [email protected]:
Quoted 7 lines
Quoted 3 lines
xxd please, and md5sum or sha256sum or really any
checksum is missing.right, I forgot the checksum.
Just curious, why do you prefer xxd over hexdump? Does it matter which tool we use?
xxd can do the reverse and its easier to get the binary version of it again. also, if you use hexdump without -C (or -c) I'm not sure about the endianess.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 21/25 mtd: spi-nor: winbond: w25q256jvm: Init flash based on SFDP
In reply to Tudor AmbarusGet rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4 0xeb, for erases SPINOR_OP_BE_4K 0x20, and for writes SPINOR_OP_PP 0x02.
--- drivers/mtd/spi-nor/winbond.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/winbond.c +1 -1
@@ -95,7 +95,7 @@ static const struct flash_info winbond_parts[] = { SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) .fixups = &w25q256_fixups }, {"w25q256jvm" ,INFO (0xef7019 ,0 ,64 *1024 ,512 , - SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + SPI_NOR_PARSE_SFDP) }, { "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024,
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 21/25] mtd: spi-nor: winbond: w25q256jvm: Init flash based on SFDP
Quoted 8 lines · Tudor Ambarus
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_40xeb, for erasesSPINOR_OP_BE_4K0x20, and for writesSPINOR_OP_PP0x02.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id ef7019 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer winbond root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname w25q256jvm root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > sfdp-w25q256jvm root@sama5d2-xplained:~# hexdump sfdp-w25q256jvm 0000000 4653 5044 0105 ff00 0500 1001 0080 ff00 0000010 ffff ffff ffff ffff ffff ffff ffff ffff * 0000080 20e5 fffb ffff 0fff eb44 6b08 3b08 bb42 0000090 fffe ffff ffff 0000 ffff eb40 200c 520f 00000a0 d810 0000 0236 00a6 ea82 d314 63e9 3376 00000b0 757a 757a a2f7 5cd5 f719 ff4d 70e9 a5f9 00000c0
Quoted 2 lines
drivers/mtd/spi-nor/winbond.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 22/25 mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing
In reply to Tudor Ambaruss25fl256s0 does not define the SFDP tables nor implements the RDSFDP 0x5a command. Skip the SFDP parsing in order to avoid issuing an unsupported command to the flash.
--- drivers/mtd/spi-nor/spansion.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/spansion.c +3 -2
@@ -209,8 +209,9 @@ static const struct flash_info spansion_parts[] = {SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | USE_CLSR) }, { "s25fl256s0", INFO6(0x010219, 0x4d0080, 256 * 1024, 128, -SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | - USE_CLSR) }, +SPI_NOR_SKIP_SFDP | +SFDP_FLAGS (SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | + USE_CLSR)) }, { "s25fl256s1", INFO6(0x010219, 0x4d0180, 64 * 1024, 512,SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | USE_CLSR) },
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 23/25 mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP
In reply to Tudor AmbarusGet rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4_4B 0xec, for erases SPINOR_OP_BE_4K_4B 0x21, and for writes SPINOR_OP_PP_1_1_4_4B 0x34.
--- drivers/mtd/spi-nor/gigadevice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/gigadevice.c +3 -3
@@ -46,9 +46,9 @@ static const struct flash_info gigadevice_parts[] = { SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, {"gd25q256" ,INFO (0xc84019 ,0 ,64 *1024 ,512 , -SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | -SPI_NOR_HAS_LOCK |SPI_NOR_HAS_TB | -SPI_NOR_TB_SR_BIT6 | +SPI_NOR_PARSE_SFDP | +NON_SFDP_FLAGS (SPI_NOR_HAS_LOCK | +SPI_NOR_HAS_TB |SPI_NOR_TB_SR_BIT6 ) |FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) .fixups = &gd25q256_fixups }, };
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 23/25] mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP
Quoted 9 lines · Tudor Ambarus
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_4_4B0xec, for erasesSPINOR_OP_BE_4K_4B0x21, and for writesSPINOR_OP_PP_1_1_4_4B0x34.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id c84019 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer gigadevice root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname gd25q256 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > gd25q256-sfdp root@sama5d2-xplained:~# hexdump gd25q256-sfdp 0000000 4653 5044 0106 ff02 0600 1001 0030 ff00 0000010 00c8 0301 0090 ff00 0084 0201 00c0 ff00 0000020 ffff ffff ffff ffff ffff ffff ffff ffff 0000030 20e5 fff3 ffff 0fff eb44 6b08 3b08 bb42 0000040 ffee ffff ffff ff00 ffff ff00 200c 520f 0000050 d810 ff00 6242 fec9 e982 5814 60ec 3306 0000060 757a 757a bd04 5cd5 0600 0044 5008 0100 0000070 ffff ffff ffff ffff ffff ffff ffff ffff * 0000090 3600 2700 f99e 6477 cbfc ffff ffff ffff 00000a0 ffff ffff ffff ffff ffff ffff ffff ffff * 00000c0 0eff fff0 5c21 ffdc 00000c8
Quoted 2 lines
drivers/mtd/spi-nor/gigadevice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 24/25 mtd: spi-nor: issi: is25lp256: Init flash based on SFDP
In reply to Tudor AmbarusGet rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4_4B 0xec, for erases SPINOR_OP_BE_4K_4B 0x21, and for writes SPINOR_OP_PP_4B 0x12.
--- drivers/mtd/spi-nor/issi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/issi.c +1 -1
@@ -45,7 +45,7 @@ static const struct flash_info issi_parts[] = { {"is25lp128" ,INFO (0x9d6018 ,0 ,64 *1024 ,256 , SECT_4K | SPI_NOR_DUAL_READ) }, { "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 512, -SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ | +SPI_NOR_PARSE_SFDP |FIXUP_FLAGS (SPI_NOR_4B_OPCODES )) .fixups = &is25lp256_fixups }, { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64,
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 24/25] mtd: spi-nor: issi: is25lp256: Init flash based on SFDP
Quoted 8 lines · Tudor Ambarus
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_4_4B0xec, for erasesSPINOR_OP_BE_4K_4B0x21, and for writesSPINOR_OP_PP_4B0x12.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id 9d6019 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer issi root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname is25lp256 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > sfdp-issi root@sama5d2-xplained:~# hexdump sfdp-issi 0000000 4653 5044 0106 ff01 0600 1001 0030 ff00 0000010 059d 0301 0080 0200 ffff ffff ffff ffff 0000020 ffff ffff ffff ffff ffff ffff ffff ffff 0000030 20e5 fff9 ffff 0fff eb44 6b08 3b08 bb80 0000040 fffe ffff ffff ff00 ffff eb44 200c 520f 0000050 d810 ff00 4a23 00c9 d882 ce11 cdcc 4668 0000060 757a 757a aef7 5cd5 424a ff2c 30f0 a9f2 0000070 ffff ffff ffff ffff ffff ffff ffff ffff 0000080 3600 2300 f99e 64c0 ef8f ffff 000008c
Quoted 2 lines
drivers/mtd/spi-nor/issi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 25/25 mtd: spi-nor: macronix: mx25l25635e: Init flash based on SFDP
In reply to Tudor AmbarusGet rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4_4B 0xec, for erases SPINOR_OP_BE_4K_4B 0x21, and for writes SPINOR_OP_PP_1_4_4_4B 0x3e.
--- drivers/mtd/spi-nor/macronix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/macronix.c +1 -1
@@ -62,7 +62,7 @@ static const struct flash_info macronix_parts[] = {SECT_4K |SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, -SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) +SPI_NOR_PARSE_SFDP ) .fixups = &mx25l25635_fixups }, { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K | FIXUP_FLAGS(SPI_NOR_4B_OPCODES)) },
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 25/25] mtd: spi-nor: macronix: mx25l25635e: Init flash based on SFDP
Quoted 9 lines · Tudor Ambarus
Get rid of the static initialization of the flash parameters and init them when parsing SFDP.
Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for readsSPINOR_OP_READ_1_4_4_4B0xec, for erasesSPINOR_OP_BE_4K_4B0x21, and for writesSPINOR_OP_PP_1_4_4_4B0x3e.Signed-off-by Tudor Ambarus <[email protected]>---
root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id c22019 root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer macronix root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname mx25l25635e root@sama5d2-xplained:~# cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > mx25l25635e-sfdp root@sama5d2-xplained:~# hexdump mx25l25635e-sfdp 0000000 4653 5044 0106 ff02 0600 1001 0030 ff00 0000010 00c2 0401 0110 ff00 0084 0201 00c0 ff00 0000020 ffff ffff ffff ffff ffff ffff ffff ffff 0000030 20e5 fffb ffff 0fff eb44 6b08 3b08 bb04 0000040 fffe ffff ffff ff00 ffff eb44 200c 520f 0000050 d810 ff00 59d6 00dd 9f82 db03 0344 3867 0000060 b030 b030 bdf7 5cd5 9e4a ff29 50f0 85f9 0000070 ffff ffff ffff ffff ffff ffff ffff ffff * 00000c0 8f7f ffff 5c21 ffdc ffff ffff ffff ffff 00000d0 ffff ffff ffff ffff ffff ffff ffff ffff * 0000110 3600 2700 f99d 64c0 cb85 ffff ffff ffff 0000120
Quoted 3 lines
drivers/mtd/spi-nor/macronix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Hi,
Quoted 49 lines · Tudor Ambarus
Clean
spi_nor_scan()and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.Changes in v3:
- movelate_init()in structspi_nor_fixupsand update patches accordingly. R-b tags were dropped.
- new patch "mtd: spi-nor: sst: Get rid ofSST_WRITEflash_infoflag" moves manufacturer specific flag out of the core.
- update methods description to make it clear who sets when
- introduceflash_infoflag masks to make it clear when one should be set.
- rework "parse SFDP first idea".Tudor Ambarus (25):
mtd: spi-nor: core: Fixspi_nor_flash_parameterotp description
mtd: spi-nor: core: Usecontainer_ofto get the pointer to struct
spi_nor
mtd: spi-nor: Introducespi_nor_set_mtd_info()
mtd: spi-nor: Get rid ofnor->page_size
mtd: spi-nor: core: Introduce thelate_init()hook
mtd: spi-nor: atmel: Use flashlate_init()for locking
mtd: spi-nor: sst: Use flashlate_init()for locking
mtd: spi-nor: winbond: Use manufacturerlate_init()for OTP ops
mtd: spi-nor: xilinx: Use manufacturerlate_init()to set setup method
mtd: spi-nor: sst: Use manufacturerlate_init()to set_write()
mtd: spi-nor: spansion: Use manufacturerlate_init()
mtd: spi-nor: core: Callspi_nor_post_sfdp_fixups()only when SFDP is
defined
mtd: spi-nor: sst: Get rid ofSST_WRITEflash_infoflag
mtd: spi-nor: Introduceflash_infoflags masks
mtd: spi-nor: Introducespi_nor_nonsfdp_init_flags()
mtd: spi-nor: Introducespi_nor_init_fixup_flags()
mtd: spi-nor: core: IntroduceSPI_NOR_PARSE_SFDP
mtd: spi-nor: core: Init flash params based on SFDP first for new
flash additions
mtd: spi-nor: core: Movespi_nor_set_addr_width()inspi_nor_setup()
mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
mtd: spi-nor: winbond: w25q256jvm: Init flash based on SFDP
mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing
mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP
mtd: spi-nor: issi: is25lp256: Init flash based on SFDP
mtd: spi-nor: macronix: mx25l25635e: Init flash based on SFDP
Quoted 16 lines
drivers/mtd/spi-nor/atmel.c | 8 +- drivers/mtd/spi-nor/core.c | 480 +++++++++++++++++-------------- drivers/mtd/spi-nor/core.h | 106 ++++--- drivers/mtd/spi-nor/gigadevice.c | 7 +- drivers/mtd/spi-nor/issi.c | 6 +- drivers/mtd/spi-nor/macronix.c | 15 +- drivers/mtd/spi-nor/micron-st.c | 20 +- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/spansion.c | 15 +- drivers/mtd/spi-nor/sst.c | 105 ++++--- drivers/mtd/spi-nor/swp.c | 2 +- drivers/mtd/spi-nor/winbond.c | 7 +- drivers/mtd/spi-nor/xilinx.c | 21 +- include/linux/mtd/spi-nor.h | 2 - 14 files changed, 460 insertions(+), 336 deletions(-)
I would like to apply this when -rc1 is out. Can some of you run some tests and check if everything is ok? I have done few tests on the flashes that I mentioned in the cover letter, all should be ok. I'm particularly interested in the locking support. I can test the unlock_all on sst26vf064b validating the locking part, but it would be good if locking is tested on other flash too.
Thanks,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Michael Walle
Tested-byAm 2021-11-08 11:15, schrieb [email protected]:
Quoted 74 lines
Hi,
Quoted 53 lines · Tudor Ambarus
Clean
spi_nor_scan()and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.Changes in v3:
- movelate_init()in structspi_nor_fixupsand update patches accordingly.
R-b tags were dropped.
- new patch "mtd: spi-nor: sst: Get rid ofSST_WRITEflash_infoflag" moves manufacturer specific flag out of the core.
- update methods description to make it clear who sets when
- introduceflash_infoflag masks to make it clear when one should be set.
- rework "parse SFDP first idea".Tudor Ambarus (25):
mtd: spi-nor: core: Fixspi_nor_flash_parameterotp description
mtd: spi-nor: core: Usecontainer_ofto get the pointer to struct
spi_nor
mtd: spi-nor: Introducespi_nor_set_mtd_info()
mtd: spi-nor: Get rid ofnor->page_size
mtd: spi-nor: core: Introduce thelate_init()hook
mtd: spi-nor: atmel: Use flashlate_init()for locking
mtd: spi-nor: sst: Use flashlate_init()for locking
mtd: spi-nor: winbond: Use manufacturerlate_init()for OTP ops
mtd: spi-nor: xilinx: Use manufacturerlate_init()to set setup
method
mtd: spi-nor: sst: Use manufacturerlate_init()to set_write()
mtd: spi-nor: spansion: Use manufacturerlate_init()
mtd: spi-nor: core: Callspi_nor_post_sfdp_fixups()only when SFDP
is
defined
mtd: spi-nor: sst: Get rid ofSST_WRITEflash_infoflag
mtd: spi-nor: Introduceflash_infoflags masks
mtd: spi-nor: Introducespi_nor_nonsfdp_init_flags()
mtd: spi-nor: Introducespi_nor_init_fixup_flags()
mtd: spi-nor: core: IntroduceSPI_NOR_PARSE_SFDP
mtd: spi-nor: core: Init flash params based on SFDP first for new
flash additions
mtd: spi-nor: core: Movespi_nor_set_addr_width()inspi_nor_setup()
mtd: spi-nor: sst: sst26vf064b: Init flash based on SFDP
mtd: spi-nor: winbond: w25q256jvm: Init flash based on SFDP
mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing
mtd: spi-nor: gigadevice: gd25q256: Init flash based on SFDP
mtd: spi-nor: issi: is25lp256: Init flash based on SFDP
mtd: spi-nor: macronix: mx25l25635e: Init flash based on SFDPQuoted 17 lines
drivers/mtd/spi-nor/atmel.c | 8 +- drivers/mtd/spi-nor/core.c | 480 +++++++++++++++++-------------- drivers/mtd/spi-nor/core.h | 106 ++++--- drivers/mtd/spi-nor/gigadevice.c | 7 +- drivers/mtd/spi-nor/issi.c | 6 +- drivers/mtd/spi-nor/macronix.c | 15 +- drivers/mtd/spi-nor/micron-st.c | 20 +- drivers/mtd/spi-nor/otp.c | 2 +- drivers/mtd/spi-nor/spansion.c | 15 +- drivers/mtd/spi-nor/sst.c | 105 ++++--- drivers/mtd/spi-nor/swp.c | 2 +- drivers/mtd/spi-nor/winbond.c | 7 +- drivers/mtd/spi-nor/xilinx.c | 21 +- include/linux/mtd/spi-nor.h | 2 - 14 files changed, 460 insertions(+), 336 deletions(-)
Quoted 7 lines
I would like to apply this when -rc1 is out. Can some of you run some tests and check if everything is ok? I have done few tests on the flashes that I mentioned in the cover letter, all should be ok. I'm particularly interested in the locking support. I can test the
unlock_allon sst26vf064b validating the locking part, but it would be good if locking is tested on other flash too.
FWIW, I've quickly tested the series on a W25Q32JW (OTP only) and W25Q128 (OTP and locking, OTP patch is not upstream).
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 9 lines · Tudor Ambarus
Clean
spi_nor_scan()and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.
I generated some random data (4 MiB), erased the flash, wrote the data to the flash, read the data back, and compared it with the original image. Works fine on Micron MT35XU512ABA, Micron N25Q128A13, Cypress S28HS512T.
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Am 2021-11-16 12:36, schrieb Pratyush Yadav:
Quoted 11 lines · Tudor Ambarus
Quoted 9 lines
Clean
spi_nor_scan()and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.
Quoted 4 lines
I generated some random data (4 MiB), erased the flash, wrote the data to the flash, read the data back, and compared it with the original image. Works fine on Micron MT35XU512ABA, Micron N25Q128A13, Cypress S28HS512T.
Ahh btw. I've tested the locking with a custom patch which can dump the status register. Haven't posted that yet, because it still uses sysfs and I was thinking of converting it to debugfs.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Tudor Ambarus
AppliedRe: (subset)[PATCH v3 00/25] mtd: spi-nor: Clean params init
In reply to Tudor AmbarusQuoted 11 lines · Tudor Ambarus
Clean
spi_nor_scan()and the flash parameters initialization code. Tested all the flashes from patch set. If someone can test the locking ops on few flashes would be great. It seems that my flashes have the non volatile bits weared out.This patch set is split from:
https://lore.kernel.org/linux-mtd/[email protected]/
The ID collision series will be set in a dedicated patch set that will depend on this one.[...]
Applied to spi-nor/next, thanks!
[01/25] mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description
https://git.kernel.org/mtd/c/a360ae43217c [02/25] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor https://git.kernel.org/mtd/c/7158c86e5607 [04/25] mtd: spi-nor: Get rid of nor->page_size https://git.kernel.org/mtd/c/5854d4a6cc35 [05/25] mtd: spi-nor: core: Introduce the late_init() hook https://git.kernel.org/mtd/c/dacc8cfee493 [06/25] mtd: spi-nor: atmel: Use flash late_init() for locking https://git.kernel.org/mtd/c/b0fa1db7d2f6 [07/25] mtd: spi-nor: sst: Use flash late_init() for locking https://git.kernel.org/mtd/c/7d4ff0613fb5 [08/25] mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops https://git.kernel.org/mtd/c/00947a964949 [09/25] mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method https://git.kernel.org/mtd/c/3fdad69e7fb2 [10/25] mtd: spi-nor: sst: Use manufacturer late_init() to set _write() https://git.kernel.org/mtd/c/f22a48dbd01b [11/25] mtd: spi-nor: spansion: Use manufacturer late_init() https://git.kernel.org/mtd/c/d396e735ba0c
Best regards,
Signature · 5 lines
Tudor Ambarus <[email protected]> ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/