diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-01-26 17:36:44 -0800 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2018-02-17 04:00:26 +0000 |
commit | ebb86be9fcaf64daa71e8ee3bff52c6982708a23 (patch) | |
tree | 565568e3bf50e7ce7e453c12a3f9d573fb8dad4f /src/ec | |
parent | 476c2c5808a77508f31d47ce871c32a97c6e6eeb (diff) |
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 <dnojiri@chromium.org>
Reviewed-on: https://review.coreboot.org/23745
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/ec')
-rw-r--r-- | src/ec/google/chromeec/ec.c | 24 | ||||
-rw-r--r-- | src/ec/google/chromeec/ec.h | 1 |
2 files changed, 25 insertions, 0 deletions
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 <rtc.h> #include <stdlib.h> #include <security/vboot/vboot_common.h> +#include <timer.h> #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); |