Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of the flashrom project. | 2 * This file is part of the flashrom project. |
| 3 * | 3 * |
| 4 * Copyright (C) 2010 Google, Inc. | 4 * Copyright (C) 2010 Google, Inc. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * Redistributions of source code must retain the above copyright | 10 * Redistributions of source code must retain the above copyright |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include <time.h> | 45 #include <time.h> |
| 46 #include <unistd.h> | 46 #include <unistd.h> |
| 47 #include <stdlib.h> | 47 #include <stdlib.h> |
| 48 #include "flash.h" | 48 #include "flash.h" |
| 49 #include "chipdrivers.h" | 49 #include "chipdrivers.h" |
| 50 #include "flashchips.h" | 50 #include "flashchips.h" |
| 51 #include "programmer.h" | 51 #include "programmer.h" |
| 52 #include "spi.h" | 52 #include "spi.h" |
| 53 #include "writeprotect.h" | 53 #include "writeprotect.h" |
| 54 | 54 |
| 55 void wpce775x_shutdown(void *); | |
|
Stefan Reinauer
2011/04/27 20:34:05
delete this.
dhendrix
2011/04/27 21:15:05
Done.
| |
| 56 | |
| 55 /** | 57 /** |
| 56 * Definition of WPCE775X WCB (Write Command Buffer), as known as Shared Access | 58 * Definition of WPCE775X WCB (Write Command Buffer), as known as Shared Access |
| 57 * Window 2. | 59 * Window 2. |
| 58 * | 60 * |
| 59 * The document name is "WPCE775X Software User Guide Revision 1.2". | 61 * The document name is "WPCE775X Software User Guide Revision 1.2". |
| 60 * | 62 * |
| 61 * Assume the host is little endian. | 63 * Assume the host is little endian. |
| 62 */ | 64 */ |
| 63 __attribute__((packed)) | 65 __attribute__((packed)) |
| 64 struct wpce775x_wcb { | 66 struct wpce775x_wcb { |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 587 |
| 586 if (get_fwh_id(&fwh_id) < 0) { | 588 if (get_fwh_id(&fwh_id) < 0) { |
| 587 msg_pdbg("Cannot get fwh_id value.\n"); | 589 msg_pdbg("Cannot get fwh_id value.\n"); |
| 588 return 0; | 590 return 0; |
| 589 } | 591 } |
| 590 msg_pdbg("get fwh_id: 0x%02x\n", fwh_id); | 592 msg_pdbg("get fwh_id: 0x%02x\n", fwh_id); |
| 591 | 593 |
| 592 /* TODO: set fwh_idsel of chipset. | 594 /* TODO: set fwh_idsel of chipset. |
| 593 Currently, we employ "-p internal:fwh_idsel=0x0000223e". */ | 595 Currently, we employ "-p internal:fwh_idsel=0x0000223e". */ |
| 594 | 596 |
| 597 if (register_shutdown(wpce775x_shutdown, NULL)) | |
| 598 return 1; | |
| 599 | |
| 595 /* Enter flash update mode unconditionally. This is required even | 600 /* Enter flash update mode unconditionally. This is required even |
| 596 for reading. */ | 601 for reading. */ |
| 597 if (EnterFlashUpdate()) return 1; | 602 if (EnterFlashUpdate()) return 1; |
| 598 | 603 |
| 599 spi_controller = SPI_CONTROLLER_WPCE775X; | 604 spi_controller = SPI_CONTROLLER_WPCE775X; |
| 600 msg_pdbg("%s(): successfully initialized wpce775x\n", __func__); | 605 msg_pdbg("%s(): successfully initialized wpce775x\n", __func__); |
| 601 return 0; | 606 return 0; |
| 602 | |
| 603 } | 607 } |
| 604 | 608 |
| 605 int wpce775x_shutdown(void) | 609 void wpce775x_shutdown(void *data) |
|
Stefan Reinauer
2011/04/27 20:34:05
static and move before register
dhendrix
2011/04/27 21:15:05
Done.
| |
| 606 { | 610 { |
| 607 if (spi_controller != SPI_CONTROLLER_WPCE775X) | 611 if (spi_controller != SPI_CONTROLLER_WPCE775X) |
| 608 » » return 0; | 612 » » return; |
| 609 | 613 |
| 610 msg_pdbg("%s(): firmware %s\n", __func__, | 614 msg_pdbg("%s(): firmware %s\n", __func__, |
| 611 firmware_changed ? "changed" : "not changed"); | 615 firmware_changed ? "changed" : "not changed"); |
| 612 | 616 |
| 613 msg_pdbg("%s: in_flash_update_mode: %d\n", __func__, in_flash_update_mod e); | 617 msg_pdbg("%s: in_flash_update_mode: %d\n", __func__, in_flash_update_mod e); |
| 614 if (in_flash_update_mode) { | 618 if (in_flash_update_mode) { |
| 615 if (firmware_changed) | 619 if (firmware_changed) |
| 616 ExitFlashUpdateFirmwareChanged(); | 620 ExitFlashUpdateFirmwareChanged(); |
| 617 else | 621 else |
| 618 ExitFlashUpdateFirmwareNoChange(); | 622 ExitFlashUpdateFirmwareNoChange(); |
| 619 | 623 |
| 620 in_flash_update_mode = 0; | 624 in_flash_update_mode = 0; |
| 621 } | 625 } |
| 622 | 626 |
| 623 if (initflash_cfg) | 627 if (initflash_cfg) |
| 624 free(initflash_cfg); | 628 free(initflash_cfg); |
| 625 else | 629 else |
| 626 msg_perr("%s(): No initflash_cfg to free?!?\n", __func__); | 630 msg_perr("%s(): No initflash_cfg to free?!?\n", __func__); |
| 627 | |
| 628 return 0; | |
| 629 } | 631 } |
| 630 | 632 |
| 631 /* Called by internal_init() */ | 633 /* Called by internal_init() */ |
| 632 int wpce775x_probe_spi_flash(const char *name) | 634 int wpce775x_probe_spi_flash(const char *name) |
| 633 { | 635 { |
| 634 int ret; | 636 int ret; |
| 635 | 637 |
| 636 if (!(buses_supported & CHIP_BUSTYPE_FWH)) { | 638 if (!(buses_supported & CHIP_BUSTYPE_FWH)) { |
| 637 msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__); | 639 msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__); |
| 638 return 1; | 640 return 1; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 /* unsupported opcodes */ | 978 /* unsupported opcodes */ |
| 977 msg_pdbg("unsupported SPI opcode: %02x\n", opcode); | 979 msg_pdbg("unsupported SPI opcode: %02x\n", opcode); |
| 978 rc = 1; | 980 rc = 1; |
| 979 break; | 981 break; |
| 980 } | 982 } |
| 981 | 983 |
| 982 msg_pdbg("%s: opcode: 0x%02x\n", __func__, opcode); | 984 msg_pdbg("%s: opcode: 0x%02x\n", __func__, opcode); |
| 983 return rc; | 985 return rc; |
| 984 } | 986 } |
| 985 #endif | 987 #endif |
| OLD | NEW |