diff options
author | Paul Fox <pgf@laptop.org> | 2009-06-12 08:10:33 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-06-12 08:10:33 +0000 |
commit | eb3acef863a3313fb5de5634192f3f131c19f6c5 (patch) | |
tree | eb0158fb55f7a6df9bf09ad72166f99a7670651e | |
parent | d51410c3aeaf413a42eb4666995aaea44962c7e6 (diff) | |
download | flashrom-eb3acef863a3313fb5de5634192f3f131c19f6c5.tar.gz flashrom-eb3acef863a3313fb5de5634192f3f131c19f6c5.tar.bz2 flashrom-eb3acef863a3313fb5de5634192f3f131c19f6c5.zip |
Add spi_nbyte_program as generic function to the SPI layer
Corresponding to flashrom svn r583.
Signed-off-by: Paul Fox <pgf@laptop.org>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
-rw-r--r-- | flash.h | 1 | ||||
-rw-r--r-- | spi.c | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -757,6 +757,7 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf); uint8_t spi_read_status_register(void); int spi_disable_blockprotect(void); void spi_byte_program(int address, uint8_t byte); +int spi_nbyte_program(int address, uint8_t *bytes, int len); int spi_nbyte_read(int address, uint8_t *bytes, int len); int spi_aai_write(struct flashchip *flash, uint8_t *buf); uint32_t spi_get_valid_read_addr(void); @@ -616,6 +616,27 @@ void spi_byte_program(int address, uint8_t byte) spi_command(sizeof(cmd), 0, cmd, NULL); } +int spi_nbyte_program(int address, uint8_t *bytes, int len) +{ + unsigned char cmd[JEDEC_BYTE_PROGRAM_OUTSIZE - 1 + 256] = { + JEDEC_BYTE_PROGRAM, + (address >> 16) & 0xff, + (address >> 8) & 0xff, + (address >> 0) & 0xff, + }; + + if (len > 256) { + printf_debug ("%s called for too long a write\n", + __FUNCTION__); + return 1; + } + + memcpy(&cmd[4], bytes, len); + + /* Send Byte-Program */ + return spi_command(4 + len, 0, cmd, NULL); +} + int spi_disable_blockprotect(void) { uint8_t status; |