ec/google/chromeec: Add API to check if charger is present
This patch introduces a new API, `google_chromeec_is_charger_present()`, to determine if a charger is connected. The API leverages the existing `ec_cmd_battery_get_dynamic()` command to retrieve battery flags and checks the `EC_BATT_FLAG_AC_PRESENT` flag to ascertain charger presence. Other components can leverage this API to query the charger status, which is particularly useful for distinguishing between barrel chargers and USB-C chargers after relying on the `google_chromeec_is_usb_pd_attached()` API. BUG=b:377798581 TEST=Able to read the charger status (w/ barrel and/or w/ USB-PD) correctly while booting google/fatcat. Change-Id: Iadf81400f71a51c093f71fe995cacc107c50c7af Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85758 Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com> Reviewed-by: Kapil Porwal <kapilporwal@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
56370d0283
commit
42fd35b486
2 changed files with 25 additions and 0 deletions
|
|
@ -985,6 +985,23 @@ bool google_chromeec_is_usb_pd_attached(void)
|
|||
return resp.type == USB_CHG_TYPE_PD;
|
||||
}
|
||||
|
||||
/* This API checks if charger is present. */
|
||||
bool google_chromeec_is_charger_present(void)
|
||||
{
|
||||
struct ec_params_battery_dynamic_info params = {
|
||||
.index = 0,
|
||||
};
|
||||
struct ec_response_battery_dynamic_info resp;
|
||||
|
||||
if (ec_cmd_battery_get_dynamic(PLAT_EC, ¶ms, &resp) == 0) {
|
||||
/* Check if AC charger is present */
|
||||
if (resp.flags & EC_BATT_FLAG_AC_PRESENT)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int google_chromeec_override_dedicated_charger_limit(uint16_t current_lim,
|
||||
uint16_t voltage_lim)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -140,6 +140,14 @@ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type,
|
|||
/* Check if a USB Power Delivery (PD) charger is attached */
|
||||
bool google_chromeec_is_usb_pd_attached(void);
|
||||
|
||||
/**
|
||||
* Check if charger is present.
|
||||
*
|
||||
* @return true: if the charger is present
|
||||
* false: if the charger is not present
|
||||
*/
|
||||
bool google_chromeec_is_charger_present(void);
|
||||
|
||||
/*
|
||||
* Set max current and voltage of a dedicated charger.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue