drivers/spi/spi_flash: introduce 'spi_flash_cmd_multi'
A following patch that adds some support for reading the serial flash discoverable parameters (SFDP) data structures needs to send more than just the one command byte that 'spi_flash_cmd' supports. To be able to do this, introduce the 'spi_flash_cmd_multi' function which supports sending multiple bytes before reading back some bytes. The prototype is added to drivers/spi/spi_flash_internal.h since only other files in the same directory are supposed to be using that function. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I1f3872463249240c0a32e2825e4302894e856b2e Reviewed-on: https://review.coreboot.org/c/coreboot/+/84789 Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
ade5b9dc48
commit
c6f60b1ddf
2 changed files with 14 additions and 0 deletions
|
|
@ -129,6 +129,16 @@ int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t le
|
|||
return ret;
|
||||
}
|
||||
|
||||
int spi_flash_cmd_multi(const struct spi_slave *spi, const u8 *dout, size_t bytes_out,
|
||||
void *din, size_t bytes_in)
|
||||
{
|
||||
int ret = do_spi_flash_cmd(spi, dout, bytes_out, din, bytes_in);
|
||||
if (ret)
|
||||
printk(BIOS_WARNING, "SF: Failed to send command %02x: %d\n", dout[0], ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* TODO: This code is quite possibly broken and overflowing stacks. Fix ASAP! */
|
||||
#pragma GCC diagnostic push
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
/* Send a single-byte command to the device and read the response */
|
||||
int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t len);
|
||||
|
||||
/* Send a multi-byte command to the device and read the response */
|
||||
int spi_flash_cmd_multi(const struct spi_slave *spi, const u8 *dout, size_t bytes_out,
|
||||
void *din, size_t bytes_in);
|
||||
|
||||
/*
|
||||
* Send a multi-byte command to the device followed by (optional)
|
||||
* data. Used for programming the flash array, etc.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue