[PATCH 2/2] mtd: spi-nor: spansion: Add a helper for ECC related initialization
Tudor Ambarus
tudor.ambarus at linaro.org
Fri Mar 17 02:43:27 PDT 2023
On 3/15/23 06:34, tkuw584924 at gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
>
> 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.
>
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
> ---
> drivers/mtd/spi-nor/spansion.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
> index 1678b7b2e9f7..9539968c4a6d 100644
> --- a/drivers/mtd/spi-nor/spansion.c
> +++ b/drivers/mtd/spi-nor/spansion.c
> @@ -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;
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
> +}
> +
> 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 = {
More information about the linux-mtd
mailing list