Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7aaacf5 authored by Anton Vorontsov's avatar Anton Vorontsov
Browse files

Revert "bq27x00_battery: Fix reporting status value for bq27500 battery"



This reverts commit 270968c0.

Grazvydas Ignotas wrote:

After 270968c0 "bq27x00_battery: Fix reporting status value for
bq27500 battery" status doesn't seem to be reported correctly when the
battery is close to fully charged state. It reports "Not charging"
while in fact there is >130mA current flowing to the battery according
to current_now.

This status report seems to be based on CHG bit in status register,
but looking at the datasheet the description says "(Fast) charging
allowed", which I guess means that the chip recommends charging and
not that charging is actually going on? If you check the bit while
battery is discharging and it's not full, the bit is also set.

Suggested-by: default avatarGrazvydas Ignotas <notasas@gmail.com>
Acked-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
parent 62aa2b53
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -62,11 +62,10 @@

#define BQ27500_REG_SOC			0x2C
#define BQ27500_REG_DCAP		0x3C /* Design capacity */
#define BQ27500_FLAG_DSG		BIT(0) /* Discharging */
#define BQ27500_FLAG_DSC		BIT(0)
#define BQ27500_FLAG_SOCF		BIT(1) /* State-of-Charge threshold final */
#define BQ27500_FLAG_SOC1		BIT(2) /* State-of-Charge threshold 1 */
#define BQ27500_FLAG_CHG		BIT(8) /* Charging */
#define BQ27500_FLAG_FC			BIT(9) /* Fully charged */
#define BQ27500_FLAG_FC			BIT(9)

#define BQ27000_RS			20 /* Resistor sense */

@@ -401,14 +400,10 @@ static int bq27x00_battery_status(struct bq27x00_device_info *di,
	if (di->chip == BQ27500) {
		if (di->cache.flags & BQ27500_FLAG_FC)
			status = POWER_SUPPLY_STATUS_FULL;
		else if (di->cache.flags & BQ27500_FLAG_DSG)
		else if (di->cache.flags & BQ27500_FLAG_DSC)
			status = POWER_SUPPLY_STATUS_DISCHARGING;
		else if (di->cache.flags & BQ27500_FLAG_CHG)
			status = POWER_SUPPLY_STATUS_CHARGING;
		else if (power_supply_am_i_supplied(&di->bat))
			status = POWER_SUPPLY_STATUS_NOT_CHARGING;
		else
			status = POWER_SUPPLY_STATUS_UNKNOWN;
			status = POWER_SUPPLY_STATUS_CHARGING;
	} else {
		if (di->cache.flags & BQ27000_FLAG_FC)
			status = POWER_SUPPLY_STATUS_FULL;