diff options
author | Ayushee <ayushee.shah@intel.com> | 2020-07-01 14:37:12 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-06 21:07:18 +0000 |
commit | 90b879c1817b7ef92bf7b7c1930aebf63dcc6bfe (patch) | |
tree | e185ea7f0fd39780af1d6f4a52c9b3e4b9bbf4f1 | |
parent | 1da311fab28081b89afa34f725aa800ca970ace1 (diff) | |
download | chrome-ec-90b879c1817b7ef92bf7b7c1930aebf63dcc6bfe.tar.gz |
usb_pd: Move 'is_vdo_present()' and 'is_usb4_vdo()' to TCPMv1
BUG=b:156749387
BRANCH=None
TEST=make buildall -j
Signed-off-by: Ayushee <ayushee.shah@intel.com>
Change-Id: I8ecffd3084de472ec3d145c3ff69df1ca2d89a56
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278562
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | common/usb_pd_alt_mode_dfp.c | 22 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 22 | ||||
-rw-r--r-- | include/usb_pd.h | 21 |
3 files changed, 22 insertions, 43 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index df07441103..be053a49e9 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -672,11 +672,6 @@ void usb_mux_set_safe_mode(int port) ppc_set_sbu(port, 0); } -bool is_vdo_present(int cnt, int index) -{ - return cnt > index; -} - static inline bool is_rev3_vdo(int port, enum tcpm_transmit_type type) { return pd_get_vdo_ver(port, type) == PD_REV30; @@ -907,23 +902,6 @@ __overridable enum tbt_compat_cable_speed board_get_max_tbt_speed(int port) * ############################################################################ */ -bool is_usb4_vdo(int port, int cnt, uint32_t *payload) -{ - enum idh_ptype ptype = PD_IDH_PTYPE(payload[VDO_I(IDH)]); - - if (IS_PD_IDH_UFP_PTYPE(ptype)) { - /* - * Ref: USB Type-C Cable and Connector Specification - * Figure 5-1 USB4 Discovery and Entry Flow Model - * Device USB4 VDO detection. - */ - return IS_ENABLED(CONFIG_USB_PD_USB4) && - is_vdo_present(cnt, VDO_INDEX_PTYPE_UFP1_VDO) && - PD_PRODUCT_IS_USB4(payload[VDO_INDEX_PTYPE_UFP1_VDO]); - } - return false; -} - /* * For Cable rev 3.0: USB4 cable speed is set according to speed supported by * the port and the response received from the cable, whichever is least. diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 53b460cd97..47c035e37a 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -191,6 +191,11 @@ static struct pd_discovery static struct partner_active_modes partner_amodes[CONFIG_USB_PD_PORT_MAX_COUNT][AMODE_TYPE_COUNT]; +static bool is_vdo_present(int cnt, int index) +{ + return cnt > index; +} + static bool is_modal(int port, int cnt, const uint32_t *payload) { return is_vdo_present(cnt, VDO_INDEX_IDH) && @@ -384,6 +389,23 @@ void pd_set_dfp_enter_mode_flag(int port, bool set) { } +static bool is_usb4_vdo(int port, int cnt, uint32_t *payload) +{ + enum idh_ptype ptype = PD_IDH_PTYPE(payload[VDO_I(IDH)]); + + if (IS_PD_IDH_UFP_PTYPE(ptype)) { + /* + * Ref: USB Type-C Cable and Connector Specification + * Figure 5-1 USB4 Discovery and Entry Flow Model + * Device USB4 VDO detection. + */ + return IS_ENABLED(CONFIG_USB_PD_USB4) && + is_vdo_present(cnt, VDO_INDEX_PTYPE_UFP1_VDO) && + PD_PRODUCT_IS_USB4(payload[VDO_INDEX_PTYPE_UFP1_VDO]); + } + return false; +} + static int process_am_discover_ident_sop(int port, int cnt, uint32_t head, uint32_t *payload, enum tcpm_transmit_type *rtype) diff --git a/include/usb_pd.h b/include/usb_pd.h index cd1ac4eacf..4c968699c0 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -1966,17 +1966,6 @@ void pd_set_dfp_enter_mode_flag(int port, bool set); void reset_pd_cable(int port); /** - * Returns true if the number of data objects in the payload is greater than - * than the VDO index - * - * @param cnt number of data objects in payload - * @param index VDO Index - * @return True if number of data objects is greater than VDO index, - * false otherwise - */ -bool is_vdo_present(int cnt, int index); - -/** * Return the type of cable attached * * @param port USB-C port number @@ -2010,16 +1999,6 @@ enum idh_ptype get_usb_pd_cable_type(int port); enum usb_rev30_ss get_usb4_cable_speed(int port); /** - * Check if attached device has USB4 VDO - * - * @param port USB-C port number - * @param cnt number of data objects in payload - * @param payload payload data - * @return True if device has USB4 VDO - */ -bool is_usb4_vdo(int port, int cnt, uint32_t *payload); - -/** * Return enter USB message payload * * @param port USB-C port number |