mtd: spi-nor: spansion: Enable JFFS2 write buffer for Infineon SEMPER flash
Subsystems (2)
cover mtd: spi-nor: spansion: Enable JFFS2 write buffer for Infineon SEMPER flash
From: Takahiro Kuwano <[email protected]>
This series changes mtd.flag handling to activate JFFS2 write buffer mode for Infineon SEMPER Flash family that has on-die ECC.
Takahiro Kuwano (2):
mtd: spi-nor: core: Allow manufacturer fixups to set nor->mtd.flags
mtd: spi-nor: spansion: Add a helper for ECC related initialization
drivers/mtd/spi-nor/core.c | 3 ++- drivers/mtd/spi-nor/spansion.c | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-)
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 1/2 mtd: spi-nor: core: Allow manufacturer fixups to set nor->mtd.flags
From: Takahiro Kuwano <[email protected]>
Infineon SEMPER Flash family has on-die ECC and multiple programming on the same 16-byte ECC data unit is not allowed to preserve ECC.
In JFFS2, ECC'd NOR Flash is supported when CONFIG_JFFS2_FS_WRITEBUFFER is set and MTD_BIT_WRITEABLE is not set in mtd.flag.
In spi-nor/core, the mtd.flags is set to MTD_CAP_NORFLASH that defined as (MTD_WRITEABLE | MTD_BIT_WRITEABLE).
The mtd.flags should be set to MTD_CAP_NORFLASH in spi-nor/core when it is not yet set, to allow manufacturer fixups set it.
--- drivers/mtd/spi-nor/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
@@ -2976,7 +2976,8 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)if (!mtd->name) mtd->name =dev_name (dev); mtd->type =MTD_NORFLASH ; - mtd->flags =MTD_CAP_NORFLASH ; +if (!mtd->flags) + mtd->flags =MTD_CAP_NORFLASH ;if (nor->info->flags &SPI_NOR_NO_ERASE ) mtd->flags |=MTD_NO_ERASE ;else
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/2] mtd: spi-nor: core: Allow manufacturer fixups to set nor->mtd.flags
Quoted 24 lines · On 3/15/23 06:34, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
Infineon SEMPER Flash family has on-die ECC and multiple programming on the same 16-byte ECC data unit is not allowed to preserve ECC.
In JFFS2, ECC'd NOR Flash is supported when
CONFIG_JFFS2_FS_WRITEBUFFERis set andMTD_BIT_WRITEABLEis not set in mtd.flag.In spi-nor/core, the mtd.flags is set to
MTD_CAP_NORFLASHthat defined as (MTD_WRITEABLE|MTD_BIT_WRITEABLE).The mtd.flags should be set to
MTD_CAP_NORFLASHin spi-nor/core when it is not yet set, to allow manufacturer fixups set it.Signed-off-by Takahiro Kuwano <[email protected]>--- drivers/mtd/spi-nor/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mtd/spi-nor/core.c +0
-0
drivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor *nor) · line 2980
Quoted 6 lines
drivers/mtd/spi-nor/core.c +2
-1@@ -2976,7 +2976,8 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)if (!mtd->name) mtd->name =dev_name (dev); mtd->type =MTD_NORFLASH ; - mtd->flags =MTD_CAP_NORFLASH ; +if (!mtd->flags) + mtd->flags =MTD_CAP_NORFLASH ;
No, I don't want manufacturer drivers to update mtd fields on their own. Instead, introduce a SNOR_F flag, set it in the manufacturer driver and then update the mtd->flags here based on the SNOR_F flag.
drivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor *nor) · line 2983
Quoted 3 lines
drivers/mtd/spi-nor/core.c +0
-0if (nor->info->flags &SPI_NOR_NO_ERASE ) mtd->flags |=MTD_NO_ERASE ;else
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/2 mtd: spi-nor: spansion: Add a helper for ECC related initialization
In reply to [email protected]From: Takahiro Kuwano <[email protected]>
JFFS2 supports write buffer mode for ECC'd NOR flash such like SEMPER flash family (s26hl/s25hs/s28hl/s28hs). To activate it, MTD_BIT_WRITEABLE needs to be unset in mtd->flags.
In existing late_init() functions for SEMPER flash family, params->writesize is set to 16 to avoid multiple programs in 16-byte ECC data unit.
This patch adds a common cypress_nor_ecc_init() helper that takes care for those ECC related initialization.
--- drivers/mtd/spi-nor/spansion.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/mtd/spi-nor/spansion.c +20 -13
@@ -219,6 +219,22 @@ static int cypress_nor_set_page_size(struct spi_nor *nor)return 0 ; } +static void cypress_nor_ecc_init (struct spi_nor *nor) +{ +/* +* Programming is supported only in 16-byte ECC data unit granularity. +* Byte-programming, bit-walking, or multiple program operations to the +* same ECC data unit without an erase are not allowed. +*/ + nor->params->writesize =16 ; + +/* +* Unset MTD_BIT_WRITEABLE to activate JFFS2 write buffer for ECC'd NOR +* flash. +*/ + nor->mtd.flags =MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE ; +} + static int s25fs256t_post_bfpt_fixup(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header,
@@ -260,13 +276,7 @@ static void s25fs256t_post_sfdp_fixup(struct spi_nor *nor)static void s25fs256t_late_init (struct spi_nor *nor) { -/* -* Programming is supported only in 16-byte ECC data unit granularity. -* Byte-programming, bit-walking, or multiple program operations to the -* same ECC data unit without an erase are not allowed. See chapter -* 5.3.1 and 5.6 in the datasheet. -*/ - nor->params->writesize =16 ; +cypress_nor_ecc_init (nor); }static struct spi_nor_fixups s25fs256t_fixups = {
@@ -312,13 +322,10 @@ static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor)static void s25hx_t_late_init (struct spi_nor *nor) { -struct spi_nor_flash_parameter *params = nor->params; -/* Fast Read 4B requires mode cycles */ - params->reads[SNOR_CMD_READ_FAST ].num_mode_clocks =8 ; + nor->params->reads[SNOR_CMD_READ_FAST ].num_mode_clocks =8 ; -/* The writesize should be ECC data unit size */ - params->writesize =16 ; +cypress_nor_ecc_init (nor); }static struct spi_nor_fixups s25hx_t_fixups = {
@@ -381,7 +388,7 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,static void s28hx_t_late_init (struct spi_nor *nor) { nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable; - nor->params->writesize =16 ; +cypress_nor_ecc_init (nor); }static const struct spi_nor_fixups s28hx_t_fixups = {
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/2] mtd: spi-nor: spansion: Add a helper for ECC related initialization
Quoted 30 lines · On 3/15/23 06:34, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
JFFS2 supports write buffer mode for ECC'd NOR flash such like SEMPER flash family (s26hl/s25hs/s28hl/s28hs). To activate it,
MTD_BIT_WRITEABLEneeds to be unset inmtd->flags.In existing
late_init()functions for SEMPER flash family,params->writesizeis set to 16 to avoid multiple programs in 16-byte ECC data unit.This patch adds a common
cypress_nor_ecc_init()helper that takes care for those ECC related initialization.Signed-off-by Takahiro Kuwano <[email protected]>--- drivers/mtd/spi-nor/spansion.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)drivers/mtd/spi-nor/spansion.c +4
-0@@ -219,6 +219,22 @@ static int cypress_nor_set_page_size(struct spi_nor *nor)return 0 ; } +static void cypress_nor_ecc_init (struct spi_nor *nor) +{ +/* +* Programming is supported only in 16-byte ECC data unit granularity.
drivers/mtd/spi-nor/spansion.c static int cypress_nor_set_page_size(struct spi_nor *nor) · line 235
Quoted 10 lines
drivers/mtd/spi-nor/spansion.c +10
-0+* Byte-programming, bit-walking, or multiple program operations to the +* same ECC data unit without an erase are not allowed. +*/ + nor->params->writesize =16 ; + +/* +* Unset MTD_BIT_WRITEABLE to activate JFFS2 write buffer for ECC'd NOR +* flash. +*/ + nor->mtd.flags =MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE ;
This should have been made available since the addition of the s28hx, and it's actually a fix, thus it deserves a fixes tag and Cc to stable.
Introduce a SNOR_F_ECC, set it here and do the mtd.flags update in the core please.
Looks good otherwise.
Cheers,
ta
Quoted 37 lines
drivers/mtd/spi-nor/spansion.c +5
-12+} + static int s25fs256t_post_bfpt_fixup(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header,@@ -260,13 +276,7 @@ static void s25fs256t_post_sfdp_fixup(struct spi_nor *nor)static void s25fs256t_late_init (struct spi_nor *nor) { -/* -* Programming is supported only in 16-byte ECC data unit granularity. -* Byte-programming, bit-walking, or multiple program operations to the -* same ECC data unit without an erase are not allowed. See chapter -* 5.3.1 and 5.6 in the datasheet. -*/ - nor->params->writesize =16 ; +cypress_nor_ecc_init (nor); }static struct spi_nor_fixups s25fs256t_fixups = {@@ -312,13 +322,10 @@ static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor)static void s25hx_t_late_init (struct spi_nor *nor) { -struct spi_nor_flash_parameter *params = nor->params; -/* Fast Read 4B requires mode cycles */ - params->reads[SNOR_CMD_READ_FAST ].num_mode_clocks =8 ; + nor->params->reads[SNOR_CMD_READ_FAST ].num_mode_clocks =8 ; -/* The writesize should be ECC data unit size */ - params->writesize =16 ; +cypress_nor_ecc_init (nor); }static struct spi_nor_fixups s25hx_t_fixups = {
drivers/mtd/spi-nor/spansion.c static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor, · line 394
Quoted 8 lines
drivers/mtd/spi-nor/spansion.c +1
-1@@ -381,7 +388,7 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,static void s28hx_t_late_init (struct spi_nor *nor) { nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable; - nor->params->writesize =16 ; +cypress_nor_ecc_init (nor); }static const struct spi_nor_fixups s28hx_t_fixups = {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/