diff options
author | Jett Rink <jettrink@chromium.org> | 2020-03-31 13:44:28 -0600 |
---|---|---|
committer | Jett Rink <jettrink@chromium.org> | 2020-04-03 17:06:28 +0000 |
commit | 736db12af829d826f0a1247b6a787fcc56d2b060 (patch) | |
tree | 044e90f6837e797f9f495cf005bfb1a4b35d1df7 | |
parent | a08de50a749ab4ec09ad2b7b32b1605f49d8a5c6 (diff) | |
download | chrome-ec-736db12af829d826f0a1247b6a787fcc56d2b060.tar.gz |
tcpmv2: move function from TC layer to PE
- Move pd_ function that belong in PE layer to PE layer. Remove the extra
pe_ layer.
- Remove unnecessary PE and Vconn ifdef guards in TC layer
- Remove unused print_dev_info function
- Move host commands in TC layer to host command file
- Move RW hash stuff from TC to PE, since this only has to do with VDO
(Which is a PE layer thing)
- Removed dependency for tc_drp test on usbc_fake as we don't really
need it anymore once we don't pull in the PRL and PE layers anymore
(based on previously landed CLs)
BRANCH=none
BUG=b:153071799
TEST=everything still builds and passes tests
Change-Id: Id1d1efa291c3525f57bc26af9fddda6ddace1b58
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2132871
-rw-r--r-- | common/usb_common.c | 3 | ||||
-rw-r--r-- | common/usb_pd_host_cmd.c | 97 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 6 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 45 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 163 | ||||
-rw-r--r-- | include/usb_pe_sm.h | 19 | ||||
-rw-r--r-- | include/usb_tc_sm.h | 7 | ||||
-rw-r--r-- | test/build.mk | 2 | ||||
-rw-r--r-- | test/fake_usbc.c | 11 | ||||
-rw-r--r-- | test/test_config.h | 4 | ||||
-rw-r--r-- | test/usb_pe_drp.c | 2 | ||||
-rw-r--r-- | test/usb_typec_drp_acc_trysrc.c | 31 |
12 files changed, 170 insertions, 220 deletions
diff --git a/common/usb_common.c b/common/usb_common.c index 2a3ac922ed..588493b823 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -588,6 +588,8 @@ const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); #endif /* CONFIG_USB_PD_CUSTOM_PDO */ /* ----------------- Vendor Defined Messages ------------------ */ +#if defined(CONFIG_USB_PE_SM) && !defined(CONFIG_USB_VPD) && \ + !defined(CONFIG_USB_CTVPD) __overridable int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { @@ -650,6 +652,7 @@ __overridable int pd_custom_vdm(int port, int cnt, uint32_t *payload, return 0; } +#endif /* CONFIG_USB_PE_SM && !CONFIG_USB_VPD && !CONFIG_USB_CTVPD */ __overridable bool vboot_allow_usb_pd(void) { diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c index d7106c4625..700b2615f7 100644 --- a/common/usb_pd_host_cmd.c +++ b/common/usb_pd_host_cmd.c @@ -8,13 +8,14 @@ #include <string.h> #include "battery.h" +#include "charge_manager.h" #include "console.h" #include "ec_commands.h" #include "host_command.h" #include "tcpm.h" #include "usb_mux.h" -#include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_pd.h" #ifdef CONFIG_COMMON_RUNTIME /* @@ -83,8 +84,7 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_RW_HASH_ENTRY, EC_VER_MASK(0)); #endif /* CONFIG_HOSTCMD_RWHASHPD */ -#ifndef CONFIG_USB_PD_TCPC -#ifdef CONFIG_EC_CMD_PD_CHIP_INFO +#if defined(CONFIG_EC_CMD_PD_CHIP_INFO) && !defined(CONFIG_USB_PD_TCPC) static enum ec_status hc_remote_pd_chip_info(struct host_cmd_handler_args *args) { const struct ec_params_pd_chip_info *p = args->params; @@ -111,8 +111,7 @@ static enum ec_status hc_remote_pd_chip_info(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, hc_remote_pd_chip_info, EC_VER_MASK(0) | EC_VER_MASK(1)); -#endif /* CONFIG_EC_CMD_PD_CHIP_INFO */ -#endif /* CONFIG_USB_PD_TCPC */ +#endif /* CONFIG_EC_CMD_PD_CHIP_INFO && !CONFIG_USB_PD_TCPC */ #ifdef CONFIG_USB_PD_ALT_MODE_DFP static enum ec_status hc_remote_pd_set_amode(struct host_cmd_handler_args *args) @@ -379,6 +378,94 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, EC_VER_MASK(0) | EC_VER_MASK(1) | EC_VER_MASK(2)); #endif /* CONFIG_COMMON_RUNTIME */ +#if defined(CONFIG_HOSTCMD_FLASHPD) && defined(CONFIG_USB_PD_TCPMV2) +static enum ec_status hc_remote_flash(struct host_cmd_handler_args *args) +{ + const struct ec_params_usb_pd_fw_update *p = args->params; + int port = p->port; + int rv = EC_RES_SUCCESS; + const uint32_t *data = &(p->size) + 1; + int i, size; + + if (port >= board_get_usb_pd_port_count()) + return EC_RES_INVALID_PARAM; + + if (p->size + sizeof(*p) > args->params_size) + return EC_RES_INVALID_PARAM; + +#if defined(CONFIG_CHARGE_MANAGER) && defined(CONFIG_BATTERY) && \ + (defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \ + defined(CONFIG_BATTERY_PRESENT_GPIO)) + /* + * Do not allow PD firmware update if no battery and this port + * is sinking power, because we will lose power. + */ + if (battery_is_present() != BP_YES && + charge_manager_get_active_charge_port() == port) + return EC_RES_UNAVAILABLE; +#endif + + switch (p->cmd) { + case USB_PD_FW_REBOOT: + pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_REBOOT, NULL, 0); + /* + * Return immediately to free pending i2c bus. Host needs to + * manage this delay. + */ + return EC_RES_SUCCESS; + + case USB_PD_FW_FLASH_ERASE: + pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_FLASH_ERASE, NULL, 0); + /* + * Return immediately. Host needs to manage delays here which + * can be as long as 1.2 seconds on 64KB RW flash. + */ + return EC_RES_SUCCESS; + + case USB_PD_FW_ERASE_SIG: + pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_ERASE_SIG, NULL, 0); + break; + + case USB_PD_FW_FLASH_WRITE: + /* Data size must be a multiple of 4 */ + if (!p->size || p->size % 4) + return EC_RES_INVALID_PARAM; + + size = p->size / 4; + for (i = 0; i < size; i += VDO_MAX_SIZE - 1) { + pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_FLASH_WRITE, + data + i, MIN(size - i, VDO_MAX_SIZE - 1)); + } + return EC_RES_SUCCESS; + + default: + return EC_RES_INVALID_PARAM; + } + + return rv; +} +DECLARE_HOST_COMMAND(EC_CMD_USB_PD_FW_UPDATE, + hc_remote_flash, + EC_VER_MASK(0)); +#endif /* CONFIG_HOSTCMD_FLASHPD && CONFIG_USB_PD_TCPMV2 */ + +#ifdef CONFIG_HOSTCMD_EVENTS +void pd_notify_dp_alt_mode_entry(void) +{ + /* + * Note: EC_HOST_EVENT_PD_MCU may be a more appropriate host event to + * send, but we do not send that here because there are other cases + * where we send EC_HOST_EVENT_PD_MCU such as charger insertion or + * removal. Currently, those do not wake the system up, but + * EC_HOST_EVENT_MODE_CHANGE does. If we made the system wake up on + * EC_HOST_EVENT_PD_MCU, we would be turning the internal display on on + * every charger insertion/removal, which is not desired. + */ + CPRINTS("Notifying AP of DP Alt Mode Entry..."); + host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); +} +#endif /* CONFIG_HOSTCMD_EVENTS */ + __overridable enum ec_pd_port_location board_get_pd_port_location(int port) { (void)port; diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 6cb69f5bc5..87d1c47a20 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -45,12 +45,6 @@ static int dp_alt_mode_entry_get_next_event(uint8_t *data) } DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_DP_ALT_MODE_ENTERED, dp_alt_mode_entry_get_next_event); - -void pd_notify_dp_alt_mode_entry(void) -{ - CPRINTS("Notifying AP of DP Alt Mode Entry..."); - mkbp_send_event(EC_MKBP_EVENT_DP_ALT_MODE_ENTERED); -} #endif /* CONFIG_MKBP_EVENT */ #ifdef CONFIG_USB_PD_DUAL_ROLE diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 9f2b3c9c50..15715051f4 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -500,6 +500,10 @@ static struct policy_engine { uint32_t src_caps[PDO_MAX_OBJECTS]; int src_cap_cnt; + /* Attached ChromeOS device id, RW hash, and current RO / RW image */ + uint16_t dev_id; + uint32_t dev_rw_hash[PD_RW_HASH_SIZE/4]; + enum ec_image current_image; } pe[CONFIG_USB_PD_PORT_MAX_COUNT]; test_export_static enum usb_pe_state get_state_pe(const int port); @@ -635,13 +639,13 @@ void pe_got_hard_reset(int port) } /* - * pe_got_frs_signal + * pd_got_frs_signal * * Called by the handler that detects the FRS signal in order to * switch PE states to complete the FRS that the hardware has * started. */ -void pe_got_frs_signal(int port) +void pd_got_frs_signal(int port) { PE_SET_FLAG(port, PE_FLAGS_FAST_ROLE_SWAP_SIGNALED); } @@ -821,7 +825,7 @@ void pe_message_sent(int port) PE_SET_FLAG(port, PE_FLAGS_TX_COMPLETE); } -void pe_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, +void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, int count) { pe[port].partner_type = PORT; @@ -852,7 +856,7 @@ void pe_exit_dp_mode(int port) if (!pd_dfp_exit_mode(port, USB_SID_DISPLAYPORT, opos)) return; - pe_send_vdm(port, USB_SID_DISPLAYPORT, + pd_send_vdm(port, USB_SID_DISPLAYPORT, CMD_EXIT_MODE | VDO_OPOS(opos), NULL, 0); } } @@ -1126,6 +1130,39 @@ static void pe_attempt_port_discovery(int port) PE_CLR_FLAG(port, PE_FLAGS_WAITING_DR_SWAP); } +int pd_dev_store_rw_hash(int port, uint16_t dev_id, uint32_t *rw_hash, + uint32_t current_image) +{ + pe[port].dev_id = dev_id; + memcpy(pe[port].dev_rw_hash, rw_hash, PD_RW_HASH_SIZE); +#ifdef CONFIG_CMD_PD_DEV_DUMP_INFO + pd_dev_dump_info(dev_id, rw_hash); +#endif + pe[port].current_image = current_image; + + if (IS_ENABLED(CONFIG_USB_PD_HOST_CMD)) { + int i; + + /* Search table for matching device / hash */ + for (i = 0; i < RW_HASH_ENTRIES; i++) + if (dev_id == rw_hash_table[i].dev_id) + return !memcmp(rw_hash, + rw_hash_table[i].dev_rw_hash, + PD_RW_HASH_SIZE); + } + + return 0; +} + +void pd_dev_get_rw_hash(int port, uint16_t *dev_id, uint8_t *rw_hash, + uint32_t *current_image) +{ + *dev_id = pe[port].dev_id; + *current_image = pe[port].current_image; + if (*dev_id) + memcpy(rw_hash, pe[port].dev_rw_hash, PD_RW_HASH_SIZE); +} + /* * This function must only be called from the PE_SNK_READY entry and * PE_SRC_READY entry State. diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index b8ceb5b7da..3b310c012e 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -250,10 +250,6 @@ static struct type_c { typec_current_t typec_curr; /* Type-C current change */ typec_current_t typec_curr_change; - /* Attached ChromeOS device id, RW hash, and current RO / RW image */ - uint16_t dev_id; - uint32_t dev_rw_hash[PD_RW_HASH_SIZE/4]; - enum ec_image current_image; } tc[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Port dual-role state */ @@ -264,11 +260,7 @@ enum pd_dual_role_states drp_state[CONFIG_USB_PD_PORT_MAX_COUNT] = { static uint8_t saved_flgs[CONFIG_USB_PD_PORT_MAX_COUNT]; -#ifdef CONFIG_USBC_VCONN static void set_vconn(int port, int enable); -#endif - -#ifdef CONFIG_USB_PE_SM #ifdef CONFIG_USB_PD_ALT_MODE_DFP /* Tracker for which task is waiting on sysjump prep to finish */ @@ -283,7 +275,6 @@ static void handle_new_power_state(int port); #endif /* CONFIG_POWER_COMMON */ static void pd_update_dual_role_config(int port); -#endif /* CONFIG_USB_PE_SM */ /* Forward declare common, private functions */ static void set_state_tc(const int port, const enum usb_tc_state new_state); @@ -449,7 +440,6 @@ void pd_set_dual_role(int port, enum pd_dual_role_states state) PD_EVENT_UPDATE_DUAL_ROLE, 0); } -#ifdef CONFIG_USB_PE_SM bool pd_get_partner_data_swap_capable(int port) { /* return data swap capable status of port partner */ @@ -461,12 +451,6 @@ int pd_comm_is_enabled(int port) return tc_get_pd_enabled(port); } -void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, - int count) -{ - pe_send_vdm(port, vid, cmd, data, count); -} - void pd_request_data_swap(int port) { /* @@ -525,41 +509,6 @@ static inline void pd_dev_dump_info(uint16_t dev_id, uint32_t *hash) } #endif /* CONFIG_CMD_PD_DEV_DUMP_INFO */ -int pd_dev_store_rw_hash(int port, uint16_t dev_id, uint32_t *rw_hash, - uint32_t current_image) -{ - int i; - - tc[port].dev_id = dev_id; - memcpy(tc[port].dev_rw_hash, rw_hash, PD_RW_HASH_SIZE); -#ifdef CONFIG_CMD_PD_DEV_DUMP_INFO - pd_dev_dump_info(dev_id, rw_hash); -#endif - tc[port].current_image = current_image; - - /* Search table for matching device / hash */ - for (i = 0; i < RW_HASH_ENTRIES; i++) - if (dev_id == rw_hash_table[i].dev_id) - return !memcmp(rw_hash, - rw_hash_table[i].dev_rw_hash, - PD_RW_HASH_SIZE); - return 0; -} - -void pd_dev_get_rw_hash(int port, uint16_t *dev_id, uint8_t *rw_hash, - uint32_t *current_image) -{ - *dev_id = tc[port].dev_id; - *current_image = tc[port].current_image; - if (*dev_id) - memcpy(rw_hash, tc[port].dev_rw_hash, PD_RW_HASH_SIZE); -} - -void pd_got_frs_signal(int port) -{ - pe_got_frs_signal(port); -} - const char *tc_get_current_state(int port) { return tc_state_names[get_state_tc(port)]; @@ -570,18 +519,6 @@ uint32_t tc_get_flags(int port) return tc[port].flags; } -void tc_print_dev_info(int port) -{ - int i; - - ccprintf("Hash "); - for (i = 0; i < PD_RW_HASH_SIZE / 4; i++) - ccprintf("%08x ", tc[port].dev_rw_hash[i]); - - ccprintf("\nImage %s\n", ec_image_to_string( - tc[port].current_image)); -} - int tc_is_attached_src(int port) { return get_state_tc(port) == TC_ATTACHED_SRC; @@ -694,7 +631,6 @@ void tc_disc_ident_complete(int port) { TC_CLR_FLAG(port, TC_FLAGS_DISC_IDENT_IN_PROGRESS); } -#endif /* CONFIG_USB_PE_SM */ void tc_try_src_override(enum try_src_override_t ov) { @@ -1154,16 +1090,13 @@ static void print_current_state(const int port) CPRINTS("C%d: %s", port, tc_state_names[get_state_tc(port)]); } -#ifdef CONFIG_USB_PE_SM static void handle_device_access(int port) { tc[port].low_power_time = get_time().val + PD_LPM_DEBOUNCE_US; } -#endif void tc_event_check(int port, int evt) { -#ifdef CONFIG_USB_PE_SM if (IS_ENABLED(CONFIG_USB_PD_TCPC_LOW_POWER)) { if (evt & PD_EXIT_LOW_POWER_EVENT_MASK) TC_SET_FLAG(port, TC_FLAGS_WAKE_FROM_LPM); @@ -1201,7 +1134,6 @@ void tc_event_check(int port, int evt) if (evt & PD_EVENT_UPDATE_DUAL_ROLE) pd_update_dual_role_config(port); -#endif } /* @@ -1290,7 +1222,6 @@ static void set_vconn(int port, int enable) ppc_set_vconn(port, enable); } -#ifdef CONFIG_USB_PE_SM /* This must only be called from the PD task */ static void pd_update_dual_role_config(int port) { @@ -1346,99 +1277,6 @@ static void handle_new_power_state(int port) } #endif /* CONFIG_POWER_COMMON */ -/* - * HOST COMMANDS - */ -#ifdef HAS_TASK_HOSTCMD - -static enum ec_status hc_remote_flash(struct host_cmd_handler_args *args) -{ - const struct ec_params_usb_pd_fw_update *p = args->params; - int port = p->port; - int rv = EC_RES_SUCCESS; - const uint32_t *data = &(p->size) + 1; - int i, size; - - if (port >= board_get_usb_pd_port_count()) - return EC_RES_INVALID_PARAM; - - if (p->size + sizeof(*p) > args->params_size) - return EC_RES_INVALID_PARAM; - -#if defined(CONFIG_BATTERY) && \ - (defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \ - defined(CONFIG_BATTERY_PRESENT_GPIO)) - /* - * Do not allow PD firmware update if no battery and this port - * is sinking power, because we will lose power. - */ - if (battery_is_present() != BP_YES && - charge_manager_get_active_charge_port() == port) - return EC_RES_UNAVAILABLE; -#endif - - switch (p->cmd) { - case USB_PD_FW_REBOOT: - pe_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_REBOOT, NULL, 0); - /* - * Return immediately to free pending i2c bus. Host needs to - * manage this delay. - */ - return EC_RES_SUCCESS; - - case USB_PD_FW_FLASH_ERASE: - pe_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_FLASH_ERASE, NULL, 0); - /* - * Return immediately. Host needs to manage delays here which - * can be as long as 1.2 seconds on 64KB RW flash. - */ - return EC_RES_SUCCESS; - - case USB_PD_FW_ERASE_SIG: - pe_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_ERASE_SIG, NULL, 0); - break; - - case USB_PD_FW_FLASH_WRITE: - /* Data size must be a multiple of 4 */ - if (!p->size || p->size % 4) - return EC_RES_INVALID_PARAM; - - size = p->size / 4; - for (i = 0; i < size; i += VDO_MAX_SIZE - 1) { - pe_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_FLASH_WRITE, - data + i, MIN(size - i, VDO_MAX_SIZE - 1)); - } - return EC_RES_SUCCESS; - - default: - return EC_RES_INVALID_PARAM; - } - - return rv; -} -DECLARE_HOST_COMMAND(EC_CMD_USB_PD_FW_UPDATE, - hc_remote_flash, - EC_VER_MASK(0)); - -#ifdef CONFIG_HOSTCMD_EVENTS -void pd_notify_dp_alt_mode_entry(void) -{ - /* - * Note: EC_HOST_EVENT_PD_MCU may be a more appropriate host event to - * send, but we do not send that here because there are other cases - * where we send EC_HOST_EVENT_PD_MCU such as charger insertion or - * removal. Currently, those do not wake the system up, but - * EC_HOST_EVENT_MODE_CHANGE does. If we made the system wake up on - * EC_HOST_EVENT_PD_MCU, we would be turning the internal display on on - * every charger insertion/removal, which is not desired. - */ - CPRINTS("Notifying AP of DP Alt Mode Entry..."); - host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); -} -#endif /* CONFIG_HOSTCMD_EVENTS */ - -#endif /* HAS_TASK_HOSTCMD */ - #if defined(CONFIG_USB_PD_ALT_MODE) && !defined(CONFIG_USB_PD_ALT_MODE_DFP) void pd_send_hpd(int port, enum hpd_event hpd) { @@ -1461,7 +1299,6 @@ void pd_send_hpd(int port, enum hpd_event hpd) VDO_OPOS(opos) | CMD_ATTENTION, data, 1); } #endif -#endif /* CONFIG_USB_PE_SM */ #ifdef CONFIG_USBC_VCONN_SWAP void pd_request_vconn_swap_off(int port) diff --git a/include/usb_pe_sm.h b/include/usb_pe_sm.h index 2a9d466b2e..bfa6f3012f 100644 --- a/include/usb_pe_sm.h +++ b/include/usb_pe_sm.h @@ -98,13 +98,6 @@ void pe_got_soft_reset(int port); void pe_hard_reset_sent(int port); /** - * Informs the Policy Engine that a Fast Role Swap signal was detected - * - * @param port USB-C port number - */ -void pe_got_frs_signal(int port); - -/** * Exit DP mode * * @param port USB-C port number @@ -141,18 +134,6 @@ void pe_ps_reset_complete(int port); void pe_vconn_swap_complete(int port); /** - * Instructs the Policy Engine to send a Vendor Defined Message - * - * @param port USB-C port number - * @param vid Vendor ID - * @param cmd Vendor Defined Command - * @param data Vendor Defined Data - * @param count Size of Vendor Defined Data in 32-bit objects - */ -void pe_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, - int count); - -/** * Indicates if an explicit contract is in place * * @param port USB-C port number diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h index 58c33143ad..a99d38a73c 100644 --- a/include/usb_tc_sm.h +++ b/include/usb_tc_sm.h @@ -367,13 +367,6 @@ const char *tc_get_current_state(int port); */ uint32_t tc_get_flags(int port); -/* - * Prints the rw hash and sysjump image string. - * - * @param port USB-C port number - */ -void tc_print_dev_info(int port); - #ifdef CONFIG_USB_CTVPD /** diff --git a/test/build.mk b/test/build.mk index aff698f125..2c7bc455f7 100644 --- a/test/build.mk +++ b/test/build.mk @@ -170,7 +170,7 @@ usb_sm_framework_h0-y=usb_sm_framework_h3.o usb_typec_vpd-y=usb_typec_ctvpd.o vpd_api.o usb_sm_checks.o fake_usbc.o usb_typec_ctvpd-y=usb_typec_ctvpd.o vpd_api.o usb_sm_checks.o fake_usbc.o usb_typec_drp_acc_trysrc-y=usb_typec_drp_acc_trysrc.o vpd_api.o \ - usb_sm_checks.o fake_usbc.o + usb_sm_checks.o usb_prl-y=usb_prl.o usb_sm_checks.o fake_usbc.o usb_pe_drp-y=usb_pe_drp.o usb_sm_checks.o \ fake_battery.o fake_prl.o fake_usbc.o diff --git a/test/fake_usbc.c b/test/fake_usbc.c index a096652020..e62fa5ac62 100644 --- a/test/fake_usbc.c +++ b/test/fake_usbc.c @@ -130,22 +130,11 @@ __overridable void pe_invalidate_explicit_contract(int port) { } -int pd_dev_store_rw_hash(int port, uint16_t dev_id, uint32_t *rw_hash, - uint32_t ec_image) -{ - return 0; -} - enum pd_dual_role_states pd_get_dual_role(int port) { return PD_DRP_TOGGLE_ON; } -void pd_dev_get_rw_hash(int port, uint16_t *dev_id, uint8_t *rw_hash, - uint32_t *current_image) -{ -} - int pd_comm_is_enabled(int port) { return 0; diff --git a/test/test_config.h b/test/test_config.h index 626cacccc5..cefaf55974 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -316,6 +316,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_PD_TCPMV2 #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM +#undef CONFIG_USB_PD_HOST_CMD #define CONFIG_USB_PRL_SM #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB @@ -336,6 +337,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USBC_VCONN #define PD_VCONN_SWAP_DELAY 5000 /* us */ #define CONFIG_USB_PD_DISCHARGE_GPIO +#undef CONFIG_USB_PD_HOST_CMD #endif /* Common TypeC tests defines */ @@ -361,6 +363,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_POWER_DELIVERY #define CONFIG_SW_CRC +#undef CONFIG_USB_PD_HOST_CMD #endif /* Common TypeC test defines */ #ifdef TEST_USB_TYPEC_VPD @@ -383,6 +386,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_POWER_DELIVERY #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM +#undef CONFIG_USB_PD_HOST_CMD #endif #ifdef TEST_USB_PD_INT diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c index f757adf8ec..2bd05047ad 100644 --- a/test/usb_pe_drp.c +++ b/test/usb_pe_drp.c @@ -68,7 +68,7 @@ static int test_pe_frs(void) /* * Trigger the Fast Role Switch from simulated ISR */ - pe_got_frs_signal(PORT0); + pd_got_frs_signal(PORT0); TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_SIGNALED)); /* diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c index 6957cb6093..5711334a1b 100644 --- a/test/usb_typec_drp_acc_trysrc.c +++ b/test/usb_typec_drp_acc_trysrc.c @@ -17,6 +17,29 @@ #define PORT0 0 +/* TODO(b/153071799): Move these pd_* and pe_* function into mock */ +__overridable void pd_request_power_swap(int port) +{} + +uint8_t pd_get_src_cap_cnt(int port) +{ + return 0; +} + +const uint32_t * const pd_get_src_caps(int port) +{ + return NULL; +} + +void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) +{ +} + +__overridable void pe_invalidate_explicit_contract(int port) +{ +} +/* End pd_ mock section */ + /* Install Mock TCPC and MUX drivers */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { @@ -81,9 +104,11 @@ __maybe_unused static int test_mux_con_dis_as_snk(void) /* This wait will go through AttachWait.SNK to Attached.SNK */ task_wait_event(5 * SECOND); - /* We are in Attached.SNK now */ - TEST_EQ(mock_usb_mux.state, USB_PD_MUX_USB_ENABLED, "%d"); - TEST_EQ(mock_usb_mux.num_set_calls, 1, "%d"); + /* + * We are in Attached.SNK now, but the port partner isn't data capable + * so we should not connect the USB data mux. + */ + TEST_EQ(mock_usb_mux.state, USB_PD_MUX_NONE, "%d"); mock_tcpc.cc1 = TYPEC_CC_VOLT_OPEN; mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; |