[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1496249719.1774.1.camel@paulk.fr>
Date: Wed, 31 May 2017 18:55:19 +0200
From: Paul Kocialkowski <contact@...lk.fr>
To: Pavel Machek <pavel@....cz>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Pali Rohár <pali.rohar@...il.com>,
"Andrew F . Davis" <afd@...com>,
Sebastian Reichel <sre@...nel.org>,
Chris Lapa <chris@...a.com.au>,
Matt Ranostay <mranostay@...il.com>
Subject: Re: [PATCH 5/5] power: supply: bq27xxx: Correct supply status with
current draw
Hi,
Le dimanche 28 mai 2017 à 21:16 +0200, Pavel Machek a écrit :
> Hi!
>
> > The status reported directly by the battery controller is not always
> > reliable and should be corrected based on the current draw information.
> >
> > This implements such a correction with a dedicated function, called
> > when retrieving the supply status.
> >
> > @@ -1182,6 +1196,8 @@ static int bq27xxx_battery_status(struct
> > bq27xxx_device_info *di,
> > else
> > status = POWER_SUPPLY_STATUS_DISCHARGING;
> > } else {
> > + curr = (int)((s16)curr) * 1000;
>
> Umm.
>
> > @@ -1190,6 +1206,18 @@ static int bq27xxx_battery_status(struct
> > bq27xxx_device_info *di,
> > status = POWER_SUPPLY_STATUS_CHARGING;
> > }
> >
> > +
> > + if (curr == 0 && status != POWER_SUPPLY_STATUS_NOT_CHARGING)
> > + status = POWER_SUPPLY_STATUS_FULL;
> > +
> > + if (status == POWER_SUPPLY_STATUS_FULL) {
> > + /* Drawing or providing current when full */
> > + if (curr > 0)
> > + status = POWER_SUPPLY_STATUS_CHARGING;
> > + else if (curr < 0)
> > + status = POWER_SUPPLY_STATUS_DISCHARGING;
> > + }
>
> Are you sure this works? On N900, we normally see small currents to/from
> "full" battery.
In my case, this works perfectly and I am quite surprised of what you're
describing. Is it the case when the battery has a PSU connected?
I guess I would consider this a hardware issue (leak currents) and we could
definitely set some range (in device-tree) to distinguish between full + leak
currents and bad reporting from the fuel gauge. That would work well in my case
too.
> Should the test be for absolute_value(curr) < something rather than for == 0?
>
> What hw did you test it on?
I tested this on nyan Chromebooks (Acer Chromebook 13 and HP Chromebook 11) as
well as veyron Chromebooks (Chromebook C201PA) that use a bq27xxx fuel gauge.
Cheers!
--
Paul Kocialkowski, developer of free digital technology and hardware support
Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists