Attention is currently required from: Boris Mittelberg, Caveh Jalali.
Kapil Porwal has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/76398?usp=email )
Change subject: ec/google/chromeec: Add a helper function to check mux info flags ......................................................................
ec/google/chromeec: Add a helper function to check mux info flags
Add a helper function to check mux information flags.
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: I70b82b67da6e486b663a01e769c8415ec0f1b7a7 --- M src/ec/google/chromeec/ec.c 1 file changed, 15 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/76398/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index f150d2c..e7bf3ee 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1383,14 +1383,21 @@ return ret; }
+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_DP_ENABLED)) { + 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 +1406,13 @@ }
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); - } while (!(mux_flags & USB_PD_MUX_DP_ENABLED)); + } printk(BIOS_INFO, "DP ready after %lld ms\n", stopwatch_duration_msecs(&sw));
return 0; @@ -1414,12 +1420,10 @@
int google_chromeec_wait_for_hpd(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)) { + if (!google_chromeec_check_mux_flag(port, USB_PD_MUX_HPD_LVL)) { printk(BIOS_WARNING, "HPD not ready. Abort.\n"); return -1; } @@ -1428,14 +1432,13 @@ }
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_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)); + } printk(BIOS_INFO, "HPD ready after %lld ms\n", stopwatch_duration_msecs(&sw));
return 0;