diff options
author | Diana Z <dzigterman@chromium.org> | 2020-09-25 13:49:20 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-05 18:11:39 +0000 |
commit | a44234c5f3741e4849809e1b57b0b2f007549769 (patch) | |
tree | 1427a3a9ff76f00a34159975a62f473a1917a2ba | |
parent | 2a045fdf01481da310dbe3f4c46569c0fd4b31e9 (diff) | |
download | chrome-ec-a44234c5f3741e4849809e1b57b0b2f007549769.tar.gz |
TCPMv2: Notify on SOP and SOP' discovery complete
Notify the AP when the task has finished discovery. The AP
doesn't need notification if nothing was found, but does need
notification by transmit type as long as at least DiscoverIdentity was
returned.
BRANCH=None
BUG=b:148816435
TEST=on waddledoo, verify:
- events are 0 with nothing plugged in
- events show SOP complete with Apple dongle
- events show SOP and SOP' complete with TBT dock
- events show SOP complete with Moshi (DiscoverIdentity only)
- events show SOP complete with WooHub (Mode discovery will NAK)
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I5fcfc1ba2bde40c70400462dcc4efc2b7b60d0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432456
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 21 | ||||
-rw-r--r-- | include/ec_commands.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index cbad15eba0..c64d8386ae 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -4945,6 +4945,10 @@ static void pe_init_port_vdm_identity_request_run(int port) case VDM_RESULT_NAK: /* PE_INIT_PORT_VDM_IDENTITY_NAKed embedded here */ pd_set_identity_discovery(port, pe[port].tx_type, PD_DISC_FAIL); + /* + * Note: AP is only notified of discovery complete when + * something was found (at least one ACK) + */ break; } @@ -5053,6 +5057,12 @@ static void pe_init_vdm_svids_request_exit(int port) */ pd_set_svids_discovery(port, pe[port].tx_type, PD_DISC_FAIL); } + + /* If SVID discovery failed, discovery is done at this point */ + if (pd_get_svids_discovery(port, pe[port].tx_type) == PD_DISC_FAIL) + pe_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + PD_STATUS_EVENT_SOP_DISC_DONE : + PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); } /** @@ -5152,6 +5162,16 @@ static void pe_init_vdm_modes_request_run(int port) set_state_pe(port, get_last_state_pe(port)); } +static void pe_init_vdm_modes_request_exit(int port) +{ + if (pd_get_modes_discovery(port, pe[port].tx_type) != PD_DISC_NEEDED) + /* Mode discovery done, notify the AP */ + pe_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + PD_STATUS_EVENT_SOP_DISC_DONE : + PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); + +} + /** * PE_VDM_REQUEST_DPM * @@ -6420,6 +6440,7 @@ static const struct usb_state pe_states[] = { [PE_INIT_VDM_MODES_REQUEST] = { .entry = pe_init_vdm_modes_request_entry, .run = pe_init_vdm_modes_request_run, + .exit = pe_init_vdm_modes_request_exit, .parent = &pe_states[PE_VDM_SEND_REQUEST], }, [PE_VDM_REQUEST_DPM] = { diff --git a/include/ec_commands.h b/include/ec_commands.h index 226b71eab7..8286f22c0d 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -6465,6 +6465,9 @@ enum tcpc_cc_polarity { #define MODE_DP_PIN_F BIT(6) #define MODE_DP_PIN_ALL GENMASK(6, 0) +#define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0) +#define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1) + struct ec_params_typec_status { uint8_t port; } __ec_align1; |