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>
This commit is contained in:
parent
476c2c5808
commit
ebb86be9fc
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue