From: Tony Lindgren <tony@atomide.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: kernel list <linux-kernel@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
linux-omap@vger.kernel.org, sre@kernel.org, nekit1000@gmail.com,
mpartap@gmx.net, merlijn@wizzup.org
Subject: Re: Motorola Droid 4 progress, power consumption
Date: Fri, 4 May 2018 13:38:19 -0700 [thread overview]
Message-ID: <20180504203819.GF98604@atomide.com> (raw)
In-Reply-To: <20180504202044.GC22519@amd>
* Pavel Machek <pavel@ucw.cz> [180504 20:22]:
> Hi!
>
> > > user@devuan:/sys/class/power_supply/battery$ date; cat current_now
> > > current_avg
> > > Thu May 3 09:33:07 CEST 2018
> > > -56000
> > > -72308
> > > user@devuan:/sys/class/power_supply/battery$ date; cat current_now
> > > current_avg
> > > Thu May 3 09:33:08 CEST 2018
> > > -37000
> > > -211362
> >
> > I recall it just being calculated based on the time between
> > the reads. Hard to say what it does, -ENODOCS.. Maybe the mc13783
> > PMIC docs have something similar.
>
> Hmm. current_avg is world readable; if it does changes to the
> hardware, that's somehow bad.
No it just calls cpcap_battery_cc_get_avg_current() that calculates
the average from last time it got sampled based on number of samples
collected between the two reads. Seems to match what I see on my
power supply here.
> But I guess I can sample charge_counter every minute or so and get
> what I need?
Not sure what the max time range is for the PMIC, but yeah I'd
assume once a minute is duoable. Maybe compare it to the chart
you already have?
> > > > Hmm oh and the POWER_SUPPLY_CHARGE_COUNTER value should be monitored
> > > > by your libbattery and it's low value and high value should be saved
> > > > to a file. Low should be saved when we get the battery low interrupt
> > > > and battery state changes to POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL.
> > > > High value should be saved on POWER_SUPPLY_CAPACITY_LEVEL_FULL.
> > > >
> > > > Then when you know the high value and low value, you can calculate
> > > > the remaining capacity based on the current value and
> > > > POWER_SUPPLY_POWER_AVG.
> > >
> > > I'll look into that... but probably will do experiments with python,
> > > first.
> >
> > Sure. The reason why I think we should not do it in the kernel in
> > addition to the earlier reasoning is that we don't have a place
> > to store the min and max values across reboot. I think there's
> > some flash on the battery over 1w bus, but it probably just
> > contains battery serial number or something and is not intended
> > for writing much to it. I guess the min and max values should be
> > really keyd based on this battery id in case the battery gets
> > changed.
>
> I agree this should not be done in kernel as it requires persistent
> storage.
>
> Battery is not user-replacable (and this will recalibrate itself on
> charge/discharge cycle) so.. I don't think keying is strictly
> neccessary for D4.
Yeah right, that can be added later on if needed if you just
plan accordingly. It's replaceable with a T5 after you peel off the
sticker from the corners :)
Regards,
Tony
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: Motorola Droid 4 progress, power consumption
Date: Fri, 4 May 2018 13:38:19 -0700 [thread overview]
Message-ID: <20180504203819.GF98604@atomide.com> (raw)
In-Reply-To: <20180504202044.GC22519@amd>
* Pavel Machek <pavel@ucw.cz> [180504 20:22]:
> Hi!
>
> > > user at devuan:/sys/class/power_supply/battery$ date; cat current_now
> > > current_avg
> > > Thu May 3 09:33:07 CEST 2018
> > > -56000
> > > -72308
> > > user at devuan:/sys/class/power_supply/battery$ date; cat current_now
> > > current_avg
> > > Thu May 3 09:33:08 CEST 2018
> > > -37000
> > > -211362
> >
> > I recall it just being calculated based on the time between
> > the reads. Hard to say what it does, -ENODOCS.. Maybe the mc13783
> > PMIC docs have something similar.
>
> Hmm. current_avg is world readable; if it does changes to the
> hardware, that's somehow bad.
No it just calls cpcap_battery_cc_get_avg_current() that calculates
the average from last time it got sampled based on number of samples
collected between the two reads. Seems to match what I see on my
power supply here.
> But I guess I can sample charge_counter every minute or so and get
> what I need?
Not sure what the max time range is for the PMIC, but yeah I'd
assume once a minute is duoable. Maybe compare it to the chart
you already have?
> > > > Hmm oh and the POWER_SUPPLY_CHARGE_COUNTER value should be monitored
> > > > by your libbattery and it's low value and high value should be saved
> > > > to a file. Low should be saved when we get the battery low interrupt
> > > > and battery state changes to POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL.
> > > > High value should be saved on POWER_SUPPLY_CAPACITY_LEVEL_FULL.
> > > >
> > > > Then when you know the high value and low value, you can calculate
> > > > the remaining capacity based on the current value and
> > > > POWER_SUPPLY_POWER_AVG.
> > >
> > > I'll look into that... but probably will do experiments with python,
> > > first.
> >
> > Sure. The reason why I think we should not do it in the kernel in
> > addition to the earlier reasoning is that we don't have a place
> > to store the min and max values across reboot. I think there's
> > some flash on the battery over 1w bus, but it probably just
> > contains battery serial number or something and is not intended
> > for writing much to it. I guess the min and max values should be
> > really keyd based on this battery id in case the battery gets
> > changed.
>
> I agree this should not be done in kernel as it requires persistent
> storage.
>
> Battery is not user-replacable (and this will recalibrate itself on
> charge/discharge cycle) so.. I don't think keying is strictly
> neccessary for D4.
Yeah right, that can be added later on if needed if you just
plan accordingly. It's replaceable with a T5 after you peel off the
sticker from the corners :)
Regards,
Tony
next prev parent reply other threads:[~2018-05-04 20:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-01 18:31 Motorola Droid 4 progress, power consumption Pavel Machek
2018-05-02 14:41 ` Tony Lindgren
2018-05-02 14:41 ` Tony Lindgren
2018-05-02 19:10 ` Pavel Machek
2018-05-02 19:10 ` Pavel Machek
2018-05-02 19:42 ` Tony Lindgren
2018-05-02 19:42 ` Tony Lindgren
2018-05-02 21:32 ` Pavel Machek
2018-05-02 21:32 ` Pavel Machek
2018-05-03 9:06 ` Pavel Machek
2018-05-03 9:06 ` Pavel Machek
2018-05-03 14:22 ` Tony Lindgren
2018-05-03 14:22 ` Tony Lindgren
2018-05-04 20:20 ` Pavel Machek
2018-05-04 20:20 ` Pavel Machek
2018-05-04 20:38 ` Tony Lindgren [this message]
2018-05-04 20:38 ` Tony Lindgren
2018-05-04 21:47 ` Pavel Machek
2018-05-04 21:47 ` Pavel Machek
2018-05-05 19:44 ` Tony Lindgren
2018-05-05 19:44 ` Tony Lindgren
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=20180504203819.GF98604@atomide.com \
--to=tony@atomide.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=merlijn@wizzup.org \
--cc=mpartap@gmx.net \
--cc=nekit1000@gmail.com \
--cc=pavel@ucw.cz \
--cc=sre@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.