diff options
author | Aaron Durbin <adurbin@chromium.org> | 2017-12-14 14:34:47 -0700 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2017-12-15 23:35:10 +0000 |
commit | 10d65b06aebbd857759c278a18c7e9e0ba70ee6c (patch) | |
tree | e23f541b7fbcdd5548b98d400c6b60c75c97d489 /src/drivers/spi/spi_flash.c | |
parent | 02103e34d76c12b46b57143cd11d96758219423d (diff) | |
download | coreboot-10d65b06aebbd857759c278a18c7e9e0ba70ee6c.tar.xz |
drivers/spi/spi_flash: add flash region protection to controller
Provide a spi controller specific protection callback to take
advantage of special spi flash controllers that have internal
protection registers built into the implementation. It's an
optional callback for spi controllers.
BUG=b:69614064
Change-Id: Ie50a6ce3bbda32620a25dd26fda1af944940bf28
Signed-off-by: Aaron Durbn <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/22879
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/drivers/spi/spi_flash.c')
-rw-r--r-- | src/drivers/spi/spi_flash.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 2dd616bb65..1b00078d5d 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -459,3 +459,29 @@ void lb_spi_flash(struct lb_header *header) flash->erase_cmd = CMD_BLOCK_ERASE; } } + + +int spi_flash_ctrlr_protect_region(const struct spi_flash *flash, + const struct region *region) +{ + const struct spi_ctrlr *ctrlr; + struct region flash_region = { 0 }; + + if (!flash) + return -1; + + flash_region.size = flash->size; + + if (!region_is_subregion(&flash_region, region)) + return -1; + + ctrlr = flash->spi.ctrlr; + + if (!ctrlr) + return -1; + + if (ctrlr->flash_protect) + return ctrlr->flash_protect(flash, region); + + return -1; +} |