From f8dc4617128f72cdcef4aae33afd665d3fbc5a2f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 20 Dec 2017 14:37:31 -0500 Subject: [PATCH] ec_flash: Add W25Q128 SPI flash Add W25Q128 flash device support. BRANCH=none BUG= TEST=Modify a board build for W25Q128 and check SPI code sets flash security bits correctly. Change-Id: I6173f4cf751f3fbf68af75983f44d357a0b954f6 Signed-off-by: Scott Worley --- common/spi_flash_reg.c | 9 ++++++++- include/config.h | 1 + include/spi_flash_reg.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/spi_flash_reg.c b/common/spi_flash_reg.c index 2e9fbbd469..1301e19dc5 100644 --- a/common/spi_flash_reg.c +++ b/common/spi_flash_reg.c @@ -72,7 +72,14 @@ static const struct protect_range spi_flash_protect_ranges[] = { { 0, 0, 1, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/4 */ { 0, 0, 1, { 1, 0, 0 }, 0, 0x80000 }, /* Lower 1/2 */ }; - +#elif defined(CONFIG_SPI_FLASH_W25Q128) +static const struct protect_range spi_flash_protect_ranges[] = { + /* CMP = 0 */ + { 0, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */ + { 0, 0, 1, { 1, 0, 0 }, 0, 0x20000 }, /* Lower 1/8 */ + { 0, 0, 1, { 1, 0, 1 }, 0, 0x40000 }, /* Lower 1/4 */ + { 0, 0, 1, { 1, 1, 0 }, 0, 0x80000 }, /* Lower 1/2 */ +}; #endif /** diff --git a/include/config.h b/include/config.h index d1dad6ee74..b242092064 100644 --- a/include/config.h +++ b/include/config.h @@ -2253,6 +2253,7 @@ /* Select any of the following SPI flash configs that your board uses. */ #undef CONFIG_SPI_FLASH_GD25LQ40 #undef CONFIG_SPI_FLASH_GD25Q41B +#undef CONFIG_SPI_FLASH_W25Q128 #undef CONFIG_SPI_FLASH_W25Q40 #undef CONFIG_SPI_FLASH_W25Q64 #undef CONFIG_SPI_FLASH_W25Q80 diff --git a/include/spi_flash_reg.h b/include/spi_flash_reg.h index e42d9baa99..2d564e6b50 100644 --- a/include/spi_flash_reg.h +++ b/include/spi_flash_reg.h @@ -38,6 +38,11 @@ #define CONFIG_SPI_FLASH_HAS_SR2 #endif +/* W25Q128 16 Mbyte SPI flash for testing */ +#ifdef CONFIG_SPI_FLASH_W25Q128 +#define CONFIG_SPI_FLASH_HAS_SR2 +#endif + /** * Computes block write protection range from registers * Returns start == len == 0 for no protection