teleshoes / tpacpi-bat

ThinkPad ACPI Battery Util
GNU General Public License v3.0
432 stars 47 forks source link

Older thinkpad support with coreboot firmware #83

Closed ArthurHeymans closed 4 years ago

ArthurHeymans commented 6 years ago

Hi

Doing some investigation I was able to figure out how to have the EC on my thinkpad X200 set the battery charging thresholds. Coreboot is a free/open source firmware (BIOS) replacement which means it is possible to modify the ACPI code. The vendor firware has no ACPI method for setting thresholds, but only smapi interface which is not implemented in coreboot.

I was able to implement it in pure ACPI (so no calls to generate SMI to have SMM set the thresholds like most recent thinkpads with vendor firmware) and when doing so I'm able to use tpacpi-bat to set and get thresholds. Inhibit and discharge are not (yet) implemented. This is the patch: https://review.coreboot.org/#/c/20913/

Do you think its worth adding x200 with coreboot to wiki when this patch is merged as a partially supported device?

Note: it probably also works on thinkpads of the same and older generation.

teleshoes commented 6 years ago

yea, absolutely! really cool stuff. (btw, is the X200 one of the ones with the write-protected EC, where you have to use a hardware flasher?)

ArthurHeymans commented 6 years ago

Ok thanks! We are still a bit debating how to handle the tpacpi-bat compatible interface ACPI (it's not that pretty with bitfields having special meanings instead of multiple arguments), but I think it is possible to create generic tpacpi-bat ACPI code for all coreboot compatible thinkpads (x60/t60, x200/t400 ,x201/t410, x220/t420, x230/t430 and similar).

I think the EC indeed has some sort of password mechanism preventing it's firmware from be written to but that not really something I mess with since I have no clue how to hardware flash the EC.

teleshoes commented 6 years ago

@ArthurHeymans a year or so later and now im on coreboot on my T430s. its WONDERFUL, but ive lost tpacpi-bat for myself, which is somewhat of a shame. (T430s is bios-locked, so i had someone with a desoldering station install a new EEPROM chip for me and flashed my BIOS)

this coreboot patch was never merged upstream right? my build doesnt appear to have it anyway. (perhaps it has been merged or partially merged, and i either dont know how to use it, or the T430s isnt supported? i see that the patchset appears to have recent merge conflicts, anyway)

if its not merged now but does get merged later, i would love to add whatever interface you guys decide to use (same one, totally different, whatever you wonderful people decide) to the api for tpacpi-bat so it works as much as possible OOTB.

please let me know if i can be of any assistance in any way!

gch1p commented 5 years ago

Hi @teleshoes! Did you try to use @ArthurHeymans's x200 patch on your t430s?

ArthurHeymans commented 5 years ago

https://review.coreboot.org/#/c/coreboot/+/23178/ implements the ACPI interface for a handful of thinkpads, but it is still not merged.

gch1p commented 5 years ago

@ArthurHeymans thanks, that's really cool!

teleshoes commented 5 years ago

(@ArthurHeymans thanks for the update!)

pickfire commented 4 years ago

https://review.coreboot.org/#/c/coreboot/+/23178/ have been merged

teleshoes commented 4 years ago

i no longer have a coreboot laptop to test on :(