power: pm8921-bms: fix override mode causes sleep current increase
The override mode is used to measure battery voltage and current
simultaneously. We observed that the XOADC and the AMUX
were left enabled even after the override mode is exited. This
causes the current consumption to increase by 500uA.
Execute a dummy XOADC read after override mode is exited. This will
ensure that the XOADC and the AMUX get turned off after the dummy
transaction is completed.
CRs-Fixed: 440864
Change-Id: I53b8b67d55bbab1de588a36b7d2eca26ba6e6bfd
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-bms.c b/drivers/power/pm8921-bms.c
index c552ae4..2eb4caa 100644
--- a/drivers/power/pm8921-bms.c
+++ b/drivers/power/pm8921-bms.c
@@ -599,6 +599,23 @@
return 0;
}
+static int get_batt_temp(struct pm8921_bms_chip *chip, int *batt_temp)
+{
+ int rc;
+ struct pm8xxx_adc_chan_result result;
+
+ rc = pm8xxx_adc_read(chip->batt_temp_channel, &result);
+ if (rc) {
+ pr_err("error reading batt_temp_channel = %d, rc = %d\n",
+ chip->batt_temp_channel, rc);
+ return rc;
+ }
+ *batt_temp = result.physical;
+ pr_debug("batt_temp phy = %lld meas = 0x%llx\n", result.physical,
+ result.measurement);
+ return 0;
+}
+
#define BMS_MODE_BIT BIT(6)
#define EN_VBAT_BIT BIT(5)
#define OVERRIDE_MODE_DELAY_MS 20
@@ -609,6 +626,7 @@
int16_t vbat_raw;
int vsense_uv;
int usb_chg;
+ int batt_temp;
mutex_lock(&the_chip->bms_output_lock);
@@ -623,12 +641,13 @@
pm_bms_read_output_data(the_chip, VBATT_AVG, &vbat_raw);
pm_bms_unlock_output_data(the_chip);
pm_bms_masked_write(the_chip, BMS_CONTROL,
- BMS_MODE_BIT | EN_VBAT_BIT, 0);
+ BMS_MODE_BIT | EN_VBAT_BIT, 0);
pm8xxx_writeb(the_chip->dev->parent, BMS_S1_DELAY, 0x0B);
mutex_unlock(&the_chip->bms_output_lock);
+ get_batt_temp(the_chip, &batt_temp);
usb_chg = usb_chg_plugged_in(the_chip);
convert_vbatt_raw_to_uv(the_chip, usb_chg, vbat_raw, vbat_uv);
@@ -1909,23 +1928,6 @@
power_supply_changed(chip->batt_psy);
}
-static int get_batt_temp(struct pm8921_bms_chip *chip, int *batt_temp)
-{
- int rc;
- struct pm8xxx_adc_chan_result result;
-
- rc = pm8xxx_adc_read(chip->batt_temp_channel, &result);
- if (rc) {
- pr_err("error reading batt_temp_channel = %d, rc = %d\n",
- chip->batt_temp_channel, rc);
- return rc;
- }
- *batt_temp = result.physical;
- pr_debug("batt_temp phy = %lld meas = 0x%llx\n", result.physical,
- result.measurement);
- return 0;
-}
-
#define MIN_DELTA_625_UV 1000
static void calib_hkadc(struct pm8921_bms_chip *chip)
{