summaryrefslogtreecommitdiff
path: root/util/comm-lpc.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-06-18 15:17:48 -0700
committerGerrit <chrome-bot@google.com>2012-06-18 16:23:33 -0700
commitbbdc155caf341a4c1cda5784f283f4a299413db6 (patch)
treeec360a72ed36b067f5cbae708b326556f7ccef6d /util/comm-lpc.c
parentc5b923d38defc535828e3b5399f03f1350e0dc54 (diff)
downloadchrome-ec-bbdc155caf341a4c1cda5784f283f4a299413db6.tar.gz
Optimize performance of flash reads/writes
1) Smaller start delay for commands 2) Reads can use the entire 128 byte parameter space This improves read speed from 350ms/64kb to 210ms/64kb. BUG=none TEST=ectool flashread 81920 81920 then compare with ec.A.bin Change-Id: I53d460bace5f21db845a3f8ec681507fca0f7b0e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25562 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'util/comm-lpc.c')
-rw-r--r--util/comm-lpc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/comm-lpc.c b/util/comm-lpc.c
index 8b42763753..4f3aae3912 100644
--- a/util/comm-lpc.c
+++ b/util/comm-lpc.c
@@ -13,7 +13,7 @@
#include "ec_commands.h"
-#define INITIAL_UDELAY 10 /* 10 us */
+#define INITIAL_UDELAY 5 /* 5 us */
#define MAXIMUM_UDELAY 10000 /* 10 ms */
int comm_init(void)
@@ -31,13 +31,13 @@ int comm_init(void)
* If they all are 0xff, then very possible you cannot access GEC. */
byte &= inb(EC_LPC_ADDR_USER_CMD);
byte &= inb(EC_LPC_ADDR_USER_DATA);
- for (i = 0; i < EC_FLASH_SIZE_MAX /* big enough */; ++i)
+ for (i = 0; i < EC_PARAM_SIZE && byte == 0xff; ++i)
byte &= inb(EC_LPC_ADDR_USER_PARAM + i);
if (byte == 0xff) {
fprintf(stderr, "Port 0x%x,0x%x,0x%x-0x%x are all 0xFF.\n",
EC_LPC_ADDR_USER_CMD, EC_LPC_ADDR_USER_DATA,
EC_LPC_ADDR_USER_PARAM,
- EC_LPC_ADDR_USER_PARAM + EC_FLASH_SIZE_MAX - 1);
+ EC_LPC_ADDR_USER_PARAM + EC_PARAM_SIZE - 1);
fprintf(stderr, "Very likely this board doesn't have GEC.\n");
return -4;
}
@@ -64,8 +64,9 @@ static int wait_for_ec(int status_addr, int timeout_usec)
if (!(inb(status_addr) & EC_LPC_STATUS_BUSY_MASK))
return 0;
- /* Increase the delay interval */
- delay = MIN(delay * 2, MAXIMUM_UDELAY);
+ /* Increase the delay interval after a few rapid checks */
+ if (i > 20)
+ delay = MIN(delay * 2, MAXIMUM_UDELAY);
}
return -1; /* Timeout */
}