Nico Huber has uploaded this change for review. ( https://review.coreboot.org/22421
Change subject: spi_master: Introduce SPI_MASTER_4BA feature flag ......................................................................
spi_master: Introduce SPI_MASTER_4BA feature flag
Add a feature flag SPI_MASTER_4BA to `struct spi_master` that advertises programmer-side support for 4-byte addresses in generic commands (and read/write commands if the master uses the default implementations). Set it for all masters that handle commands address-agnostic.
Change-Id: Ife66e3fc49b9716f9c99cad957095b528135ec2c Signed-off-by: Nico Huber nico.h@gmx.de --- M bitbang_spi.c M buspirate_spi.c M ch341a_spi.c M dummyflasher.c M ft2232_spi.c M linux_spi.c M programmer.h M serprog.c 8 files changed, 14 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/22421/1
diff --git a/bitbang_spi.c b/bitbang_spi.c index 0b27a67..5af2370 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -65,6 +65,7 @@
static const struct spi_master spi_master_bitbang = { .type = SPI_CONTROLLER_BITBANG, + .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_READ_UNLIMITED, .max_data_write = MAX_DATA_WRITE_UNLIMITED, .command = bitbang_spi_send_command, diff --git a/buspirate_spi.c b/buspirate_spi.c index b6554ac..6f4c6d0 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -136,6 +136,7 @@
static struct spi_master spi_master_buspirate = { .type = SPI_CONTROLLER_BUSPIRATE, + .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_UNSPECIFIED, .max_data_write = MAX_DATA_UNSPECIFIED, .command = NULL, diff --git a/ch341a_spi.c b/ch341a_spi.c index 6eb2804..2253e43 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -399,6 +399,7 @@
static const struct spi_master spi_master_ch341a_spi = { .type = SPI_CONTROLLER_CH341A_SPI, + .features = SPI_MASTER_4BA, /* flashrom's current maximum is 256 B. CH341A was tested on Linux and Windows to accept atleast * 128 kB. Basically there should be no hard limit because transfers are broken up into USB packets * sent to the device and most of their payload streamed via SPI. */ diff --git a/dummyflasher.c b/dummyflasher.c index f171128..1c0c85b 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -111,6 +111,7 @@
static const struct spi_master spi_master_dummyflasher = { .type = SPI_CONTROLLER_DUMMY, + .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_READ_UNLIMITED, .max_data_write = MAX_DATA_UNSPECIFIED, .command = dummy_spi_send_command, diff --git a/ft2232_spi.c b/ft2232_spi.c index be60837..3889eed 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -159,6 +159,7 @@
static const struct spi_master spi_master_ft2232 = { .type = SPI_CONTROLLER_FT2232, + .features = SPI_MASTER_4BA, .max_data_read = 64 * 1024, .max_data_write = 256, .command = ft2232_spi_send_command, diff --git a/linux_spi.c b/linux_spi.c index e51fbc4..16eb133 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -55,6 +55,7 @@
static const struct spi_master spi_master_linux = { .type = SPI_CONTROLLER_LINUX, + .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_UNSPECIFIED, /* TODO? */ .max_data_write = MAX_DATA_UNSPECIFIED, /* TODO? */ .command = linux_spi_send_command, @@ -189,7 +190,7 @@ static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { return spi_write_chunked(flash, buf, start, len, - ((unsigned int)getpagesize()) - 4); + ((unsigned int)getpagesize()) - 5); }
#endif // CONFIG_LINUX_SPI == 1 diff --git a/programmer.h b/programmer.h index b390a53..3525aa6 100644 --- a/programmer.h +++ b/programmer.h @@ -24,6 +24,8 @@ #ifndef __PROGRAMMER_H__ #define __PROGRAMMER_H__ 1
+#include <stdint.h> + #include "flash.h" /* for chipaddr and flashctx */
enum programmer { @@ -610,8 +612,12 @@ #define MAX_DATA_UNSPECIFIED 0 #define MAX_DATA_READ_UNLIMITED 64 * 1024 #define MAX_DATA_WRITE_UNLIMITED 256 + +#define SPI_MASTER_4BA (1U << 0) + struct spi_master { enum spi_controller type; + uint32_t features; unsigned int max_data_read; // (Ideally,) maximum data read size in one go (excluding opcode+address). unsigned int max_data_write; // (Ideally,) maximum data write size in one go (excluding opcode+address). int (*command)(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, diff --git a/serprog.c b/serprog.c index 25c9944..62f2820 100644 --- a/serprog.c +++ b/serprog.c @@ -305,6 +305,7 @@ unsigned char *readarr); static struct spi_master spi_master_serprog = { .type = SPI_CONTROLLER_SERPROG, + .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_READ_UNLIMITED, .max_data_write = MAX_DATA_WRITE_UNLIMITED, .command = serprog_spi_send_command,