ec/google/chromeec: Split wait-loop for DP and HPD flags
Split wait-loop for DP and HPD flags as below - - google_chromeec_wait_for_hpd - google_chromeec_wait_for_dp_mode_entry BUG=b:247670186 TEST=Verify display over TCSS and its impact on boot time for google/rex Signed-off-by: Kapil Porwal <kapilporwal@google.com> Change-Id: I3e565d6134f6433930916071e94d56d92dc6cb06 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76370 Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
1d85464df8
commit
2ba4b1bebe
@ -1383,15 +1383,29 @@ int google_chromeec_wait_for_displayport(long timeout_ms)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
|
/**
|
||||||
|
* Check for given flag in PD mux info for a port.
|
||||||
|
*
|
||||||
|
* @param port Type-C port number
|
||||||
|
* flag Flag to check
|
||||||
|
* @return 1: Flag is set. 0: Flag is not set.
|
||||||
|
*/
|
||||||
|
static int google_chromeec_check_mux_flag(int port, uint8_t flag)
|
||||||
|
{
|
||||||
|
uint8_t mux_flags = 0;
|
||||||
|
google_chromeec_usb_get_pd_mux_info(port, &mux_flags);
|
||||||
|
if ((mux_flags & flag) == flag)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int google_chromeec_wait_for_dp_mode_entry(int port, long timeout_ms)
|
||||||
{
|
{
|
||||||
uint8_t mux_flags;
|
|
||||||
struct stopwatch sw;
|
struct stopwatch sw;
|
||||||
|
|
||||||
if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY)) {
|
if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY)) {
|
||||||
google_chromeec_usb_get_pd_mux_info(port, &mux_flags);
|
if (!google_chromeec_check_mux_flag(port, USB_PD_MUX_DP_ENABLED)) {
|
||||||
if (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED)) {
|
printk(BIOS_WARNING, "DP mode entry is not ready. Abort.\n");
|
||||||
printk(BIOS_WARNING, "DP/HPD not ready. Abort.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,14 +1413,39 @@ int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_init_msecs_expire(&sw, timeout_ms);
|
stopwatch_init_msecs_expire(&sw, timeout_ms);
|
||||||
do {
|
while (!google_chromeec_check_mux_flag(port, USB_PD_MUX_DP_ENABLED)) {
|
||||||
google_chromeec_usb_get_pd_mux_info(port, &mux_flags);
|
if (stopwatch_expired(&sw)) {
|
||||||
|
printk(BIOS_WARNING, "DP not ready after %ldms. Abort.\n", timeout_ms);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mdelay(100);
|
||||||
|
}
|
||||||
|
printk(BIOS_INFO, "DP ready after %lld ms\n", stopwatch_duration_msecs(&sw));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int google_chromeec_wait_for_hpd(int port, long timeout_ms)
|
||||||
|
{
|
||||||
|
struct stopwatch sw;
|
||||||
|
|
||||||
|
if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY)) {
|
||||||
|
if (!google_chromeec_check_mux_flag(port, USB_PD_MUX_HPD_LVL)) {
|
||||||
|
printk(BIOS_WARNING, "HPD not ready. Abort.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stopwatch_init_msecs_expire(&sw, timeout_ms);
|
||||||
|
while (!google_chromeec_check_mux_flag(port, USB_PD_MUX_HPD_LVL)) {
|
||||||
if (stopwatch_expired(&sw)) {
|
if (stopwatch_expired(&sw)) {
|
||||||
printk(BIOS_WARNING, "HPD not ready after %ldms. Abort.\n", timeout_ms);
|
printk(BIOS_WARNING, "HPD not ready after %ldms. Abort.\n", timeout_ms);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mdelay(100);
|
mdelay(100);
|
||||||
} while (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED));
|
}
|
||||||
printk(BIOS_INFO, "HPD ready after %lld ms\n", stopwatch_duration_msecs(&sw));
|
printk(BIOS_INFO, "HPD ready after %lld ms\n", stopwatch_duration_msecs(&sw));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -38,10 +38,14 @@ int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags);
|
|||||||
* >=1: Bitmask of the ports that DP device is connected
|
* >=1: Bitmask of the ports that DP device is connected
|
||||||
*/
|
*/
|
||||||
int google_chromeec_wait_for_displayport(long timeout_ms);
|
int google_chromeec_wait_for_displayport(long timeout_ms);
|
||||||
|
/* Poll (up to `timeout_ms` ms) for the DP mode entry
|
||||||
|
* event on the specified port.
|
||||||
|
* Return: 0 on DP mode entry success, -1 on timeout */
|
||||||
|
int google_chromeec_wait_for_dp_mode_entry(int port, long timeout_ms);
|
||||||
/* Poll (up to `timeout_ms` ms) for a Hot-Plug Detect (HPD)
|
/* Poll (up to `timeout_ms` ms) for a Hot-Plug Detect (HPD)
|
||||||
* event on the specified port.
|
* event on the specified port.
|
||||||
* Return: 0 on HPD ready, -1 on timeout */
|
* Return: 0 on HPD ready, -1 on timeout */
|
||||||
int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms);
|
int google_chromeec_wait_for_hpd(int port, long timeout_ms);
|
||||||
/* Send command to EC to request to enter DisplayPort ALT mode on the
|
/* Send command to EC to request to enter DisplayPort ALT mode on the
|
||||||
* specified port.
|
* specified port.
|
||||||
* Return: 0 on success, -1 on error */
|
* Return: 0 on success, -1 on error */
|
||||||
|
@ -9,7 +9,8 @@ static const struct usbc_ops google_chromeec_usbc_ops = {
|
|||||||
.dp_ops = {
|
.dp_ops = {
|
||||||
.wait_for_connection = google_chromeec_wait_for_displayport,
|
.wait_for_connection = google_chromeec_wait_for_displayport,
|
||||||
.enter_dp_mode = google_chromeec_typec_control_enter_dp_mode,
|
.enter_dp_mode = google_chromeec_typec_control_enter_dp_mode,
|
||||||
.wait_for_hpd = google_chromeec_wait_for_dp_hpd,
|
.wait_for_dp_mode_entry = google_chromeec_wait_for_dp_mode_entry,
|
||||||
|
.wait_for_hpd = google_chromeec_wait_for_hpd,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,6 +54,15 @@ struct usbc_dp_ops {
|
|||||||
*/
|
*/
|
||||||
int (*enter_dp_mode)(int port);
|
int (*enter_dp_mode)(int port);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait up to `timeout_ms` for DP mode entry on a given port.
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* -1 = timeout
|
||||||
|
* 0 = success
|
||||||
|
*/
|
||||||
|
int (*wait_for_dp_mode_entry)(int port, long timeout_ms);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait up to `timeout_ms` for HPD on a given port.
|
* Wait up to `timeout_ms` for HPD on a given port.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user