Skip to content

Commit 77d4ac6

Browse files
mwallePratyush Yadav
authored andcommitted
mtd: spi-nor: move SECT_4K_PMC special handling
The SECT_4K_PMC flag will set a device specific opcode for the 4k sector erase. Instead of handling it in the core, we can move it to a late_init(). In that late init, loop over all erase types, look for the 4k size and replace the opcode. Signed-off-by: Michael Walle <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 03c765b commit 77d4ac6

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

drivers/mtd/spi-nor/core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,12 +2382,7 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor)
23822382
*/
23832383
erase_mask = 0;
23842384
i = 0;
2385-
if (no_sfdp_flags & SECT_4K_PMC) {
2386-
erase_mask |= BIT(i);
2387-
spi_nor_set_erase_type(&map->erase_type[i], 4096u,
2388-
SPINOR_OP_BE_4K_PMC);
2389-
i++;
2390-
} else if (no_sfdp_flags & SECT_4K) {
2385+
if (no_sfdp_flags & SECT_4K) {
23912386
erase_mask |= BIT(i);
23922387
spi_nor_set_erase_type(&map->erase_type[i], 4096u,
23932388
SPINOR_OP_BE_4K);

drivers/mtd/spi-nor/core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ struct spi_nor_fixups {
457457
* flags are used together with the SPI_NOR_SKIP_SFDP flag.
458458
* SPI_NOR_SKIP_SFDP: skip parsing of SFDP tables.
459459
* SECT_4K: SPINOR_OP_BE_4K works uniformly.
460-
* SECT_4K_PMC: SPINOR_OP_BE_4K_PMC works uniformly.
461460
* SPI_NOR_DUAL_READ: flash supports Dual Read.
462461
* SPI_NOR_QUAD_READ: flash supports Quad Read.
463462
* SPI_NOR_OCTAL_READ: flash supports Octal Read.
@@ -505,7 +504,6 @@ struct flash_info {
505504
u8 no_sfdp_flags;
506505
#define SPI_NOR_SKIP_SFDP BIT(0)
507506
#define SECT_4K BIT(1)
508-
#define SECT_4K_PMC BIT(2)
509507
#define SPI_NOR_DUAL_READ BIT(3)
510508
#define SPI_NOR_QUAD_READ BIT(4)
511509
#define SPI_NOR_OCTAL_READ BIT(5)

drivers/mtd/spi-nor/issi.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ static const struct spi_nor_fixups is25lp256_fixups = {
2929
.post_bfpt = is25lp256_post_bfpt_fixups,
3030
};
3131

32+
static void pm25lv_nor_late_init(struct spi_nor *nor)
33+
{
34+
struct spi_nor_erase_map *map = &nor->params->erase_map;
35+
int i;
36+
37+
/* The PM25LV series has a different 4k sector erase opcode */
38+
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++)
39+
if (map->erase_type[i].size == 4096)
40+
map->erase_type[i].opcode = SPINOR_OP_BE_4K_PMC;
41+
}
42+
43+
static const struct spi_nor_fixups pm25lv_nor_fixups = {
44+
.late_init = pm25lv_nor_late_init,
45+
};
46+
3247
static const struct flash_info issi_nor_parts[] = {
3348
/* ISSI */
3449
{ "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2)
@@ -62,9 +77,13 @@ static const struct flash_info issi_nor_parts[] = {
6277

6378
/* PMC */
6479
{ "pm25lv512", INFO(0, 0, 32 * 1024, 2)
65-
NO_SFDP_FLAGS(SECT_4K_PMC) },
80+
NO_SFDP_FLAGS(SECT_4K)
81+
.fixups = &pm25lv_nor_fixups
82+
},
6683
{ "pm25lv010", INFO(0, 0, 32 * 1024, 4)
67-
NO_SFDP_FLAGS(SECT_4K_PMC) },
84+
NO_SFDP_FLAGS(SECT_4K)
85+
.fixups = &pm25lv_nor_fixups
86+
},
6887
{ "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64)
6988
NO_SFDP_FLAGS(SECT_4K) },
7089
};

0 commit comments

Comments
 (0)