Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Carl-Daniel Hailfinger |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <string.h> |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 21 | #include <usb.h> |
| 22 | #include "flash.h" |
Sean Nelson | 14ba668 | 2010-02-26 05:48:29 +0000 | [diff] [blame] | 23 | #include "chipdrivers.h" |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame^] | 24 | #include "programmer.h" |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 25 | #include "spi.h" |
| 26 | |
| 27 | #define DEFAULT_TIMEOUT 3000 |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 28 | static usb_dev_handle *dediprog_handle; |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 29 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 30 | #if 0 |
| 31 | /* Might be useful for other pieces of code as well. */ |
| 32 | static void print_hex(void *buf, size_t len) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 33 | { |
| 34 | size_t i; |
| 35 | |
| 36 | for (i = 0; i < len; i++) |
| 37 | msg_pdbg(" %02x", ((uint8_t *)buf)[i]); |
| 38 | } |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 39 | #endif |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 40 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 41 | /* Might be useful for other USB devices as well. static for now. */ |
| 42 | static struct usb_device *get_device_by_vid_pid(uint16_t vid, uint16_t pid) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 43 | { |
| 44 | struct usb_bus *bus; |
| 45 | struct usb_device *dev; |
| 46 | |
| 47 | for (bus = usb_get_busses(); bus; bus = bus->next) |
| 48 | for (dev = bus->devices; dev; dev = dev->next) |
| 49 | if ((dev->descriptor.idVendor == vid) && |
| 50 | (dev->descriptor.idProduct == pid)) |
| 51 | return dev; |
| 52 | |
| 53 | return NULL; |
| 54 | } |
| 55 | |
| 56 | //int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout); |
| 57 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 58 | static int dediprog_set_spi_voltage(uint16_t voltage) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 59 | { |
| 60 | int ret; |
| 61 | unsigned int mv; |
| 62 | |
| 63 | switch (voltage) { |
| 64 | case 0x0: |
| 65 | /* Admittedly this one is an assumption. */ |
| 66 | mv = 0; |
| 67 | break; |
| 68 | case 0x12: |
| 69 | mv = 1800; |
| 70 | break; |
| 71 | case 0x11: |
| 72 | mv = 2500; |
| 73 | break; |
| 74 | case 0x10: |
| 75 | mv = 3500; |
| 76 | break; |
| 77 | default: |
| 78 | msg_perr("Unknown voltage selector 0x%x! Aborting.\n", voltage); |
| 79 | return 1; |
| 80 | } |
| 81 | msg_pdbg("Setting SPI voltage to %u.%03u V\n", mv / 1000, mv % 1000); |
| 82 | |
| 83 | ret = usb_control_msg(dediprog_handle, 0x42, 0x9, voltage, 0xff, NULL, 0x0, DEFAULT_TIMEOUT); |
| 84 | if (ret != 0x0) { |
| 85 | msg_perr("Command Set SPI Voltage 0x%x failed!\n", voltage); |
| 86 | return 1; |
| 87 | } |
| 88 | return 0; |
| 89 | } |
| 90 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 91 | #if 0 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 92 | /* After dediprog_set_spi_speed, the original app always calls |
| 93 | * dediprog_set_spi_voltage(0) and then |
| 94 | * dediprog_check_devicestring() four times in a row. |
| 95 | * After that, dediprog_command_a() is called. |
| 96 | * This looks suspiciously like the microprocessor in the SF100 has to be |
| 97 | * restarted/reinitialized in case the speed changes. |
| 98 | */ |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 99 | static int dediprog_set_spi_speed(uint16_t speed) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 100 | { |
| 101 | int ret; |
| 102 | unsigned int khz; |
| 103 | |
| 104 | /* Case 1 and 2 are in weird order. Probably an organically "grown" |
| 105 | * interface. |
| 106 | * Base frequency is 24000 kHz, divisors are (in order) |
| 107 | * 1, 3, 2, 8, 11, 16, 32, 64. |
| 108 | */ |
| 109 | switch (speed) { |
| 110 | case 0x0: |
| 111 | khz = 24000; |
| 112 | break; |
| 113 | case 0x1: |
| 114 | khz = 8000; |
| 115 | break; |
| 116 | case 0x2: |
| 117 | khz = 12000; |
| 118 | break; |
| 119 | case 0x3: |
| 120 | khz = 3000; |
| 121 | break; |
| 122 | case 0x4: |
| 123 | khz = 2180; |
| 124 | break; |
| 125 | case 0x5: |
| 126 | khz = 1500; |
| 127 | break; |
| 128 | case 0x6: |
| 129 | khz = 750; |
| 130 | break; |
| 131 | case 0x7: |
| 132 | khz = 375; |
| 133 | break; |
| 134 | default: |
| 135 | msg_perr("Unknown frequency selector 0x%x! Aborting.\n", speed); |
| 136 | return 1; |
| 137 | } |
| 138 | msg_pdbg("Setting SPI speed to %u kHz\n", khz); |
| 139 | |
| 140 | ret = usb_control_msg(dediprog_handle, 0x42, 0x61, speed, 0xff, NULL, 0x0, DEFAULT_TIMEOUT); |
| 141 | if (ret != 0x0) { |
| 142 | msg_perr("Command Set SPI Speed 0x%x failed!\n", speed); |
| 143 | return 1; |
| 144 | } |
| 145 | return 0; |
| 146 | } |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 147 | #endif |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 148 | |
| 149 | int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) |
| 150 | { |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 151 | msg_pspew("%s, start=0x%x, len=0x%x\n", __func__, start, len); |
| 152 | /* Chosen read length is 16 bytes for now. */ |
| 153 | return spi_read_chunked(flash, buf, start, len, 16); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 157 | const unsigned char *writearr, unsigned char *readarr) |
| 158 | { |
| 159 | int ret; |
| 160 | |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 161 | msg_pspew("%s, writecnt=%i, readcnt=%i\n", __func__, writecnt, readcnt); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 162 | /* Paranoid, but I don't want to be blamed if anything explodes. */ |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 163 | if (writecnt > 5) { |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 164 | msg_perr("Untested writecnt=%i, aborting.\n", writecnt); |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 165 | return 1; |
| 166 | } |
| 167 | /* 16 byte reads should work. */ |
| 168 | if (readcnt > 16) { |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 169 | msg_perr("Untested readcnt=%i, aborting.\n", readcnt); |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 170 | return 1; |
| 171 | } |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 172 | |
| 173 | ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, DEFAULT_TIMEOUT); |
| 174 | if (ret != writecnt) { |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 175 | msg_perr("Send SPI failed, expected %i, got %i %s!\n", |
| 176 | writecnt, ret, usb_strerror()); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 177 | return 1; |
| 178 | } |
| 179 | if (!readcnt) |
| 180 | return 0; |
| 181 | memset(readarr, 0, readcnt); |
| 182 | ret = usb_control_msg(dediprog_handle, 0xc2, 0x01, 0xbb8, 0x0000, (char *)readarr, readcnt, DEFAULT_TIMEOUT); |
| 183 | if (ret != readcnt) { |
Carl-Daniel Hailfinger | eac6579 | 2010-01-22 02:53:30 +0000 | [diff] [blame] | 184 | msg_perr("Receive SPI failed, expected %i, got %i %s!\n", |
| 185 | readcnt, ret, usb_strerror()); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 186 | return 1; |
| 187 | } |
| 188 | return 0; |
| 189 | } |
| 190 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 191 | static int dediprog_check_devicestring(void) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 192 | { |
| 193 | int ret; |
| 194 | char buf[0x11]; |
| 195 | |
| 196 | /* Command Prepare Receive Device String. */ |
| 197 | memset(buf, 0, sizeof(buf)); |
| 198 | ret = usb_control_msg(dediprog_handle, 0xc3, 0x7, 0x0, 0xef03, buf, 0x1, DEFAULT_TIMEOUT); |
| 199 | /* The char casting is needed to stop gcc complaining about an always true comparison. */ |
| 200 | if ((ret != 0x1) || (buf[0] != (char)0xff)) { |
| 201 | msg_perr("Unexpected response to Command Prepare Receive Device" |
| 202 | " String!\n"); |
| 203 | return 1; |
| 204 | } |
| 205 | /* Command Receive Device String. */ |
| 206 | memset(buf, 0, sizeof(buf)); |
| 207 | ret = usb_control_msg(dediprog_handle, 0xc2, 0x8, 0xff, 0xff, buf, 0x10, DEFAULT_TIMEOUT); |
| 208 | if (ret != 0x10) { |
| 209 | msg_perr("Incomplete/failed Command Receive Device String!\n"); |
| 210 | return 1; |
| 211 | } |
| 212 | buf[0x10] = '\0'; |
| 213 | msg_pdbg("Found a %s\n", buf); |
| 214 | if (memcmp(buf, "SF100", 0x5)) { |
| 215 | msg_perr("Device not a SF100!\n"); |
| 216 | return 1; |
| 217 | } |
| 218 | /* Only these versions were tested. */ |
| 219 | if (memcmp(buf, "SF100 V:2.1.1 ", 0x10) && |
| 220 | memcmp(buf, "SF100 V:3.1.8 ", 0x10)) { |
| 221 | msg_perr("Unexpected firmware version!\n"); |
| 222 | return 1; |
| 223 | } |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | /* Command A seems to be some sort of device init. It is either followed by |
| 228 | * dediprog_check_devicestring (often) or Command A (often) or |
| 229 | * Command F (once). |
| 230 | */ |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 231 | static int dediprog_command_a(void) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 232 | { |
| 233 | int ret; |
| 234 | char buf[0x1]; |
| 235 | |
| 236 | memset(buf, 0, sizeof(buf)); |
| 237 | ret = usb_control_msg(dediprog_handle, 0xc3, 0xb, 0x0, 0x0, buf, 0x1, DEFAULT_TIMEOUT); |
| 238 | if ((ret != 0x1) || (buf[0] != 0x6f)) { |
| 239 | msg_perr("Unexpected response to Command A!\n"); |
| 240 | return 1; |
| 241 | } |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* Command C is only sent after dediprog_check_devicestring, but not after every |
| 246 | * invocation of dediprog_check_devicestring. It is only sent after the first |
| 247 | * dediprog_command_a(); dediprog_check_devicestring() sequence in each session. |
| 248 | * I'm tempted to call this one start_SPI_engine or finish_init. |
| 249 | */ |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 250 | static int dediprog_command_c(void) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 251 | { |
| 252 | int ret; |
| 253 | |
| 254 | ret = usb_control_msg(dediprog_handle, 0x42, 0x4, 0x0, 0x0, NULL, 0x0, DEFAULT_TIMEOUT); |
| 255 | if (ret != 0x0) { |
| 256 | msg_perr("Unexpected response to Command C!\n"); |
| 257 | return 1; |
| 258 | } |
| 259 | return 0; |
| 260 | } |
| 261 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 262 | #if 0 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 263 | /* Very strange. Seems to be a programmer keepalive or somesuch. |
| 264 | * Wait unsuccessfully for timeout ms to read one byte. |
| 265 | * Is usually called after setting voltage to 0. |
| 266 | */ |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 267 | static int dediprog_command_f(int timeout) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 268 | { |
| 269 | int ret; |
| 270 | char buf[0x1]; |
| 271 | |
| 272 | memset(buf, 0, sizeof(buf)); |
| 273 | ret = usb_control_msg(dediprog_handle, 0xc2, 0x11, 0xff, 0xff, buf, 0x1, timeout); |
| 274 | if (ret != 0x0) { |
| 275 | msg_perr("Unexpected response to Command F!\n"); |
| 276 | return 1; |
| 277 | } |
| 278 | return 0; |
| 279 | } |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 280 | #endif |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 281 | |
| 282 | /* URB numbers refer to the first log ever captured. */ |
| 283 | int dediprog_init(void) |
| 284 | { |
| 285 | struct usb_device *dev; |
| 286 | |
| 287 | msg_pspew("%s\n", __func__); |
| 288 | |
| 289 | /* Here comes the USB stuff. */ |
| 290 | usb_init(); |
| 291 | usb_find_busses(); |
| 292 | usb_find_devices(); |
| 293 | dev = get_device_by_vid_pid(0x0483, 0xdada); |
| 294 | if (!dev) { |
| 295 | msg_perr("Could not find a Dediprog SF100 on USB!\n"); |
| 296 | return 1; |
| 297 | } |
| 298 | msg_pdbg("Found USB device (%04x:%04x).\n", |
| 299 | dev->descriptor.idVendor, |
| 300 | dev->descriptor.idProduct); |
| 301 | dediprog_handle = usb_open(dev); |
Patrick Georgi | 975aa7e | 2010-02-04 08:29:18 +0000 | [diff] [blame] | 302 | usb_set_configuration(dediprog_handle, 1); |
| 303 | usb_claim_interface(dediprog_handle, 0); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 304 | /* URB 6. Command A. */ |
| 305 | if (dediprog_command_a()) |
| 306 | return 1; |
| 307 | /* URB 7. Command A. */ |
| 308 | if (dediprog_command_a()) |
| 309 | return 1; |
| 310 | /* URB 8. Command Prepare Receive Device String. */ |
| 311 | /* URB 9. Command Receive Device String. */ |
| 312 | if (dediprog_check_devicestring()) |
| 313 | return 1; |
| 314 | /* URB 10. Command C. */ |
| 315 | if (dediprog_command_c()) |
| 316 | return 1; |
| 317 | /* URB 11. Command Set SPI Voltage. */ |
| 318 | if (dediprog_set_spi_voltage(0x10)) |
| 319 | return 1; |
| 320 | |
| 321 | buses_supported = CHIP_BUSTYPE_SPI; |
| 322 | spi_controller = SPI_CONTROLLER_DEDIPROG; |
| 323 | |
| 324 | /* RE leftover, leave in until the driver is complete. */ |
| 325 | #if 0 |
| 326 | /* Execute RDID by hand if you want to test it. */ |
| 327 | dediprog_do_stuff(); |
| 328 | #endif |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 333 | #if 0 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 334 | /* Leftovers from reverse engineering. Keep for documentation purposes until |
| 335 | * completely understood. |
| 336 | */ |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 337 | static int dediprog_do_stuff(void) |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 338 | { |
| 339 | char buf[0x4]; |
| 340 | /* SPI command processing starts here. */ |
| 341 | |
| 342 | /* URB 12. Command Send SPI. */ |
| 343 | /* URB 13. Command Receive SPI. */ |
| 344 | memset(buf, 0, sizeof(buf)); |
| 345 | /* JEDEC RDID */ |
| 346 | msg_pdbg("Sending RDID\n"); |
| 347 | buf[0] = JEDEC_RDID; |
| 348 | if (dediprog_spi_send_command(JEDEC_RDID_OUTSIZE, JEDEC_RDID_INSIZE, (unsigned char *)buf, (unsigned char *)buf)) |
| 349 | return 1; |
| 350 | msg_pdbg("Receiving response: "); |
| 351 | print_hex(buf, JEDEC_RDID_INSIZE); |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 352 | /* URB 14-27 are more SPI commands. */ |
| 353 | /* URB 28. Command Set SPI Voltage. */ |
| 354 | if (dediprog_set_spi_voltage(0x0)) |
| 355 | return 1; |
| 356 | /* URB 29-38. Command F, unsuccessful wait. */ |
| 357 | if (dediprog_command_f(544)) |
| 358 | return 1; |
| 359 | /* URB 39. Command Set SPI Voltage. */ |
| 360 | if (dediprog_set_spi_voltage(0x10)) |
| 361 | return 1; |
| 362 | /* URB 40. Command Set SPI Speed. */ |
| 363 | if (dediprog_set_spi_speed(0x2)) |
| 364 | return 1; |
| 365 | /* URB 41 is just URB 28. */ |
| 366 | /* URB 42,44,46,48,51,53 is just URB 8. */ |
| 367 | /* URB 43,45,47,49,52,54 is just URB 9. */ |
| 368 | /* URB 50 is just URB 6/7. */ |
| 369 | /* URB 55-131 is just URB 29-38. (wait unsuccessfully for 4695 (maybe 4751) ms)*/ |
| 370 | /* URB 132,134 is just URB 6/7. */ |
| 371 | /* URB 133 is just URB 29-38. */ |
| 372 | /* URB 135 is just URB 8. */ |
| 373 | /* URB 136 is just URB 9. */ |
| 374 | /* URB 137 is just URB 11. */ |
| 375 | |
| 376 | /* Command I is probably Start Bulk Read. Data is u16 blockcount, u16 blocksize. */ |
| 377 | /* Command J is probably Start Bulk Write. Data is u16 blockcount, u16 blocksize. */ |
| 378 | /* Bulk transfer sizes for Command I/J are always 512 bytes, rest is filled with 0xff. */ |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 379 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 380 | return 0; |
| 381 | } |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 382 | #endif |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 383 | |
| 384 | int dediprog_shutdown(void) |
| 385 | { |
| 386 | msg_pspew("%s\n", __func__); |
| 387 | |
| 388 | /* URB 28. Command Set SPI Voltage to 0. */ |
| 389 | if (dediprog_set_spi_voltage(0x0)) |
| 390 | return 1; |
| 391 | |
| 392 | if (usb_close(dediprog_handle)) { |
| 393 | msg_perr("Couldn't close USB device!\n"); |
| 394 | return 1; |
| 395 | } |
| 396 | return 0; |
| 397 | } |