diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-09-21 14:10:01 -0700 |
---|---|---|
committer | Tom Hughes <tomhughes@chromium.org> | 2022-09-22 12:49:33 -0700 |
commit | 2bcf863b492fe7ed8105c853814dba6ed32ba719 (patch) | |
tree | fcf6ce5810f9ff9e3c8cce434812dd75492269ed /test/usb_typec_ctvpd.c | |
parent | e5fb0b9ba488614b5684e640530f00821ab7b943 (diff) | |
parent | 28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff) | |
download | chrome-ec-firmware-fpmcu-bloonchipper-release.tar.gz |
Merge remote-tracking branch cros/main into firmware-fpmcu-bloonchipper-releasefirmware-fpmcu-bloonchipper-release
Generated by: ./util/update_release_branch.py --board bloonchipper
--relevant_paths_file ./util/fingerprint-relevant-paths.txt firmware-
fpmcu-bloonchipper-release
Relevant changes:
git log --oneline e5fb0b9ba4..28712dae9d -- board/hatch_fp
board/bloonchipper 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
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
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
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
dc3e9008b8 board/hatch_fp/board.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:246424843 b:234181908 b:244781166 b:234181908 b:244387210
BUG=b:242720240 chromium:1098010 b:180945056 b:236025198 b:234181908
BUG=b:234181908 b:237344361 b:131913998 b:236386294 b:234143158
BUG=b:234781655 b:215613183 b:242720910
TEST=`make -j buildall`
TEST=./test/run_device_tests.py --board bloonchipper
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 "stm32f_rtc": PASSED
Test "panic_data_bloonchipper_v2.0.4277": PASSED
Test "panic_data_bloonchipper_v2.0.5938": PASSED
Force-Relevant-Builds: all
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I264ad0ffe7afcd507a1e483c6e934a9c4fea47c3
Diffstat (limited to 'test/usb_typec_ctvpd.c')
-rw-r--r-- | test/usb_typec_ctvpd.c | 164 |
1 files changed, 75 insertions, 89 deletions
diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c index 583c529fca..71d543cec0 100644 --- a/test/usb_typec_ctvpd.c +++ b/test/usb_typec_ctvpd.c @@ -1,4 +1,4 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. +/* Copyright 2019 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -18,12 +18,12 @@ #include "usb_sm_checks.h" #include "vpd_api.h" -#define PORT0 0 +#define PORT0 0 -enum cc_type {CC1, CC2}; -enum vbus_type {VBUS_0 = 0, VBUS_5 = 5000}; -enum vconn_type {VCONN_0 = 0, VCONN_3 = 3000, VCONN_5 = 5000}; -enum snk_con_voltage_type {SRC_CON_DEF, SRC_CON_1_5, SRC_CON_3_0}; +enum cc_type { CC1, CC2 }; +enum vbus_type { VBUS_0 = 0, VBUS_5 = 5000 }; +enum vconn_type { VCONN_0 = 0, VCONN_3 = 3000, VCONN_5 = 5000 }; +enum snk_con_voltage_type { SRC_CON_DEF, SRC_CON_1_5, SRC_CON_3_0 }; /* * These enum definitions are declared in usb_tc_*_sm and are private to that @@ -92,15 +92,15 @@ static int ct_connect_sink(enum cc_type cc, enum snk_con_voltage_type v) switch (v) { case SRC_CON_DEF: ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_DEF_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_DEF_RD_THRESH_MV); + mock_set_cc1_rp3a0_rd_l(PD_SRC_DEF_RD_THRESH_MV); break; case SRC_CON_1_5: ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_1_5_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_1_5_RD_THRESH_MV); + mock_set_cc1_rp3a0_rd_l(PD_SRC_1_5_RD_THRESH_MV); break; case SRC_CON_3_0: ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_3_0_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_3_0_RD_THRESH_MV); + mock_set_cc1_rp3a0_rd_l(PD_SRC_3_0_RD_THRESH_MV); break; default: ret = 0; @@ -124,7 +124,7 @@ static int ct_connect_source(enum cc_type cc, enum vbus_type vbus) { mock_set_ct_vbus(vbus); return (cc) ? mock_set_cc2_rpusb_odh(PD_SNK_VA_MV) : - mock_set_cc1_rpusb_odh(PD_SNK_VA_MV); + mock_set_cc1_rpusb_odh(PD_SNK_VA_MV); } static int ct_disconnect_source(void) @@ -297,14 +297,15 @@ void inc_rx_id(int port) static int verify_goodcrc(int port, int role, int id) { return pd_test_tx_msg_verify_sop_prime(port) && - pd_test_tx_msg_verify_short(port, PD_HEADER(PD_CTRL_GOOD_CRC, - role, role, id, 0, 0, 0)) && - pd_test_tx_msg_verify_crc(port) && - pd_test_tx_msg_verify_eop(port); + pd_test_tx_msg_verify_short(port, + PD_HEADER(PD_CTRL_GOOD_CRC, role, + role, id, 0, 0, 0)) && + pd_test_tx_msg_verify_crc(port) && + pd_test_tx_msg_verify_eop(port); } static void simulate_rx_msg(int port, uint16_t header, int cnt, - const uint32_t *data) + const uint32_t *data) { int i; @@ -330,20 +331,20 @@ static void simulate_rx_msg(int port, uint16_t header, int cnt, static void simulate_goodcrc(int port, int role, int id) { - simulate_rx_msg(port, PD_HEADER(PD_CTRL_GOOD_CRC, role, role, id, 0, - pd_port[port].rev, 0), 0, NULL); + simulate_rx_msg(port, + PD_HEADER(PD_CTRL_GOOD_CRC, role, role, id, 0, + pd_port[port].rev, 0), + 0, NULL); } static void simulate_discovery_identity(int port) { - uint16_t header = PD_HEADER(PD_DATA_VENDOR_DEF, PD_ROLE_SOURCE, - 1, pd_port[port].msg_rx_id, - 1, pd_port[port].rev, 0); - uint32_t msg = VDO(USB_SID_PD, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_INIT) | - CMD_DISCOVER_IDENT); + uint16_t header = PD_HEADER(PD_DATA_VENDOR_DEF, PD_ROLE_SOURCE, 1, + pd_port[port].msg_rx_id, 1, + pd_port[port].rev, 0); + uint32_t msg = VDO(USB_SID_PD, 1, /* Structured VDM */ + VDO_SVDM_VERS(1) | VDO_CMDT(CMDT_INIT) | + CMD_DISCOVER_IDENT); simulate_rx_msg(port, header, 1, (const uint32_t *)&msg); } @@ -538,35 +539,27 @@ static int test_vpd_host_src_detection_vconn(void) static int test_vpd_host_src_detection_message_reception(void) { int port = PORT0; - uint32_t expected_vdm_header = VDO(USB_VID_GOOGLE, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_RSP_ACK) | - CMD_DISCOVER_IDENT); - uint32_t expected_vdo_id_header = VDO_IDH( - 0, /* Not a USB Host */ + uint32_t expected_vdm_header = VDO( + USB_VID_GOOGLE, 1, /* Structured VDM */ + VDO_SVDM_VERS(1) | VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT); + uint32_t expected_vdo_id_header = + VDO_IDH(0, /* Not a USB Host */ 1, /* Capable of being enumerated as USB Device */ - IDH_PTYPE_VPD, - 0, /* Modal Operation Not Supported */ + IDH_PTYPE_VPD, 0, /* Modal Operation Not Supported */ USB_VID_GOOGLE); uint32_t expected_vdo_cert = 0; - uint32_t expected_vdo_product = VDO_PRODUCT( - CONFIG_USB_PID, - USB_BCD_DEVICE); + uint32_t expected_vdo_product = + VDO_PRODUCT(CONFIG_USB_PID, USB_BCD_DEVICE); uint32_t expected_vdo_vpd = VDO_VPD( - VPD_HW_VERSION, - VPD_FW_VERSION, - VPD_MAX_VBUS_20V, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_VBUS_IMP( - VPD_VBUS_IMPEDANCE) - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP( - VPD_GND_IMPEDANCE) - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED - : VPD_CTS_NOT_SUPPORTED); + VPD_HW_VERSION, VPD_FW_VERSION, VPD_MAX_VBUS_20V, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT : 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? + VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE) : + 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP(VPD_GND_IMPEDANCE) : + 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED : + VPD_CTS_NOT_SUPPORTED); mock_set_vconn(VCONN_0); host_disconnect_source(); @@ -608,8 +601,8 @@ static int test_vpd_host_src_detection_message_reception(void) simulate_discovery_identity(port); task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); + TEST_ASSERT( + verify_goodcrc(port, PD_ROLE_SINK, pd_port[port].msg_rx_id)); task_wake(PD_PORT_TO_TASK_ID(port)); task_wait_event(30 * MSEC); @@ -617,9 +610,10 @@ static int test_vpd_host_src_detection_message_reception(void) /* Test Discover Identity Ack */ TEST_ASSERT(pd_test_tx_msg_verify_sop_prime(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, - pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); + TEST_ASSERT(pd_test_tx_msg_verify_short( + port, + PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, + pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdm_header)); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_id_header)); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_cert)); @@ -648,7 +642,6 @@ static int test_vpd_host_src_detection_message_reception(void) TEST_EQ(get_state_tc(port), TC_UNATTACHED_SNK, "%d"); - return EC_SUCCESS; } @@ -992,35 +985,27 @@ static int test_ctvpd_behavior_case3(void) static int test_ctvpd_behavior_case4(void) { int port = PORT0; - uint32_t expected_vdm_header = VDO(USB_VID_GOOGLE, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_RSP_ACK) | - CMD_DISCOVER_IDENT); - uint32_t expected_vdo_id_header = VDO_IDH( - 0, /* Not a USB Host */ + uint32_t expected_vdm_header = VDO( + USB_VID_GOOGLE, 1, /* Structured VDM */ + VDO_SVDM_VERS(1) | VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT); + uint32_t expected_vdo_id_header = + VDO_IDH(0, /* Not a USB Host */ 1, /* Capable of being enumerated as USB Device */ - IDH_PTYPE_VPD, - 0, /* Modal Operation Not Supported */ + IDH_PTYPE_VPD, 0, /* Modal Operation Not Supported */ USB_VID_GOOGLE); uint32_t expected_vdo_cert = 0; - uint32_t expected_vdo_product = VDO_PRODUCT( - CONFIG_USB_PID, - USB_BCD_DEVICE); + uint32_t expected_vdo_product = + VDO_PRODUCT(CONFIG_USB_PID, USB_BCD_DEVICE); uint32_t expected_vdo_vpd = VDO_VPD( - VPD_HW_VERSION, - VPD_FW_VERSION, - VPD_MAX_VBUS_20V, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_VBUS_IMP( - VPD_VBUS_IMPEDANCE) - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP( - VPD_GND_IMPEDANCE) - : 0, - IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED - : VPD_CTS_NOT_SUPPORTED); + VPD_HW_VERSION, VPD_FW_VERSION, VPD_MAX_VBUS_20V, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CT_CURRENT : 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? + VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE) : + 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_GND_IMP(VPD_GND_IMPEDANCE) : + 0, + IS_ENABLED(CONFIG_USB_CTVPD) ? VPD_CTS_SUPPORTED : + VPD_CTS_NOT_SUPPORTED); init_port(port); mock_set_vconn(VCONN_0); @@ -1107,8 +1092,8 @@ static int test_ctvpd_behavior_case4(void) simulate_discovery_identity(port); task_wait_event(40 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); + TEST_ASSERT( + verify_goodcrc(port, PD_ROLE_SINK, pd_port[port].msg_rx_id)); task_wake(PD_PORT_TO_TASK_ID(port)); task_wait_event(40 * MSEC); @@ -1116,9 +1101,10 @@ static int test_ctvpd_behavior_case4(void) /* Test Discover Identity Ack */ TEST_ASSERT(pd_test_tx_msg_verify_sop_prime(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, - pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); + TEST_ASSERT(pd_test_tx_msg_verify_short( + port, + PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, + pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdm_header)); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_id_header)); TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_cert)); @@ -1268,8 +1254,8 @@ static int test_ctvpd_behavior_case5(void) * e. CTVPD connects VBUS from the Charge-Through side to the Host * side */ - wait_for_state_change(port, PD_T_TRY_CC_DEBOUNCE + - PD_T_DRP_TRY + 40 * MSEC); + wait_for_state_change(port, + PD_T_TRY_CC_DEBOUNCE + PD_T_DRP_TRY + 40 * MSEC); TEST_ASSERT(get_state_tc(port) == TC_TRY_WAIT_SRC); TEST_ASSERT(check_host_rpusb()); @@ -1502,7 +1488,7 @@ static int test_ctvpd_behavior_case6(void) } #endif -void run_test(int argc, char **argv) +void run_test(int argc, const char **argv) { test_reset(); |