ec/google/chromeec: Add API to check if a USB PD charger is attached
This change introduces a new API, `google_chromeec_is_usb_pd_attached()` which checks the current status of the USB-C port and returns whether a USB Power Delivery (PD) charger is currently connected. This API is useful for determining if the system is currently being powered by a PD charger. BUG=b:377798581 TEST=Able to read the PD status correctly while booting google/fatcat. Change-Id: I47c934ee8a7563d4ba5124bff5613e61dd66e923 Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85743 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
parent
001e7a0b45
commit
56370d0283
2 changed files with 22 additions and 0 deletions
|
|
@ -966,6 +966,25 @@ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This API checks the current status of the USB-C port and returns
|
||||
* whether a USB Power Delivery (PD) charger is currently connected.
|
||||
*/
|
||||
bool google_chromeec_is_usb_pd_attached(void)
|
||||
{
|
||||
const struct ec_params_usb_pd_power_info params = {
|
||||
.port = PD_POWER_CHARGING_PORT,
|
||||
};
|
||||
struct ec_response_usb_pd_power_info resp = {};
|
||||
int rv;
|
||||
|
||||
rv = ec_cmd_usb_pd_power_info(PLAT_EC, ¶ms, &resp);
|
||||
if (rv != 0)
|
||||
return false;
|
||||
|
||||
return resp.type == USB_CHG_TYPE_PD;
|
||||
}
|
||||
|
||||
int google_chromeec_override_dedicated_charger_limit(uint16_t current_lim,
|
||||
uint16_t voltage_lim)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ int google_chromeec_set_usb_pd_role(uint8_t port, enum usb_pd_control_role role)
|
|||
int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type,
|
||||
uint16_t *current_max, uint16_t *voltage_max);
|
||||
|
||||
/* Check if a USB Power Delivery (PD) charger is attached */
|
||||
bool google_chromeec_is_usb_pd_attached(void);
|
||||
|
||||
/*
|
||||
* Set max current and voltage of a dedicated charger.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue