[lkml]   [2009]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [POWER] battery calibration parameters from sysfs
Thanks for all the great attention Mark!

[Mark wrote]
> On Sat, Dec 05, 2009 at 02:08:11PM +0100, Linus Walleij wrote:
> > (...)
> > That's an easy solution of course, but then the sysfs files
> > specified by the power subsystem, i.e. all "charge_*",
> > "energy_*", "capacity" and "time_to_*" loose their meaning
> > and must be ignored by userspace.
> These files should only be present if we have data for them.
> Userspace can't be reliant on them at present since relatively few
> systems seem to implement them, for example none of my laptops
> have time_to, energy_ or capacity attributes.

Well, yeah, we're not exactly in the laptop business.
(But my HP laptop nc2400 has the "charge_*" attributes,
4990000 uAh in "charge_now" and this corresponds to
what is shown in g-p-m converted over to Wh, but I don't
know exactly where it's getting it from...)

One of the things we're facing is Android, which has
its userspace in plain Java JNI at the end of this link:;a=blob;f=s

If you browse down to line 275 you can see it parse the sysfs
attribute "capacity", then this propagates up to the battery
status indicator on *all* Android phones out there. So if
you want to run Android unmodified, this is what you need to
provide. They are effectively using the power sysfs as
their hardware abstraction layer in this case.

Note: I'm not claiming that Android is doing it right or that
we can't modify this code or so, it's just that this is the way
a few million Android devices out there are actually doing it.

> > We have other odd code. Actually we have full software-
> > controlled CC/CV charging in our driver, and that
> > would *definately* go in such a library if it was
> > to end up in kernelspace. We have actually
> > pushed that to userspace, while I still tend to think
> > that the kernel (with right parameters) should be able
> > to charge a battery. But, well.
> As was previously discussed (in another thread) I do think there needs
> to be at least some in kernel part to charger code like this
> in order to
> ensure that we're robust against userspace failure and cope well with
> suspend and resume. There's the potential for serious hardware damage
> if the battery is mistreated.

You're right of course. In our case we have a hardware
watchdog protecting against overcharging etc, and charging will
halt when the watchdog is not periodically fed. So actually
we're on the safe side here. (I think!)

> There's other kernel filesystems that might be more
> approprite for this
> sort of stuff, trying to fit this into sysfs really does feel like far
> too much pain to be right.

You're right GKH already pointed me to configfs so that's
where it's going to sit if we do this thing.

We'd better write up some code to show how this would
work instead so I'll be back with that sooner or later.

Linus Walleij

 \ /
  Last update: 2009-12-07 15:25    [W:0.122 / U:36.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site