From e2fc5e25f2d1cab86edac352d1a91f55c15c9f0a Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 17 May 2017 17:26:01 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/19757 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/include/spi_flash.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/include') 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); -- cgit v1.2.3