summaryrefslogtreecommitdiff
path: root/common/usb_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/usb_common.c')
-rw-r--r--common/usb_common.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index fcd6862264..a0764b45e0 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -29,6 +29,7 @@
#include "usb_pd_dpm.h"
#include "usb_pd_flags.h"
#include "usb_pd_tcpm.h"
+#include "usb_pe_sm.h"
#include "usbc_ocp.h"
#include "usbc_ppc.h"
#include "util.h"
@@ -1059,24 +1060,35 @@ void pd_srccaps_dump(int port)
}
}
-int pd_build_alert_msg(uint32_t *msg, uint32_t *len, enum pd_power_role pr)
+int pd_broadcast_alert_msg(uint32_t ado)
{
- if (msg == NULL || len == NULL)
- return EC_ERROR_INVAL;
+#if defined(CONFIG_USB_PD_TCPMV2) && defined(CONFIG_USB_PE_SM) && \
+ !defined(CONFIG_USB_VPD) && !defined(CONFIG_USB_CTVPD)
+ int ret = EC_SUCCESS;
- /*
- * SOURCE: currently only supports OCP
- * SINK: currently only supports OVP
- */
- if (pr == PD_ROLE_SOURCE)
- *msg = ADO_OCP_EVENT;
- else
- *msg = ADO_OVP_EVENT;
+ for (int i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (pd_send_alert_msg(i, ado) != EC_SUCCESS)
+ ret = EC_ERROR_BUSY;
+ }
+
+ return ret;
+#else
+ return EC_ERROR_INVALID_CONFIG;
+#endif
+}
- /* Alert data is 4 bytes */
- *len = 4;
+int pd_send_alert_msg(int port, uint32_t ado)
+{
+#if defined(CONFIG_USB_PD_TCPMV2) && defined(CONFIG_USB_PE_SM) && \
+ !defined(CONFIG_USB_VPD) && !defined(CONFIG_USB_CTVPD)
+ if (pe_set_ado(port, ado) != EC_SUCCESS)
+ return EC_ERROR_BUSY;
+ pd_dpm_request(port, DPM_REQUEST_SEND_ALERT);
return EC_SUCCESS;
+#else
+ return EC_ERROR_INVALID_CONFIG;
+#endif
}
#if defined(HAS_TASK_HOSTCMD) && !defined(TEST_BUILD)