From 04698e3df16960e5cc97094f186ccd2e41a0bd34 Mon Sep 17 00:00:00 2001 From: Josh-Tsai Date: Tue, 20 Dec 2022 19:41:30 +0800 Subject: skyrim: save and store the io expander status when NCT38xx reset Upstream Zephyr support the get_config and get_direction in nct38xx. Use the upstream API to implement the function which saves and stores the nct38xx gpio status when it is doing the reset. BRANCH=None BUG=b:260534665 LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 TEST=Winterhold USBA is workable when wake up from battery cutoff Change-Id: I3394ed2c7f39be494bd5df9e076871d11ea0bcf0 Signed-off-by: Josh-Tsai Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4115055 Reviewed-by: Keith Short Code-Coverage: Zoss Reviewed-by: Elthan Huang Commit-Queue: Keith Short Reviewed-by: Diana Z --- zephyr/program/skyrim/src/usbc_config.c | 15 ++++++++++++--- zephyr/program/skyrim/winterhold/project.conf | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index 5319504069..4f2c43ce4c 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -244,7 +244,10 @@ static void reset_nct38xx_port(int port) const struct gpio_dt_spec *reset_gpio_l; const struct device *ioex_port0, *ioex_port1; - /* TODO(b/225189538): Save and restore ioex signals */ + /* The maximum pin numbers of the NCT38xx IO expander port is 8 */ + gpio_flags_t saved_port0_flags[8] = { 0 }; + gpio_flags_t saved_port1_flags[8] = { 0 }; + if (port == USBC_PORT_C0) { reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_l); ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0)); @@ -257,6 +260,10 @@ static void reset_nct38xx_port(int port) /* Invalid port: do nothing */ return; } + gpio_save_port_config(ioex_port0, saved_port0_flags, + ARRAY_SIZE(saved_port0_flags)); + gpio_save_port_config(ioex_port1, saved_port1_flags, + ARRAY_SIZE(saved_port1_flags)); gpio_pin_set_dt(reset_gpio_l, 0); msleep(NCT38XX_RESET_HOLD_DELAY_MS); @@ -266,8 +273,10 @@ static void reset_nct38xx_port(int port) msleep(NCT3807_RESET_POST_DELAY_MS); /* Re-enable the IO expander pins */ - gpio_reset_port(ioex_port0); - gpio_reset_port(ioex_port1); + gpio_restore_port_config(ioex_port0, saved_port0_flags, + ARRAY_SIZE(saved_port0_flags)); + gpio_restore_port_config(ioex_port1, saved_port1_flags, + ARRAY_SIZE(saved_port1_flags)); } void board_reset_pd_mcu(void) diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf index 5c8087ddd8..4c0aba19ab 100644 --- a/zephyr/program/skyrim/winterhold/project.conf +++ b/zephyr/program/skyrim/winterhold/project.conf @@ -48,3 +48,6 @@ CONFIG_PLATFORM_EC_BODY_DETECTION=y CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y + +# GPIO configuration +CONFIG_GPIO_GET_CONFIG=y -- cgit v1.2.1