summaryrefslogtreecommitdiff
path: root/common/usb_pd_protocol.c
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-01-15 09:47:02 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-21 06:44:33 +0000
commitb13063c247a39603bf63f89e4442434a58cde236 (patch)
tree2466cd340fdce607c6d7100d90c5128742aed893 /common/usb_pd_protocol.c
parent3075113c856dc0c26325a7e5ff9d8ed7f9658b4d (diff)
downloadchrome-ec-b13063c247a39603bf63f89e4442434a58cde236.tar.gz
pd: retrieve logs from accessories
Send the VDO_CMD_GET_LOG VDM to accessories to get their PD event log and append it to the PD MCU log. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33248 chrome-os-partner:32785 TEST=ectool --name=cros_pd pdlog Change-Id: Ib52d1e2cae5f77dcec6d0489eaa49527388b02b6 Reviewed-on: https://chromium-review.googlesource.com/242013 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r--common/usb_pd_protocol.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 9796462564..c18af2093a 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -2931,6 +2931,31 @@ void pd_send_hpd(int port, enum hpd_event hpd)
}
#endif
+int pd_fetch_acc_log_entry(int port)
+{
+ timestamp_t timeout;
+
+ /* Cannot send a VDM now, the host should retry */
+ if (pd[port].vdm_state > 0)
+ return pd[port].vdm_state == VDM_STATE_BUSY ?
+ EC_RES_BUSY : EC_RES_UNAVAILABLE;
+
+ pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_GET_LOG, NULL, 0);
+ timeout.val = get_time().val + 500*MSEC;
+
+ /* Wait until VDM is done */
+ while ((pd[port].vdm_state > 0) &&
+ (get_time().val < timeout.val))
+ task_wait_event(10*MSEC);
+
+ if (pd[port].vdm_state > 0)
+ return EC_RES_TIMEOUT;
+ else if (pd[port].vdm_state < 0)
+ return EC_RES_ERROR;
+
+ return EC_RES_SUCCESS;
+}
+
void pd_request_source_voltage(int port, int mv)
{
pd_set_max_voltage(mv);