mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
control charger irq for otg or battery presence
Disable charger IRQ if OTG is enabled or battery is absence to prevent unexpected charger IRQ wakeup. Change-Id: I71b699f25a5624f0f3699434f142abc8cd3d69d4 Signed-off-by: Yonghua Yan <yanyh2@motorola.com> Reviewed-on: https://gerrit.mot.com/2319107 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
fc575f57fc
commit
ed90b000ce
2 changed files with 28 additions and 3 deletions
|
|
@ -2271,6 +2271,7 @@ static void sgm4154x_charger_set_constraint(void *data,
|
|||
#define VBAT_OVP_MV (4600)
|
||||
#define IBAT_OCP_MA (1500)
|
||||
#define PROTECT_DELAY_MS (60000)
|
||||
#define OTG_VBUS_MIN_MV (4600)
|
||||
static void sgm4154x_paired_battery_notify(void *data,
|
||||
struct mmi_battery_info *batt_info)
|
||||
{
|
||||
|
|
@ -2295,6 +2296,7 @@ static void sgm4154x_paired_battery_notify(void *data,
|
|||
static struct timespec64 start = {0};
|
||||
uint32_t elapsed_ms;
|
||||
static bool batt_protected = false;
|
||||
bool otg_enabled = false;
|
||||
|
||||
if (!batt_info || batt_info->batt_mv <= 0) {
|
||||
pr_warn("Invalid paired battery info\n");
|
||||
|
|
@ -2304,16 +2306,37 @@ static void sgm4154x_paired_battery_notify(void *data,
|
|||
memcpy(&chg->paired_batt_info, batt_info, sizeof(struct mmi_battery_info));
|
||||
batt_present = (chg->batt_info.batt_temp >= BPD_TEMP_THRE)? true : false;
|
||||
|
||||
if (!chg->chg_info.chrg_present &&
|
||||
chg->chg_info.chrg_ma == 0 &&
|
||||
chg->chg_info.chrg_mv > OTG_VBUS_MIN_MV) {
|
||||
otg_enabled = true;
|
||||
}
|
||||
|
||||
if (batt_present) {
|
||||
rc = power_supply_get_property(chg->fg_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT, &val);
|
||||
if (!rc && !val.intval)
|
||||
batt_present = false;
|
||||
}
|
||||
if (!batt_present) {
|
||||
if (!batt_present || otg_enabled) {
|
||||
sgm4154x_set_hiz_en(chg->sgm, true);
|
||||
pr_warn("%s is absent\n", chg->fg_psy->desc->name);
|
||||
return;
|
||||
if (chg->sgm->client->irq && chg->sgm->irq_enabled) {
|
||||
disable_irq_wake(chg->sgm->client->irq);
|
||||
disable_irq(chg->sgm->client->irq);
|
||||
chg->sgm->irq_enabled = false;
|
||||
pr_warn("irq is disabled, bpd=%d, otg=%d\n",
|
||||
batt_present, otg_enabled);
|
||||
}
|
||||
if (!batt_present)
|
||||
return;
|
||||
} else {
|
||||
if (!chg->sgm->irq_enabled && chg->sgm->client->irq) {
|
||||
enable_irq_wake(chg->sgm->client->irq);
|
||||
enable_irq(chg->sgm->client->irq);
|
||||
chg->sgm->irq_enabled = true;
|
||||
pr_warn("irq is enabled, bpd=%d, otg=%d\n",
|
||||
batt_present, otg_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
batt_ocv = chg->batt_info.batt_mv;
|
||||
|
|
@ -2961,6 +2984,7 @@ static int sgm4154x_probe(struct i2c_client *client,
|
|||
if (ret)
|
||||
goto error_out;
|
||||
enable_irq_wake(client->irq);
|
||||
sgm->irq_enabled = true;
|
||||
}
|
||||
|
||||
INIT_DELAYED_WORK(&sgm->charge_detect_delayed_work, charger_detect_work_func);
|
||||
|
|
|
|||
|
|
@ -338,6 +338,7 @@ struct sgm4154x_device {
|
|||
|
||||
struct dentry *debug_root;
|
||||
|
||||
bool irq_enabled;
|
||||
int high_load_en_gpio;
|
||||
int low_load_en_gpio;
|
||||
bool high_load_active_low;
|
||||
|
|
|
|||
Loading…
Reference in a new issue