ec/google/chromeec: Update some PD and DisplayPort APIs
1. Update google_chromeec_pd_get_amode() to return bitmask. 2. Update google_chromeec_wait_for_displayport() to handle the updated return value of google_chromeec_pd_get_amode(). 3. Drop google_chromeec_pd_get_amode() from ec.h and make it static because it's not used outside of ec.c. BUG=b:192947843 Signed-off-by: Derek Huang <derek.huang@intel.corp-partner.google.com> Change-Id: I6020c4305e30018d4c97d862c16e8d642c951765 Reviewed-on: https://review.coreboot.org/c/coreboot/+/58058 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
f1f9b3d5f5
commit
c0f005a5d6
|
@ -1542,9 +1542,10 @@ int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags)
|
||||||
* Check if EC/TCPM is in an alternate mode or not.
|
* Check if EC/TCPM is in an alternate mode or not.
|
||||||
*
|
*
|
||||||
* @param svid SVID of the alternate mode to check
|
* @param svid SVID of the alternate mode to check
|
||||||
* @return 0: Not in the mode. -1: Error. 1: Yes.
|
* @return 0: Not in the mode. -1: Error.
|
||||||
|
* >=1: bitmask of the ports that are in the mode.
|
||||||
*/
|
*/
|
||||||
int google_chromeec_pd_get_amode(uint16_t svid)
|
static int google_chromeec_pd_get_amode(uint16_t svid)
|
||||||
{
|
{
|
||||||
struct ec_response_usb_pd_ports resp;
|
struct ec_response_usb_pd_ports resp;
|
||||||
struct chromeec_command cmd = {
|
struct chromeec_command cmd = {
|
||||||
|
@ -1557,6 +1558,7 @@ int google_chromeec_pd_get_amode(uint16_t svid)
|
||||||
.cmd_dev_index = 0,
|
.cmd_dev_index = 0,
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (google_chromeec_command(&cmd) < 0)
|
if (google_chromeec_command(&cmd) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1582,12 +1584,12 @@ int google_chromeec_pd_get_amode(uint16_t svid)
|
||||||
if (google_chromeec_command(&cmd) < 0)
|
if (google_chromeec_command(&cmd) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (resp2.svid == svid)
|
if (resp2.svid == svid)
|
||||||
return 1;
|
ret |= BIT(i);
|
||||||
svid_idx++;
|
svid_idx++;
|
||||||
} while (resp2.svid);
|
} while (resp2.svid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USB_SID_DISPLAYPORT 0xff01
|
#define USB_SID_DISPLAYPORT 0xff01
|
||||||
|
@ -1595,20 +1597,31 @@ int google_chromeec_pd_get_amode(uint16_t svid)
|
||||||
/**
|
/**
|
||||||
* Wait for DisplayPort to be ready
|
* Wait for DisplayPort to be ready
|
||||||
*
|
*
|
||||||
* @param timeout Wait aborts after <timeout> ms.
|
* @param timeout_ms Wait aborts after <timeout_ms> ms.
|
||||||
* @return 1: Success or 0: Timeout.
|
* @return -1: Error. 0: Timeout.
|
||||||
|
* >=1: Bitmask of the ports that DP device is connected
|
||||||
*/
|
*/
|
||||||
int google_chromeec_wait_for_displayport(long timeout)
|
int google_chromeec_wait_for_displayport(long timeout_ms)
|
||||||
{
|
{
|
||||||
struct stopwatch sw;
|
struct stopwatch sw;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
printk(BIOS_INFO, "Waiting for DisplayPort\n");
|
printk(BIOS_INFO, "Waiting for DisplayPort\n");
|
||||||
stopwatch_init_msecs_expire(&sw, timeout);
|
stopwatch_init_msecs_expire(&sw, timeout_ms);
|
||||||
while (google_chromeec_pd_get_amode(USB_SID_DISPLAYPORT) != 1) {
|
while (1) {
|
||||||
|
ret = google_chromeec_pd_get_amode(USB_SID_DISPLAYPORT);
|
||||||
|
if (ret > 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
printk(BIOS_ERR, "Can't get alternate mode!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (stopwatch_expired(&sw)) {
|
if (stopwatch_expired(&sw)) {
|
||||||
printk(BIOS_WARNING,
|
printk(BIOS_WARNING,
|
||||||
"DisplayPort not ready after %ldms. Abort.\n",
|
"DisplayPort not ready after %ldms. Abort.\n",
|
||||||
timeout);
|
timeout_ms);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mdelay(200);
|
mdelay(200);
|
||||||
|
@ -1616,7 +1629,7 @@ int google_chromeec_wait_for_displayport(long timeout)
|
||||||
printk(BIOS_INFO, "DisplayPort ready after %lu ms\n",
|
printk(BIOS_INFO, "DisplayPort ready after %lu ms\n",
|
||||||
stopwatch_duration_msecs(&sw));
|
stopwatch_duration_msecs(&sw));
|
||||||
|
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd)
|
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd)
|
||||||
|
|
|
@ -26,7 +26,6 @@ bool google_chromeec_is_uhepi_supported(void);
|
||||||
int google_ec_running_ro(void);
|
int google_ec_running_ro(void);
|
||||||
enum ec_image google_chromeec_get_current_image(void);
|
enum ec_image google_chromeec_get_current_image(void);
|
||||||
void google_chromeec_init(void);
|
void google_chromeec_init(void);
|
||||||
int google_chromeec_pd_get_amode(uint16_t svid);
|
|
||||||
/* Check for the current mux state in EC
|
/* Check for the current mux state in EC
|
||||||
* in: int port physical port number of the type-c port
|
* in: int port physical port number of the type-c port
|
||||||
* out: uint8_t flags representing the status of the mux such as
|
* out: uint8_t flags representing the status of the mux such as
|
||||||
|
@ -36,7 +35,11 @@ int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags);
|
||||||
/* Returns data role and type of device connected */
|
/* Returns data role and type of device connected */
|
||||||
int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc,
|
int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc,
|
||||||
bool *active_cable, uint8_t *dp_mode);
|
bool *active_cable, uint8_t *dp_mode);
|
||||||
int google_chromeec_wait_for_displayport(long timeout);
|
/* Poll (up to `timeout_ms` ms) for DisplayPort to be ready
|
||||||
|
* Return: -1: Error. 0: Timeout.
|
||||||
|
* >=1: Bitmask of the ports that DP device is connected
|
||||||
|
*/
|
||||||
|
int google_chromeec_wait_for_displayport(long timeout_ms);
|
||||||
|
|
||||||
/* Device events */
|
/* Device events */
|
||||||
uint64_t google_chromeec_get_device_enabled_events(void);
|
uint64_t google_chromeec_get_device_enabled_events(void);
|
||||||
|
|
Loading…
Reference in New Issue