mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 05:39:54 -04:00
qpnp_adaptive_charge: Add adap_reinit
In 8350/7325 platform, batt_psy needs to wait for Glink module to complete, therefore, the qpnp_adaptive_charger module init will faile due to batt_psy not ready. Add adap_reinit_work to rerun module init when it failed by batt_psy not ready. Change-Id: Ib73aa4dcbe9e069c36ec4Montana415601ab6991e795 Signed-off-by: xuwt2 <xuwt2@lenovo.com> Reviewed-on: https://gerrit.mot.com/2008716 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Tao Sun <suntao2@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
dc475e8c19
commit
cd073b1eef
1 changed files with 54 additions and 7 deletions
|
|
@ -64,6 +64,7 @@ static struct adap_chg_data {
|
|||
bool init_success;
|
||||
bool charging_suspended;
|
||||
bool charging_stopped;
|
||||
struct delayed_work reinit_work;
|
||||
} adap_chg_data;
|
||||
|
||||
int upper_limit = -1;
|
||||
|
|
@ -262,12 +263,19 @@ static int get_blocking(char *buffer, const struct kernel_param *kp)
|
|||
bool usb_connected = false;
|
||||
|
||||
if (adap_chg_data.init_success) {
|
||||
#ifdef USE_MMI_CHARGER
|
||||
usb_connected = (get_ps_int_prop(adap_chg_data.usb_psy,
|
||||
POWER_SUPPLY_PROP_ONLINE) > 0 ? true : false);
|
||||
|
||||
dc_connected = (get_ps_int_prop(adap_chg_data.dc_psy,
|
||||
POWER_SUPPLY_PROP_ONLINE) > 0 ? true : false);
|
||||
#else
|
||||
usb_connected = (get_ps_int_prop(adap_chg_data.usb_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT) > 0 ? true : false);
|
||||
|
||||
dc_connected = (get_ps_int_prop(adap_chg_data.dc_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT) > 0 ? true : false);
|
||||
|
||||
#endif
|
||||
blocking = ((adap_chg_data.charging_suspended || adap_chg_data.charging_stopped) &&
|
||||
(dc_connected || usb_connected));
|
||||
} else
|
||||
|
|
@ -328,7 +336,10 @@ module_param_cb(blocking,
|
|||
S_IRUGO
|
||||
);
|
||||
|
||||
static int __init qpnp_adap_chg_init(void)
|
||||
#define ADAP_INIT_SUCCESS 0
|
||||
#define ADAP_INIT_FAILED 1
|
||||
#define ADAP_INIT_RERUN 2
|
||||
static int qpnp_adap_chg_init_work(void)
|
||||
{
|
||||
upper_limit = -1;
|
||||
lower_limit = -1;
|
||||
|
|
@ -339,18 +350,24 @@ static int __init qpnp_adap_chg_init(void)
|
|||
adap_chg_data.batt_psy = power_supply_get_by_name("battery");
|
||||
if (!adap_chg_data.batt_psy) {
|
||||
pr_err("Failed to get battery power supply\n");
|
||||
goto fail;
|
||||
goto psy_fail;
|
||||
}
|
||||
|
||||
adap_chg_data.usb_psy = power_supply_get_by_name("usb");
|
||||
if (!adap_chg_data.usb_psy) {
|
||||
pr_err("Failed to get usb power supply\n");
|
||||
goto fail;
|
||||
goto psy_fail;
|
||||
}
|
||||
|
||||
#ifdef USE_MMI_CHARGER
|
||||
adap_chg_data.dc_psy = power_supply_get_by_name("wireless");
|
||||
if (!adap_chg_data.dc_psy)
|
||||
pr_info("No wireless power supply found\n");
|
||||
#else
|
||||
adap_chg_data.dc_psy = power_supply_get_by_name("dc");
|
||||
if (!adap_chg_data.dc_psy)
|
||||
pr_info("No dc power supply found\n");
|
||||
#endif
|
||||
|
||||
adap_chg_data.batt_capacity = get_ps_int_prop(adap_chg_data.batt_psy,
|
||||
POWER_SUPPLY_PROP_CAPACITY);
|
||||
|
|
@ -385,6 +402,7 @@ static int __init qpnp_adap_chg_init(void)
|
|||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
adap_chg_data.ps_notif.notifier_call = ps_notify_callback;
|
||||
if (power_supply_reg_notifier(&adap_chg_data.ps_notif)) {
|
||||
pr_err("Failed to register notifier\n");
|
||||
|
|
@ -395,10 +413,39 @@ static int __init qpnp_adap_chg_init(void)
|
|||
schedule_work(&adap_chg_data.update);
|
||||
|
||||
adap_chg_data.init_success = true;
|
||||
|
||||
return 0;
|
||||
return ADAP_INIT_SUCCESS;
|
||||
fail:
|
||||
return 1;
|
||||
return ADAP_INIT_FAILED;
|
||||
psy_fail:
|
||||
return ADAP_INIT_RERUN;
|
||||
|
||||
}
|
||||
|
||||
static void adap_reinit_work(struct work_struct *work)
|
||||
{
|
||||
int ret = ADAP_INIT_FAILED;
|
||||
ret = qpnp_adap_chg_init_work();
|
||||
|
||||
if (ret == ADAP_INIT_RERUN) {
|
||||
cancel_delayed_work(&adap_chg_data.reinit_work);
|
||||
schedule_delayed_work(&adap_chg_data.reinit_work,
|
||||
msecs_to_jiffies(5000));
|
||||
}
|
||||
}
|
||||
|
||||
static int __init qpnp_adap_chg_init(void)
|
||||
{
|
||||
int ret = ADAP_INIT_FAILED;
|
||||
|
||||
ret = qpnp_adap_chg_init_work();
|
||||
|
||||
if (ret == ADAP_INIT_RERUN) {
|
||||
INIT_DELAYED_WORK(&adap_chg_data.reinit_work, adap_reinit_work);
|
||||
schedule_delayed_work(&adap_chg_data.reinit_work,
|
||||
msecs_to_jiffies(5000));
|
||||
return ADAP_INIT_SUCCESS;
|
||||
} else
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void qpnp_adap_chg_exit(void)
|
||||
|
|
|
|||
Loading…
Reference in a new issue