mtd: spi-nor: add erase die (chip) capability
authorTudor Ambarus <tudor.ambarus@linaro.org>
Sat, 25 Nov 2023 12:35:25 +0000 (14:35 +0200)
committerTudor Ambarus <tudor.ambarus@linaro.org>
Wed, 6 Dec 2023 09:24:42 +0000 (11:24 +0200)
commit9641423174d05da32543e96ced66bb30cebcce16
treef3adf216eb72535d8d7965bd61eded0e70076253
parent9b3eae3486c86304e047829cfe0073b66dc02b36
mtd: spi-nor: add erase die (chip) capability

JESD216 mentions die erase, but does not provide an opcode for it.
Check BFPT dword 11, bits 30:24, "Chip Erase, Typical time", it says:

"Typical time to erase one chip (die). User must poll device busy to
determine if the operation has completed. For a device consisting of
multiple dies, that are individually accessed, the time is for each die
to which a chip erase command is applied."

So when a flash consists of a single die, this is the erase time for the
full chip (die) erase, and when it consists of multiple dies, it's the
die erase time. Chip and die are the same thing.

Add support for die erase. For now, benefit of the die erase when addr
and len are aligned with die size. This could be improved however for
the uniform and non-uniform erases cases to use the die erase when
possible. For example if one requests that an erase of a 2 die device
starting from the last 64KB of the first die to the end of the flash
size, we could use just 2 commands, a 64KB erase and a die erase.
This improvement is left as an exercise for the reader.

Tested-by: Fabio Estevam <festevam@denx.de>
Link: https://lore.kernel.org/r/20231125123529.55686-2-tudor.ambarus@linaro.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/debugfs.c