From 037c04236fdccb37b02075f46b47c7ee92ac9ab8 Mon Sep 17 00:00:00 2001 From: Tang Qijun Date: Sat, 29 Apr 2023 10:26:48 +0800 Subject: crystaldrift: modify port0 ppc config design port0 ppc change from aoz1380 to sm5360 BRANCH=skyrim BUG=b:260771028 TEST=1. zmake build crystaldrift test port0 typeC function is ok 2. twister -T zephyr/test/skyrim Change-Id: I4c33c1004d18a07e84cb9390ccf1b686e71c9da7 Signed-off-by: Tang Qijun Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4493843 Commit-Queue: Chao Gui Reviewed-by: Diana Z (cherry picked from commit dcb771689a6fd8c78a3ea110ac492e957c4e1850) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4493445 Reviewed-by: Chao Gui --- zephyr/program/skyrim/crystaldrift/project.overlay | 6 ---- .../program/skyrim/crystaldrift/src/ppc_config.c | 20 +----------- zephyr/test/skyrim/testcase.yaml | 2 +- .../test/skyrim/tests/crystaldrift/CMakeLists.txt | 1 + .../skyrim/tests/crystaldrift/src/ppc_config.c | 37 ++++++++++++++++++++++ 5 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 zephyr/test/skyrim/tests/crystaldrift/src/ppc_config.c diff --git a/zephyr/program/skyrim/crystaldrift/project.overlay b/zephyr/program/skyrim/crystaldrift/project.overlay index bf4e420367..7a6219d4be 100644 --- a/zephyr/program/skyrim/crystaldrift/project.overlay +++ b/zephyr/program/skyrim/crystaldrift/project.overlay @@ -158,16 +158,10 @@ 0 0 1>; }; }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; }; /* i2c overrides */ &i2c0_0 { - /delete-node/ nx20p348x@71; /delete-node/ anx7483@3e; }; &i2c4_1 { diff --git a/zephyr/program/skyrim/crystaldrift/src/ppc_config.c b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c index 0e5cd33606..4a4bb07a3f 100644 --- a/zephyr/program/skyrim/crystaldrift/src/ppc_config.c +++ b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c @@ -14,29 +14,11 @@ #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - if (port != 0) - return EC_ERROR_INVAL; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - void ppc_interrupt(enum gpio_signal signal) { switch (signal) { case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); + nx20p348x_interrupt(0); break; case GPIO_USB_C1_PPC_INT_ODL: diff --git a/zephyr/test/skyrim/testcase.yaml b/zephyr/test/skyrim/testcase.yaml index 43ea40da6f..2084a37bba 100644 --- a/zephyr/test/skyrim/testcase.yaml +++ b/zephyr/test/skyrim/testcase.yaml @@ -34,7 +34,7 @@ tests: skyrim.crystaldrift.ppc_config: extra_configs: - CONFIG_TEST_BOARD_CRYSTALDRIFT=y - - CONFIG_TEST_BOARD_PPC_CONFIG=y + - CONFIG_TEST_BOARD_PPC_CONFIG_CUSTOM=y # Frostflow tests skyrim.frostflow: diff --git a/zephyr/test/skyrim/tests/crystaldrift/CMakeLists.txt b/zephyr/test/skyrim/tests/crystaldrift/CMakeLists.txt index e78711fed2..cec3317f7f 100644 --- a/zephyr/test/skyrim/tests/crystaldrift/CMakeLists.txt +++ b/zephyr/test/skyrim/tests/crystaldrift/CMakeLists.txt @@ -3,3 +3,4 @@ # found in the LICENSE file. target_sources(app PRIVATE src/common.c) +target_sources_ifdef(CONFIG_TEST_BOARD_PPC_CONFIG app PRIVATE src/ppc_config.c) diff --git a/zephyr/test/skyrim/tests/crystaldrift/src/ppc_config.c b/zephyr/test/skyrim/tests/crystaldrift/src/ppc_config.c new file mode 100644 index 0000000000..0f319d8ea4 --- /dev/null +++ b/zephyr/test/skyrim/tests/crystaldrift/src/ppc_config.c @@ -0,0 +1,37 @@ +/* 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 +#include + +#include +#include + +FAKE_VOID_FUNC(nx20p348x_interrupt, int); + +static void ppc_config_before(void *fixture) +{ + ARG_UNUSED(fixture); + RESET_FAKE(nx20p348x_interrupt); +} + +void ppc_interrupt(enum gpio_signal signal); + +ZTEST_SUITE(ppc_config, NULL, NULL, ppc_config_before, NULL, NULL); + +ZTEST(ppc_config, test_ppc_interrupt_c0) +{ + ppc_interrupt(GPIO_USB_C0_PPC_INT_ODL); + zassert_equal(nx20p348x_interrupt_fake.call_count, 1); + /* port */ + zassert_equal(nx20p348x_interrupt_fake.arg0_val, 0); +} + +ZTEST(ppc_config, test_ppc_interrupt_c1) +{ + ppc_interrupt(GPIO_USB_C1_PPC_INT_ODL); + zassert_equal(nx20p348x_interrupt_fake.call_count, 1); + /* port */ + zassert_equal(nx20p348x_interrupt_fake.arg0_val, 1); +} -- cgit v1.2.1