diff options
-rw-r--r-- | common/usbc/usb_pd_dpm.c | 23 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 22 | ||||
-rw-r--r-- | include/usb_pd_dpm.h | 14 | ||||
-rw-r--r-- | test/fake_usbc.c | 6 |
4 files changed, 22 insertions, 43 deletions
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index e2f2c4d356..b84b5b075f 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -93,14 +93,16 @@ void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid, } } -void dpm_attempt_mode_entry(int port) +/* + * The call to this function requests that the PE send one VDM, whichever is + * next in the mode entry sequence. This only happens if preconditions for mode + * entry are met. + */ +static void dpm_attempt_mode_entry(int port) { int vdo_count = 0; uint32_t vdm[VDO_MAX_SIZE]; - if (dpm[port].mode_entry_done) - return; - if (pd_get_data_role(port) != PD_ROLE_DFP) return; /* @@ -172,15 +174,12 @@ void dpm_attempt_mode_entry(int port) pe_dpm_request(port, DPM_REQUEST_VDM); } -void dpm_attempt_mode_exit(int port) +static void dpm_attempt_mode_exit(int port) { int opos; uint16_t svid; uint32_t vdm; - if (!dpm[port].mode_exit_request) - return; - /* TODO: Add exit mode support for SOP' and SOP'' */ if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && @@ -214,3 +213,11 @@ void dpm_attempt_mode_exit(int port) pe_dpm_request(port, DPM_REQUEST_VDM); } } + +void dpm_run(int port) +{ + if (dpm[port].mode_exit_request) + dpm_attempt_mode_exit(port); + else if (!dpm[port].mode_entry_done) + dpm_attempt_mode_entry(port); +} diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index beffd61d60..5a76b00a7a 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -2084,16 +2084,8 @@ static void pe_src_ready_run(int port) return; } - /* - * TODO b/155890173: Combine the entry and exit mode requests - * so that there is only a single entry point into DPM. - */ - - /* No DPM requests; attempt mode exit if needed */ - dpm_attempt_mode_exit(port); - - /* No DPM requests; attempt mode entry if needed */ - dpm_attempt_mode_entry(port); + /* No DPM requests; attempt mode entry/exit if needed */ + dpm_run(port); } } @@ -2834,15 +2826,9 @@ static void pe_snk_ready_run(int port) return; } - /* - * TODO b/155890173: Combine the entry and exit mode requests - * so that there is only a single entry point into DPM. - */ - /* No DPM requests; attempt mode exit if needed */ - dpm_attempt_mode_exit(port); + /* No DPM requests; attempt mode entry/exit if needed */ + dpm_run(port); - /* No DPM requests; attempt mode entry if needed */ - dpm_attempt_mode_entry(port); } } diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h index d431256e18..2948fd3fbd 100644 --- a/include/usb_pd_dpm.h +++ b/include/usb_pd_dpm.h @@ -57,20 +57,10 @@ void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid, uint8_t vdm_cmd); /* - * Drives the Policy Engine through the mode entry/configuration process. Each - * call to this function requests that the PE send one VDM, whichever is next in - * the mode entry sequence. This only happens if preconditions for mode entry - * are met. + * Drives the Policy Engine through entry/exit mode process * * @param port USB-C port number */ -void dpm_attempt_mode_entry(int port); - -/* - * Drives the Policy Engine through exit mode process for each active mode - * - * @param port USB-C port number - */ -void dpm_attempt_mode_exit(int port); +void dpm_run(int port); #endif /* __CROS_EC_USB_DPM_H */ diff --git a/test/fake_usbc.c b/test/fake_usbc.c index 37d1c0bf09..0f92379b38 100644 --- a/test/fake_usbc.c +++ b/test/fake_usbc.c @@ -270,11 +270,7 @@ void dpm_set_mode_exit_request(int port) { } -void dpm_attempt_mode_entry(int port) -{ -} - -void dpm_attempt_mode_exit(int port) +void dpm_run(int port) { } |