diff options
Diffstat (limited to 'common/usb_common.c')
-rw-r--r-- | common/usb_common.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/usb_common.c b/common/usb_common.c index 9c1c980a8c..7b7f392e32 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -792,3 +792,23 @@ static int command_tcpc_dump(int argc, char **argv) DECLARE_CONSOLE_COMMAND(tcpci_dump, command_tcpc_dump, "<Type-C port>", "dump the TCPC regs"); #endif /* defined(CONFIG_CMD_TCPC_DUMP) */ + +int pd_build_alert_msg(uint32_t *msg, uint32_t *len, enum pd_power_role pr) +{ + if (msg == NULL || len == NULL) + return EC_ERROR_INVAL; + + /* + * SOURCE: currently only supports OCP + * SINK: currently only supports OVP + */ + if (pr == PD_ROLE_SOURCE) + *msg = ADO_OCP_EVENT; + else + *msg = ADO_OVP_EVENT; + + /* Alert data is 4 bytes */ + *len = 4; + + return EC_SUCCESS; +} |