summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-01-25 18:39:39 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-09 22:50:50 -0800
commit4ff544a573302336b1e2d8b55bfa8a32f847de4e (patch)
tree1951ca71b4247a18d3f306dcd37879f6bd8a2c4b /util
parentb889e47410698986822712078ec232c1715b4845 (diff)
downloadchrome-ec-4ff544a573302336b1e2d8b55bfa8a32f847de4e.tar.gz
Add host command to get PD chip information
This patch adds a host command to get PD chip info. For PS8751, tcpci_get_chip_info will fail if the chip is in low power mode. It can be woken up by reading a random register first then wait for 10ms. This code doesn't have the wake-up read to avoid 10ms delay. Instead, we call this function immediately after the chip is initialized because it'll gurantee the chip is awake. Once it's called, the chip info will be stored in cache, which can be accessed by tcpc_get_chip_info without worrying about chip states. localhost ~ # ectool pdchipinfo 0 vendor_id: 0xaaaa product_id: 0x3429 device_id: 0xad fw_version: 0x15 localhost ~ # ectool pdchipinfo 1 vendor_id: 0x1da0 product_id: 0x8751 device_id: 0x1 fw_version: 0x37 BUG=chrome-os-partner:62383 BRANCH=none TEST=ectool pdchipinfo 0/1. make buildall Change-Id: I3f1667d00ce1826936d90882ada1df6ed6b0ea37 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/433166
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 08f0e77ea2..5b14c78203 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -154,6 +154,8 @@ const char help_str[] =
" Whether or not the AP should pause in S5 on shutdown\n"
" pdcontrol [suspend|resume|reset|disable]\n"
" Controls the PD chip\n"
+ " pdchipinfo <port>\n"
+ " Get PD chip information\n"
" pdlog\n"
" Prints the PD event log entries\n"
" pdwritelog <type> <port>\n"
@@ -6861,6 +6863,36 @@ int cmd_pd_control(int argc, char *argv[])
return (rv < 0 ? rv : 0);
}
+int cmd_pd_chip_info(int argc, char *argv[])
+{
+ struct ec_params_pd_chip_info p;
+ struct ec_response_pd_chip_info r;
+ char *e;
+ int rv;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s <port>\n", argv[0]);
+ return -1;
+ }
+
+ p.port = strtol(argv[1], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "Bad port number.\n");
+ return -1;
+ }
+
+ rv = ec_command(EC_CMD_PD_CHIP_INFO, 0, &p, sizeof(p), &r, sizeof(r));
+ if (rv < 0)
+ return rv;
+
+ printf("vendor_id: 0x%x\n", r.vendor_id);
+ printf("product_id: 0x%x\n", r.product_id);
+ printf("device_id: 0x%x\n", r.device_id);
+ printf("fw_version: 0x%x\n", r.fw_version);
+
+ return 0;
+}
+
int cmd_pd_write_log(int argc, char *argv[])
{
struct ec_params_pd_write_log_entry p;
@@ -6954,6 +6986,7 @@ const struct command commands[] = {
{"port80read", cmd_port80_read},
{"pdlog", cmd_pd_log},
{"pdcontrol", cmd_pd_control},
+ {"pdchipinfo", cmd_pd_chip_info},
{"pdwritelog", cmd_pd_write_log},
{"powerinfo", cmd_power_info},
{"protoinfo", cmd_proto_info},