@@ -3469,6 +3469,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
nor->page_size = nor->params->page_size;
mtd->writebufsize = nor->page_size;
+ if (info->flags & SPI_NOR_NO_MULTI_PASS_PP) {
+ mtd->flags |= MTD_NO_MULTI_PASS_WRITE;
+ mtd->writesize = nor->page_size;
+ }
+
if (of_property_read_bool(np, "broken-flash-reset"))
nor->flags |= SNOR_F_BROKEN_RESET;
@@ -329,6 +329,12 @@ struct flash_info {
* available I/O mode via a
* volatile bit.
*/
+#define SPI_NOR_NO_MULTI_PASS_PP BIT(22) /*
+ * Once a page is programmed it
+ * cannot be programmed again
+ * without an erase operation in
+ * between.
+ */
/* Part specific fixup hooks. */
const struct spi_nor_fixups *fixups;
@@ -275,7 +275,7 @@ static const struct flash_info spansion_parts[] = {
SPI_NOR_NO_ERASE) },
{ "s28hs512t", INFO(0x345b1a, 0, 256 * 1024, 256,
SECT_4K | SPI_NOR_OCTAL_DTR_READ |
- SPI_NOR_OCTAL_DTR_PP)
+ SPI_NOR_OCTAL_DTR_PP | SPI_NOR_NO_MULTI_PASS_PP)
.fixups = &s28hs512t_fixups,
},
};
The Cypress Semper S28 flash family uses 2-bit ECC by default. Under this ECC scheme, multi-pass page programs result in a program error. This means that unlike many other SPI NOR flashes, bit-walking cannot be done. In other words, once a page is programmed, its bits cannot then be flipped to 0 without an erase in between. This causes problems with UBIFS because it uses bit-walking to clear EC and VID magic numbers from a PEB before issuing an erase to preserve the file system correctness in case of power cuts. Use SPI_NOR_NO_MULTI_PASS_PP to set MTD_NO_MULTI_PASS_WRITE, telling upper layers to avoid multi-pass page programming. In addition, update mtd->writesize to match the page size to make sure upper layers make the changes they need in one single go. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> --- drivers/mtd/spi-nor/core.c | 5 +++++ drivers/mtd/spi-nor/core.h | 6 ++++++ drivers/mtd/spi-nor/spansion.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-)