diff options
-rw-r--r-- | common/usb_common.c | 20 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 4 | ||||
-rw-r--r-- | common/usbc/usb_pd_console.c | 3 | ||||
-rw-r--r-- | include/usb_common.h | 7 |
4 files changed, 33 insertions, 1 deletions
diff --git a/common/usb_common.c b/common/usb_common.c index 6fde61cfab..7a21eb1676 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -904,6 +904,26 @@ DECLARE_CONSOLE_COMMAND(tcpci_dump, command_tcpc_dump, "<Type-C port>", "dump the TCPC regs"); #endif /* defined(CONFIG_CMD_TCPC_DUMP) */ +void pd_srccaps_dump(int port) +{ + int i; + const uint32_t *const srccaps = pd_get_src_caps(port); + + for (i = 0; i < pd_get_src_cap_cnt(port); ++i) { + uint32_t max_ma, max_mv, min_mv; + + pd_extract_pdo_power(srccaps[i], &max_ma, &max_mv, &min_mv); + + if ((srccaps[i] & PDO_TYPE_MASK) == PDO_TYPE_AUGMENTED) { + if (IS_ENABLED(CONFIG_USB_PD_REV30)) + ccprintf("%d: %dmV-%dmV/%dmA\n", i, min_mv, + max_mv, max_ma); + } else { + ccprintf("%d: %dmV/%dmA\n", i, max_mv, max_ma); + } + } +} + int pd_build_alert_msg(uint32_t *msg, uint32_t *len, enum pd_power_role pr) { if (msg == NULL || len == NULL) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 1734be269d..13e6c7842f 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -5200,6 +5200,8 @@ static int command_pd(int argc, char **argv) #endif else return EC_ERROR_PARAM3; + } else if (!strncasecmp(argv[2], "srccaps", 7)) { + pd_srccaps_dump(port); } else if (!strncasecmp(argv[2], "ping", 4)) { int enable; @@ -5317,7 +5319,7 @@ DECLARE_CONSOLE_COMMAND(pd, command_pd, "\n\t<port> flash [erase|reboot|signature|info|version]" #endif /* CONFIG_CMD_PD_FLASH */ #endif /* CONFIG_USB_PD_DUAL_ROLE */ - , + "\n\t<port> srccaps", "USB PD"); #ifdef HAS_TASK_HOSTCMD diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c index e1e65e2b01..5153be387e 100644 --- a/common/usbc/usb_pd_console.c +++ b/common/usbc/usb_pd_console.c @@ -175,6 +175,8 @@ test_export_static int command_pd(int argc, char **argv) pe_get_flags(port)); else ccprintf("\n"); + } else if (!strcasecmp(argv[2], "srccaps")) { + pd_srccaps_dump(port); } if (IS_ENABLED(CONFIG_CMD_PD_TIMER) && @@ -191,6 +193,7 @@ DECLARE_CONSOLE_COMMAND(pd, command_pd, "\ntrysrc [0|1|2]" #endif "\n\t<port> state" + "\n\t<port> srccaps" #ifdef CONFIG_CMD_PD_TIMER "\n\t<port> timer" #endif /* CONFIG_CMD_PD_TIMER */ diff --git a/include/usb_common.h b/include/usb_common.h index 91418937df..57c2e1d870 100644 --- a/include/usb_common.h +++ b/include/usb_common.h @@ -254,4 +254,11 @@ int usb_retimer_fw_update_get_result(void); * @param port USB-C port number */ void usb_retimer_fw_update_process_op_cb(int port); + +/** + * Dump SourceCap information. + * + * @param port USB-C port number + */ +void pd_srccaps_dump(int port); #endif /* __CROS_EC_USB_COMMON_H */ |