Commit 29a1c66a authored by Carl-Daniel Hailfinger's avatar Carl-Daniel Hailfinger
Browse files

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: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: default avatarMichael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
parent ca812d40
......@@ -141,6 +141,5 @@ int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
{
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, 256);
}
......@@ -311,6 +311,5 @@ int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len
int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
{
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, 12);
}
......@@ -47,7 +47,7 @@ int spi_chip_write_1_new(struct flashchip *flash, uint8_t *buf, int start, int l
int spi_chip_write_256_new(struct flashchip *flash, uint8_t *buf, int start, int len);
int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
uint8_t spi_read_status_register(void);
int spi_disable_blockprotect(void);
int spi_disable_blockprotect(struct flashchip *flash);
int spi_byte_program(int addr, uint8_t databyte);
int spi_nbyte_program(int addr, uint8_t *bytes, int len);
int spi_nbyte_read(int addr, uint8_t *bytes, int len);
......
......@@ -173,6 +173,5 @@ int dummy_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
*/
int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
{
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, 256);
}
This diff is collapsed.
......@@ -290,7 +290,6 @@ int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
{
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, 256);
}
......
......@@ -690,7 +690,6 @@ int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len
if (spi_controller == SPI_CONTROLLER_VIA)
maxdata = 16;
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, maxdata);
}
......
......@@ -344,7 +344,6 @@ int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start,
spi_chip_write_1_new(flash, buf, start, len);
} else {
int lenhere;
spi_disable_blockprotect();
if (start % 256) {
/* start to the end of the page or start + len,
......
......@@ -50,7 +50,6 @@ int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len)
{
spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, 5);
}
......
......@@ -217,7 +217,6 @@ int spi_chip_write_256(struct flashchip *flash, uint8_t *buf)
{
int ret;
spi_disable_blockprotect();
msg_pinfo("Erasing flash before programming... ");
if (erase_flash(flash)) {
msg_perr("ERASE FAILED!\n");
......
......@@ -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)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment