summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-10-23 10:27:00 +0800
committerVic Yang <victoryang@chromium.org>2012-10-22 20:22:39 -0700
commit965ec04fffdee6c85035d288ed427acbed142629 (patch)
tree7b62ba3079c54ff80806d939ee81933b00eb7075
parent99011554fa802373878982033129fa2e64fe2f1d (diff)
downloadchrome-ec-965ec04fffdee6c85035d288ed427acbed142629.tar.gz
lm4: Report raw DID value when chip name cannot be determined
We map the raw DID value to chip name in EC. If the raw value is not in the mapping table, EC just returns empty string and we lose this information from host side. Let's return raw DID value like "Unknown-10ea". BUG=chrome-os-partner:15519 TEST=remove 0x10ea from the mapping and check 'mosys -k ec info' shows 'Unknown-10ea'. BRANCH=link Change-Id: I9399f44ab40db02202ee03ba3f988f3ece010d9f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36305 Reviewed-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r--chip/lm4/system.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/chip/lm4/system.c b/chip/lm4/system.c
index 7af9a3aca5..d69942e85c 100644
--- a/chip/lm4/system.c
+++ b/chip/lm4/system.c
@@ -387,6 +387,31 @@ const char *system_get_chip_vendor(void)
return "ti";
}
+static char to_hex(int x)
+{
+ if (x >= 0 && x <= 9)
+ return '0' + x;
+ return 'a' + x - 10;
+}
+
+const char *system_get_raw_chip_name(void)
+{
+ static char str[15] = "Unknown-";
+ char *p = str + 8;
+ uint32_t did = LM4_SYSTEM_DID1 >> 16;
+
+ if (*p)
+ return (const char *)str;
+
+ *p = to_hex(did >> 12);
+ *(p + 1) = to_hex((did >> 8) & 0xf);
+ *(p + 2) = to_hex((did >> 4) & 0xf);
+ *(p + 3) = to_hex(did & 0xf);
+ *(p + 4) = '\0';
+
+ return (const char *)str;
+}
+
const char *system_get_chip_name(void)
{
if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10e20000) {
@@ -400,7 +425,7 @@ const char *system_get_chip_name(void)
} else if ((LM4_SYSTEM_DID1 & 0xffff0000) == 0x10ea0000) {
return "lm4fs1gh5bb";
} else {
- return "";
+ return system_get_raw_chip_name();
}
}