Skip to content

Commit 5587fa4

Browse files
Sergei Shtylyovambarus
authored andcommitted
mtd: spi-nor: spansion: fix writes on S25FS512S
Spansion S25FS-S family has an issue in the Basic Flash Parameter Table (BFPT): Dword-11 bits 7:4 specify a page size of 512 bytes. Actually this is configurable in the vendor unique register (CR3V) and even the factory default setting is to "wrap at 256 bytes", so blindly relying on BFPT breaks the page writes on these chips. Add the post-BFPT fixup which restores the default page size of 256 bytes -- to properly read CR3V this early is quite intrusive and should better be done as a new feature; Alexander Sverdlin had the patch doing that: https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/ Fixes: dfd2b74 ("mtd: spi-nor: add Spansion S25FS512S ID") Signed-off-by: Sergei Shtylyov <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Tested-by: Kuldeep Singh <[email protected]> Signed-off-by: Tudor Ambarus <[email protected]>
1 parent b846915 commit 5587fa4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

drivers/mtd/spi-nor/spansion.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@
88

99
#include "core.h"
1010

11+
static int
12+
s25fs_s_post_bfpt_fixups(struct spi_nor *nor,
13+
const struct sfdp_parameter_header *bfpt_header,
14+
const struct sfdp_bfpt *bfpt,
15+
struct spi_nor_flash_parameter *params)
16+
{
17+
/*
18+
* The S25FS-S chip family reports 512-byte pages in BFPT but
19+
* in reality the write buffer still wraps at the safe default
20+
* of 256 bytes. Overwrite the page size advertised by BFPT
21+
* to get the writes working.
22+
*/
23+
params->page_size = 256;
24+
25+
return 0;
26+
}
27+
28+
static struct spi_nor_fixups s25fs_s_fixups = {
29+
.post_bfpt = s25fs_s_post_bfpt_fixups,
30+
};
31+
1132
static const struct flash_info spansion_parts[] = {
1233
/* Spansion/Cypress -- single (large) sector size only, at least
1334
* for the chips listed here (without boot sectors).
@@ -32,8 +53,8 @@ static const struct flash_info spansion_parts[] = {
3253
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
3354
SPI_NOR_HAS_LOCK | USE_CLSR) },
3455
{ "s25fs512s", INFO6(0x010220, 0x4d0081, 256 * 1024, 256,
35-
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
36-
USE_CLSR) },
56+
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR)
57+
.fixups = &s25fs_s_fixups, },
3758
{ "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
3859
{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) },
3960
{ "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) },

0 commit comments

Comments
 (0)