summaryrefslogtreecommitdiffstats
path: root/src/include/spi_flash.h
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2020-01-11 14:03:27 -0700
committerAaron Durbin <adurbin@chromium.org>2020-01-16 15:21:08 +0000
commitf584f19efc58ba3c80a462024ae680320b17b9ce (patch)
tree69b4419e008e40d2442d11e28af48b28cc535472 /src/include/spi_flash.h
parentcb01aa586f45277043d36500d9694d750ed33190 (diff)
downloadcoreboot-f584f19efc58ba3c80a462024ae680320b17b9ce.tar.gz
coreboot-f584f19efc58ba3c80a462024ae680320b17b9ce.tar.bz2
coreboot-f584f19efc58ba3c80a462024ae680320b17b9ce.zip
drivers/spi/spi_flash: separate out protection ops
Put the write protection into its own object. This allows for easier future reuse of objects in future consolidation patches. It's also possible to eliminate the code implmementing these in the future if the platform doesn't require it. For now leave current behavior as-is. The names of the callbacks were shortened as they are now in the spi_flash_protection_ops object which is a new field in the spi_flash object. Change-Id: I2fec4e4430709fcf3e08a55dd36583211c035c08 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38376 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/include/spi_flash.h')
-rw-r--r--src/include/spi_flash.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index 1a5a82934e30..9c11433ff00d 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -59,6 +59,10 @@ struct spi_flash_ops {
const void *buf);
int (*erase)(const struct spi_flash *flash, u32 offset, size_t len);
int (*status)(const struct spi_flash *flash, u8 *reg);
+};
+
+/* Current code assumes all callbacks are supplied in this object. */
+struct spi_flash_protection_ops {
/*
* Returns 1 if the whole region is software write protected.
* Hardware write protection mechanism aren't accounted.
@@ -66,7 +70,7 @@ struct spi_flash_ops {
* register for example, 0 should be returned.
* Returns 0 on success.
*/
- int (*get_write_protection)(const struct spi_flash *flash,
+ int (*get_write)(const struct spi_flash *flash,
const struct region *region);
/*
* Enable the status register write protection, if supported on the
@@ -80,7 +84,7 @@ struct spi_flash_ops {
* @return 0 on success
*/
int
- (*set_write_protection)(const struct spi_flash *flash,
+ (*set_write)(const struct spi_flash *flash,
const struct region *region,
const bool non_volatile,
const enum spi_flash_status_reg_lockdown mode);
@@ -107,6 +111,8 @@ struct spi_flash {
u8 pp_cmd; /* Page program command. */
u8 wren_cmd; /* Write Enable command. */
const struct spi_flash_ops *ops;
+ /* If !NULL all protection callbacks exist. */
+ const struct spi_flash_protection_ops *prot_ops;
const void *driver_private;
};