diff options
-rw-r--r-- | driver/charger/rt9490.c | 2 | ||||
-rw-r--r-- | driver/charger/rt9490.h | 4 | ||||
-rw-r--r-- | zephyr/projects/corsola/src/krabby/hooks.c | 12 |
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); |