From 9239f343bc9bf69aac3cf6438a4d34ba3e578a7e Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Fri, 24 Feb 2023 11:28:42 +0800 Subject: geralt: disable RT9490 ADC on AC off The RT9490 ADC is used as IBUS ADC, so this is not needed when there's no AC coming from the port. Disable it when AC is off. BUG=b:269708282 TEST=unplug power, in G3. $ dut-power -t 60 | grep @@ BRANCH=none LOW_COVERAGE_REASON=geralt early bringup Change-Id: I5dacd383420f942aa863b45a4e70d858fa7ac1f3 Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290092 Auto-Submit: Eric Yilun Lin Reviewed-by: Ting Shen Tested-by: Alvis Hsu Tested-by: Eric Yilun Lin Commit-Queue: Ting Shen --- zephyr/program/geralt/src/hooks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zephyr/program/geralt/src/hooks.c b/zephyr/program/geralt/src/hooks.c index bc21babe66..fd106732ae 100644 --- a/zephyr/program/geralt/src/hooks.c +++ b/zephyr/program/geralt/src/hooks.c @@ -3,6 +3,9 @@ * found in the LICENSE file. */ +#include "charger.h" +#include "driver/charger/rt9490.h" +#include "extpower.h" #include "gpio/gpio_int.h" #include "gpio_signal.h" #include "hooks.h" @@ -85,3 +88,10 @@ static int install_suspend_handler(const struct device *unused) } SYS_INIT(install_suspend_handler, APPLICATION, 1); + +static void board_hook_ac_change(void) +{ + 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); -- cgit v1.2.1