Karthik Ramasubramanian has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83735?usp=email )
Change subject: ec/google/chromeec: Add is_battery_present() ......................................................................
ec/google/chromeec: Add is_battery_present()
This patch adds is_battery_present() to check if the battery is physically present
BUG=b:335046538,b:329722827 TEST=Build Brox and check is_battery_present returns the correct battery status.
Change-Id: Ie49ed8f6d8b0fa59ec0e7b06efea9cac4d253957 Signed-off-by: Sowmya Aralguppe sowmya.aralguppe@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/83735 Reviewed-by: Caveh Jalali caveh@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Karthik Ramasubramanian kramasub@google.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h 2 files changed, 24 insertions(+), 0 deletions(-)
Approvals: Caveh Jalali: Looks good to me, approved Karthik Ramasubramanian: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 088f2fe..2ef2ea9 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1566,3 +1566,19 @@
return false; } + +bool google_chromeec_is_battery_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 battery is present */ + if (resp.flags & EC_BATT_FLAG_BATT_PRESENT) + return true; + } + + return false; +} diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 0062df6..20b508c 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -425,6 +425,14 @@ bool google_chromeec_is_battery_present_and_above_critical_threshold(void);
/** + * Check if battery is present. + * + * @return true: if the battery is present + * false: if the battery is not present + */ +bool google_chromeec_is_battery_present(void); + +/** * Determine if the UCSI stack is currently active. * * @return true if EC implements the UCSI stack