From 33f6d2d5d32cc24792c463ba730bb79a82a4a529 Mon Sep 17 00:00:00 2001 From: Donald Huang Date: Wed, 17 Oct 2018 17:24:01 +0800 Subject: Disable the EC Read/Write Protect register at initial. BRANCH=no BUG=None TEST=~/trunk/src/platform/ec/util/flash_ec --board=it83xx_evb Change-Id: Ie03605f4d10db0760a7e6e3067837b6f9a21417c Signed-off-by: Donald Huang Reviewed-on: https://chromium-review.googlesource.com/1286316 Commit-Ready: Dino Li Tested-by: Dino Li Reviewed-by: Jett Rink --- util/iteflash.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'util/iteflash.c') diff --git a/util/iteflash.c b/util/iteflash.c index aeb868ec95..421a109bf4 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -506,6 +506,24 @@ static int dbgr_disable_watchdog(struct common_hnd *chnd) return 0; } +/* disable protect path from DBGR */ +static int dbgr_disable_protect_path(struct common_hnd *chnd) +{ + int ret = 0, i; + + ret |= i2c_write_byte(chnd, 0x2f, 0x20); + for (i = 0; i < 32; i++) { + ret |= i2c_write_byte(chnd, 0x2e, 0xa0+i); + ret |= i2c_write_byte(chnd, 0x30, 0); + } + + if (ret < 0) + printf("DISABLE PROTECT PATH FROM DBGR FAILED!\n"); + + return 0; +} + + /* Enter follow mode and FSCE# high level */ static int spi_flash_follow_mode(struct common_hnd *chnd, char *desc) { @@ -800,15 +818,19 @@ static int send_special_waveform(struct common_hnd *chnd) usleep(10 * MSEC); if (spi_flash_follow_mode(chnd, "enter follow mode") >= 0) { + spi_flash_follow_mode_exit(chnd, "exit follow mode"); /* * If we can talk to chip, then we can break the retry * loop */ ret = check_chipid(chnd); + /* disable watchdog before programming sequence */ - if (!ret) + if (!ret) { dbgr_disable_watchdog(chnd); + dbgr_disable_protect_path(chnd); + } } else { ret = -1; if (!(iterations % 10)) -- cgit v1.2.1