diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-09-21 14:08:36 -0700 |
---|---|---|
committer | Tom Hughes <tomhughes@chromium.org> | 2022-09-22 12:59:38 -0700 |
commit | c453fd704268ef72de871b0c5ac7a989de662334 (patch) | |
tree | fcf6ce5810f9ff9e3c8cce434812dd75492269ed /common/usb_pd_policy.c | |
parent | 6c1587ca70f558b4f96b3f0b18ad8b027d3ba99d (diff) | |
parent | 28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff) | |
download | chrome-ec-c453fd704268ef72de871b0c5ac7a989de662334.tar.gz |
Merge remote-tracking branch cros/main into firmware-fpmcu-dartmonkey-releasefirmware-fpmcu-dartmonkey-release
Generated by: ./util/update_release_branch.py --board dartmonkey --relevant_paths_file
./util/fingerprint-relevant-paths.txt firmware-fpmcu-dartmonkey-release
Relevant changes:
git log --oneline 6c1587ca70..28712dae9d -- board/nocturne_fp
board/dartmonkey common/fpsensor docs/fingerprint driver/fingerprint
util/getversion.sh
ded9307b79 util/getversion.sh: Fix version when not in a git repo
956055e692 board: change Google USB vendor info
71b2ef709d Update license boilerplate text in source code files
33e11afda0 Revert "fpsensor: Build fpsensor source file with C++"
c8d0360723 fpsensor: Build fpsensor source file with C++
bc113abd53 fpsensor: Fix g++ compiler error
150a58a0dc fpsensor: Fix fp_set_sensor_mode return type
b33b5ce85b fpsensor: Remove nested designators for C++ compatibility
2e864b2539 tree-wide: const-ify argv for console commands
56d8b360f9 test: Add test for get ikm failure when seed not set
3a3d6c3690 test: Add test for fpsensor trivial key failure
233e6bbd08 fpsensor_crypto: Abstract calls to hmac_SHA256
0a041b285b docs/fingerprint: Typo correction
c03fab67e2 docs/fingerprint: Fix the path of fputils.py
0b5d4baf5a util/getversion.sh: Fix empty file list handling
6e128fe760 FPMCU dev board environment with Satlab
3eb29b6aa5 builtin: Move ssize_t to sys/types.h
345d62ebd1 docs/fingerprint: Update power numbers for latest dartmonkey release
c25ffdb316 common: Conditionally support printf %l and %i modifiers
9a3c514b45 test: Add a test to check if the debugger is connected
54e603413f Move standard library tests to their own file
43fa6b4bf8 docs/fingerprint: Update power numbers for latest bloonchipper release
25536f9a84 driver/fingerprint/fpc/bep/fpc_sensor_spi.c: Format with clang-format
4face99efd driver/fingerprint/fpc/libfp/fpc_sensor_pal.h: Format with clang-format
738de2b575 trng: Rename rand to trng_rand
14b8270edd docs/fingerprint: Update dragonclaw power numbers
0b268f93d1 driver/fingerprint/fpc/libfp/fpc_private.c: Format with clang-format
f80da163f2 driver/fingerprint/fpc/libfp/fpc_private.h: Format with clang-format
a0751778f4 board/nocturne_fp/ro_workarounds.c: Format with clang-format
5e9c85c9b1 driver/fingerprint/fpc/libfp/fpc_sensor_pal.c: Format with clang-format
c1f9dd3cf8 driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h: Format with clang-format
eb1e1bed8d driver/fingerprint/fpc/libfp/fpc1145_private.h: Format with clang-format
6e7b611821 driver/fingerprint/fpc/bep/fpc_bio_algorithm.h: Format with clang-format
e0589cd5e2 driver/fingerprint/fpc/bep/fpc1035_private.h: Format with clang-format
58f0246dbe board/nocturne_fp/board_ro.c: Format with clang-format
7905e556a0 common/fpsensor/fpsensor_crypto.c: Format with clang-format
21289d170c driver/fingerprint/fpc/bep/fpc1025_private.h: Format with clang-format
98a20f937e common/fpsensor/fpsensor_state.c: Format with clang-format
a2d255d8af common/fpsensor/fpsensor.c: Format with clang-format
84e53a65da board/nocturne_fp/board.h: Format with clang-format
73055eeb3f driver/fingerprint/fpc/bep/fpc_private.c: Format with clang-format
0f7b5cb509 common/fpsensor/fpsensor_private.h: Format with clang-format
1ceade6e65 driver/fingerprint/fpc/bep/fpc_private.h: Format with clang-format
dca9d74321 Revert "trng: Rename rand to trng_rand"
a6b0b3554f trng: Rename rand to trng_rand
28d0b75b70 third_party/boringssl: Remove unused header
BRANCH=None
BUG=b:244387210 b:242720240 b:215613183 b:242720910 b:236386294
BUG=b:234181908 b:244781166 b:234781655 b:234143158 b:234181908
BUG=b:237344361 b:236025198 b:234181908 b:180945056 chromium:1098010
BUG=b:246424843 b:234181908 b:131913998
TEST=`make -j buildall`
TEST=./util/run_device_tests.py --board dartmonkey
Test "aes": PASSED
Test "cec": PASSED
Test "cortexm_fpu": PASSED
Test "crc": PASSED
Test "flash_physical": PASSED
Test "flash_write_protect": PASSED
Test "fpsensor_hw": PASSED
Test "fpsensor_spi_ro": PASSED
Test "fpsensor_spi_rw": PASSED
Test "fpsensor_uart_ro": PASSED
Test "fpsensor_uart_rw": PASSED
Test "mpu_ro": PASSED
Test "mpu_rw": PASSED
Test "mutex": PASSED
Test "pingpong": PASSED
Test "printf": PASSED
Test "queue": PASSED
Test "rollback_region0": PASSED
Test "rollback_region1": PASSED
Test "rollback_entropy": PASSED
Test "rtc": PASSED
Test "sha256": PASSED
Test "sha256_unrolled": PASSED
Test "static_if": PASSED
Test "stdlib": PASSED
Test "system_is_locked_wp_on": PASSED
Test "system_is_locked_wp_off": PASSED
Test "timer_dos": PASSED
Test "utils": PASSED
Test "utils_str": PASSED
Test "panic_data_dartmonkey_v2.0.2887": PASSED
Test "panic_data_nocturne_fp_v2.2.64": PASSED
Test "panic_data_nami_fp_v2.2.144": PASSED
Force-Relevant-Builds: all
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I2c312583a709fedae8fe11d92c22328c3b634bc7
Diffstat (limited to 'common/usb_pd_policy.c')
-rw-r--r-- | common/usb_pd_policy.c | 512 |
1 files changed, 17 insertions, 495 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 30aa936f28..c63cde6301 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -1,9 +1,10 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. +/* Copyright 2014 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "atomic.h" +#include "builtin/assert.h" #include "charge_manager.h" #include "common.h" #include "console.h" @@ -77,20 +78,11 @@ __overridable void pd_check_dr_role(int port, enum pd_data_role dr_role, pd_request_data_swap(port); } -#ifdef CONFIG_MKBP_EVENT -static int dp_alt_mode_entry_get_next_event(uint8_t *data) -{ - return EC_SUCCESS; -} -DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_DP_ALT_MODE_ENTERED, - dp_alt_mode_entry_get_next_event); -#endif /* CONFIG_MKBP_EVENT */ - /* Last received source cap */ static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_MAX_COUNT][PDO_MAX_OBJECTS]; static uint8_t pd_src_cap_cnt[CONFIG_USB_PD_PORT_MAX_COUNT]; -const uint32_t * const pd_get_src_caps(int port) +const uint32_t *const pd_get_src_caps(int port) { return pd_src_caps[port]; } @@ -110,76 +102,6 @@ uint8_t pd_get_src_cap_cnt(int port) return pd_src_cap_cnt[port]; } -static struct pd_cable cable[CONFIG_USB_PD_PORT_MAX_COUNT]; - -enum pd_rev_type get_usb_pd_cable_revision(int port) -{ - return cable[port].rev; -} - -bool consume_sop_prime_repeat_msg(int port, uint8_t msg_id) -{ - if (cable[port].last_sop_p_msg_id != msg_id) { - cable[port].last_sop_p_msg_id = msg_id; - return false; - } - CPRINTF("C%d SOP Prime repeat msg_id %d\n", port, msg_id); - return true; -} - -bool consume_sop_prime_prime_repeat_msg(int port, uint8_t msg_id) -{ - if (cable[port].last_sop_p_p_msg_id != msg_id) { - cable[port].last_sop_p_p_msg_id = msg_id; - return false; - } - CPRINTF("C%d SOP Prime Prime repeat msg_id %d\n", port, msg_id); - return true; -} - -__maybe_unused static uint8_t is_sop_prime_ready(int port) -{ - /* - * Ref: USB PD 3.0 sec 2.5.4: When an Explicit Contract is in place the - * VCONN Source (either the DFP or the UFP) can communicate with the - * Cable Plug(s) using SOP’/SOP’’ Packets - * - * Ref: USB PD 2.0 sec 2.4.4: When an Explicit Contract is in place the - * DFP (either the Source or the Sink) can communicate with the - * Cable Plug(s) using SOP’/SOP” Packets. - * Sec 3.6.11 : Before communicating with a Cable Plug a Port Should - * ensure that it is the Vconn Source - */ - return (pd_get_vconn_state(port) && - (IS_ENABLED(CONFIG_USB_PD_REV30) || - (pd_get_data_role(port) == PD_ROLE_DFP))); -} - -void reset_pd_cable(int port) -{ - memset(&cable[port], 0, sizeof(cable[port])); - cable[port].last_sop_p_msg_id = INVALID_MSG_ID_COUNTER; - cable[port].last_sop_p_p_msg_id = INVALID_MSG_ID_COUNTER; -} - -bool should_enter_usb4_mode(int port) -{ - return IS_ENABLED(CONFIG_USB_PD_USB4) && - cable[port].flags & CABLE_FLAGS_ENTER_USB_MODE; -} - -void enable_enter_usb4_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_USB4)) - cable[port].flags |= CABLE_FLAGS_ENTER_USB_MODE; -} - -void disable_enter_usb4_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_USB4)) - cable[port].flags &= ~CABLE_FLAGS_ENTER_USB_MODE; -} - #ifdef CONFIG_USB_PD_ALT_MODE #ifdef CONFIG_USB_PD_ALT_MODE_DFP @@ -189,168 +111,6 @@ static struct pd_discovery discovery[CONFIG_USB_PD_PORT_MAX_COUNT] 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) && - PD_IDH_IS_MODAL(payload[VDO_INDEX_IDH]); -} - -static bool is_tbt_compat_mode(int port, int cnt, const uint32_t *payload) -{ - /* - * Ref: USB Type-C cable and connector specification - * F.2.5 TBT3 Device Discover Mode Responses - */ - return is_vdo_present(cnt, VDO_INDEX_IDH) && - PD_VDO_RESP_MODE_INTEL_TBT(payload[VDO_INDEX_IDH]); -} - -static bool cable_supports_tbt_speed(int port) -{ - enum tbt_compat_cable_speed tbt_cable_speed = get_tbt_cable_speed(port); - - return (tbt_cable_speed == TBT_SS_TBT_GEN3 || - tbt_cable_speed == TBT_SS_U32_GEN1_GEN2); -} - -static bool is_tbt_compat_enabled(int port) -{ - return (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && - (cable[port].flags & CABLE_FLAGS_TBT_COMPAT_ENABLE)); -} - -static void enable_tbt_compat_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE)) - cable[port].flags |= CABLE_FLAGS_TBT_COMPAT_ENABLE; -} - -static inline void disable_tbt_compat_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE)) - cable[port].flags &= ~CABLE_FLAGS_TBT_COMPAT_ENABLE; -} - -static inline void limit_tbt_cable_speed(int port) -{ - /* Cable flags are cleared when cable reset is called */ - cable[port].flags |= CABLE_FLAGS_TBT_COMPAT_LIMIT_SPEED; -} - -static inline bool is_limit_tbt_cable_speed(int port) -{ - return !!(cable[port].flags & CABLE_FLAGS_TBT_COMPAT_LIMIT_SPEED); -} - -static bool is_intel_svid(int port, enum tcpci_msg_type type) -{ - int i; - - for (i = 0; i < discovery[port][type].svid_cnt; i++) { - if (pd_get_svid(port, i, type) == USB_VID_INTEL) - return true; - } - - return false; -} - -static inline bool is_usb4_mode_enabled(int port) -{ - return (IS_ENABLED(CONFIG_USB_PD_USB4) && - (cable[port].flags & CABLE_FLAGS_USB4_CAPABLE)); -} - -static inline void enable_usb4_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_USB4)) - cable[port].flags |= CABLE_FLAGS_USB4_CAPABLE; -} - -static inline void disable_usb4_mode(int port) -{ - if (IS_ENABLED(CONFIG_USB_PD_USB4)) - cable[port].flags &= ~CABLE_FLAGS_USB4_CAPABLE; -} - -/* - * Ref: USB Type-C Cable and Connector Specification - * Figure 5-1 USB4 Discovery and Entry Flow Model. - * - * Note: USB Type-C Cable and Connector Specification - * doesn't include details for Revision 2 cables. - * - * Passive Cable - * | - * ----------------------------------- - * | | - * Revision 2 Revision 3 - * USB Signalling USB Signalling - * | | - * ------------------ ------------------------- - * | | | | | | | - * USB2.0 USB3.1 USB3.1 USB3.2 USB4 USB3.2 USB2 - * | Gen1 Gen1 Gen2 Gen2 Gen3 Gen1 | - * | | | | | | Exit - * -------- ------------ -------- USB4 - * | | | Discovery. - * Exit Is DFP Gen3 Capable? Enter USB4 - * USB4 | with respective - * Discovery. --- No ---|--- Yes --- cable speed. - * | | - * Enter USB4 with Is Cable TBT3 - * respective cable | - * speed. --- No ---|--- Yes --- - * | | - * Enter USB4 with Enter USB4 with - * TBT Gen2 passive TBT Gen3 passive - * cable. cable. - * - */ -static bool is_cable_ready_to_enter_usb4(int port, int cnt) -{ - /* TODO: USB4 enter mode for Active cables */ - struct pd_discovery *disc = &discovery[port][TCPCI_MSG_SOP_PRIME]; - if (IS_ENABLED(CONFIG_USB_PD_USB4) && - (get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) && - is_vdo_present(cnt, VDO_INDEX_PTYPE_CABLE1)) { - switch (cable[port].rev) { - case PD_REV30: - switch (disc->identity.product_t1.p_rev30.ss) { - case USB_R30_SS_U40_GEN3: - case USB_R30_SS_U32_U40_GEN1: - return true; - case USB_R30_SS_U32_U40_GEN2: - /* Check if DFP is Gen 3 capable */ - if (IS_ENABLED(CONFIG_USB_PD_TBT_GEN3_CAPABLE)) - return false; - return true; - default: - disable_usb4_mode(port); - return false; - } - case PD_REV20: - switch (disc->identity.product_t1.p_rev20.ss) { - case USB_R20_SS_U31_GEN1_GEN2: - /* Check if DFP is Gen 3 capable */ - if (IS_ENABLED(CONFIG_USB_PD_TBT_GEN3_CAPABLE)) - return false; - return true; - default: - disable_usb4_mode(port); - return false; - } - default: - disable_usb4_mode(port); - } - } - return false; -} - void pd_dfp_discovery_init(int port) { memset(&discovery[port], 0, sizeof(struct pd_discovery)); @@ -361,26 +121,20 @@ void pd_dfp_mode_init(int port) memset(&partner_amodes[port], 0, sizeof(partner_amodes[0])); } -static int dfp_discover_ident(uint32_t *payload) -{ - payload[0] = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT); - return 1; -} - static int dfp_discover_svids(uint32_t *payload) { payload[0] = VDO(USB_SID_PD, 1, CMD_DISCOVER_SVID); return 1; } -struct pd_discovery *pd_get_am_discovery_and_notify_access( - int port, enum tcpci_msg_type type) +struct pd_discovery * +pd_get_am_discovery_and_notify_access(int port, enum tcpci_msg_type type) { return (struct pd_discovery *)pd_get_am_discovery(port, type); } const struct pd_discovery *pd_get_am_discovery(int port, - enum tcpci_msg_type type) + enum tcpci_msg_type type) { return &discovery[port][type]; } @@ -407,7 +161,7 @@ void pd_set_dfp_enter_mode_flag(int port, bool set) static int dfp_discover_modes(int port, uint32_t *payload) { const struct pd_discovery *disc = - pd_get_am_discovery(port, TCPCI_MSG_SOP); + pd_get_am_discovery(port, TCPCI_MSG_SOP); uint16_t svid = disc->svids[disc->svid_idx].svid; if (disc->svid_idx >= disc->svid_cnt) @@ -418,23 +172,6 @@ static int dfp_discover_modes(int port, uint32_t *payload) return 1; } -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 tcpci_msg_type *rtype) @@ -443,63 +180,6 @@ static int process_am_discover_ident_sop(int port, int cnt, uint32_t head, pd_dfp_mode_init(port); dfp_consume_identity(port, TCPCI_MSG_SOP, cnt, payload); - if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP) && is_sop_prime_ready(port) && - board_is_tbt_usb4_port(port)) { - /* Enable USB4 mode if USB4 VDO present and port partner - * supports USB Rev 3.0. - */ - if (is_usb4_vdo(port, cnt, payload) && - PD_HEADER_REV(head) == PD_REV30) - enable_usb4_mode(port); - - /* - * Enable Thunderbolt-compatible mode if the modal operation is - * supported. - */ - if (is_modal(port, cnt, payload)) - enable_tbt_compat_mode(port); - - if (is_modal(port, cnt, payload) || - is_usb4_vdo(port, cnt, payload)) { - *rtype = TCPCI_MSG_SOP_PRIME; - return dfp_discover_ident(payload); - } - } - - return dfp_discover_svids(payload); -} - -static int process_am_discover_ident_sop_prime(int port, int cnt, uint32_t head, - uint32_t *payload) -{ - dfp_consume_identity(port, TCPCI_MSG_SOP_PRIME, cnt, payload); - cable[port].rev = PD_HEADER_REV(head); - - /* - * Enter USB4 mode if the cable supports USB4 operation and has USB4 - * VDO. - */ - if (is_usb4_mode_enabled(port) && - is_cable_ready_to_enter_usb4(port, cnt)) { - enable_enter_usb4_mode(port); - usb_mux_set_safe_mode(port); - /* - * To change the mode of operation from USB4 the port needs to - * be reconfigured. - * Ref: USB Type-C Cable and Connectot Spec section 5.4.4. - */ - disable_tbt_compat_mode(port); - return 0; - } - - /* - * Disable Thunderbolt-compatible mode if the cable does not support - * superspeed. - */ - if (is_tbt_compat_enabled(port) && - get_tbt_cable_speed(port) < TBT_SS_U31_GEN1) - disable_tbt_compat_mode(port); - return dfp_discover_svids(payload); } @@ -514,133 +194,8 @@ static int process_am_discover_svids(int port, int cnt, uint32_t *payload, */ dfp_consume_svids(port, sop, cnt, payload); - /* - * Ref: USB Type-C Cable and Connector Specification, - * figure F-1: TBT3 Discovery Flow - * - * For USB4 mode if device or cable doesn't have Intel SVID, - * disable Thunderbolt-Compatible mode directly enter USB4 mode - * with USB3.2 Gen1/Gen2 speed. - * - * For Thunderbolt-compatible, check if 0x8087 is received for - * Discover SVID SOP. If not, disable Thunderbolt-compatible mode - * - * If 0x8087 is not received for Discover SVID SOP' limit to TBT - * passive Gen 2 cable. - */ - if (is_tbt_compat_enabled(port)) { - bool intel_svid = is_intel_svid(port, sop); - if (!intel_svid) { - if (is_usb4_mode_enabled(port)) { - disable_tbt_compat_mode(port); - cable[port].cable_mode_resp.tbt_cable_speed = - TBT_SS_U32_GEN1_GEN2; - enable_enter_usb4_mode(port); - usb_mux_set_safe_mode(port); - return 0; - } - - if (sop == TCPCI_MSG_SOP_PRIME) - limit_tbt_cable_speed(port); - else - disable_tbt_compat_mode(port); - } else if (sop == TCPCI_MSG_SOP) { - *rtype = TCPCI_MSG_SOP_PRIME; - return dfp_discover_svids(payload); - } - } - return dfp_discover_modes(port, payload); } - -static int process_tbt_compat_discover_modes(int port, - enum tcpci_msg_type sop, - uint32_t *payload, - enum tcpci_msg_type *rtype) -{ - int rsize; - - /* Initialize transmit type to SOP */ - *rtype = TCPCI_MSG_SOP; - - /* - * For active cables, Enter mode: SOP', SOP'', SOP - * Ref: USB Type-C Cable and Connector Specification, figure F-1: TBT3 - * Discovery Flow and Section F.2.7 TBT3 Cable Enter Mode Command. - */ - if (sop == TCPCI_MSG_SOP_PRIME) { - /* Store Discover Mode SOP' response */ - cable[port].cable_mode_resp.raw_value = payload[1]; - - if (is_usb4_mode_enabled(port)) { - /* - * If Cable is not Thunderbolt Gen 3 - * capable or Thunderbolt Gen1_Gen2 - * capable, disable USB4 mode and - * continue flow for - * Thunderbolt-compatible mode - */ - if (cable_supports_tbt_speed(port)) { - enable_enter_usb4_mode(port); - usb_mux_set_safe_mode(port); - return 0; - } - disable_usb4_mode(port); - } - - /* - * Send TBT3 Cable Enter Mode (SOP') for active cables, - * otherwise send TBT3 Device Enter Mode (SOP). - */ - if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) - *rtype = TCPCI_MSG_SOP_PRIME; - - rsize = enter_tbt_compat_mode(port, *rtype, payload); - } else { - /* Store Discover Mode SOP response */ - cable[port].dev_mode_resp.raw_value = payload[1]; - - if (is_limit_tbt_cable_speed(port)) { - /* - * Passive cable has Nacked for Discover SVID. - * No need to do Discover modes of cable. - * Enter into device Thunderbolt-compatible mode. - */ - rsize = enter_tbt_compat_mode(port, *rtype, payload); - } else { - /* Discover modes for SOP' */ - discovery[port][TCPCI_MSG_SOP].svid_idx--; - rsize = dfp_discover_modes(port, payload); - *rtype = TCPCI_MSG_SOP_PRIME; - } - } - - return rsize; -} - -static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpci_msg_type sop, - uint32_t *payload, - enum tcpci_msg_type *rtype) -{ - struct pd_discovery *disc = &discovery[port][TCPCI_MSG_SOP_PRIME]; - - /* Enter mode SOP' for active cables */ - if (sop == TCPCI_MSG_SOP_PRIME) { - /* Check if the cable has a SOP'' controller */ - if (disc->identity.product_t1.a_rev20.sop_p_p) - *rtype = TCPCI_MSG_SOP_PRIME_PRIME; - return enter_tbt_compat_mode(port, *rtype, payload); - } - - /* Enter Mode SOP'' for active cables with SOP'' controller */ - if (sop == TCPCI_MSG_SOP_PRIME_PRIME) - return enter_tbt_compat_mode(port, *rtype, payload); - - /* Update Mux state to Thunderbolt-compatible mode. */ - set_tbt_compat_mode_ready(port); - /* No response once device (and cable) acks */ - return 0; -} #endif /* CONFIG_USB_PD_ALT_MODE_DFP */ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, @@ -725,15 +280,9 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, switch (cmd) { #ifdef CONFIG_USB_PD_ALT_MODE_DFP case CMD_DISCOVER_IDENT: - /* Received a SOP' Discover Ident msg */ - if (sop == TCPCI_MSG_SOP_PRIME) { - rsize = process_am_discover_ident_sop_prime( - port, cnt, head, payload); - /* Received a SOP Discover Ident Message */ - } else { - rsize = process_am_discover_ident_sop( - port, cnt, head, payload, rtype); - } + /* Received a SOP Discover Ident Message */ + rsize = process_am_discover_ident_sop(port, cnt, head, + payload, rtype); break; case CMD_DISCOVER_SVID: rsize = process_am_discover_svids(port, cnt, payload, @@ -741,22 +290,10 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, break; case CMD_DISCOVER_MODES: dfp_consume_modes(port, sop, cnt, payload); - if (is_tbt_compat_enabled(port) && - is_tbt_compat_mode(port, cnt, payload)) { - rsize = process_tbt_compat_discover_modes( - port, sop, payload, rtype); - break; - } rsize = dfp_discover_modes(port, payload); /* enter the default mode for DFP */ if (!rsize) { - /* - * Disabling Thunderbolt-Compatible mode if - * discover mode response doesn't include Intel - * SVID. - */ - disable_tbt_compat_mode(port); payload[0] = pd_dfp_enter_mode( port, TCPCI_MSG_SOP, 0, 0); if (payload[0]) @@ -764,19 +301,12 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, } break; case CMD_ENTER_MODE: - if (is_tbt_compat_enabled(port)) { - rsize = obj_cnt_enter_tbt_compat_mode( - port, sop, payload, rtype); - /* - * Continue with PD flow if - * Thunderbolt-compatible mode is disabled. - */ - } else if (!modep) { + if (!modep) { rsize = 0; } else { if (!modep->opos) pd_dfp_enter_mode(port, TCPCI_MSG_SOP, - 0, 0); + 0, 0); if (modep->opos) { rsize = modep->fx->status(port, @@ -805,7 +335,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, * config ack). */ if (svdm_dp_get_mux_mode(port) == - USB_PD_MUX_DP_ENABLED) + USB_PD_MUX_DP_ENABLED) usb_mux_set_safe_mode(port); rsize = modep->fx->config(port, payload); } else { @@ -856,15 +386,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, rsize = 0; } } else if (cmd_type == CMDT_RSP_NAK) { - /* Passive cable Nacked for Discover SVID */ - if (cmd == CMD_DISCOVER_SVID && is_tbt_compat_enabled(port) && - sop == TCPCI_MSG_SOP_PRIME && - get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) { - limit_tbt_cable_speed(port); - rsize = dfp_discover_modes(port, payload); - } else { - rsize = 0; - } + rsize = 0; #endif /* CONFIG_USB_PD_ALT_MODE_DFP */ } else { CPRINTF("ERR:CMDT:%d\n", cmd); @@ -952,7 +474,7 @@ int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload) flash_offset = CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF; crec_flash_physical_erase(CONFIG_EC_WRITABLE_STORAGE_OFF + - CONFIG_RW_STORAGE_OFF, + CONFIG_RW_STORAGE_OFF, CONFIG_RW_SIZE); rw_flash_changed = 1; break; @@ -963,7 +485,7 @@ int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload) CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF)) break; crec_flash_physical_write(flash_offset, 4 * (cnt - 1), - (const char *)(payload + 1)); + (const char *)(payload + 1)); flash_offset += 4 * (cnt - 1); rw_flash_changed = 1; break; @@ -976,7 +498,7 @@ int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload) for (offset = FW_RW_END - RSANUMBYTES; offset < FW_RW_END; offset += 4) crec_flash_physical_write(offset, 4, - (const char *)&zero); + (const char *)&zero); } break; default: |