Skip to content

Commit 128c156

Browse files
committed
Revert "mtd: spi-nor: fix setting of SNOR_LAST_REGION bit"
This reverts commit 908bf46. There are slightly different changes between what we applied back in linux4sam-6.0 and what reached mainline. Revert the 4BAIT, SMPT and non-uniform erase support and backport the support and fixes from mainline. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent 908bf46 commit 128c156

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,9 +2413,8 @@ static inline void
24132413
spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
24142414
u8 erase_mask, u64 flash_size)
24152415
{
2416-
/* Offset 0 with erase_mask and SNOR_LAST_REGION bit set */
2417-
map->uniform_region.offset = (erase_mask & SNOR_ERASE_TYPE_MASK) |
2418-
SNOR_LAST_REGION;
2416+
map->uniform_region.offset = SNOR_ERASE_FLAGS_OFFSET(erase_mask, 1, 0,
2417+
0);
24192418
map->uniform_region.size = flash_size;
24202419
map->regions = &map->uniform_region;
24212420
map->uniform_erase_type = erase_mask;

include/linux/mtd/spi-nor.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ struct spi_nor_erase_region {
296296
#define SNOR_ERASE_FLAGS_MAX 6
297297
#define SNOR_ERASE_FLAGS_MASK GENMASK_ULL(SNOR_ERASE_FLAGS_MAX - 1, 0)
298298

299+
#define SNOR_ERASE_FLAGS_OFFSET(_cmd_mask, _last_region, _overlaid_region, \
300+
_offset) \
301+
((((u64)(_offset)) & ~SNOR_ERASE_FLAGS_MASK) | \
302+
(((u64)(_cmd_mask)) & SNOR_ERASE_TYPE_MASK) | \
303+
(((u64)(_last_region)) & SNOR_LAST_REGION) | \
304+
(((u64)(_overlaid_region)) & SNOR_OVERLAID_REGION))
305+
299306
/**
300307
* struct spi_nor_erase_map - Structure to describe the SPI NOR erase map
301308
* @regions: array of erase regions. The regions are consecutive in

0 commit comments

Comments
 (0)