mtd: spi-nor-core: Add non-uniform erase for Spansion/Cypress
authorTakahiro Kuwano <Takahiro.Kuwano@infineon.com>
Fri, 25 Jun 2021 19:17:27 +0000 (00:47 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 28 Jun 2021 06:36:07 +0000 (12:06 +0530)
commitee52b0b764d3eaa69f20f7e142945d56fe3f6fdb
treee61be487cd84cfab3f5e941c6519febabfe498ee
parentaba0bcd7bda494d7fe9c82e581db9791ce41e2f3
mtd: spi-nor-core: Add non-uniform erase for Spansion/Cypress

Some of Spansion/Cypress chips have overlaid 4KB sectors at top and/or
bottom, depending on the device configuration, while U-Boot supports
uniform sector layout only.

The spansion_erase_non_uniform()  erases overlaid 4KB sectors,
non-overlaid portion of normal sector, and remaining normal sectors, by
selecting correct erase command and size based on the address to erase
and size of overlaid portion in parameters. Since different Spansion
flashes can use different opcode for erasing the 4K sectors, the opcode
must be passed in as a parameter based on the flash being used.

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
[p.yadav@ti.com: Refactor the function to be compatible with nor->erase,
make 4K opcode customizable, call spi_nor_setup_op() before executing
the op.]
Acked-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/spi-nor-core.c