Commit d829dc75 authored by Chanwoo Choi's avatar Chanwoo Choi Committed by Anton Vorontsov

charger-manager: Poll battery health in normal state

Charger-Manager needs to check battery health in normal state
as well as suspend-to-RAM state. When the battery is fully charged,
Charger-Manager needs to determine when the chargers restart charging.

This patch allows Charger-Manager to monitor battery health in normal
state and handle operation for chargers after battery is fully charged.
Signed-off-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: default avatarDonggeun Kim <dg77.kim@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent 34298d40
...@@ -44,6 +44,12 @@ Charger Manager supports the following: ...@@ -44,6 +44,12 @@ Charger Manager supports the following:
Normally, the platform will need to resume and suspend some devices Normally, the platform will need to resume and suspend some devices
that are used by Charger Manager. that are used by Charger Manager.
* Support for premature full-battery event handling
If the battery voltage drops by "fullbatt_vchkdrop_uV" after
"fullbatt_vchkdrop_ms" from the full-battery event, the framework
restarts charging. This check is also performed while suspended by
setting wakeup time accordingly and using suspend_again.
2. Global Charger-Manager Data related with suspend_again 2. Global Charger-Manager Data related with suspend_again
======================================================== ========================================================
In order to setup Charger Manager with suspend-again feature In order to setup Charger Manager with suspend-again feature
...@@ -55,7 +61,7 @@ if there are multiple batteries. If there are multiple batteries, the ...@@ -55,7 +61,7 @@ if there are multiple batteries. If there are multiple batteries, the
multiple instances of Charger Manager share the same charger_global_desc multiple instances of Charger Manager share the same charger_global_desc
and it will manage in-suspend monitoring for all instances of Charger Manager. and it will manage in-suspend monitoring for all instances of Charger Manager.
The user needs to provide all the two entries properly in order to activate The user needs to provide all the three entries properly in order to activate
in-suspend monitoring: in-suspend monitoring:
struct charger_global_desc { struct charger_global_desc {
...@@ -74,6 +80,11 @@ bool (*rtc_only_wakeup)(void); ...@@ -74,6 +80,11 @@ bool (*rtc_only_wakeup)(void);
same struct. If there is any other wakeup source triggered the same struct. If there is any other wakeup source triggered the
wakeup, it should return false. If the "rtc" is the only wakeup wakeup, it should return false. If the "rtc" is the only wakeup
reason, it should return true. reason, it should return true.
bool assume_timer_stops_in_suspend;
: if true, Charger Manager assumes that
the timer (CM uses jiffies as timer) stops during suspend. Then, CM
assumes that the suspend-duration is same as the alarm length.
}; };
3. How to setup suspend_again 3. How to setup suspend_again
...@@ -111,6 +122,16 @@ enum polling_modes polling_mode; ...@@ -111,6 +122,16 @@ enum polling_modes polling_mode;
CM_POLL_CHARGING_ONLY: poll this battery if and only if the CM_POLL_CHARGING_ONLY: poll this battery if and only if the
battery is being charged. battery is being charged.
unsigned int fullbatt_vchkdrop_ms;
unsigned int fullbatt_vchkdrop_uV;
: If both have non-zero values, Charger Manager will check the
battery voltage drop fullbatt_vchkdrop_ms after the battery is fully
charged. If the voltage drop is over fullbatt_vchkdrop_uV, Charger
Manager will try to recharge the battery by disabling and enabling
chargers. Recharge with voltage drop condition only (without delay
condition) is needed to be implemented with hardware interrupts from
fuel gauges or charger devices/chips.
unsigned int fullbatt_uV; unsigned int fullbatt_uV;
: If specified with a non-zero value, Charger Manager assumes : If specified with a non-zero value, Charger Manager assumes
that the battery is full (capacity = 100) if the battery is not being that the battery is full (capacity = 100) if the battery is not being
...@@ -122,6 +143,8 @@ unsigned int polling_interval_ms; ...@@ -122,6 +143,8 @@ unsigned int polling_interval_ms;
this battery every polling_interval_ms or more frequently. this battery every polling_interval_ms or more frequently.
enum data_source battery_present; enum data_source battery_present;
: CM_BATTERY_PRESENT: assume that the battery exists.
CM_NO_BATTERY: assume that the battery does not exists.
CM_FUEL_GAUGE: get battery presence information from fuel gauge. CM_FUEL_GAUGE: get battery presence information from fuel gauge.
CM_CHARGER_STAT: get battery presence from chargers. CM_CHARGER_STAT: get battery presence from chargers.
......
This diff is collapsed.
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/power_supply.h> #include <linux/power_supply.h>
enum data_source { enum data_source {
CM_BATTERY_PRESENT,
CM_NO_BATTERY,
CM_FUEL_GAUGE, CM_FUEL_GAUGE,
CM_CHARGER_STAT, CM_CHARGER_STAT,
}; };
...@@ -38,11 +40,18 @@ enum polling_modes { ...@@ -38,11 +40,18 @@ enum polling_modes {
* rtc_only_wakeup() returning false. * rtc_only_wakeup() returning false.
* If the RTC given to CM is the only wakeup reason, * If the RTC given to CM is the only wakeup reason,
* rtc_only_wakeup should return true. * rtc_only_wakeup should return true.
* @assume_timer_stops_in_suspend:
* Assume that the jiffy timer stops in suspend-to-RAM.
* When enabled, CM does not rely on jiffies value in
* suspend_again and assumes that jiffies value does not
* change during suspend.
*/ */
struct charger_global_desc { struct charger_global_desc {
char *rtc_name; char *rtc_name;
bool (*rtc_only_wakeup)(void); bool (*rtc_only_wakeup)(void);
bool assume_timer_stops_in_suspend;
}; };
/** /**
...@@ -50,6 +59,11 @@ struct charger_global_desc { ...@@ -50,6 +59,11 @@ struct charger_global_desc {
* @psy_name: the name of power-supply-class for charger manager * @psy_name: the name of power-supply-class for charger manager
* @polling_mode: * @polling_mode:
* Determine which polling mode will be used * Determine which polling mode will be used
* @fullbatt_vchkdrop_ms:
* @fullbatt_vchkdrop_uV:
* Check voltage drop after the battery is fully charged.
* If it has dropped more than fullbatt_vchkdrop_uV after
* fullbatt_vchkdrop_ms, CM will restart charging.
* @fullbatt_uV: voltage in microvolt * @fullbatt_uV: voltage in microvolt
* If it is not being charged and VBATT >= fullbatt_uV, * If it is not being charged and VBATT >= fullbatt_uV,
* it is assumed to be full. * it is assumed to be full.
...@@ -76,6 +90,8 @@ struct charger_desc { ...@@ -76,6 +90,8 @@ struct charger_desc {
enum polling_modes polling_mode; enum polling_modes polling_mode;
unsigned int polling_interval_ms; unsigned int polling_interval_ms;
unsigned int fullbatt_vchkdrop_ms;
unsigned int fullbatt_vchkdrop_uV;
unsigned int fullbatt_uV; unsigned int fullbatt_uV;
enum data_source battery_present; enum data_source battery_present;
...@@ -101,6 +117,11 @@ struct charger_desc { ...@@ -101,6 +117,11 @@ struct charger_desc {
* @fuel_gauge: power_supply for fuel gauge * @fuel_gauge: power_supply for fuel gauge
* @charger_stat: array of power_supply for chargers * @charger_stat: array of power_supply for chargers
* @charger_enabled: the state of charger * @charger_enabled: the state of charger
* @fullbatt_vchk_jiffies_at:
* jiffies at the time full battery check will occur.
* @fullbatt_vchk_uV: voltage in microvolt
* criteria for full battery
* @fullbatt_vchk_work: work queue for full battery check
* @emergency_stop: * @emergency_stop:
* When setting true, stop charging * When setting true, stop charging
* @last_temp_mC: the measured temperature in milli-Celsius * @last_temp_mC: the measured temperature in milli-Celsius
...@@ -121,6 +142,10 @@ struct charger_manager { ...@@ -121,6 +142,10 @@ struct charger_manager {
bool charger_enabled; bool charger_enabled;
unsigned long fullbatt_vchk_jiffies_at;
unsigned int fullbatt_vchk_uV;
struct delayed_work fullbatt_vchk_work;
int emergency_stop; int emergency_stop;
int last_temp_mC; int last_temp_mC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment