Skip to contentSkip to conversation

ACPI: Battery information?

DISCUSSION Binary Xerroz 6 participants 15 messages Jun 7, 2004 – Jun 14, 2004 12 messages not in the archive ACPI

lore
Share & tools
lore
#0 lore raw

Forgive me if this is off topic in anyway, that said; I am curious how ACPI detects batteries, I assume its done while the kernel is initializing, is this true? Also, how is a battery detected? via tables such as the DSDT or equivalent? One last thing, could someone point me to the file where the batteries are listed and detected, I have spent some time looking through the code and have yet to find it. Thank you for your help.

Signature · 21 lines
____  ___            _______   \   \/  /___________ \   _  \  \     // __ \_  __ \/  /_\  \ /     \  ___/|  | \/\  \_/   \
/___/\  \___  >__|    \_____  /
     \_/   \/              \/
01011000 01100101 01110010 01110010 01101111
01111010 00001101 00001010 01111000 00111000
00110110 00100000 01000001 01110011 01110011
01100101 01101101 01100010 01101100 01100101
01110010 00100000 01000011 01101111 01100100
01100101 01110010 00001101 00001010 01000001
00100000 01011100 00100111 01010000 01110010
01101111 01100110 01100101 01110011 01110011
01101001 01101111 01101110 01100001 01101100
01011100 00100111 00000000 00000000 00000000



-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · Binary Xerroz

Forgive me if this is off topic in anyway, that said; I am curious how ACPI detects batteries, I assume its done while the kernel is initializing, is this true? Also, how is a battery detected? via tables such as the DSDT or equivalent? One last thing, could someone point me to the file where the batteries are listed and detected, I have spent some time looking through the code and have yet to find it.

Are you looking for this???

/usr/src/linux/drivers/acpi/battery.c

Signature · 5 lines
-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#3 lore raw
In reply to a message not in the archive

Hello Binary Xerroz,

Quoted 7 lines · On Mon, 07 Jun 2004 16:41:27 -0700 Binary Xerroz…

Forgive me if this is off topic in anyway, that said; I am curious how ACPI detects batteries, I assume its done while the kernel is initializing, is this true? Also, how is a battery detected? via tables such as the DSDT or equivalent? One last thing, could someone point me to the file where the batteries are listed and detected, I have spent some time looking through the code and have yet to find it. Thank you for your help.

16 lines, 640 bytes, nice obfuscated signature (no chance that it is displayed correctly if displayed w/ a variable-width font). Couldn't you pack the binary representation to 80 ASCII chars instead (even if still not RFC compliant)?

:-p

Regards,

Signature · 8 lines
wwp


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#5 lore raw
In reply to a message not in the archive
Quoted 8 lines · wwp

Hello Binary Xerroz,

Quoted 3 lines · On Mon, 07 Jun 2004 16:41:27 -0700 Binary Xerroz…

Forgive me if this is off topic in anyway, that said; I am curious how ACPI detects batteries, I assume its done while the kernel is initializing, is this true?

Yes or not. In fact, it depend if you compile battery as module or statically.

Quoted 2 lines
Quoted 2 lines

Also, how is a battery detected? via tables
such as the DSDT or equivalent?

The DSDT is actually no more than a kind of bytes-codes that need to be interpreted by an interpreter. For batteries, it's a "device" (as defined by ACPI). Such "device" do have a kind of identifier (a la PnP). A "device" containts "methods", and for a battery there is well-known "methods" from which you can get informations, trip-point and so on.

You should take a look at ACPI spec <http://www.acpi.info/>,
more precisely "The ACPI Specification - Revision 2.0c".

Quoted 3 lines
Quoted 3 lines

One last thing, could someone point me
to the file where the batteries are listed and detected, I have spent some time looking through the code and have yet to find it.

linux-2.6/drivers/acpi/battery.c

Quoted 5 lines
Quoted 1 line

Thank you for your help.

16 lines, 640 bytes, nice obfuscated signature (no chance that it is displayed correctly if displayed w/ a variable-width font). Couldn't you pack the binary representation to 80 ASCII chars instead (even if still not RFC compliant)?

wwp: We are not here in order to discuss about how e-mail have to be displayed or what, or if that's fine or not if your client can handle variable-width font and so on. If you can answer to the OP, then all is good. If not, then please do not comment how email have to be written. You are indeed off-topic.

Signature · 11 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#7 lore raw
In reply to a message not in the archive

Hello Bruno,

Quoted 9 lines · On Tue, 8 Jun 2004 11:47:07 +0200 Bruno Ducrot…
Quoted 3 lines

16 lines, 640 bytes, nice obfuscated signature (no chance that it is displayed correctly if displayed w/ a variable-width font). Couldn't you pack the binary representation to 80 ASCII chars instead (even if still not RFC compliant)?

wwp: We are not here in order to discuss about how e-mail have to be displayed or what, or if that's fine or not if your client can handle variable-width font and so on. If you can answer to the OP, then all is good. If not, then please do not comment how email have to be written. You are indeed off-topic.

You're definitely right, my bad, I should have sent my email privately. My apologizes for the noise on this mailing list. My aim was to friendly inform about the uses around signing email (at least towards RFC compliance, which is not a bad starting reference). We have continued this discussion privately.

Regards,

Signature · 8 lines
wwp


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#12 lore raw
In reply to a message not in the archive
Quoted 11 lines · Binary Xerroz

Ive looked over the battery.c file and modified it quite a bit (nothing too drastic), however even compiled as a module, it &lt;u&gt;WILL NOT&lt;/u&gt; detect the second battery unless its booted with it at boot time. Forgive me as i forget to mention this is a laptop, with a 'hot-swappable' battery/cdrom; It works fine if i boot with second batery in, then i can swap it in/out with cdrom, and with the modifications i made to battery.c, it displays battery's and their status correctly; though booting with the second battery isnt that big of a deal, it would be nice to be able todo so without that limitation. Any suggestions? (i can also send my modified battery.c if anyone cares to take a look).<br>

I think it's more a problem with an ACPI event handling then. Do you have an acpidump somewhere to look at ?

wget ftp://ftp.kernel.org//pub/linux/kernel/people/lenb/acpi/utils/pmtools-20031210.tar.bz2 tar xjvfp pmtools-20031210.tar.bz2
cd pmtools-20031210/acpidmp
make
sudo ./acpidmp > acpidmp.out
bzip2 acpidmp.out

Then mail me the acpidmp.out.bz2

Cheers,

Signature · 11 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#9 lore raw
In reply to a message not in the archive

Hi,

Quoted 5 lines · wwp

You're definitely right, my bad, I should have sent my email privately. My apologizes for the noise on this mailing list. My aim was to friendly inform about the uses around signing email (at least towards RFC compliance, which is not a bad starting reference). We have continued this discussion privately.

No problem. I actually agree with most of your coments, but that's not on topic..

Cheers,

Signature · 11 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#14 lore raw
In reply to a message not in the archive

Bruno Ducrot wrote: On Tue, Jun 08, 2004 at 03:04:53AM -0700, Binary Xerroz wrote: Ive looked over the battery.c file and modified it quite a bit (nothing too drastic), however even compiled as a module, it &lt;u&gt;WILL NOT&lt;/u&gt; detect the second battery unless its booted with it at boot time. Forgive me as i forget to mention this is a laptop, with a 'hot-swappable' battery/cdrom; It works fine if i boot with second batery in, then i can swap it in/out with cdrom, and with the modifications i made to battery.c, it displays battery's and their status correctly; though booting with the second battery isnt that big of a deal, it would be nice to be able todo so without that limitation. Any suggestions? (i can also send my modified battery.c if anyone cares to take a look).<br>

62c62
<
---

Quoted 1 line

int battery_init = 0;

75d74
<
306d304
<
324a323

Quoted 1 line
		//return_VALUE('1');

334d332
<
362c360,361
<
---

Quoted 2 lines
	acpi_battery_check(battery);
	battery_init = 0;

365c364
<
---

Quoted 1 line

