diff options
author | Kapil Porwal <kapilporwal@google.com> | 2023-07-10 11:37:26 +0000 |
---|---|---|
committer | Subrata Banik <subratabanik@google.com> | 2023-07-15 12:47:51 +0000 |
commit | 2ba4b1bebea4321cc4998ac5bf51a9e97795157e (patch) | |
tree | 9002e8befded4312cd719dd6f2596678133b6693 /src/ec/google/chromeec/ec.c | |
parent | 1d85464df80eaefeef06df9a74018ed93f67e19d (diff) |
ec/google/chromeec: Split wait-loop for DP and HPD flags
Split wait-loop for DP and HPD flags as below -
- google_chromeec_wait_for_hpd
- google_chromeec_wait_for_dp_mode_entry
BUG=b:247670186
TEST=Verify display over TCSS and its impact on boot time for
google/rex
Signed-off-by: Kapil Porwal <kapilporwal@google.com>
Change-Id: I3e565d6134f6433930916071e94d56d92dc6cb06
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76370
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/ec/google/chromeec/ec.c')
-rw-r--r-- | src/ec/google/chromeec/ec.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index a3b1fe3045..c950673c65 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1383,15 +1383,29 @@ int google_chromeec_wait_for_displayport(long timeout_ms) return ret; } -int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms) +/** + * Check for given flag in PD mux info for a port. + * + * @param port Type-C port number + * flag Flag to check + * @return 1: Flag is set. 0: Flag is not set. + */ +static int google_chromeec_check_mux_flag(int port, uint8_t flag) +{ + uint8_t mux_flags = 0; + google_chromeec_usb_get_pd_mux_info(port, &mux_flags); + if ((mux_flags & flag) == flag) + return 1; + return 0; +} + +int google_chromeec_wait_for_dp_mode_entry(int port, long timeout_ms) { - uint8_t mux_flags; struct stopwatch sw; if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY)) { - google_chromeec_usb_get_pd_mux_info(port, &mux_flags); - if (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED)) { - printk(BIOS_WARNING, "DP/HPD not ready. Abort.\n"); + if (!google_chromeec_check_mux_flag(port, USB_PD_MUX_DP_ENABLED)) { + printk(BIOS_WARNING, "DP mode entry is not ready. Abort.\n"); return -1; } @@ -1399,14 +1413,39 @@ int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms) } stopwatch_init_msecs_expire(&sw, timeout_ms); - do { - google_chromeec_usb_get_pd_mux_info(port, &mux_flags); + while (!google_chromeec_check_mux_flag(port, USB_PD_MUX_DP_ENABLED)) { + if (stopwatch_expired(&sw)) { + printk(BIOS_WARNING, "DP not ready after %ldms. Abort.\n", timeout_ms); + return -1; + } + mdelay(100); + } + printk(BIOS_INFO, "DP ready after %lld ms\n", stopwatch_duration_msecs(&sw)); + + return 0; +} + +int google_chromeec_wait_for_hpd(int port, long timeout_ms) +{ + struct stopwatch sw; + + if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY)) { + if (!google_chromeec_check_mux_flag(port, USB_PD_MUX_HPD_LVL)) { + printk(BIOS_WARNING, "HPD not ready. Abort.\n"); + return -1; + } + + return 0; + } + + stopwatch_init_msecs_expire(&sw, timeout_ms); + while (!google_chromeec_check_mux_flag(port, USB_PD_MUX_HPD_LVL)) { if (stopwatch_expired(&sw)) { printk(BIOS_WARNING, "HPD not ready after %ldms. Abort.\n", timeout_ms); return -1; } mdelay(100); - } while (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED)); + } printk(BIOS_INFO, "HPD ready after %lld ms\n", stopwatch_duration_msecs(&sw)); return 0; |