summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJameson Thies <jthies@google.com>2023-04-26 22:03:26 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-04 19:00:32 +0000
commit25067066458e2a4c28e9b7185a07e4f7af7aacbd (patch)
treeb2f8bd2d7c6503c66cc8449e76c11d2ff66c78c6
parentf9ff4e75a57f16627bc2a52ecdde46fbd3a0bea3 (diff)
downloadchrome-ec-25067066458e2a4c28e9b7185a07e4f7af7aacbd.tar.gz
Rex: Allow VCONN swap when PWR_ALL_SYS_PWRGD is asserted
The current USB PD policy will only allow Vconn swaps when the AP is on. This causes the EC to send a hard reset to USB PD partners instead of trying to Vconn swap when the device is booting, leading to device discovery issues in the kernel. This CL updates the Vconn swap policy to allow Vconn swaps when PWR_ALL_SYS_PWRGD is asserted. During boot, this policy prevents a USB PD hard reset from disrupting device discovery in the cros-ec-typec driver. BUG=b:274576896 TEST=emerge-rex chromeos-base/chromeos-zephyr, ./twister -T zephyr/test/rex -c, checked that the EC did not hard reset with connected partners during boot. Change-Id: Ic9560509f4d7f6161bb001a80ba588f3d5108b13 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4484808 Commit-Queue: Jameson Thies <jthies@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jameson Thies <jthies@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--zephyr/program/rex/src/usb_pd_policy.c5
-rw-r--r--zephyr/test/rex/board_power.dtsi7
-rw-r--r--zephyr/test/rex/src/usb_pd_policy.c18
-rw-r--r--zephyr/test/rex/testcase.yaml6
4 files changed, 30 insertions, 6 deletions
diff --git a/zephyr/program/rex/src/usb_pd_policy.c b/zephyr/program/rex/src/usb_pd_policy.c
index 24e78acf60..3541f93140 100644
--- a/zephyr/program/rex/src/usb_pd_policy.c
+++ b/zephyr/program/rex/src/usb_pd_policy.c
@@ -12,6 +12,7 @@
#include "console.h"
#include "ec_commands.h"
#include "ioexpander.h"
+#include "power_signals.h"
#include "system.h"
#include "usb_mux.h"
#include "usb_pd.h"
@@ -22,8 +23,8 @@
int pd_check_vconn_swap(int port)
{
- /* Allow VCONN swaps if the AP is on. */
- return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+ /* Allow VCONN swaps when PWR_ALL_SYS_PWRGD is set. */
+ return power_signal_get(PWR_ALL_SYS_PWRGD);
}
void pd_power_supply_reset(int port)
diff --git a/zephyr/test/rex/board_power.dtsi b/zephyr/test/rex/board_power.dtsi
index e5f90dfa80..beb1fbb700 100644
--- a/zephyr/test/rex/board_power.dtsi
+++ b/zephyr/test/rex/board_power.dtsi
@@ -125,4 +125,11 @@
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
output;
};
+ pwr-all-sys-pwrgd {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "all power good";
+ enum-name = "PWR_ALL_SYS_PWRGD";
+ gpios = <&gpio0 23 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
};
diff --git a/zephyr/test/rex/src/usb_pd_policy.c b/zephyr/test/rex/src/usb_pd_policy.c
index d49e10a495..d638747b28 100644
--- a/zephyr/test/rex/src/usb_pd_policy.c
+++ b/zephyr/test/rex/src/usb_pd_policy.c
@@ -13,6 +13,8 @@
#include <zephyr/fff.h>
#include <zephyr/ztest.h>
+#include <mock/power_signals.h>
+
FAKE_VALUE_FUNC(int, chipset_in_state, int);
FAKE_VALUE_FUNC(int, ppc_vbus_source_enable, int, int);
FAKE_VOID_FUNC(pd_set_vbus_discharge, int, int);
@@ -20,9 +22,16 @@ FAKE_VOID_FUNC(pd_send_host_event, int);
FAKE_VALUE_FUNC(int, ppc_vbus_sink_enable, int, int);
FAKE_VALUE_FUNC(int, ppc_is_sourcing_vbus, int);
-int chipset_in_state_mock(int state_mask)
+int power_signal_get_all_sys_pwrgd_mock(enum power_signal signal)
{
- return state_mask == (CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+ if (signal == PWR_ALL_SYS_PWRGD) {
+ return 1;
+ }
+
+ /* LCOV_EXCL_START */
+ zassert_unreachable("Wrong input received");
+ return -1;
+ /* LCOV_EXCL_STOP */
}
int ppc_vbus_source_enable_0_mock(int port, int enable)
@@ -105,6 +114,7 @@ static void usb_pd_policy_before(void *fixture)
{
ARG_UNUSED(fixture);
RESET_FAKE(chipset_in_state);
+ RESET_FAKE(power_signal_get);
RESET_FAKE(ppc_vbus_source_enable);
RESET_FAKE(pd_set_vbus_discharge);
RESET_FAKE(pd_send_host_event);
@@ -114,9 +124,9 @@ static void usb_pd_policy_before(void *fixture)
ZTEST_USER(usb_pd_policy, test_pd_check_vconn_swap)
{
- chipset_in_state_fake.custom_fake = chipset_in_state_mock;
+ power_signal_get_fake.custom_fake = power_signal_get_all_sys_pwrgd_mock;
zassert_true(pd_check_vconn_swap(0), NULL, NULL);
- zassert_equal(1, chipset_in_state_fake.call_count);
+ zassert_equal(1, power_signal_get_fake.call_count);
}
ZTEST_USER(usb_pd_policy, test_pd_power_supply_reset)
diff --git a/zephyr/test/rex/testcase.yaml b/zephyr/test/rex/testcase.yaml
index 9331a51956..3d6bd61604 100644
--- a/zephyr/test/rex/testcase.yaml
+++ b/zephyr/test/rex/testcase.yaml
@@ -6,10 +6,16 @@ common:
platform_allow: native_posix
tests:
rex.usb_pd_policy:
+ extra_dtc_overlay_files:
+ - board_power.dtsi
extra_configs:
- CONFIG_TEST_USB_PD_POLICY=y
- CONFIG_TEST_ENABLE_USB_PD_DISCHARGE=y
- CONFIG_TEST_ENABLE_USB_PD_HOST_CMD=y
+ - CONFIG_TEST_BOARD_POWER=y
+ - CONFIG_TEST_X86_NON_DSX_PWRSEQ_MTL=y
+ - CONFIG_POWER_SIGNALS_MOCK=y
+ - CONFIG_AP_EVENTS=n
rex.board_power:
extra_dtc_overlay_files: