diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2018-03-09 14:20:25 +0100 |
---|---|---|
committer | Philipp Deppenwiese <zaolin.daisuki@gmail.com> | 2018-09-16 13:02:50 +0000 |
commit | 0f8bf022fca97659efef400794d38ec0d1f48d2b (patch) | |
tree | 28938953b32650e403459943cf03a4dc535ceeb1 /src/drivers/spi/spi_flash.c | |
parent | ee8780eb788047755b5cbb6915b42f9adab533e6 (diff) | |
download | coreboot-0f8bf022fca97659efef400794d38ec0d1f48d2b.tar.xz |
drivers/spi: Read Winbond's flash protection bits
Extend the generic flash interface to probe for write protected regions.
Add Winbond custom code to return flash protection.
Tested on Cavium EVB CN81xx using W25Q128.
Change-Id: I933a8abdc28174ec32acf323c102d606b58c1ea5
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25082
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/spi/spi_flash.c')
-rw-r--r-- | src/drivers/spi/spi_flash.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index f2714791db..c4840886bb 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -432,6 +432,28 @@ int spi_flash_status(const struct spi_flash *flash, u8 *reg) return -1; } +int spi_flash_is_write_protected(const struct spi_flash *flash, + const struct region *region) +{ + struct region flash_region = { 0 }; + + if (!flash || !region) + return -1; + + flash_region.size = flash->size; + + if (!region_is_subregion(&flash_region, region)) + return -1; + + if (!flash->ops->get_write_protection) { + printk(BIOS_WARNING, "SPI: Write-protection gathering not " + "implemented for this vendor.\n"); + return 0; + } + + return flash->ops->get_write_protection(flash, region); +} + static uint32_t volatile_group_count CAR_GLOBAL; int spi_flash_volatile_group_begin(const struct spi_flash *flash) |