summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2013-05-23 21:47:46 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-05-23 21:47:46 +0000
commitefe2d43056bcc15d70903354c6410a498b56b285 (patch)
treefc6a7fd4d6872b6c85d41868a97f948c73cb525c
parente659d2dfe3bbcc15e6c6cdb77ab7c09d040c06e3 (diff)
downloadast2050-flashrom-efe2d43056bcc15d70903354c6410a498b56b285.zip
ast2050-flashrom-efe2d43056bcc15d70903354c6410a498b56b285.tar.gz
dediprog: fix SPI clock setting
Avoid setting SPI speed on firmware versions < 5.0.0 and note this limitation in the man page. Use the correct offset of the "12M" element in the spispeeds array to match our manpage and the default of Dediprog's dpcmd. Corresponding to flashrom svn r1674. Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--dediprog.c15
-rw-r--r--flashrom.83
2 files changed, 11 insertions, 7 deletions
diff --git a/dediprog.c b/dediprog.c
index ab5388b..fb95d10 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -184,12 +184,15 @@ static const struct dediprog_spispeeds spispeeds[] = {
*/
static int dediprog_set_spi_speed(unsigned int spispeed_idx)
{
- int ret;
+ if (dediprog_firmwareversion < FIRMWARE_VERSION(5, 0, 0)) {
+ msg_pwarn("Skipping to set SPI speed because firmware is too old.\n");
+ return 0;
+ }
- msg_pdbg("SPI speed is %sHz\n", spispeeds[spispeed_idx].name);
+ msg_pdbg("SPI speed is %s Hz\n", spispeeds[spispeed_idx].name);
- ret = usb_control_msg(dediprog_handle, 0x42, 0x61, spispeeds[spispeed_idx].speed, 0xff,
- NULL, 0x0, DEFAULT_TIMEOUT);
+ int ret = usb_control_msg(dediprog_handle, 0x42, 0x61, spispeeds[spispeed_idx].speed, 0xff,
+ NULL, 0x0, DEFAULT_TIMEOUT);
if (ret != 0x0) {
msg_perr("Command Set SPI Speed 0x%x failed!\n", spispeeds[spispeed_idx].speed);
return 1;
@@ -789,7 +792,7 @@ int dediprog_init(void)
{
struct usb_device *dev;
char *voltage, *device, *spispeed, *target_str;
- int spispeed_idx = 2;
+ int spispeed_idx = 1;
int millivolt = 3500;
long usedevice = 0;
long target = 1;
@@ -806,7 +809,7 @@ int dediprog_init(void)
}
}
if (!spispeeds[i].name) {
- msg_perr("Error: Invalid 'spispeed' value.\n");
+ msg_perr("Error: Invalid spispeed value: '%s'.\n", spispeed);
free(spispeed);
return 1;
}
diff --git a/flashrom.8 b/flashrom.8
index c7a6c69..4e6ab55 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -683,7 +683,8 @@ Usage example to select the second device:
.sp
An optional
.B spispeed
-parameter specifies the frequency of the SPI bus. Syntax is
+parameter specifies the frequency of the SPI bus. The firmware on the device needs to be 5.0.0 or newer.
+Syntax is
.sp
.B " flashrom \-p dediprog:spispeed=frequency"
.sp
OpenPOWER on IntegriCloud