diff options
author | Sam Hurst <shurst@google.com> | 2020-06-24 13:21:40 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-27 05:58:29 +0000 |
commit | 9fe816a1c3a1286a6510b92503857ded5ae4b5fe (patch) | |
tree | ec12b19e331bc5a389b8b0a9df32a8259700cb67 | |
parent | 48a55c8b351bc10e5637e90814293a4b7869ac84 (diff) | |
download | chrome-ec-9fe816a1c3a1286a6510b92503857ded5ae4b5fe.tar.gz |
TCPMv2: Add PE State name to pd state console command
Some faft_pd tests need to query which state the pe state
machine is in.
BRANCH=none
BUG=b:159682253
TEST=make -j buildall
Signed-off-by: Sam Hurst <shurst@google.com>
Change-Id: I1782761328212f45bd690fd7285f016cf9285538
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2264484
-rw-r--r-- | common/usbc/usb_pd_console.c | 7 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 14 | ||||
-rw-r--r-- | include/usb_pe_sm.h | 17 |
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 */ |