UPSTREAM: 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: I29deaa94b0339972aa016b77a80344da6abadd06
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Original-Commit-Id: e2fc5e25f2
Original-Change-Id: I550cc4556fc4b63ebc174a7e2fde42251fe56052
Original-Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/19757
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/509524
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
This commit is contained in:
parent
8a4cee3e75
commit
f33185570b
15 changed files with 170 additions and 101 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue