From 477dda563e0ee3bb831ebb8883cb72903bbb8141 Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Mon, 17 May 2021 20:20:31 -0700 Subject: raa489000: Add raa489000_is_acok() This commit adds a function to return the status of the ACOK pin in FW. BUG=b:187965740 BRANCH=dedede TEST=Build and flash madoo, verify that "AC on" is on printed when we actually decide to charge from a port and not just when VBUS is present. Signed-off-by: Aseda Aboagye Change-Id: Iacff19542587d102798c645d66a0ea15aaa51439 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2901252 Tested-by: Aseda Aboagye Reviewed-by: Diana Z Commit-Queue: Aseda Aboagye --- driver/charger/isl923x.c | 17 +++++++++++++++++ driver/charger/isl923x.h | 1 + include/driver/charger/isl923x_public.h | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index b918cec8a4..9e3284c29f 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -797,6 +797,23 @@ out: } #ifdef CONFIG_CHARGER_RAA489000 +enum ec_error_list raa489000_is_acok(int chgnum, bool *acok) +{ + int regval, rv; + + if ((chgnum < 0) || (chgnum > board_get_charger_chip_count())) { + CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum); + return EC_ERROR_INVAL; + } + + rv = raw_read16(chgnum, ISL9238_REG_INFO2, ®val); + if (rv != EC_SUCCESS) + return rv; + *acok = (regval & RAA489000_INFO2_ACOK); + + return EC_SUCCESS; +} + int raa489000_enable_asgate(int chgnum, bool enable) { enum mask_update_action action = enable ? MASK_SET : MASK_CLR; diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h index 1ab0973b03..558c17f971 100644 --- a/driver/charger/isl923x.h +++ b/driver/charger/isl923x.h @@ -294,6 +294,7 @@ #define ISL923X_INFO_TRICKLE_ACTIVE_MASK BIT(4) #define ISL9237_INFO_PSTATE_SHIFT 5 #define ISL9237_INFO_PSTATE_MASK 3 +#define RAA489000_INFO2_ACOK BIT(14) /* ADC registers */ #define RAA489000_REG_ADC_INPUT_CURRENT 0x83 diff --git a/include/driver/charger/isl923x_public.h b/include/driver/charger/isl923x_public.h index d8cc9cf662..2ee5f62cdb 100644 --- a/include/driver/charger/isl923x_public.h +++ b/include/driver/charger/isl923x_public.h @@ -8,6 +8,7 @@ #ifndef __CROS_EC_DRIVER_CHARGER_ISL923X_PUBLIC_H #define __CROS_EC_DRIVER_CHARGER_ISL923X_PUBLIC_H +#include "common.h" #include "stdbool.h" #define ISL923X_ADDR_FLAGS (0x09) @@ -37,6 +38,15 @@ int isl923x_set_dc_prochot(int chgnum, uint16_t ma); */ int isl923x_set_comparator_inversion(int chgnum, int invert); +/** + * Return whether ACOK is high or low. + * + * @param chgnum index into chg_chips table. + * @param acok will be set to true if ACOK is asserted, otherwise false. + * @return EC_SUCCESS, error otherwise. + */ +enum ec_error_list raa489000_is_acok(int chgnum, bool *acok); + /** * Prepare the charger IC for battery ship mode. Battery ship mode sets the * lowest power state for the IC. Battery ship mode can only be entered from -- cgit v1.2.1