summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@google.com>2022-10-13 08:28:44 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 01:33:38 +0000
commit56dd0dc9e1ba7259b81b1620acb8ef16178b5bca (patch)
treec9f3ad260d80dbe70404f4c47910dde2dc887168
parent87b811257a46409020535545ab7913f9c4189298 (diff)
downloadchrome-ec-stabilize-15185.B-main.tar.gz
Revert "rt9490: remove set_mode function"stabilize-15185.B-mainstabilize-15185.7.B-main
This reverts commit 48ed43a6f372ea3588ccc7e14ff5da1501050216. Reason for revert: charger_task need set_mode function to prevent error. Original change's description: > rt9490: remove set_mode function > > The flags we implemented is not used anywhere in the codebase. > > BUG=none > TEST=zmake > BRANCH=none > > Signed-off-by: Ting Shen <phoenixshen@google.com> > Change-Id: I72b01806463aec903b1bfe23bb1c12a58a97265d > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896556 > Tested-by: Ting Shen <phoenixshen@chromium.org> > Reviewed-by: Eric Yilun Lin <yllin@google.com> > Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> > Commit-Queue: Ting Shen <phoenixshen@chromium.org> Bug: none Change-Id: I5a3942111dbe2e707c34f79a7e5d170be635d69e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949076 Reviewed-by: Sung-Chi Li <lschyi@chromium.org> Auto-Submit: Eric Yilun Lin <yllin@google.com> Code-Coverage: Sung-Chi Li <lschyi@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
-rw-r--r--driver/charger/rt9490.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/driver/charger/rt9490.c b/driver/charger/rt9490.c
index 9a6e8b301a..14b8449d35 100644
--- a/driver/charger/rt9490.c
+++ b/driver/charger/rt9490.c
@@ -231,6 +231,15 @@ static int rt9490_is_sourcing_otg_power(int chgnum, int port)
}
#endif
+/* Reset all registers' value to default */
+static int rt9490_reset_chip(int chgnum)
+{
+ /* disable hz before reset chip */
+ RETURN_ERROR(rt9490_enable_hz(chgnum, false));
+
+ return rt9490_set_bit(chgnum, RT9490_REG_EOC_CTRL, RT9490_RST_ALL_MASK);
+}
+
static inline int rt9490_enable_chgdet_flow(int chgnum, bool en)
{
return rt9490_update8(chgnum, RT9490_REG_CHG_CTRL2, RT9490_BC12_EN,
@@ -381,6 +390,24 @@ static enum ec_error_list rt9490_get_status(int chgnum, int *status)
return EC_SUCCESS;
}
+static int rt9490_reset_to_zero(int chgnum)
+{
+ RETURN_ERROR(rt9490_set_current(chgnum, 0));
+ RETURN_ERROR(rt9490_set_voltage(chgnum, 0));
+ RETURN_ERROR(rt9490_enable_hz(chgnum, true));
+
+ return EC_SUCCESS;
+}
+
+static enum ec_error_list rt9490_set_mode(int chgnum, int mode)
+{
+ if (mode & CHARGE_FLAG_POR_RESET)
+ RETURN_ERROR(rt9490_reset_chip(chgnum));
+ if (mode & CHARGE_FLAG_RESET_TO_ZERO)
+ RETURN_ERROR(rt9490_reset_to_zero(chgnum));
+ return EC_SUCCESS;
+}
+
static enum ec_error_list rt9490_get_actual_current(int chgnum, int *current)
{
uint16_t reg_val;
@@ -541,6 +568,7 @@ const struct charger_drv rt9490_drv = {
.init = &rt9490_init,
.get_info = &rt9490_get_info,
.get_status = &rt9490_get_status,
+ .set_mode = &rt9490_set_mode,
#ifdef CONFIG_CHARGER_OTG
.enable_otg_power = &rt9490_enable_otg_power,
.set_otg_current_voltage = &rt9490_set_otg_current_voltage,