summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2021-05-17 20:20:31 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-19 20:26:17 +0000
commit477dda563e0ee3bb831ebb8883cb72903bbb8141 (patch)
treec431526540fb66b4993a4c47ee16f91e04b88a65
parentdef759427d9bc1781e7b23a536694fd0ab8bb01f (diff)
downloadchrome-ec-477dda563e0ee3bb831ebb8883cb72903bbb8141.tar.gz
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 <aaboagye@google.com> Change-Id: Iacff19542587d102798c645d66a0ea15aaa51439 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2901252 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/charger/isl923x.c17
-rw-r--r--driver/charger/isl923x.h1
-rw-r--r--include/driver/charger/isl923x_public.h10
3 files changed, 28 insertions, 0 deletions
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, &regval);
+ 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)
@@ -38,6 +39,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
* battery only mode.