recheck:

369,370c368,373
< p += sprintf(p, "present: no\n");
< goto end;
---

Quoted 6 lines
		
		if(battery_init==1) {  p += sprintf(p, "present:                 no\n"); goto end; }
			acpi_battery_check(battery);
			battery_init++;
			goto recheck;

461c464,465
<
---

Quoted 2 lines
	acpi_battery_check(battery);
	battery_init = 0;

464a469

Quoted 1 line

recheck:

468,469c473,477
< p += sprintf(p, "present: no\n");
< goto end;
---

Quoted 5 lines
		if(battery_init==1) {  p += sprintf(p, "present:                 no\n"); goto end; }
			acpi_battery_check(battery);
			battery_init++;
			goto recheck;

471d478
<

#16 lore raw
In reply to a message not in the archive
Quoted 10 lines · Binary Xerroz

Included is the output of acpidmp, also i included a diff patch for kernel 2.6.6, patched with patch from acpi.sf.net
About the battery.c, the main reason for my modifications is
because to me ACPI for linux doesnt expect a battery to be removed (physically) such as on a laptop. the modified code reruns check routines to make sure the battery is still there, if not its updated as no present; before it still showed as present, but had critical status and such, this patch fixes that and updates accordingly. Double check routines added to make it work on status update instead of two. Anything else, let me know.

ACPI support hotplug of batteries if the hardware generate an SCI (an interrupt), then a handler is called which will call an AML method which in turn will call a special opcode (Notify()).
Then, after a Notify(FOO, 0x80) (or 0x81), drivers/acpi/battery::acpi_battery_notify() will be called which will reprobe the battery FOO (and (re)attach or detach to the acpi bus if needed).

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

