linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dirk Brandewie <dirk.brandewie@gmail.com>
To: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: dirk.brandewie@gmail.com, linux-kernel@vger.kernel.org,
	dg77.kim@samsung.com, kyungmin.park@samsung.com,
	myungjoo.ham@samsung.com, Jason.Wortham@maxim-ic.com,
	bruce.e.robertson@intel.com,
	Karol Lewandowski <k.lewandowsk@samsung.com>
Subject: Re: [PATCH 5/5] max17042: Change capacity property to use reported SOC register
Date: Tue, 13 Mar 2012 15:54:25 -0700	[thread overview]
Message-ID: <4F5FD021.1080409@gmail.com> (raw)
In-Reply-To: <20120313183452.GB15964@oksana.dev.rtsoft.ru>

On 03/13/2012 11:34 AM, Anton Vorontsov wrote:
> On Tue, Jan 24, 2012 at 09:26:08AM -0800, dirk.brandewie@gmail.com wrote:
>> From: Dirk Brandewie<dirk.brandewie@gmail.com>
>>
>> The SOC register (0dh) reports the state of charge before empty
>> compensation adjustments are applied.  The max value reported by this
>> register will decrease as the battery ages.
>>
>> Use the RepSOC register (06h) to report the capacity of the
>> battery. RepSOC contains a filtered version of the battery capacity
>> after empty compensation adjustments have been applied.
>>
>> Reported-by: Gary Keyes<gary.e.keyes@intel.com>
>>
>> Signed-off-by: Dirk Brandewie<dirk.brandewie@gmail.com>
>> ---
>>   drivers/power/max17042_battery.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
>> index 6e96b58..2194278 100644
>> --- a/drivers/power/max17042_battery.c
>> +++ b/drivers/power/max17042_battery.c
>> @@ -160,7 +160,7 @@ static int max17042_get_property(struct power_supply *psy,
>>   		break;
>>   	case POWER_SUPPLY_PROP_CAPACITY:
>>   		val->intval = max17042_read_reg(chip->client,
>> -				MAX17042_SOC) / 256;
>> +				MAX17042_RepSOC) / 256;
>
> Applied. But I don't get it: PROP_CAPACITY should report
> percents! And it looks that it reports something very
> different.
>

The resolution of the register is 1/256 of a percent so we are actually 
returning the value in percent.

> Also, if you look down the file, you'll see this:
>
>          case POWER_SUPPLY_PROP_CHARGE_FULL:
>                  ret = max17042_read_reg(chip->client, MAX17042_RepSOC);
>                  if (ret<  0)
>                          return ret;
>
>                  if ((ret>>  8)>= MAX17042_BATTERY_FULL)
>                          val->intval = 1;
>                  else if (ret>= 0)
>                          val->intval = 0;
>                  break;
>

I hadn't looked at this property. Looks like that code came from commit 60a1f6e4

> Wut? This is also wrong. PROP_CHARGE_FULL reports uAh, not "fully
> charged" boolean status.
>
> Please, read Documentation/power/power_supply_class.txt:
>
> ~ ~ ~ ~ ~ ~ ~  Charge/Energy/Capacity - how to not confuse  ~ ~ ~ ~ ~ ~ ~
> ~                                                                       ~
> ~ Because both "charge" (µAh) and "energy" (µWh) represents "capacity"  ~
> ~ of battery, this class distinguish these terms. Don't mix them!       ~
> ~                                                                       ~
> ~ CHARGE_* attributes represents capacity in µAh only.                  ~
> ~ ENERGY_* attributes represents capacity in µWh only.                  ~
> ~ CAPACITY attribute represents capacity in *percents*, from 0 to 100.  ~
> ~                                                                       ~
> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
>
> The driver is seriously broken, very. I'd even consider adding
> 'depends on BROKEN', as the driver might be the source of the
> confusion for drivers based on this one and for userland devs.
>
> Thanks,
>


  reply	other threads:[~2012-03-13 22:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24 17:26 [PATCH 0/5] MAX17042 add support for maxim POR procedure dirk.brandewie
2012-01-24 17:26 ` [PATCH 1/5] max17042: Align register definitions with data sheet and init appnote dirk.brandewie
2012-01-24 17:26 ` [PATCH 2/5] max17042: Add POR init procedure from Maxim appnote dirk.brandewie
2012-01-24 17:26 ` [PATCH 3/5] max17042: Add support for signalling change in SOC dirk.brandewie
2012-01-24 17:26 ` [PATCH 4/5] max17042: Fix value scaling for VCELL and avgVCELL dirk.brandewie
2012-03-13 18:19   ` Anton Vorontsov
2012-03-13 21:00     ` bruce robertson
2012-03-13 21:04       ` Jason Wortham
2012-03-13 22:59         ` Dirk Brandewie
2012-03-14  0:04           ` Jason Wortham
2012-03-13 23:18         ` bruce robertson
2012-03-14  0:37           ` Jason Wortham
2012-01-24 17:26 ` [PATCH 5/5] max17042: Change capacity property to use reported SOC register dirk.brandewie
2012-03-13 18:34   ` Anton Vorontsov
2012-03-13 22:54     ` Dirk Brandewie [this message]
2012-02-28 16:17 ` [PATCH 0/5] MAX17042 add support for maxim POR procedure Dirk Brandewie
2012-03-13 18:48 ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F5FD021.1080409@gmail.com \
    --to=dirk.brandewie@gmail.com \
    --cc=Jason.Wortham@maxim-ic.com \
    --cc=bruce.e.robertson@intel.com \
    --cc=cbouatmailru@gmail.com \
    --cc=dg77.kim@samsung.com \
    --cc=k.lewandowsk@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).