diff options
author | Alice Sheng <alicesheng@google.com> | 2022-02-23 12:07:31 -0800 |
---|---|---|
committer | Alice Sheng <alicesheng@google.com> | 2022-11-17 00:13:38 +0000 |
commit | 5913b30383a8e8d87b503511cecc13ab44962466 (patch) | |
tree | 5af6c0dca1848a55deb1407b403688a28af0bb1c | |
parent | aaba4aad869d17c28e3440635e19afaeae29d0d3 (diff) | |
download | drivers-5913b30383a8e8d87b503511cecc13ab44962466.tar.gz |
wlc: Delay charging reporting.
Wait for authentication to finish before reporting charging present.
Bug: 255784023
Change-Id: Ie276df3324df452eda52c6c017c2132b7e95c419
-rw-r--r-- | battery/google_battery.c | 6 | ||||
-rw-r--r-- | wlc/hl6111_charger.c | 30 | ||||
-rw-r--r-- | wlc/hl6111_charger.h | 7 |
3 files changed, 25 insertions, 18 deletions
diff --git a/battery/google_battery.c b/battery/google_battery.c index 09da6d3..601c1cf 100644 --- a/battery/google_battery.c +++ b/battery/google_battery.c @@ -854,7 +854,7 @@ static int wireless_get_property(struct power_supply *psy, switch(psp) { case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_PRESENT: - if (battery->power_supply_type == POWER_SUPPLY_TYPE_WIRELESS || battery->wlc_connected) + if (battery->wlc_connected) val->intval = 1; else val->intval = 0; @@ -915,9 +915,7 @@ static int battery_handle_notification(struct notifier_block *nb, mutex_lock(&battery->wlc_state_lock); - if (battery->wlc_connected) { - set_wlc_online(battery); - } + set_wlc_online(battery); old_status = battery->status; set_bat_status_by_cable(battery); mutex_unlock(&battery->wlc_state_lock); diff --git a/wlc/hl6111_charger.c b/wlc/hl6111_charger.c index 8e71298..a216db7 100644 --- a/wlc/hl6111_charger.c +++ b/wlc/hl6111_charger.c @@ -862,7 +862,7 @@ static void hl6111_charge_power_detected(struct hl6111_charger *chg) { pm_stay_awake(chg->dev); dev_info(chg->dev, "%s: Start timer for Authentication!\n", __func__); chg->timer_id = TIMER_PRESET_AUTH; - schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(1000)); + schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(0)); if (gpio_get_value(chg->pdata->auth_gpio) == 0) { chg->auth_chok = true; } @@ -909,6 +909,10 @@ static int hl6111_psy_set_property(struct power_supply *psy, enum power_supply_p LOG_DBG("Start!, prop==[%d], val==[%d]\n", psp, val->intval); switch(psp) { case POWER_SUPPLY_PROP_ONLINE: + if (!chg->tx_det) { + // if WLC is not present, ignore power changes + break; + } dev_info(chg->dev, "Setting WLC online: %d\n", val->intval); if (val->intval == 0 ) { //charging off chg->online = false; @@ -962,8 +966,9 @@ static irqreturn_t hl6111_pad_detect_handler(int irq, void *data) sts = gpio_get_value(chg->pdata->det_gpio); if (sts == 0){ dev_info(chg->dev, "TX connection detected\n"); + // Make sure we don't go back to sleep before the WLC power establishes + pm_stay_awake(chg->dev); chg->tx_det = true; - chg->tx_valid = true; } else if (sts == 1) { dev_info(chg->dev, "TX disconnection detected\n"); chg->last_off_time = 0; @@ -974,11 +979,12 @@ static irqreturn_t hl6111_pad_detect_handler(int irq, void *data) if (chg->irq_state == 0) { // Just in case authntication didn't get cleaned up properly hl6111_auth_irq_set_state(chg, 0); - pm_relax(chg->dev); } + // In case WLC power never established + pm_relax(chg->dev); + power_supply_changed(chg->psy_chg); } - power_supply_changed(chg->psy_chg); return IRQ_HANDLED; } @@ -998,14 +1004,16 @@ static irqreturn_t hl6111_auth_irq_handler(int irq, void *data) dev_info(chg->dev, "%s: Start timer for Authentication!\n", __func__); chg->timer_id = TIMER_PRESET_AUTH; - schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(1000)); + schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(0)); } else if (chg->timer_id == TIMER_DETECT_LOW) { LOG_DBG("%s: TIMR_END_AUTH!, Google TX Connected!\n", __func__); + chg->tx_valid = true; chg->timer_id = TIMER_END_AUTH; + power_supply_changed(chg->psy_chg); - schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(0)); + schedule_delayed_work(&chg->auth_work, msecs_to_jiffies(100)); } } else if (sts == 1 && chg->auth_chok) { chg->auth_chok = false; @@ -1149,7 +1157,6 @@ static void hl6111_rx_authentication_work(struct work_struct *work) chg->timer_id = TIMER_GOOGLE_TX; chg->tx_authenticated = true; - chg->tx_valid = true; chg->auth_retry = 0; if (chg->online) { hl6111_write_reg(chg, REG_INTERRUPT_ENABLE, 0xFF); @@ -1157,7 +1164,6 @@ static void hl6111_rx_authentication_work(struct work_struct *work) hl6111_device_init(chg); } hl6111_auth_irq_set_state(chg, 0); - power_supply_changed(chg->psy_chg); pm_relax(chg->dev); break; @@ -1215,7 +1221,10 @@ static int hl6111_psy_get_property(struct power_supply *psy, enum power_supply_p case POWER_SUPPLY_PROP_PRESENT: LOG_DBG("PRESENT!!\r\n"); - val->intval = chg->tx_det; + if (chg->tx_det) + val->intval = chg->tx_valid; + else + val->intval = false; break; case POWER_SUPPLY_PROP_AUTHENTIC: @@ -1823,8 +1832,7 @@ static int hl6111_charger_probe(struct i2c_client *client, const struct i2c_devi dev_info(charger->dev, "TX connection initially detected\n"); charger->tx_det = true; - charger->tx_valid = true; - + charger->tx_valid = false; } else { dev_info(charger->dev, "TX connection was not detected\n"); charger->tx_det = false; diff --git a/wlc/hl6111_charger.h b/wlc/hl6111_charger.h index c84560b..845fb86 100644 --- a/wlc/hl6111_charger.h +++ b/wlc/hl6111_charger.h @@ -217,9 +217,10 @@ struct hl6111_charger{ u32 debug_address; bool online; - bool tx_det; - bool tx_valid; - bool tx_authenticated; + bool tx_det; // whether the tx is physically detected + bool tx_valid; // whether the full authentication has passed once + // sometimes the authentication resets on the TX side so we have to resend + bool tx_authenticated; // whether the full authentication is still active bool auth_chok; int irq_state; |