It may be also the case that the hardware do not support this scheme, (the problem is that the interrupt used for this is not the same for APM and ACPI, and hardware need to be configured of the mode of operation. It's done at init stage of kernel).

So one step perhaps to debug this is to see if interrupts are generated. You can, for example, do a
watch -d 'cat /proc/interrupts'
then see if the interrupt associated to acpi change whenever you plug/unplug a battery.

btw, your acpidump.bz2 seems to be corrupted somehow. Could you please resend it?

ps: my email client do not support HTML. Would be fine if you can send at least a text alternative somehow.

Signature · 11 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#18 lore raw
In reply to a message not in the archive
Quoted 4 lines · Bruno Ducrot

On Tue, Jun 08, 2004 at 02:37:30PM -0700, Binary Xerroz wrote:

btw, your acpidump.bz2 seems to be corrupted somehow. Could you please resend it?

Ok, got it.

The problem (if I understand correctly) is that there is a device (SWAP) with _HID being EisaId ("IBM0069") which (I guess) hold the second battery. There is also some "Notify" called to this device with value 0x83 which can't be understood by Linux without a specific driver for. I think the second battery is handled with this device somehow, so that some of the functions (under the EC) which should call the Notify (with 0x80 or 0x81) is not called by the embedded controller somehow, because the state machine associated to the battery handling is screwed.

There may be a need to create an ACPI driver specific to this device, perhaps, if that's not done already?

Cheers,

Signature · 11 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#19 lore raw
In reply to a message not in the archive
Quoted 5 lines · Bruno Ducrot
Quoted 3 lines · Binary Xerroz

About the battery.c, the main reason for my modifications is
because to me ACPI for linux doesnt expect a battery to be removed (physically) such as on a laptop. the modified code reruns check

Well, this works fine for me on a hp compaq nx5000 with 2 batteries. So i suspect the quality of your BIOS / DSDT is to blame.

Quoted 14 lines
Quoted 5 lines

routines to make sure the battery is still there, if not its updated as no present; before it still showed as present, but had critical status and such, this patch fixes that and updates accordingly. Double check routines added to make it work on status update instead of two. Anything else, let me know.

ACPI support hotplug of batteries if the hardware generate an SCI (an interrupt), then a handler is called which will call an AML method which in turn will call a special opcode (Notify()).
Then, after a Notify(FOO, 0x80) (or 0x81), drivers/acpi/battery::acpi_battery_notify() will be called which will reprobe the battery FOO (and (re)attach or detach to the acpi bus if needed).

Quoted 1 line

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

As written above, it works for me under Linux.

Quoted 2 lines

ps: my email client do not support HTML. Would be fine if you can send at least a text alternative somehow.

indeed.

Signature · 6 lines
Stefan Seyfried



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#21 lore raw
In reply to a message not in the archive
Quoted 2 lines · Stefan Seyfried

Well, this works fine for me on a hp compaq nx5000 with 2 batteries. So i suspect the quality of your BIOS / DSDT is to blame.

It work for me since 2 or 3 years at least.
...

Quoted 3 lines
Quoted 1 line

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

As written above, it works for me under Linux.

Fine. And you assume then if it work for you, but not for others, then the AML is faulty? Why?

Cheers,

Signature · 8 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#23 lore raw
In reply to a message not in the archive
Quoted 6 lines · Bruno Ducrot
Quoted 2 lines · Stefan Seyfried

Well, this works fine for me on a hp compaq nx5000 with 2 batteries. So i suspect the quality of your BIOS / DSDT is to blame.

It work for me since 2 or 3 years at least.

Ok, qouted wrong: Binary Xerroz's BIOS may be to blame.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

As written above, it works for me under Linux.

Fine. And you assume then if it work for you, but not for others, then the AML is faulty? Why?

No, what i wanted to say was: it works for my small sample of about 5 Machines with multiple batteries. If there was this general bug which would prevent multiple batteries from working all the time i think i would have hit it, too.
Of course there also can be a bug which is only triggered by some special machine.

Signature · 6 lines
Stefan Seyfried



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#25 lore raw
In reply to a message not in the archive
Quoted 17 lines · Stefan Seyfried
Quoted 6 lines · Bruno Ducrot
Quoted 2 lines · Stefan Seyfried

Well, this works fine for me on a hp compaq nx5000 with 2 batteries. So i suspect the quality of your BIOS / DSDT is to blame.

It work for me since 2 or 3 years at least.

Ok, qouted wrong: Binary Xerroz's BIOS may be to blame.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

As written above, it works for me under Linux.

Fine. And you assume then if it work for you, but not for others, then the AML is faulty? Why?

Quoted 6 lines

No, what i wanted to say was: it works for my small sample of about 5 Machines with multiple batteries. If there was this general bug which would prevent multiple batteries from working all the time i think i would have hit it, too.
Of course there also can be a bug which is only triggered by some special machine.

... some special machine containing some special DSDT which is not standards compliant...

AML tools are fairly mature and check DSTD well. IME at least half of all DSTDs disassmbled some bugs, many minor, some major breaking things.

-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.

Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#26 lore raw
In reply to a message not in the archive
Quoted 9 lines · Stefan Seyfried
Quoted 6 lines · Bruno Ducrot
Quoted 2 lines · Stefan Seyfried

Well, this works fine for me on a hp compaq nx5000 with 2 batteries. So i suspect the quality of your BIOS / DSDT is to blame.

It work for me since 2 or 3 years at least.

Ok, qouted wrong: Binary Xerroz's BIOS may be to blame.

Ok.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So it's more likely a trouble somewhere in your DSDT, or a bug under linux.

As written above, it works for me under Linux.

Fine. And you assume then if it work for you, but not for others, then the AML is faulty? Why?

Quoted 6 lines

No, what i wanted to say was: it works for my small sample of about 5 Machines with multiple batteries. If there was this general bug which would prevent multiple batteries from working all the time i think i would have hit it, too.
Of course there also can be a bug which is only triggered by some special machine.

In fact, as I already stated, I think the root of the trouble is that there is a device from which there is no driver, which is problably a kind of mediabay. I think (but I may be wrong) that unless a special driver is written for this device, the second battery will not work as expected. So, AFAIK, it's not a bug in the DSDT, nor even a bug in linux since this driver have to be written... Note that I don't have a clue on how to start for developing this driver.

Cheers,

Signature · 8 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504