From 7a4e700b6488a138d0c5c55aaa47e626d90a5299 Mon Sep 17 00:00:00 2001 From: Denis Brockus Date: Mon, 14 Oct 2019 14:06:05 -0600 Subject: pd: Add PE FRS unit test for new stack BUG=none BRANCH=none TEST=make buildall -j Change-Id: I55453ddf1d1da0fdee902a33e14357716fb12c4a Signed-off-by: Denis Brockus Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1859826 Reviewed-by: Jett Rink --- test/usb_pe.h | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 test/usb_pe.h (limited to 'test/usb_pe.h') diff --git a/test/usb_pe.h b/test/usb_pe.h new file mode 100644 index 0000000000..f54040e6a6 --- /dev/null +++ b/test/usb_pe.h @@ -0,0 +1,133 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Test USB PE module. + */ +#ifndef __CROS_TEST_USB_PE_H +#define __CROS_TEST_USB_PE_H + +#include "common.h" + +/* + * Test references to port + */ +#define PORT0 0 + +/* + * Parameters for pe_run + * + * pe_run(port, evt, enable) + * evt - currently ignored in the implementation + * enable - 0 Disable/1 Enable + */ +#define EVT_IGNORED 0 + +#define ENABLED 1 +#define DISABLED 0 + +/** + * usb_pe_drp_sm.c locally defined. If it changes there, it must + * be changed here as well. + */ + +/* Policy Engine Layer Flags */ +#define PE_FLAGS_PD_CONNECTION BIT(0) +#define PE_FLAGS_ACCEPT BIT(1) +#define PE_FLAGS_PS_READY BIT(2) +#define PE_FLAGS_PROTOCOL_ERROR BIT(3) +#define PE_FLAGS_MODAL_OPERATION BIT(4) +#define PE_FLAGS_TX_COMPLETE BIT(5) +#define PE_FLAGS_MSG_RECEIVED BIT(6) +#define PE_FLAGS_HARD_RESET_PENDING BIT(7) +#define PE_FLAGS_WAIT BIT(8) +#define PE_FLAGS_EXPLICIT_CONTRACT BIT(9) +#define PE_FLAGS_SNK_WAIT_CAP_TIMEOUT BIT(10) +#define PE_FLAGS_PS_TRANSITION_TIMEOUT BIT(11) +#define PE_FLAGS_INTERRUPTIBLE_AMS BIT(12) +#define PE_FLAGS_PS_RESET_COMPLETE BIT(13) +#define PE_FLAGS_SEND_SVDM BIT(14) +#define PE_FLAGS_VCONN_SWAP_COMPLETE BIT(15) +#define PE_FLAGS_DISCOVER_PORT_IDENTITY_DONE BIT(16) +#define PE_FLAGS_DISCOVER_VDM_IDENTITY_DONE BIT(17) +#define PE_FLAGS_RUN_SOURCE_START_TIMER BIT(19) +#define PE_FLAGS_VDM_REQUEST_BUSY BIT(20) +#define PE_FLAGS_VDM_REQUEST_NAKED BIT(21) +#define PE_FLAGS_FAST_ROLE_SWAP_PATH BIT(22)/* FRS/PRS Exec Path */ +#define PE_FLAGS_FAST_ROLE_SWAP_ENABLED BIT(23)/* FRS Listening State */ +#define PE_FLAGS_FAST_ROLE_SWAP_SIGNALED BIT(24)/* FRS PPC/TCPC Signal */ + +/* List of all Policy Engine level states */ +enum usb_pe_state { + /* Normal States */ + PE_SRC_STARTUP, + PE_SRC_DISCOVERY, + PE_SRC_SEND_CAPABILITIES, + PE_SRC_NEGOTIATE_CAPABILITY, + PE_SRC_TRANSITION_SUPPLY, + PE_SRC_READY, + PE_SRC_DISABLED, + PE_SRC_CAPABILITY_RESPONSE, + PE_SRC_HARD_RESET, + PE_SRC_HARD_RESET_RECEIVED, + PE_SRC_TRANSITION_TO_DEFAULT, + PE_SRC_VDM_IDENTITY_REQUEST, + PE_SNK_STARTUP, + PE_SNK_DISCOVERY, + PE_SNK_WAIT_FOR_CAPABILITIES, + PE_SNK_EVALUATE_CAPABILITY, + PE_SNK_SELECT_CAPABILITY, + PE_SNK_READY, + PE_SNK_HARD_RESET, + PE_SNK_TRANSITION_TO_DEFAULT, + PE_SNK_GIVE_SINK_CAP, + PE_SNK_GET_SOURCE_CAP, + PE_SNK_TRANSITION_SINK, + PE_SEND_SOFT_RESET, + PE_SOFT_RESET, + PE_SEND_NOT_SUPPORTED, + PE_SRC_PING, + PE_GIVE_BATTERY_CAP, + PE_GIVE_BATTERY_STATUS, + PE_DRS_EVALUATE_SWAP, + PE_DRS_CHANGE, + PE_DRS_SEND_SWAP, + PE_PRS_SRC_SNK_EVALUATE_SWAP, + PE_PRS_SRC_SNK_TRANSITION_TO_OFF, + PE_PRS_SRC_SNK_WAIT_SOURCE_ON, + PE_PRS_SRC_SNK_SEND_SWAP, + PE_PRS_SNK_SRC_EVALUATE_SWAP, + PE_PRS_SNK_SRC_TRANSITION_TO_OFF, + PE_PRS_SNK_SRC_ASSERT_RP, + PE_PRS_SNK_SRC_SOURCE_ON, + PE_PRS_SNK_SRC_SEND_SWAP, + PE_FRS_SNK_SRC_START_AMS, + PE_VCS_EVALUATE_SWAP, + PE_VCS_SEND_SWAP, + PE_VCS_WAIT_FOR_VCONN_SWAP, + PE_VCS_TURN_ON_VCONN_SWAP, + PE_VCS_TURN_OFF_VCONN_SWAP, + PE_VCS_SEND_PS_RDY_SWAP, + PE_DO_PORT_DISCOVERY, + PE_VDM_REQUEST, + PE_VDM_ACKED, + PE_VDM_RESPONSE, + PE_HANDLE_CUSTOM_VDM_REQUEST, + PE_WAIT_FOR_ERROR_RECOVERY, + PE_BIST, + PE_DR_SNK_GET_SINK_CAP, + + /* Super States */ + PE_PRS_FRS_SHARED, +}; + +void set_state_pe(const int port, const enum usb_pe_state new_state); +enum usb_pe_state get_state_pe(const int port); + +void pe_set_flag(int port, int flag); +void pe_clr_flag(int port, int flag); +int pe_chk_flag(int port, int flag); +int pe_get_all_flags(int port); +void pe_set_all_flags(int port, int flags); + +#endif /* __CROS_TEST_USB_PE_H */ -- cgit v1.2.1