From ebb86be9fcaf64daa71e8ee3bff52c6982708a23 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Fri, 26 Jan 2018 17:36:44 -0800 Subject: chromeec: Add google_chromeec_wait_for_display The google_chromeec_wait_for_display API checks whether a display is ready or not. It waits in a loop until EC says it entered DisplayPort alternative mode or times out in 2 seconds. BUG=b:72387533 BRANCH=none TEST=See 23746 "mb/google/fizz: Wait until display is ready" Change-Id: Ieee5db77bd6e147936ea8fc735dcbeffec98c0f8 Signed-off-by: Daisuke Nojiri Reviewed-on: https://review.coreboot.org/23745 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/ec/google/chromeec/ec.c | 24 ++++++++++++++++++++++++ src/ec/google/chromeec/ec.h | 1 + 2 files changed, 25 insertions(+) (limited to 'src/ec/google/chromeec') diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 7fc360af64..764c6ac74f 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "chip.h" #include "ec.h" @@ -984,3 +985,26 @@ int google_chromeec_pd_get_amode(uint16_t svid) return 0; } + +const static long wait_for_display_timeout_ms = 2000; + +#define USB_SID_DISPLAYPORT 0xff01 + +void google_chromeec_wait_for_display(void) +{ + struct stopwatch sw; + + printk(BIOS_INFO, "Waiting for display\n"); + stopwatch_init_msecs_expire(&sw, wait_for_display_timeout_ms); + while (google_chromeec_pd_get_amode(USB_SID_DISPLAYPORT) != 1) { + if (stopwatch_expired(&sw)) { + printk(BIOS_WARNING, + "Display not ready after %ldms. Abort.\n", + wait_for_display_timeout_ms); + return; + } + mdelay(200); + } + printk(BIOS_INFO, "Display ready after %lu ms\n", + stopwatch_duration_msecs(&sw)); +} diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 945e0b9891..1ff07b7117 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -37,6 +37,7 @@ bool google_chromeec_is_uhepi_supported(void); int google_ec_running_ro(void); void google_chromeec_init(void); int google_chromeec_pd_get_amode(uint16_t svid); +void google_chromeec_wait_for_display(void); /* Device events */ uint64_t google_chromeec_get_device_enabled_events(void); -- cgit v1.2.3