diff options
author | David Hendricks <dhendrix@chromium.org> | 2016-02-18 21:42:41 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2016-02-18 21:42:41 +0000 |
commit | 3bec0d385dec2b6c7a7df0e5c0cd03803c059a91 (patch) | |
tree | 89f3c8aaf6ec9e21faa98c486649e24a6983c323 | |
parent | 659fd0f7975494e8a187bff1b0233c32710cfe44 (diff) | |
download | flashrom-3bec0d385dec2b6c7a7df0e5c0cd03803c059a91.zip flashrom-3bec0d385dec2b6c7a7df0e5c0cd03803c059a91.tar.gz |
dediprog: use command 0x0B (set voltage) only on older SF100s
As per e-mail with Dediprog, command 0x0B (which is not listed in the
command spec) is need on older Dediprogs only. SF100 with firmware
V6.0.0 and newer as well as all SF600 programmers do not support it.
The original wording by Dediprog was: "0x0B is used to adjust voltage
level, but it's available for some version of SF100 only. SF100 of
firmware V6.x.x and all version of SF600/SF600Plus not support this
command. If you have old version of SF100, 0x0B is still needed."
This patch renames dediprog_device_init() to something more
appropriate and adds comments for clarity, and only runs it
conditionally if we cannot query the devicestring initially.
Based on ChromiumOS'
Change-Id: I42de7d28401d7ad5be8fcf8a8c165e2614a45960
Corresponding to flashrom svn r1928.
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r-- | dediprog.c | 37 |
1 files changed, 24 insertions, 13 deletions
@@ -82,6 +82,7 @@ enum dediprog_cmds { CMD_READ_PROG_INFO = 0x08, CMD_SET_VCC = 0x09, CMD_SET_STANDALONE = 0x0A, + CMD_SET_VOLTAGE = 0x0B, /* Only in firmware older than 6.0.0 */ CMD_GET_BUTTON = 0x11, CMD_GET_UID = 0x12, CMD_SET_CS = 0x14, @@ -628,22 +629,29 @@ static int dediprog_check_devicestring(void) return 0; } -static int dediprog_device_init(void) -{ - int ret; - char buf[0x1]; +/* + * This command presumably sets the voltage for the SF100 itself (not the + * SPI flash). Only use this command with firmware older than V6.0.0. Newer + * (including all SF600s) do not support it. + */ - memset(buf, 0, sizeof(buf)); - ret = usb_control_msg(dediprog_handle, REQTYPE_OTHER_IN, 0x0B, 0x0, 0x0, +/* This command presumably sets the voltage for the SF100 itself (not the SPI flash). + * Only use dediprog_set_voltage on SF100 programmers with firmware older + * than V6.0.0. Newer programmers (including all SF600s) do not support it. */ +static int dediprog_set_voltage(void) +{ + char buf[1] = {0}; + int ret = usb_control_msg(dediprog_handle, REQTYPE_OTHER_IN, CMD_SET_VOLTAGE, 0x0, 0x0, buf, 0x1, DEFAULT_TIMEOUT); if (ret < 0) { - msg_perr("Command A failed (%s)!\n", usb_strerror()); + msg_perr("Command Set Voltage failed (%s)!\n", usb_strerror()); return 1; } - if ((ret != 0x1) || (buf[0] != 0x6f)) { + if ((ret != 1) || (buf[0] != 0x6f)) { msg_perr("Unexpected response to init!\n"); return 1; } + return 0; } @@ -914,11 +922,14 @@ int dediprog_init(void) if (register_shutdown(dediprog_shutdown, NULL)) return 1; - /* Perform basic setup. */ - if (dediprog_device_init()) - return 1; - if (dediprog_check_devicestring()) - return 1; + /* Try reading the devicestring. If that fails and the device is old (FW < 6.0.0, which we can not know) + * then we need to try the "set voltage" command and then attempt to read the devicestring again. */ + if (dediprog_check_devicestring()) { + if (dediprog_set_voltage()) + return 1; + if (dediprog_check_devicestring()) + return 1; + } /* SF100 only has 1 endpoint for in/out, SF600 uses two separate endpoints instead. */ dediprog_in_endpoint = 2; |