summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-10-22 13:53:37 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-23 04:09:50 +0000
commitbbf6b9b076d28b55a81c2eae69f3913721afa54b (patch)
tree0fc2ee5cbbbce0e2997639a2e95c015be231eaa7
parent5f26987366fefe22f9f6157f3d13c18aed3c9e03 (diff)
downloadchrome-ec-bbf6b9b076d28b55a81c2eae69f3913721afa54b.tar.gz
lpc: No need to scan entire host command I/O space for detection
The EC LPC implementation guarantees that the status byte will have at least one zero bit, so there's no need to scan the parameter space as well. Removing this unneeded check will slightly speed up ectool. BUG=chrome-os-partner:10963 BRANCH=none TEST=on an x86 chromebook (e.g. link), ectool hello still works iotools io_read8 0x200 && iotools io_read8 0x204 -> not both 0xff Change-Id: Ic02ca0ee686ab10e50093807717ec638aaa468c6 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174059 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--chip/lm4/lpc.c6
-rw-r--r--util/comm-lpc.c19
2 files changed, 12 insertions, 13 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 587c79c22a..8a99247c74 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -724,6 +724,12 @@ static void lpc_init(void)
*/
LM4_LPC_ADR(LPC_CH_CMD) = EC_LPC_ADDR_HOST_DATA;
LM4_LPC_CTL(LPC_CH_CMD) = (LPC_POOL_OFFS_CMD << (5 - 1));
+ /*
+ * Initialize status bits to 0. We never set the ACPI burst status bit,
+ * so this guarantees that at least one status bit will always be 0.
+ * This is used by comm_lpc.c to detect that the EC is present on the
+ * LPC bus. See crosbug.com/p/10963.
+ */
LM4_LPC_ST(LPC_CH_CMD) = 0;
/* Unmask interrupt for host command writes */
LM4_LPC_LPCIM |= LM4_LPC_INT_MASK(LPC_CH_CMD, 4);
diff --git a/util/comm-lpc.c b/util/comm-lpc.c
index adbbb89f10..8ea4e9ddd8 100644
--- a/util/comm-lpc.c
+++ b/util/comm-lpc.c
@@ -257,22 +257,15 @@ int comm_init_lpc(void)
/*
* Test if the I/O port has been configured for Chromium EC LPC
- * interface. If all the bytes are 0xff, very likely that Chromium EC
- * is not present.
- *
- * TODO: (crosbug.com/p/10963) Should only need to look at the command
- * byte, since we don't support ACPI burst mode and thus bit 4 should
- * be 0.
+ * interface. Chromium EC guarantees that at least one status bit will
+ * be 0, so if the command and data bytes are both 0xff, very likely
+ * that Chromium EC is not present. See crosbug.com/p/10963.
*/
byte &= inb(EC_LPC_ADDR_HOST_CMD);
byte &= inb(EC_LPC_ADDR_HOST_DATA);
- for (i = 0; i < EC_PROTO2_MAX_PARAM_SIZE && byte == 0xff; ++i)
- byte &= inb(EC_LPC_ADDR_HOST_PARAM + i);
if (byte == 0xff) {
- fprintf(stderr, "Port 0x%x,0x%x,0x%x-0x%x are all 0xFF.\n",
- EC_LPC_ADDR_HOST_CMD, EC_LPC_ADDR_HOST_DATA,
- EC_LPC_ADDR_HOST_PARAM,
- EC_LPC_ADDR_HOST_PARAM + EC_PROTO2_MAX_PARAM_SIZE - 1);
+ fprintf(stderr, "Port 0x%x,0x%x are both 0xFF.\n",
+ EC_LPC_ADDR_HOST_CMD, EC_LPC_ADDR_HOST_DATA);
fprintf(stderr,
"Very likely this board doesn't have a Chromium EC.\n");
return -4;
@@ -304,7 +297,7 @@ int comm_init_lpc(void)
sizeof(struct ec_host_response);
} else if (i & EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED) {
- /* Protocol version 2*/
+ /* Protocol version 2 */
ec_command = ec_command_lpc;
ec_max_outsize = ec_max_insize = EC_PROTO2_MAX_PARAM_SIZE;