summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbc/usb_pd_console.c7
-rw-r--r--common/usbc/usb_pe_drp_sm.c14
-rw-r--r--include/usb_pe_sm.h17
3 files changed, 37 insertions, 1 deletions
diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c
index bc89daca05..29c0f9a9bb 100644
--- a/common/usbc/usb_pd_console.c
+++ b/common/usbc/usb_pd_console.c
@@ -164,9 +164,14 @@ test_export_static int command_pd(int argc, char **argv)
if (IS_ENABLED(CONFIG_USBC_VCONN))
ccprintf("%s ", tc_is_vconn_src(port) ? "-VC" : "");
- ccprintf("TC State: %s, Flags: 0x%04x\n",
+ ccprintf("TC State: %s, Flags: 0x%04x ",
tc_get_current_state(port),
tc_get_flags(port));
+
+ if (IS_ENABLED(CONFIG_USB_PE_SM))
+ ccprintf(" PE State: %s, Flags: 0x%04x\n",
+ pe_get_current_state(port),
+ pe_get_flags(port));
}
return EC_SUCCESS;
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 4281136a87..356a688e6e 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -5419,6 +5419,20 @@ void pd_set_dfp_enter_mode_flag(int port, bool set)
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
+const char *pe_get_current_state(int port)
+{
+ if (IS_ENABLED(USB_PD_DEBUG_LABELS))
+ return pe_state_names[get_state_pe(port)];
+ else
+ return "";
+}
+
+uint32_t pe_get_flags(int port)
+{
+ return pe[port].flags;
+}
+
+
static const struct usb_state pe_states[] = {
/* Super States */
#ifdef CONFIG_USB_PD_REV30
diff --git a/include/usb_pe_sm.h b/include/usb_pe_sm.h
index 949df6d516..2ad41991a2 100644
--- a/include/usb_pe_sm.h
+++ b/include/usb_pe_sm.h
@@ -197,5 +197,22 @@ void pe_invalidate_explicit_contract(int port);
* @param port USB-C port number
*/
bool pe_in_local_ams(int port);
+
+/**
+ * Returns the name of the current PE state
+ *
+ * @param port USB-C port number
+ * @return name of current pe state
+ */
+const char *pe_get_current_state(int port);
+
+/**
+ * Returns the flag mask of the PE state machine
+ *
+ * @param port USB-C port number
+ * @return flag mask of the pe state machine
+ */
+uint32_t pe_get_flags(int port);
+
#endif /* __CROS_EC_USB_PE_H */