mtd: spi-nor: Add CHIP_ERASE optimization
authorMarek Vasut <marex@denx.de>
Thu, 2 Mar 2023 01:46:32 +0000 (02:46 +0100)
committerJagan Teki <jagan@edgeble.ai>
Tue, 25 Apr 2023 17:22:55 +0000 (22:52 +0530)
commitb91a0822d752a1d46ea9ad1ad0d28b93b16088f9
tree1853365c4d460b9424febf928192e9b6e7967224
parent6a11fdf0536e02ac9cd4a3da0535a271c694715f
mtd: spi-nor: Add CHIP_ERASE optimization

Add support for CHIP_ERASE opcode 0xc7 . This is useful in case the
entire SPI NOR is supposed to be erase at once, as is it considerably
faster than 4k sector erase and even slightly faster than 64k block
erase. The spi_nor_erase_chip() implementation is adapted from Linux
6.1.y as of commit 7d54cb2c26dad ("Linux 6.1.14") . The chip erase is
only used in case the entire MTD device is being erased, and the chip
does support this functionality.

Timing figures from W25Q128JW:
16 MiB erase using 4kiB sector erase opcode 0x20 ... 107.5s
16 MiB erase using 64kiB block erase opcode 0xd8 ... 39.1s
16 MiB erase using chip erase opcode 0xc7 .......... 38.7s

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/spi-nor-core.c