[coreboot] Adding cycle count to battery.asl on the x60

Charles Devereaux coreboot at guylhem.net
Thu Dec 4 01:38:02 CET 2014


Hello

Cycle count are not reported in /proc/acpi/battery/BAT0/info

Apparently, this is due to omitting SBCC in the DSDT.

If the h8 is close enough to the it8518 (which seems to be the case), then
the following should apply:
    //
// Battery Information ID : 01/11
//
Field (ERAM, ByteAcc, NoLock, Preserve)
{
Offset(0xA0),
// Battery Mode(w)
, 15,
SBCM, 1, // bit 15 - CAPACITY_MODE
// 0: Report in mA/mAh ; 1: Enabled
SBMD, 16, // Manufacture Data
SBCC, 16, // Cycle Count
}

In Lenovo original DSDT, I see a similar SBCC field at this same position,
so this is very plausible.

In battery.asl I only see:
/* PAGE == 0x01 */
Field (ERAM, ByteAcc, NoLock, Preserve)
{
        Offset(0xa0),
                            , 15,
                        BAMA,  1,
}

I believe adding :
BMAN, 16
BCYC, 16

woud read the value, but then I do not know where to display them.

In drivers/acpi/battery.c, I see :
static enum power_supply_property energy_battery_props[] = {
        POWER_SUPPLY_PROP_STATUS,
        POWER_SUPPLY_PROP_PRESENT,
        POWER_SUPPLY_PROP_TECHNOLOGY,
        POWER_SUPPLY_PROP_CYCLE_COUNT,
        POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
        POWER_SUPPLY_PROP_VOLTAGE_NOW,
        POWER_SUPPLY_PROP_POWER_NOW,
        POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
        POWER_SUPPLY_PROP_ENERGY_FULL,
        POWER_SUPPLY_PROP_ENERGY_NOW,
        POWER_SUPPLY_PROP_CAPACITY,
        POWER_SUPPLY_PROP_MODEL_NAME,
        POWER_SUPPLY_PROP_MANUFACTURER,
        POWER_SUPPLY_PROP_SERIAL_NUMBER,
};

Basically, it seems the order of the fields is important, and that BCYC
should be added just befofore design voltage.

It battery.asl, it seems to be handled by Method(BINF, 2, NotSerialized),
and design voltage is BADV:
                        BADV, 16,               /* Design voltage */

So I first thought   I would add BCYC just after:
        Store(BADV, Index(Arg0, 4))     // Design Voltage
        Store(BCYC, Index(Arg0, 3))     // Cycle count

But Method(BINF, 2, NotSerialized) seems to be for static information, so I
guess I should add that instead to Method(BSTA, 4, NotSerialized)

BAVO is voltage now, so I guess I should add BCYC at 2 item before BAVO,
yet I see :
(...)
        } else {
                Store(BARC, Index(Arg1, 2))
                Store(Local2, Index(Arg1, 1))
        }
        Store(BAVO, Index(Arg1, 3))

So Arg1,1 is already used by Local2, which contains BAPR (present rate), so
I'm stuck. It seems very illogical - there should be an empty field instead
of the missing BCYC.

Where exactly am I making a mistake here?

Thanks
Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20141203/41a0981f/attachment-0001.html>


More information about the coreboot mailing list