From eb3acef863a3313fb5de5634192f3f131c19f6c5 Mon Sep 17 00:00:00 2001 From: Paul Fox Date: Fri, 12 Jun 2009 08:10:33 +0000 Subject: Add spi_nbyte_program as generic function to the SPI layer Corresponding to flashrom svn r583. Signed-off-by: Paul Fox Acked-by: Carl-Daniel Hailfinger --- spi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'spi.c') diff --git a/spi.c b/spi.c index a3429238..dc02300b 100644 --- a/spi.c +++ b/spi.c @@ -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; -- cgit v1.2.3