diff options
author | Peter Marheine <pmarheine@chromium.org> | 2023-02-16 00:14:21 +0000 |
---|---|---|
committer | Peter Marheine <pmarheine@chromium.org> | 2023-02-16 00:14:21 +0000 |
commit | f43d6df6f2860dbe8ec15aebdc28890771ad7897 (patch) | |
tree | 6877eff7016f9979e46017ea5221a16d36344304 /zephyr/test/skyrim/src/frostflow/usb_mux_config.c | |
parent | dce247e97903a2464ff8884106bffa43587c1dcb (diff) | |
parent | 0849542c72359150a357945c010dca6b5a213633 (diff) | |
download | chrome-ec-f43d6df6f2860dbe8ec15aebdc28890771ad7897.tar.gz |
Merge remote-tracking branch cros/main into firmware-nissa-15217.B-mainfirmware-nissa-15217.126.B-main
Generated by: ./util/update_release_branch.py --zephyr --board nissa firmware-
nissa-15217.B-main
Relevant changes:
git log --oneline dce247e979..0849542c72 -- zephyr/program/nissa
util/getversion.sh
0849542c72 zephyr: add sleep property for keyboard factory test
5825d894b9 nissa: disable PLATFORM_EC_TCPC_INTERRUPT
25a400690f yavikso: Update fan table version 3
9263f14536 zephyr: remove shi node and add references to shi0
b40c6970d3 Craask: Charger limit for 65w adapter
6fd2d3ea6c zephyr: add comments for tcpc driver
00986ffb1c zephyr: move usbc interrupt handler to shim
2508094b14 yaviks: reduce RW image size (64KB)
55b6aaf52f yaviks: enable keyboard factory test
4786d1eac6 nissa: Add ocpc init function to Nissa boards
2ae1083638 zephyr: cros_kb: set KSI/KSO kbs mode by pinctrl driver
d415f4665a yaviks: Fix OCPC Vsys overshooting
93f9d42a7c zephyr: config: drop few more redundant options
BRANCH=None
BUG=b:254148652 b:260762509 b:265220075 b:268273712 b:265763662
BUG=b:253557900 b:254148652 b:269212593 b:267404783 b:262352202
TEST=`make -j buildall`
Force-Relevant-Builds: all
Change-Id: I195dd82af114180b611f9afd1465a69f7f43d417
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'zephyr/test/skyrim/src/frostflow/usb_mux_config.c')
-rw-r--r-- | zephyr/test/skyrim/src/frostflow/usb_mux_config.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/zephyr/test/skyrim/src/frostflow/usb_mux_config.c b/zephyr/test/skyrim/src/frostflow/usb_mux_config.c new file mode 100644 index 0000000000..929bd318d4 --- /dev/null +++ b/zephyr/test/skyrim/src/frostflow/usb_mux_config.c @@ -0,0 +1,60 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include <zephyr/drivers/gpio/gpio_emul.h> +#include <zephyr/fff.h> +#include <zephyr/ztest.h> + +#include <gpio.h> +#include <usbc/usb_muxes.h> + +int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state); +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state); + +ZTEST_SUITE(usb_mux_config, NULL, NULL, NULL, NULL, NULL); + +ZTEST(usb_mux_config, board_c0_amd_fp6_mux_set) +{ + const struct gpio_dt_spec *c0 = + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip); + const struct gpio_dt_spec *c1 = + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip); + struct usb_mux mux; + int rv; + + /* Output for each port should match inverted status. */ + mux.usb_port = 0; + rv = board_c0_amd_fp6_mux_set(&mux, 0); + zassert_equal(rv, EC_SUCCESS); + zassert_equal(gpio_emul_output_get(c0->port, c0->pin), 0); + + rv = board_c0_amd_fp6_mux_set(&mux, USB_PD_MUX_POLARITY_INVERTED); + zassert_equal(rv, EC_SUCCESS); + zassert_equal(gpio_emul_output_get(c0->port, c0->pin), 1); + + mux.usb_port = 1; + rv = board_c0_amd_fp6_mux_set(&mux, 0); + zassert_equal(rv, EC_SUCCESS); + zassert_equal(gpio_emul_output_get(c1->port, c1->pin), 0); + + rv = board_c0_amd_fp6_mux_set(&mux, USB_PD_MUX_POLARITY_INVERTED); + zassert_equal(rv, EC_SUCCESS); + zassert_equal(gpio_emul_output_get(c1->port, c1->pin), 1); +} + +ZTEST(usb_mux_config, board_c1_ps8818_mux_set) +{ + const struct gpio_dt_spec *gpio = + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_in_hpd); + struct usb_mux mux; + + /* gpio_usb_c1_in_hpd should match if DP is enabled. */ + mux.usb_port = 0; + zassert_ok(board_c1_ps8818_mux_set(&mux, 0)); + zassert_equal(gpio_emul_output_get(gpio->port, gpio->pin), 0); + + mux.usb_port = 1; + zassert_ok(board_c1_ps8818_mux_set(&mux, USB_PD_MUX_DP_ENABLED)); + zassert_equal(gpio_emul_output_get(gpio->port, gpio->pin), 1); +} |