1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

Add write support

Speed up reads by a factor of 4 by switching block size from 4 to 16.
Add support for 4 byte RDID.
Add USB error decoding via usb_strerror.

Corresponding to flashrom svn r879.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
This commit is contained in:
Carl-Daniel Hailfinger 2010-01-22 02:53:30 +00:00
parent 2fea3f3197
commit eac6579090
2 changed files with 18 additions and 11 deletions

View File

@ -145,8 +145,9 @@ int dediprog_set_spi_speed(uint16_t speed)
int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{ {
/* Maximum read length is 4 bytes for now. */ msg_pspew("%s, start=0x%x, len=0x%x\n", __func__, start, len);
return spi_read_chunked(flash, buf, start, len, 4); /* Chosen read length is 16 bytes for now. */
return spi_read_chunked(flash, buf, start, len, 16);
} }
int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
@ -154,19 +155,22 @@ int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
{ {
int ret; int ret;
msg_pspew("%s, writecnt=%i, readcnt=%i\n", __func__, writecnt, readcnt);
/* Paranoid, but I don't want to be blamed if anything explodes. */ /* Paranoid, but I don't want to be blamed if anything explodes. */
if ((writecnt != 1) && (writecnt != 4)) if (writecnt > 5) {
msg_perr("Untested writecnt=%i, aborting.\n", writecnt); msg_perr("Untested writecnt=%i, aborting.\n", writecnt);
if (readcnt > 4) return 1;
}
/* 16 byte reads should work. */
if (readcnt > 16) {
msg_perr("Untested readcnt=%i, aborting.\n", readcnt); msg_perr("Untested readcnt=%i, aborting.\n", readcnt);
if ((readcnt == 0) && (writecnt != 1)) return 1;
msg_perr("Untested writecnt=%i, readcnt=%i combination, " }
"aborting.\n", writecnt, readcnt);
ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, DEFAULT_TIMEOUT); ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, DEFAULT_TIMEOUT);
if (ret != writecnt) { if (ret != writecnt) {
msg_perr("Command Send SPI failed, ret=%i, expected %i!\n", msg_perr("Send SPI failed, expected %i, got %i %s!\n",
ret, writecnt); writecnt, ret, usb_strerror());
return 1; return 1;
} }
if (!readcnt) if (!readcnt)
@ -174,8 +178,8 @@ int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
memset(readarr, 0, readcnt); memset(readarr, 0, readcnt);
ret = usb_control_msg(dediprog_handle, 0xc2, 0x01, 0xbb8, 0x0000, (char *)readarr, readcnt, DEFAULT_TIMEOUT); ret = usb_control_msg(dediprog_handle, 0xc2, 0x01, 0xbb8, 0x0000, (char *)readarr, readcnt, DEFAULT_TIMEOUT);
if (ret != readcnt) { if (ret != readcnt) {
msg_perr("Command Receive SPI failed, ret=%i, expected %i!\n", msg_perr("Receive SPI failed, expected %i, got %i %s!\n",
ret, readcnt); readcnt, ret, usb_strerror());
return 1; return 1;
} }
return 0; return 0;

3
spi.c
View File

@ -334,6 +334,9 @@ int probe_spi_rdid4(struct flashchip *flash)
#endif #endif
#if BUSPIRATE_SPI_SUPPORT == 1 #if BUSPIRATE_SPI_SUPPORT == 1
case SPI_CONTROLLER_BUSPIRATE: case SPI_CONTROLLER_BUSPIRATE:
#endif
#if DEDIPROG_SUPPORT == 1
case SPI_CONTROLLER_DEDIPROG:
#endif #endif
return probe_spi_rdid_generic(flash, 4); return probe_spi_rdid_generic(flash, 4);
default: default: