2011-05-01 13:02:46 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 by Amaury Pouly
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-11-19 22:12:42 +00:00
|
|
|
#include "system.h"
|
2011-07-23 11:45:22 +00:00
|
|
|
#include "powermgmt.h"
|
2011-11-14 21:45:25 +00:00
|
|
|
#include "power-imx233.h"
|
2011-12-31 18:43:59 +00:00
|
|
|
#include "usb.h"
|
2011-12-24 19:20:12 +00:00
|
|
|
#include "string.h"
|
|
|
|
//#define LOGF_ENABLE
|
|
|
|
#include "logf.h"
|
2013-11-19 22:12:42 +00:00
|
|
|
#include "powermgmt-imx233.h"
|
2011-07-23 11:45:22 +00:00
|
|
|
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
#include "regs/power.h"
|
|
|
|
|
2011-12-24 19:20:12 +00:00
|
|
|
#if !defined(IMX233_CHARGE_CURRENT) || !defined(IMX233_STOP_CURRENT) \
|
|
|
|
|| !defined(IMX233_CHARGING_TIMEOUT) || !defined(IMX233_TOPOFF_TIMEOUT)
|
|
|
|
#error You must define IMX233_CHARGE_CURRENT, IMX233_STOP_CURRENT, \
|
|
|
|
IMX233_CHARGING_TIMEOUT and IMX233_TOPOFF_TIMEOUT !
|
|
|
|
#endif
|
2011-09-13 23:40:06 +00:00
|
|
|
|
2011-12-24 19:20:12 +00:00
|
|
|
/* charger state is maintained in charge_state (see powermgmt.h) */
|
|
|
|
static int timeout_charging; /* timeout before charging will be declared broken */
|
|
|
|
static int timeout_topping_off; /* timeout before stopping charging after topping off */
|
|
|
|
static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit */
|
2011-09-13 23:40:06 +00:00
|
|
|
|
|
|
|
/* Returns battery voltage from ADC [millivolts] */
|
2012-01-03 23:44:38 +00:00
|
|
|
int _battery_voltage(void)
|
2011-09-13 23:40:06 +00:00
|
|
|
{
|
2011-11-14 21:45:25 +00:00
|
|
|
/* battery value is in 8mV LSB */
|
2013-06-16 15:16:48 +00:00
|
|
|
return BF_RD(POWER_BATTMONITOR, BATT_VAL) * 8;
|
2011-09-13 23:40:06 +00:00
|
|
|
}
|
|
|
|
|
2013-07-07 15:29:41 +00:00
|
|
|
void imx233_powermgmt_init(void)
|
2011-07-23 11:45:22 +00:00
|
|
|
{
|
2011-12-24 19:20:12 +00:00
|
|
|
imx233_power_set_charge_current(IMX233_CHARGE_CURRENT);
|
|
|
|
imx233_power_set_stop_current(IMX233_STOP_CURRENT);
|
2013-11-18 20:07:02 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3700
|
2011-12-24 19:20:12 +00:00
|
|
|
/* assume that adc_init was called and battery monitoring via LRADC setup */
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_BATTMONITOR, EN_BATADJ(1));
|
2013-07-07 15:29:41 +00:00
|
|
|
/* setup linear regulator offsets to 25 mV below to prevent contention between
|
|
|
|
* linear regulators and DCDC */
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_VDDDCTRL, LINREG_OFFSET(2));
|
|
|
|
BF_WR(POWER_VDDACTRL, LINREG_OFFSET(2));
|
|
|
|
BF_WR(POWER_VDDIOCTRL, LINREG_OFFSET(2));
|
2013-07-07 15:29:41 +00:00
|
|
|
/* enable a few bits controlling the DC-DC as recommended by Freescale */
|
|
|
|
BF_SET(POWER_LOOPCTRL, TOGGLE_DIF);
|
|
|
|
BF_SET(POWER_LOOPCTRL, EN_CM_HYST);
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_CS(POWER_LOOPCTRL, EN_RCSCALE(1));
|
2014-02-03 23:28:26 +00:00
|
|
|
#else
|
|
|
|
BF_SET(POWER_5VCTRL, LINREG_OFFSET);
|
2013-06-16 22:26:24 +00:00
|
|
|
#endif
|
2013-07-07 15:29:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void powermgmt_init_target(void)
|
|
|
|
{
|
2011-12-24 19:20:12 +00:00
|
|
|
charge_state = DISCHARGING;
|
2011-07-23 11:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void charging_algorithm_step(void)
|
|
|
|
{
|
2013-12-02 18:59:16 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3700
|
2011-12-31 18:43:59 +00:00
|
|
|
bool is_5v_present = usb_detect() == USB_INSERTED;
|
2011-12-24 19:20:12 +00:00
|
|
|
|
|
|
|
/* initial state & 5v -> battery transition */
|
|
|
|
if(!is_5v_present && charge_state != DISCHARGING)
|
|
|
|
{
|
|
|
|
logf("pwrmgmt: * -> discharging");
|
|
|
|
logf("pwrmgmt: disable charger and 4p2");
|
|
|
|
/* 5V has been lost: disable 4p2 power rail */
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_SET(POWER_CHARGE, PWD_BATTCHRG);
|
2013-12-01 22:37:36 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3780
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_DCDC4P2, ENABLE_DCDC(0));
|
|
|
|
BF_WR(POWER_DCDC4P2, ENABLE_4P2(0));
|
|
|
|
BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT(1));
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2);
|
2013-12-01 22:37:36 +00:00
|
|
|
#endif
|
2011-12-24 19:20:12 +00:00
|
|
|
charge_state = DISCHARGING;
|
|
|
|
}
|
|
|
|
/* battery -> 5v transition */
|
|
|
|
else if(is_5v_present && charge_state == DISCHARGING)
|
|
|
|
{
|
|
|
|
logf("pwrmgmt: discharging -> trickle");
|
|
|
|
logf("pwrmgmt: begin charging 4p2");
|
2013-12-01 22:37:36 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3780
|
2014-02-03 23:28:26 +00:00
|
|
|
/* 5V has been detected: prepare 4.2V power rail for activation
|
|
|
|
* WARNING we can reach this situation when starting after Freescale bootloader
|
|
|
|
* or after RoLo in a state where the DCDC is running. In this case,
|
|
|
|
* we must *NOT* disable it or this will shutdown the device. This procedure
|
|
|
|
* is safe: it will never disable the DCDC and will not reduce the charge
|
|
|
|
* limit on the 4P2 rail. */
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_DCDC4P2, ENABLE_4P2(1));
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_SET(POWER_CHARGE, ENABLE_LOAD);
|
2016-05-02 20:14:11 +00:00
|
|
|
BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT(1)); /* start by drawing 10mA only */
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2);// FIXME: manual error ?
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_DCDC4P2, ENABLE_DCDC(1));
|
2013-12-01 22:37:36 +00:00
|
|
|
#endif
|
2011-12-24 19:20:12 +00:00
|
|
|
timeout_4p2_ilimit_increase = current_tick + HZ / 100;
|
|
|
|
charge_state = TRICKLE;
|
|
|
|
}
|
|
|
|
else if(charge_state == TRICKLE && TIME_AFTER(current_tick, timeout_4p2_ilimit_increase))
|
|
|
|
{
|
2013-12-01 22:37:36 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3780
|
2011-12-24 19:20:12 +00:00
|
|
|
/* if 4.2V current limit has not reached 780mA, increase it slowly to
|
|
|
|
* charge the 4.2V capacitance */
|
2013-06-16 15:16:48 +00:00
|
|
|
if(BF_RD(POWER_5VCTRL, CHARGE_4P2_ILIMIT) != 0x3f)
|
2011-12-24 19:20:12 +00:00
|
|
|
{
|
|
|
|
//logf("pwrmgmt: incr 4.2 ilimit");
|
2013-06-16 15:16:48 +00:00
|
|
|
HW_POWER_5VCTRL += BF_POWER_5VCTRL_CHARGE_4P2_ILIMIT(1);
|
2011-12-24 19:20:12 +00:00
|
|
|
timeout_4p2_ilimit_increase = current_tick + HZ / 100;
|
|
|
|
}
|
|
|
|
/* we've reached the maximum, take action */
|
|
|
|
else
|
2013-12-01 22:37:36 +00:00
|
|
|
#endif
|
2011-12-24 19:20:12 +00:00
|
|
|
{
|
|
|
|
logf("pwrmgmt: enable dcdc and charger");
|
|
|
|
logf("pwrmgmt: trickle -> charging");
|
2014-02-03 23:28:26 +00:00
|
|
|
#if IMX233_SUBTARGET >= 3780
|
|
|
|
/* adjust arbitration between 4.2 and battery */
|
imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.
The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
its equivalent for BF_WR(reg_SET, ...)
I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".
Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml
Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-24 19:29:56 +00:00
|
|
|
BF_WR(POWER_DCDC4P2, CMPTRIP(0)); /* 85% */
|
|
|
|
BF_WR(POWER_DCDC4P2, DROPOUT_CTRL(0xe)); /* select greater, 200 mV drop */
|
2014-02-03 23:28:26 +00:00
|
|
|
#endif
|
|
|
|
/* switch to DCDC */
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_CLR(POWER_5VCTRL, DCDC_XFER);
|
|
|
|
BF_SET(POWER_5VCTRL, ENABLE_DCDC);
|
2011-12-24 19:20:12 +00:00
|
|
|
/* enable battery charging */
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_CLR(POWER_CHARGE, PWD_BATTCHRG);
|
2011-12-24 19:20:12 +00:00
|
|
|
charge_state = CHARGING;
|
|
|
|
timeout_charging = current_tick + IMX233_CHARGING_TIMEOUT;
|
|
|
|
}
|
|
|
|
}
|
2016-05-02 20:14:11 +00:00
|
|
|
/* charging -> error transition */
|
2011-12-24 19:20:12 +00:00
|
|
|
else if(charge_state == CHARGING && TIME_AFTER(current_tick, timeout_charging))
|
|
|
|
{
|
|
|
|
/* we have charged for a too long time, declare charger broken */
|
|
|
|
logf("pwrmgmt: charging timeout exceeded!");
|
|
|
|
logf("pwrmgmt: charging -> error");
|
2016-05-02 20:14:11 +00:00
|
|
|
/* stop charging, note that we leave the 4.2 rail active so that the DCDC
|
|
|
|
* keep drawing current from the 4.2 only and leave the battery untouched */
|
2013-12-01 22:37:36 +00:00
|
|
|
BF_SET(POWER_CHARGE, PWD_BATTCHRG);
|
2011-12-24 19:20:12 +00:00
|
|
|
/* goto error state */
|
|
|
|
charge_state = CHARGE_STATE_ERROR;
|
|
|
|
}
|
2016-05-02 20:14:11 +00:00
|
|
|
/* charging -> topoff transition */
|
2013-06-16 15:16:48 +00:00
|
|
|
else if(charge_state == CHARGING && !BF_RD(POWER_STS, CHRGSTS))
|
2011-12-24 19:20:12 +00:00
|
|
|
{
|
|
|
|
logf("pwrmgmt: topping off");
|
|
|
|
logf("pwrmgmt: charging -> topoff");
|
|
|
|
charge_state = TOPOFF;
|
|
|
|
timeout_topping_off = current_tick + IMX233_TOPOFF_TIMEOUT;
|
|
|
|
}
|
2016-05-02 20:14:11 +00:00
|
|
|
/* topoff -> disabled transition */
|
2011-12-24 19:20:12 +00:00
|
|
|
else if(charge_state == TOPOFF && TIME_AFTER(current_tick, timeout_topping_off))
|
|
|
|
{
|
|
|
|
logf("pwrmgmt: charging finished");
|
|
|
|
logf("pwrmgmt: topoff -> disabled");
|
2016-05-02 20:14:11 +00:00
|
|
|
/* stop charging, note that we leave the 4.2 rail active so that the DCDC
|
|
|
|
* keep drawing current from the 4.2 only and leave the battery untouched */
|
2013-06-16 15:16:48 +00:00
|
|
|
BF_SET(POWER_CHARGE, PWD_BATTCHRG);
|
2011-12-24 19:20:12 +00:00
|
|
|
charge_state = CHARGE_STATE_DISABLED;
|
|
|
|
}
|
2013-12-02 18:59:16 +00:00
|
|
|
#endif
|
2011-07-23 11:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void charging_algorithm_close(void)
|
|
|
|
{
|
|
|
|
}
|
2011-12-24 19:20:12 +00:00
|
|
|
|
|
|
|
struct imx233_powermgmt_info_t imx233_powermgmt_get_info(void)
|
|
|
|
{
|
|
|
|
struct imx233_powermgmt_info_t info;
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.state = charge_state;
|
|
|
|
info.charging_timeout =
|
|
|
|
charge_state == CHARGING ? timeout_charging - current_tick : 0;
|
|
|
|
info.topoff_timeout =
|
|
|
|
charge_state == TOPOFF ? timeout_topping_off - current_tick : 0;
|
|
|
|
info.incr_4p2_ilimit_timeout =
|
|
|
|
charge_state == TRICKLE ? timeout_4p2_ilimit_increase - current_tick : 0;
|
|
|
|
return info;
|
|
|
|
}
|