diff options
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); |