From 509d7298256e9ea6f4e843d3e89747a64f53a5c9 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Wed, 8 Nov 2017 13:08:54 -0600 Subject: [PATCH] drivers/power/bq2429x.c: Add BATIO_OPRTN_SYSON for enabling BATFET after SYSOFF --- drivers/power/bq2429x.c | 25 +++++++++++++++++++++++++ include/nuttx/power/battery_ioctl.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/power/bq2429x.c b/drivers/power/bq2429x.c index 46bc65ebbb..c1fa4fa4e8 100644 --- a/drivers/power/bq2429x.c +++ b/drivers/power/bq2429x.c @@ -428,6 +428,27 @@ static int bq2429x_sysoff(FAR struct bq2429x_dev_s *priv) return ret; } +/**************************************************************************** + * Name: bq2429x_syson + * + * Description: + * Turn the internal battery FET on. + * + ****************************************************************************/ + +static int bq2429x_syson(FAR struct bq2429x_dev_s *priv) +{ + int ret; + uint8_t value = 0; + + ret = bq2429x_getreg8(priv, BQ2429X_REG07, &value, 1); + batdbg("REG7 read value: 0x%08X\n", value); + value &= ~BQ2429XR7_BATFET_DISABLE; + ret |= bq2429x_putreg8(priv, BQ2429X_REG07, value); + + return ret; +} + /**************************************************************************** * Name: bq2429x_en_term * @@ -1153,6 +1174,10 @@ static int bq2429x_operate(FAR struct battery_charger_dev_s *dev, ret = bq2429x_sysoff(priv); break; + case BATIO_OPRTN_SYSON: + ret = bq2429x_syson(priv); + break; + case BATIO_OPRTN_RESET: ret = bq2429x_reset(priv); break; diff --git a/include/nuttx/power/battery_ioctl.h b/include/nuttx/power/battery_ioctl.h index 3256f1c87f..bf61c093c3 100644 --- a/include/nuttx/power/battery_ioctl.h +++ b/include/nuttx/power/battery_ioctl.h @@ -85,6 +85,7 @@ enum batio_operate_e BATIO_OPRTN_EN_TERM, BATIO_OPRTN_HIZ, BATIO_OPRTN_SYSOFF, + BATIO_OPRTN_SYSON, BATIO_OPRTN_RESET, BATIO_OPRTN_WDOG, BATIO_OPRTN_END