summaryrefslogtreecommitdiff
path: root/spi.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-12 08:10:33 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-12 08:10:33 +0000
commit2df50a230a7892fc8cdf839346332c783af1dfa6 (patch)
treeeb0158fb55f7a6df9bf09ad72166f99a7670651e /spi.c
parentb28e94acff42f68c4f4014b67eb7e1f962e2bb71 (diff)
downloadflashrom-2df50a230a7892fc8cdf839346332c783af1dfa6.tar.gz
Add spi_nbyte_program as generic function to the SPI layer.
Signed-off-by: Paul Fox <pgf@laptop.org> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@583 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/spi.c b/spi.c
index a342923..dc02300 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;