summaryrefslogtreecommitdiff
path: root/include/usb_pd.h
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-01-06 11:00:36 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-15 01:07:02 +0000
commit4e75e20f4ec5cecda6742d821b1a4484952fd07e (patch)
tree210a7f79055092da7b180a27a67f7d3331b339ee /include/usb_pd.h
parent389ef0f90ff9318ced905d7a1ed8c025953aebc3 (diff)
downloadchrome-ec-4e75e20f4ec5cecda6742d821b1a4484952fd07e.tar.gz
Add PD events logging
Add a FIFO to log important events on the PD MCU and coming from the PD accessories. The retrieval of the accessories log from the accessories by the PD MCU is not implemented yet. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:32785 TEST=execute "ectool --name=cros_pd pdlog" before and after plugging Zinger charger. Change-Id: If96d73e711ff6ad64cfb99bd3e4d2d8f2643f19a Reviewed-on: https://chromium-review.googlesource.com/238854 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/usb_pd.h')
-rw-r--r--include/usb_pd.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 4d499327cf..51f23fba39 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -282,6 +282,7 @@ struct pd_policy {
#define VDO_CMD_PING_ENABLE VDO_CMD_VENDOR(10)
#define VDO_CMD_CURRENT VDO_CMD_VENDOR(11)
#define VDO_CMD_FLIP VDO_CMD_VENDOR(12)
+#define VDO_CMD_GET_LOG VDO_CMD_VENDOR(13)
#define PD_VDO_VID(vdo) ((vdo) >> 16)
#define PD_VDO_SVDM(vdo) (((vdo) >> 15) & 1)
@@ -1276,4 +1277,32 @@ void pd_prepare_sysjump(void);
*/
void pd_set_new_power_request(int port);
+/* ----- Logging ----- */
+#ifdef CONFIG_USB_PD_LOGGING
+/**
+ * Record one event in the PD logging FIFO.
+ *
+ * @param type event type as defined by PD_EVENT_xx in ec_commands.h
+ * @param size_port payload size and port num (defined by PD_LOG_PORT_SIZE)
+ * @param data type-defined information
+ * @param payload pointer to the optional payload (0..16 bytes)
+ */
+void pd_log_event(uint8_t type, uint8_t size_port,
+ uint16_t data, void *payload);
+
+/**
+ * Retrieve one logged event and prepare a VDM with it.
+ *
+ * Used to answer the VDO_CMD_GET_LOG unstructured VDM.
+ *
+ * @param payload pointer to the payload data buffer (must be 7 words)
+ * @return number of 32-bit words in the VDM payload.
+ */
+int pd_vdm_get_log_entry(uint32_t *payload);
+#else /* CONFIG_USB_PD_LOGGING */
+static inline void pd_log_event(uint8_t type, uint8_t size_port,
+ uint16_t data, void *payload) {}
+static inline int pd_vdm_get_log_entry(uint32_t *payload) { return 0; }
+#endif /* CONFIG_USB_PD_LOGGING */
+
#endif /* __USB_PD_H */