diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 7377b33d32..815dec34f8 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -24,6 +24,11 @@ #define CMD_S25FSXX_BE 0x60 #endif +#if defined CONFIG_SPI_FLASH_CYPRESS +#define CYPRESS_JEDEC_ID 0x012018 +#define CYPRESS_EXT_JEDEC_ID 0x4d01 +#endif + DECLARE_GLOBAL_DATA_PTR; static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd) @@ -380,6 +385,22 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len) while (len) { erase_addr = offset; +#ifdef CONFIG_SPI_FLASH_CYPRESS + if ((flash->jedec == CYPRESS_JEDEC_ID) && + (flash->ext_jedec == CYPRESS_EXT_JEDEC_ID)){ + if (offset <= (SZ_32K - SZ_4K)){ + cmd[0] = CMD_ERASE_4K; + erase_size = SZ_4K; + }else { + cmd[0] = CMD_ERASE_64K; + if (offset < SZ_64K){ + erase_size = SZ_32K; + }else { + erase_size = SZ_64K; + } + } + } +#endif #ifdef CONFIG_SF_DUAL_FLASH if (flash->dual_flash > SF_SINGLE_FLASH) spi_flash_dual(flash, &erase_addr); @@ -1120,6 +1141,8 @@ try_with_dummy_byte: /* Assign spi data */ flash->name = params->name; + flash->jedec = params->jedec; + flash->ext_jedec = params->ext_jedec; flash->memory_map = spi->memory_map; flash->dual_flash = flash->spi->option; diff --git a/include/configs/ipq5018.h b/include/configs/ipq5018.h index dbf83c85a4..0878a42b60 100644 --- a/include/configs/ipq5018.h +++ b/include/configs/ipq5018.h @@ -19,7 +19,7 @@ #endif #define CONFIG_IPQ5018 -#define IPQ5018_EMULATION +#define CONFIG_SPI_FLASH_CYPRESS #define CONFIG_SYS_NO_FLASH #define CONFIG_SYS_CACHELINE_SIZE 64 #define CONFIG_CMD_CACHE diff --git a/include/spi_flash.h b/include/spi_flash.h index 1e05be230c..adaf189f8d 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -73,6 +73,8 @@ struct spi_flash { struct udevice *dev; #endif const char *name; + u32 jedec; + u16 ext_jedec; u8 dual_flash; u8 shift; u8 addr_width;