Joey Peng has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/78262?usp=email )
Change subject: mb/google/dedede/var/boxy: Add wait for HPD function ......................................................................
mb/google/dedede/var/boxy: Add wait for HPD function
Boxy project need to wait for HPD ready to continue boot in ramstage to avoid no display in DEV screen and recovery screen
BUG=b:303346324 TEST=Both type-c ports can display in DEV screen and recovery screen
Signed-off-by: Joey Peng joey.peng@lcfc.corp-partner.google.com Change-Id: I208fdf8234886b2ef43a4b972e6682892238e8e9 --- M src/mainboard/google/dedede/variants/boxy/ramstage.c 1 file changed, 45 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/78262/1
diff --git a/src/mainboard/google/dedede/variants/boxy/ramstage.c b/src/mainboard/google/dedede/variants/boxy/ramstage.c index c317d3b..2700c8e 100644 --- a/src/mainboard/google/dedede/variants/boxy/ramstage.c +++ b/src/mainboard/google/dedede/variants/boxy/ramstage.c @@ -1,7 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <bootmode.h> +#include <baseboard/gpio.h> #include <baseboard/variants.h> +#include <console/console.h> +#include <delay.h> +#include <ec/google/chromeec/ec.h> +#include <gpio.h> +#include <intelblocks/gpio.h> +#include <timer.h>
+#define GPIO_USB_C0_HPD GPP_B23 +#define GPIO_USB_C1_HPD GPP_A16 /* * Psys_pmax considerations * @@ -22,6 +32,25 @@ * and the Psys_pmax setting is 120W. Then IMVP9.1 can calculate the current system * power = 120W * 5A / 6.009A = 100W, which is the actual system power. */ + +static void wait_for_hpd(gpio_t gpio, long timeout) +{ + struct stopwatch sw; + + printk(BIOS_INFO, "Waiting for HPD\n"); + stopwatch_init_msecs_expire(&sw, timeout); + while (!gpio_get(gpio)) { + if (stopwatch_expired(&sw)) { + printk(BIOS_WARNING, + "HPD not ready after %ldms. Abort.\n", timeout); + return; + } + mdelay(200); + } + printk(BIOS_INFO, "HPD ready after %ld ms\n", + stopwatch_duration_msecs(&sw)); +} + const struct psys_config psys_config = { .efficiency = 97, .psys_imax_ma = 6009, @@ -31,5 +60,21 @@
void variant_devtree_update(void) { + static const long display_timeout_ms = 3000; + + if (display_init_required() + && !gpio_get(GPIO_USB_C0_HPD)) { + /* This has to be done before FSP-S runs. */ + if (google_chromeec_wait_for_displayport(display_timeout_ms)){ + wait_for_hpd(GPIO_USB_C0_HPD, display_timeout_ms); + } + } + else if (display_init_required() + && !gpio_get(GPIO_USB_C1_HPD)) { + /* This has to be done before FSP-S runs. */ + if (google_chromeec_wait_for_displayport(display_timeout_ms)){ + wait_for_hpd(GPIO_USB_C1_HPD, display_timeout_ms); + } + } variant_update_psys_power_limits(&psys_config); }