summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2022-04-12 16:05:58 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-13 09:13:04 +0000
commitb0e0f785f5ea0130da531008d6c801ef4d0c5385 (patch)
tree1e47ab389a2ab56a2b90662c8a1b3b3c7e812bbd
parent82b4173c6c34a9194a103fe2280c0d19b74f1738 (diff)
downloadchrome-ec-stabilize-14695.85.B-main.tar.gz
To save G3 power as suggested in b:228574354 BUG=b:228574354 TEST=measure G3 power BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I4862a10c025289ce75471bb105a68819d4147374 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3583742 Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--driver/charger/rt9490.c2
-rw-r--r--driver/charger/rt9490.h4
-rw-r--r--zephyr/projects/corsola/src/krabby/hooks.c12
3 files changed, 17 insertions, 1 deletions
diff --git a/driver/charger/rt9490.c b/driver/charger/rt9490.c
index e2d2b76b0b..e3eee4ebad 100644
--- a/driver/charger/rt9490.c
+++ b/driver/charger/rt9490.c
@@ -264,7 +264,7 @@ static inline int rt9490_enable_jeita(int chgnum, bool en)
en ? MASK_CLR : MASK_SET);
}
-static inline int rt9490_enable_adc(int chgnum, bool en)
+int rt9490_enable_adc(int chgnum, bool en)
{
return rt9490_update8(chgnum, RT9490_REG_ADC_CTRL, RT9490_ADC_EN,
en ? MASK_SET : MASK_CLR);
diff --git a/driver/charger/rt9490.h b/driver/charger/rt9490.h
index 0ea7746d8e..a6ace8c1eb 100644
--- a/driver/charger/rt9490.h
+++ b/driver/charger/rt9490.h
@@ -4,6 +4,8 @@
*
* Richtek 5A 1-4 cell buck-boost switching battery charger driver.
*/
+#include <stdbool.h>
+
#ifndef __CROS_EC_RT9490_H
#define __CROS_EC_RT9490_H
@@ -241,4 +243,6 @@ extern const struct bc12_drv rt9490_bc12_drv;
void rt9490_interrupt(int port);
+int rt9490_enable_adc(int chgnum, bool en);
+
#endif /* __CROS_EC_RT9490_H */
diff --git a/zephyr/projects/corsola/src/krabby/hooks.c b/zephyr/projects/corsola/src/krabby/hooks.c
index 1cc9b82219..e91993be10 100644
--- a/zephyr/projects/corsola/src/krabby/hooks.c
+++ b/zephyr/projects/corsola/src/krabby/hooks.c
@@ -7,6 +7,9 @@
#include <drivers/gpio.h>
#include <ap_power/ap_power.h>
+#include "charger.h"
+#include "driver/charger/rt9490.h"
+#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -76,3 +79,12 @@ static int install_suspend_handler(const struct device *unused)
}
SYS_INIT(install_suspend_handler, APPLICATION, 1);
+
+static void board_hook_ac_change(void)
+{
+ if (system_get_board_version() >= 1) {
+ rt9490_enable_adc(CHARGER_SOLO, extpower_is_present());
+ }
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, board_hook_ac_change, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, board_hook_ac_change, HOOK_PRIO_LAST);