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>
diff --git a/bitbang_spi.c b/bitbang_spi.c
index adb1038..446be11 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -141,6 +141,5 @@
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);
}
diff --git a/buspirate_spi.c b/buspirate_spi.c
index e93cf1a..55e71c2 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -311,6 +311,5 @@
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);
}
diff --git a/chipdrivers.h b/chipdrivers.h
index ca3b190..3a9c611 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -47,7 +47,7 @@
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);
diff --git a/dummyflasher.c b/dummyflasher.c
index 479a938..241dcee 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -173,6 +173,5 @@
*/
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);
}
diff --git a/flashchips.c b/flashchips.c
index 5954eb2..354bd95 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -335,6 +335,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -369,6 +370,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -403,6 +405,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -437,6 +440,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -471,6 +475,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -505,6 +510,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -539,6 +545,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -573,6 +580,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -607,6 +615,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -641,6 +650,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -697,6 +707,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -731,6 +742,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -765,6 +777,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -781,6 +794,7 @@
.tested = TEST_UNTESTED,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},*/
@@ -1184,6 +1198,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1215,6 +1230,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1246,6 +1262,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1423,6 +1440,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -1453,6 +1471,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1483,6 +1502,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1513,6 +1533,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1543,6 +1564,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1574,6 +1596,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1605,6 +1628,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1636,6 +1660,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1667,6 +1692,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1698,6 +1724,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1729,6 +1756,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1760,6 +1788,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1791,6 +1820,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1822,6 +1852,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1853,6 +1884,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1884,6 +1916,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1915,6 +1948,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1949,6 +1983,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -1983,6 +2018,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2017,6 +2053,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2051,6 +2088,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2082,6 +2120,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2113,6 +2152,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2144,6 +2184,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2175,6 +2216,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2718,6 +2760,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2749,6 +2792,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2783,6 +2827,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2817,6 +2862,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2851,6 +2897,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2885,6 +2932,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2916,6 +2964,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2947,6 +2996,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -2978,6 +3028,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3009,6 +3060,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3040,6 +3092,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3220,6 +3273,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3248,6 +3302,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3276,6 +3331,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3304,6 +3360,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3332,6 +3389,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3360,6 +3418,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3394,6 +3453,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3422,6 +3482,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3450,6 +3511,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3484,6 +3546,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3512,6 +3575,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3746,6 +3810,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3803,6 +3868,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3828,6 +3894,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -3862,6 +3929,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -3896,6 +3964,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -3924,6 +3993,7 @@
.block_erase = spi_block_erase_60,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -3958,6 +4028,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -3986,6 +4057,7 @@
.block_erase = spi_block_erase_60,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -4020,6 +4092,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -4054,6 +4127,7 @@
.block_erase = spi_block_erase_c7,
},
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1,
.read = spi_chip_read,
},
@@ -4834,6 +4908,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -4864,6 +4939,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1, /* 128 */
.read = spi_chip_read,
},
@@ -4889,6 +4965,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -4915,6 +4992,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_1, /* 128 */
.read = spi_chip_read,
},
@@ -4940,6 +5018,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -4965,6 +5044,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -4990,6 +5070,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5015,6 +5096,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5040,6 +5122,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5065,6 +5148,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5090,6 +5174,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5115,6 +5200,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5796,6 +5882,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5830,6 +5917,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5864,6 +5952,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5898,6 +5987,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5926,6 +6016,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5954,6 +6045,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -5982,6 +6074,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -6010,6 +6103,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -6044,6 +6138,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -6078,6 +6173,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
@@ -6112,6 +6208,7 @@
.block_erase = spi_block_erase_c7,
}
},
+ .unlock = spi_disable_blockprotect,
.write = spi_chip_write_256,
.read = spi_chip_read,
},
diff --git a/ft2232_spi.c b/ft2232_spi.c
index ee8515f..c8711e9 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -290,7 +290,6 @@
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);
}
diff --git a/ichspi.c b/ichspi.c
index 8fa3c29..d6f9118 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -690,7 +690,6 @@
if (spi_controller == SPI_CONTROLLER_VIA)
maxdata = 16;
- spi_disable_blockprotect();
return spi_write_chunked(flash, buf, start, len, maxdata);
}
diff --git a/it87spi.c b/it87spi.c
index 69d10a6..cf3d3b9 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -344,7 +344,6 @@
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,
diff --git a/sb600spi.c b/sb600spi.c
index 72181d1..caf1a99 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -50,7 +50,6 @@
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);
}
diff --git a/spi.c b/spi.c
index 9a31abf..2b64463 100644
--- a/spi.c
+++ b/spi.c
@@ -217,7 +217,6 @@
{
int ret;
- spi_disable_blockprotect();
msg_pinfo("Erasing flash before programming... ");
if (erase_flash(flash)) {
msg_perr("ERASE FAILED!\n");
diff --git a/spi25.c b/spi25.c
index fa76531..32bb73c 100644
--- a/spi25.c
+++ b/spi25.c
@@ -436,12 +436,6 @@
.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 @@
.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 @@
return result;
}
-int spi_disable_blockprotect(void)
+int spi_disable_blockprotect(struct flashchip *flash)
{
uint8_t status;
int result;
@@ -855,6 +843,11 @@
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 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(struct flashchip *flash, uint8_t *buf)
{
- spi_disable_blockprotect();
/* Erase first */
msg_cinfo("Erasing flash before programming... ");
if (erase_flash(flash)) {