summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-05-17 17:26:01 -0700
committerFurquan Shaikh <furquan@google.com>2017-05-19 21:23:39 +0200
commite2fc5e25f2d1cab86edac352d1a91f55c15c9f0a (patch)
tree71a86a3dd19e445a04d9088eedd1f14373da75bb /src/include
parenta1491574ef2c91ff8b89df70feba67ad34836c75 (diff)
downloadcoreboot-e2fc5e25f2d1cab86edac352d1a91f55c15c9f0a.tar.xz
drivers/spi/spi_flash: Move flash ops to spi_flash_ops structure
Define a new spi_flash_ops structure, move all spi flash operations to this structure and add a pointer to this structure in struct spi_flash. BUG=b:38330715 Change-Id: I550cc4556fc4b63ebc174a7e2fde42251fe56052 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19757 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/spi_flash.h32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index ab8155d8e7..e9ea50c4d2 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -24,6 +24,24 @@
#define SPI_OPCODE_WREN 0x06
#define SPI_OPCODE_FAST_READ 0x0b
+struct spi_flash;
+
+/*
+ * Representation of SPI flash operations:
+ * read: Flash read operation.
+ * write: Flash write operation.
+ * erase: Flash erase operation.
+ * status: Read flash status register.
+ */
+struct spi_flash_ops {
+ int (*read)(const struct spi_flash *flash, u32 offset, size_t len,
+ void *buf);
+ int (*write)(const struct spi_flash *flash, u32 offset, size_t len,
+ const void *buf);
+ int (*erase)(const struct spi_flash *flash, u32 offset, size_t len);
+ int (*status)(const struct spi_flash *flash, u8 *reg);
+};
+
struct spi_flash {
struct spi_slave spi;
const char *name;
@@ -32,19 +50,7 @@ struct spi_flash {
u32 page_size;
u8 erase_cmd;
u8 status_cmd;
- /*
- * Internal functions are expected to be called ONLY by spi flash
- * driver. External components should only use the public API calls
- * spi_flash_{read,write,erase,status,volatile_group_begin,
- * volatile_group_end}.
- */
- int (*internal_read)(const struct spi_flash *flash, u32 offset,
- size_t len, void *buf);
- int (*internal_write)(const struct spi_flash *flash, u32 offset,
- size_t len, const void *buf);
- int (*internal_erase)(const struct spi_flash *flash, u32 offset,
- size_t len);
- int (*internal_status)(const struct spi_flash *flash, u8 *reg);
+ const struct spi_flash_ops *ops;
};
void lb_spi_flash(struct lb_header *header);