diff options
-rw-r--r-- | common/usb_common.c | 17 | ||||
-rw-r--r-- | include/usb_pd.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/common/usb_common.c b/common/usb_common.c index 022580af0d..372d55d2a0 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -1025,6 +1025,23 @@ 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) + struct rmdo partner_rmdo; + + /* + * The Alert Data Object (ADO) definition changed between USB PD + * Revision 3.0 and 3.1. Clear reserved bits from the USB PD 3.0 + * ADO before sending to a USB PD 3.0 partner and block the + * message if the ADO is empty. + */ + partner_rmdo = pe_get_partner_rmdo(port); + if (partner_rmdo.major_rev == 0) { + ado &= ~(ADO_EXTENDED_ALERT_EVENT | + ADO_EXTENDED_ALERT_EVENT_TYPE); + } + + if (!ado) + return EC_ERROR_INVAL; + if (pe_set_ado(port, ado) != EC_SUCCESS) return EC_ERROR_BUSY; diff --git a/include/usb_pd.h b/include/usb_pd.h index aaf365d389..4304c60c7a 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -1283,6 +1283,7 @@ enum pd_ext_msg_type { /* Alert Data Object fields for REV 3.1 */ #define ADO_EXTENDED_ALERT_EVENT (BIT(24) << 7) +#define ADO_EXTENDED_ALERT_EVENT_TYPE 0xf /* Alert Data Object fields for REV 3.0 */ #define ADO_OVP_EVENT (BIT(24) << 6) #define ADO_SOURCE_INPUT_CHANGE (BIT(24) << 5) |