Skip to content

Commit 9fd0945

Browse files
Kuwano-sanambarus
authored andcommitted
mtd: spi-nor: spansion: Enable JFFS2 write buffer for Infineon s28hx SEMPER flash
Infineon(Cypress) SEMPER NOR flash family has on-die ECC and its program granularity is 16-byte ECC data unit size. JFFS2 supports write buffer mode for ECC'd NOR flash. Provide a way to clear the MTD_BIT_WRITEABLE flag in order to enable JFFS2 write buffer mode support. A new SNOR_F_ECC flag is introduced to determine if the part has on-die ECC and if it has, MTD_BIT_WRITEABLE is unset. In vendor specific driver, a common cypress_nor_ecc_init() helper is added. This helper takes care for ECC related initialization for SEMPER flash family by setting up params->writesize and SNOR_F_ECC. Fixes: c3266af ("mtd: spi-nor: spansion: add support for Cypress Semper flash") Suggested-by: Tudor Ambarus <tudor.ambarus@linaro.org> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/d586723f6f12aaff44fbcd7b51e674b47ed554ed.1680760742.git.Takahiro.Kuwano@infineon.com Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent c87c9b1 commit 9fd0945

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,9 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)
34073407
mtd->name = dev_name(dev);
34083408
mtd->type = MTD_NORFLASH;
34093409
mtd->flags = MTD_CAP_NORFLASH;
3410+
/* Unset BIT_WRITEABLE to enable JFFS2 write buffer for ECC'd NOR */
3411+
if (nor->flags & SNOR_F_ECC)
3412+
mtd->flags &= ~MTD_BIT_WRITEABLE;
34103413
if (nor->info->flags & SPI_NOR_NO_ERASE)
34113414
mtd->flags |= MTD_NO_ERASE;
34123415
else

drivers/mtd/spi-nor/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ enum spi_nor_option_flags {
131131
SNOR_F_SOFT_RESET = BIT(12),
132132
SNOR_F_SWP_IS_VOLATILE = BIT(13),
133133
SNOR_F_RWW = BIT(14),
134+
SNOR_F_ECC = BIT(15),
134135
};
135136

136137
struct spi_nor_read_command {

drivers/mtd/spi-nor/debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static const char *const snor_f_names[] = {
2626
SNOR_F_NAME(SOFT_RESET),
2727
SNOR_F_NAME(SWP_IS_VOLATILE),
2828
SNOR_F_NAME(RWW),
29+
SNOR_F_NAME(ECC),
2930
};
3031
#undef SNOR_F_NAME
3132

drivers/mtd/spi-nor/spansion.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ static int cypress_nor_set_page_size(struct spi_nor *nor)
332332
return 0;
333333
}
334334

335+
static void cypress_nor_ecc_init(struct spi_nor *nor)
336+
{
337+
/*
338+
* Programming is supported only in 16-byte ECC data unit granularity.
339+
* Byte-programming, bit-walking, or multiple program operations to the
340+
* same ECC data unit without an erase are not allowed.
341+
*/
342+
nor->params->writesize = 16;
343+
nor->flags |= SNOR_F_ECC;
344+
}
345+
335346
static int
336347
s25fs256t_post_bfpt_fixup(struct spi_nor *nor,
337348
const struct sfdp_parameter_header *bfpt_header,
@@ -506,7 +517,7 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
506517
static void s28hx_t_late_init(struct spi_nor *nor)
507518
{
508519
nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable;
509-
nor->params->writesize = 16;
520+
cypress_nor_ecc_init(nor);
510521
}
511522

512523
static const struct spi_nor_fixups s28hx_t_fixups = {

0 commit comments

Comments
 (0)