Daisuke Nojiri has uploaded this change for review. ( https://review.coreboot.org/23801
Change subject: chromeec: Make google_chromeec_wait_for_display wait for HPD ......................................................................
chromeec: Make google_chromeec_wait_for_display wait for HPD
Some type-c monitors do not immediately assert HPD. If we continue to boot without HPD asserted, Depthcharge fails to show pictures on a monitor even if HPD is asserted later.
This patch makes google_chromeec_wait_for_display wait until EC_CMD_GET_HPD returns EC_RES_SUCCESS.
BUG=b:72387533 BRANCH=none TEST=Verify Depthcharge can show dev warning screen on a type-c monitor.
Change-Id: I07aee3bcca3bca93db66578014500b578402a4de Signed-off-by: Daisuke Nojiri dnojiri@chromium.org --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec_commands.h 2 files changed, 38 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/01/23801/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index c902c3f..1005266 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -986,7 +986,25 @@ return 0; }
-const static long wait_for_display_timeout_ms = 2000; +static int google_chromeec_get_hpd(void) +{ + struct chromeec_command cmd; + cmd.cmd_code = EC_CMD_GET_HPD; + cmd.cmd_version = 0; + cmd.cmd_data_in = NULL; + cmd.cmd_size_in = 0; + cmd.cmd_data_out = NULL; + cmd.cmd_size_out = 0; + cmd.cmd_dev_index = 0; + return google_chromeec_command(&cmd) == EC_RES_SUCCESS ? 1 : 0; +} + +/* + * TODO: If no monitor is plugged in or other monitor port (e.g. HDMI) is used, + * this timeout always needs to expire. Make EC detect type-c device presence + * and abort earlier when waiting does not make sense. + */ +const static long wait_for_display_timeout_ms = 3000;
#define USB_SID_DISPLAYPORT 0xff01
@@ -994,17 +1012,31 @@ { struct stopwatch sw;
- printk(BIOS_INFO, "Waiting for display\n"); + printk(BIOS_INFO, "Waiting for DisplayPort\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", + "DisplayPort not ready after %ldms. Abort.\n", wait_for_display_timeout_ms); return; } mdelay(200); } - printk(BIOS_INFO, "Display ready after %lu ms\n", + printk(BIOS_INFO, "DisplayPort ready after %lu ms\n", + stopwatch_duration_msecs(&sw)); + + printk(BIOS_INFO, "Waiting for HPD\n"); + stopwatch_init_msecs_expire(&sw, wait_for_display_timeout_ms); + while (!google_chromeec_get_hpd()) { + if (stopwatch_expired(&sw)) { + printk(BIOS_WARNING, + "HPD not ready after %ldms. Abort.\n", + wait_for_display_timeout_ms); + return; + } + mdelay(200); + } + printk(BIOS_INFO, "HPD ready after %lu ms\n", stopwatch_duration_msecs(&sw)); } diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h index 4f46fab..a5a5623 100644 --- a/src/ec/google/chromeec/ec_commands.h +++ b/src/ec/google/chromeec/ec_commands.h @@ -4420,6 +4420,8 @@ uint8_t data[]; /* For string and raw data */ };
+#define EC_CMD_GET_HPD 0x0121 + /*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */