diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-07-14 20:21:22 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-07-14 20:21:22 +0000 |
commit | 29a1c66a23bc8685f456d548361b735bf36dcf2b (patch) | |
tree | 963d487fa71ce4b6ad998d89fde9e167ce11e6bb /spi25.c | |
parent | ca812d40d461e70a70df6079978e96642775e7b2 (diff) | |
download | flashrom-29a1c66a23bc8685f456d548361b735bf36dcf2b.tar.gz flashrom-29a1c66a23bc8685f456d548361b735bf36dcf2b.tar.bz2 flashrom-29a1c66a23bc8685f456d548361b735bf36dcf2b.zip |
Use generic unlocking infrastructure for SPI chips
Actually check if the unlock worked instead of just assuming it worked.
Corresponding to flashrom svn r1082.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'spi25.c')
-rw-r--r-- | spi25.c | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -436,12 +436,6 @@ int spi_chip_erase_60(struct flashchip *flash) .readarr = NULL, }}; - result = spi_disable_blockprotect(); - if (result) { - msg_cerr("spi_disable_blockprotect failed\n"); - return result; - } - result = spi_send_multicommand(cmds); if (result) { msg_cerr("%s failed during command execution\n", @@ -482,12 +476,6 @@ int spi_chip_erase_c7(struct flashchip *flash) .readarr = NULL, }}; - result = spi_disable_blockprotect(); - if (result) { - msg_cerr("spi_disable_blockprotect failed\n"); - return result; - } - result = spi_send_multicommand(cmds); if (result) { msg_cerr("%s failed during command execution\n", __func__); @@ -841,7 +829,7 @@ int spi_nbyte_program(int addr, uint8_t *bytes, int len) return result; } -int spi_disable_blockprotect(void) +int spi_disable_blockprotect(struct flashchip *flash) { uint8_t status; int result; @@ -855,6 +843,11 @@ int spi_disable_blockprotect(void) msg_cerr("spi_write_status_register failed\n"); return result; } + status = spi_read_status_register(); + if ((status & 0x3c) != 0) { + msg_cerr("Block protection could not be disabled!\n"); + return 1; + } } return 0; } @@ -970,7 +963,6 @@ int spi_chip_write_1_new(struct flashchip *flash, uint8_t *buf, int start, int l { int i, result = 0; - spi_disable_blockprotect(); for (i = start; i < start + len; i++) { result = spi_byte_program(i, buf[i]); if (result) @@ -984,7 +976,6 @@ int spi_chip_write_1_new(struct flashchip *flash, uint8_t *buf, int start, int l int spi_chip_write_1(struct flashchip *flash, uint8_t *buf) { - spi_disable_blockprotect(); /* Erase first */ msg_cinfo("Erasing flash before programming... "); if (erase_flash(flash)) { |