power: pmic8058-charger: api to get fsm state
Implement an api to return the pmic internal charging state. Now that we have a enum to define the states, replace the hard-coded state numbers to enum values. CRs-Fixed: 299629 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
committed by
Bryan Huntsman
parent
e1fd3dae5d
commit
f734c67fa1
@@ -26,6 +26,7 @@
|
||||
#include <linux/msm_adc.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/pmic8058-batt-alarm.h>
|
||||
#include <linux/pmic8058-charger.h>
|
||||
|
||||
#include <mach/msm_xo.h>
|
||||
#include <mach/msm_hsusb.h>
|
||||
@@ -574,6 +575,16 @@ static int get_fsm_status(void *data, u64 * val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum pmic8058_chg_state pmic8058_get_fsm_state(void)
|
||||
{
|
||||
if (!pm8058_chg.inited) {
|
||||
pr_err("%s: called when not inited\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return get_fsm_state();
|
||||
}
|
||||
|
||||
static int pm_chg_disable(int value)
|
||||
{
|
||||
u8 temp;
|
||||
@@ -720,9 +731,9 @@ static void charging_check_work(struct work_struct *work)
|
||||
|
||||
switch (fsm_state) {
|
||||
/* We're charging, so disarm alarm */
|
||||
case 2:
|
||||
case 7:
|
||||
case 8:
|
||||
case PMIC8058_CHG_STATE_ATC:
|
||||
case PMIC8058_CHG_STATE_FAST_CHG:
|
||||
case PMIC8058_CHG_STATE_TRKL_CHG:
|
||||
rc = pm8058_batt_alarm_state_set(0, 0);
|
||||
if (rc)
|
||||
dev_err(pm8058_chg.dev,
|
||||
|
||||
@@ -12,10 +12,61 @@
|
||||
|
||||
#ifndef __PMIC8058_CHARGER_H__
|
||||
#define __PMIC8058_CHARGER_H__
|
||||
/**
|
||||
* enum pmic8058_chg_state - pmic8058 charging states
|
||||
* @PMIC8058_CHG_STATE_NONE: Initial off state
|
||||
* @PMIC8058_CHG_STATE_PWR_CHG: Device powered from charger
|
||||
* @PMIC8058_CHG_STATE_ATC: Device is Auto Tricke Charged (ATC)
|
||||
* @PMIC8058_CHG_STATE_PWR_BAT: Device powered from Battery
|
||||
* @PMIC8058_CHG_STATE_ATC_FAIL: ATC failed
|
||||
* @PMIC8058_CHG_STATE_AUX_EN: Transient state
|
||||
* @PMIC8058_CHG_STATE_PON_AFTER_ATC: Power on from battery and chg with limit
|
||||
* of 90mA
|
||||
* @PMIC8058_CHG_STATE_FAST_CHG: pmic is fast charging the battery
|
||||
* @PMIC8058_CHG_STATE_TRKL_CHG: pmic is trck charging the battery
|
||||
* @PMIC8058_CHG_STATE_CHG_FAIL: charging failed
|
||||
* @PMIC8058_CHG_STATE_EOC: end of charging reached
|
||||
* @PMIC8058_CHG_STATE_INRUSH_LIMIT: Brings up Vdd with 90mA max drawn from
|
||||
* VBUS
|
||||
* @PMIC8058_CHG_STATE_USB_SUSPENDED: USB supended, no current drawn from VBUS
|
||||
* @PMIC8058_CHG_STATE_PAUSE_ATC: ATC paused
|
||||
* @PMIC8058_CHG_STATE_PAUSE_FAST_CHG: FAST charging paused
|
||||
* @PMIC8058_CHG_STATE_PAUSE_TRKL_CHG: TRLK charging paused
|
||||
*
|
||||
* The paused states happen when a unfavourable condition for charging is
|
||||
* detected. The most common one being the battery gets too hot ot gets
|
||||
* too cold for charging.
|
||||
*/
|
||||
enum pmic8058_chg_state {
|
||||
PMIC8058_CHG_STATE_NONE,
|
||||
PMIC8058_CHG_STATE_PWR_CHG,
|
||||
PMIC8058_CHG_STATE_ATC,
|
||||
PMIC8058_CHG_STATE_PWR_BAT,
|
||||
PMIC8058_CHG_STATE_ATC_FAIL,
|
||||
PMIC8058_CHG_STATE_AUX_EN,
|
||||
PMIC8058_CHG_STATE_PON_AFTER_ATC,
|
||||
PMIC8058_CHG_STATE_FAST_CHG,
|
||||
PMIC8058_CHG_STATE_TRKL_CHG,
|
||||
PMIC8058_CHG_STATE_CHG_FAIL,
|
||||
PMIC8058_CHG_STATE_EOC,
|
||||
PMIC8058_CHG_STATE_INRUSH_LIMIT,
|
||||
PMIC8058_CHG_STATE_USB_SUSPENDED,
|
||||
PMIC8058_CHG_STATE_PAUSE_ATC,
|
||||
PMIC8058_CHG_STATE_PAUSE_FAST_CHG,
|
||||
PMIC8058_CHG_STATE_PAUSE_TRKL_CHG
|
||||
};
|
||||
|
||||
#if defined(CONFIG_BATTERY_MSM8X60) || defined(CONFIG_BATTERY_MSM8X60_MODULE)
|
||||
int pmic8058_get_charge_batt(void);
|
||||
int pmic8058_set_charge_batt(int);
|
||||
/**
|
||||
* pmic8058_get_fsm_state -
|
||||
*
|
||||
* CONTEXT: may sleep - should not be called from non-atomic context
|
||||
*
|
||||
* RETURNS: The pmic internal state, or error otherwise
|
||||
*/
|
||||
enum pmic8058_chg_state pmic8058_get_fsm_state(void);
|
||||
#else
|
||||
int pmic8058_get_charge_batt(void)
|
||||
{
|
||||
@@ -25,5 +76,9 @@ int pmic8058_set_charge_batt(int)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
enum pmic8058_chg_state pmic8058_get_fsm_state(void)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
#endif /* __PMIC8058_CHARGER_H__ */
|
||||
|
||||
Reference in New Issue
Block a user