Author: hailfinger Date: Wed Jul 14 22:21:22 2010 New Revision: 1082 URL: http://flashrom.org/trac/coreboot/changeset/1082
Log: We have a generic unlocking infrastructure. Use it for SPI chips. Actually check if the unlock worked instead of just assuming it worked.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net Acked-by: Michael Karcher flashrom@mkarcher.dialup.fu-berlin.de
Modified: trunk/bitbang_spi.c trunk/buspirate_spi.c trunk/chipdrivers.h trunk/dummyflasher.c trunk/flashchips.c trunk/ft2232_spi.c trunk/ichspi.c trunk/it87spi.c trunk/sb600spi.c trunk/spi.c trunk/spi25.c
Modified: trunk/bitbang_spi.c ============================================================================== --- trunk/bitbang_spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/bitbang_spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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); }
Modified: trunk/buspirate_spi.c ============================================================================== --- trunk/buspirate_spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/buspirate_spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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); }
Modified: trunk/chipdrivers.h ============================================================================== --- trunk/chipdrivers.h Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/chipdrivers.h Wed Jul 14 22:21:22 2010 (r1082) @@ -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);
Modified: trunk/dummyflasher.c ============================================================================== --- trunk/dummyflasher.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/dummyflasher.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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); }
Modified: trunk/flashchips.c ============================================================================== --- trunk/flashchips.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/flashchips.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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, },
Modified: trunk/ft2232_spi.c ============================================================================== --- trunk/ft2232_spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/ft2232_spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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); }
Modified: trunk/ichspi.c ============================================================================== --- trunk/ichspi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/ichspi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -690,7 +690,6 @@ if (spi_controller == SPI_CONTROLLER_VIA) maxdata = 16;
- spi_disable_blockprotect(); return spi_write_chunked(flash, buf, start, len, maxdata); }
Modified: trunk/it87spi.c ============================================================================== --- trunk/it87spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/it87spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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,
Modified: trunk/sb600spi.c ============================================================================== --- trunk/sb600spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/sb600spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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); }
Modified: trunk/spi.c ============================================================================== --- trunk/spi.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/spi.c Wed Jul 14 22:21:22 2010 (r1082) @@ -217,7 +217,6 @@ { int ret;
- spi_disable_blockprotect(); msg_pinfo("Erasing flash before programming... "); if (erase_flash(flash)) { msg_perr("ERASE FAILED!\n");
Modified: trunk/spi25.c ============================================================================== --- trunk/spi25.c Wed Jul 14 21:57:52 2010 (r1081) +++ trunk/spi25.c Wed Jul 14 22:21:22 2010 (r1082) @@ -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)) {