summaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
authorIan Douglas Scott <idscott@system76.com>2021-09-15 09:27:49 -0600
committerFelix Held <felix-coreboot@felixheld.de>2021-09-17 01:03:59 +0000
commit8031abfcc2968d19242168950988d5adff65c426 (patch)
treee2da716fb1a1f84948873cf2d471afe2109b0773 /src/ec
parent6260bf712a836762b18d80082505e981e040f4bc (diff)
ec/system76/ec: acpi: Implement _BIX method
Implement _BIX method to expose battery cycle count. Requires an EC version with support for cycle count. Change-Id: I5f7a1d275caff59960aaf9c39b9c707970350987 Signed-off-by: Ian Douglas Scott <idscott@system76.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/57678 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jeremy Soller <jeremy@system76.com>
Diffstat (limited to 'src/ec')
-rw-r--r--src/ec/system76/ec/acpi/battery.asl78
-rw-r--r--src/ec/system76/ec/acpi/ec_ram.asl1
2 files changed, 79 insertions, 0 deletions
diff --git a/src/ec/system76/ec/acpi/battery.asl b/src/ec/system76/ec/acpi/battery.asl
index 50aaf9ef9e..027bbad0d6 100644
--- a/src/ec/system76/ec/acpi/battery.asl
+++ b/src/ec/system76/ec/acpi/battery.asl
@@ -96,6 +96,84 @@ Device (BAT0)
Return (PBIF) /* \_SB_.BAT0.PBIF */
}
+ Name (PBIX, Package ()
+ {
+ 0, // 0 - Revision
+ 1, // 1 - Power Unit: mAh
+ 0xFFFFFFFF, // 2 - Design Capacity
+ 0xFFFFFFFF, // 3 - Last Full Charge Capacity
+ 1, // 4 - Battery Technology: Rechargeable
+ 0xFFFFFFFF, // 5 - Design Voltage
+ 0, // 6 - Design Capacity of Warning
+ 0, // 7 - Design Capacity of Low
+ 0, // 8 - Cycle Count
+ 98000, // 9 - Measurement Accuracy
+ 0xFFFFFFFF, // 10 - Max Sampling Time
+ 0xFFFFFFFF, // 11 - Min Sampling Time
+ 0xFFFFFFFF, // 12 - Max Averaging Interval
+ 0xFFFFFFFF, // 13 - Min Averaging Interval
+ 0x40, // 14 - Battery Capacity Granularity 1
+ 0x40, // 15 - Battery Capacity Granularity 2
+ " ", // 16 - Model Number
+ " ", // 17 - Serial Number
+ " ", // 18 - Battery Type
+ " " // 19 - OEM Information
+ })
+
+ Method (IVBX, 0, NotSerialized)
+ {
+ PBIX [2] = 0xFFFFFFFF
+ PBIX [3] = 0xFFFFFFFF
+ PBIX [5] = 0xFFFFFFFF
+ PBIX [16] = " "
+ PBIX [17] = " "
+ PBIX [18] = " "
+ PBIX [19] = " "
+ BFCC = 0
+ }
+
+ Method (UPBX, 0, NotSerialized)
+ {
+ If (^^PCI0.LPCB.EC0.BAT0)
+ {
+ Local0 = (^^PCI0.LPCB.EC0.BDC0 & 0xFFFF)
+ PBIX [2] = Local0
+ Local0 = (^^PCI0.LPCB.EC0.BFC0 & 0xFFFF)
+ PBIX [3] = Local0
+ BFCC = Local0
+ Local0 = (^^PCI0.LPCB.EC0.BDV0 & 0xFFFF)
+ PBIX [5] = Local0
+ Local0 = (^^PCI0.LPCB.EC0.BCW0 & 0xFFFF)
+ PBIX [6] = Local0
+ Local0 = (^^PCI0.LPCB.EC0.BCL0 & 0xFFFF)
+ PBIX [7] = Local0
+ LOCAL0 = ^^PCI0.LPCB.EC0.CYC0
+ PBIX [8] = LOCAL0
+ PBIX [16] = "BAT"
+ PBIX [17] = "0001"
+ PBIX [18] = "LION"
+ PBIX [19] = "Notebook"
+ }
+ Else
+ {
+ IVBX ()
+ }
+ }
+
+ // _BIX: Battery Information Extended
+ Method (_BIX, 0, NotSerialized)
+ {
+ If (^^PCI0.LPCB.EC0.ECOK)
+ {
+ UPBX ()
+ }
+ Else
+ {
+ IVBX ()
+ }
+ Return (PBIX) /* \_SB_.BAT0.PBIX */
+ }
+
Name (PBST, Package (0x04)
{
Zero, // 0 - Battery state
diff --git a/src/ec/system76/ec/acpi/ec_ram.asl b/src/ec/system76/ec/acpi/ec_ram.asl
index 6ef54540b6..2faaeddf53 100644
--- a/src/ec/system76/ec/acpi/ec_ram.asl
+++ b/src/ec/system76/ec/acpi/ec_ram.asl
@@ -28,6 +28,7 @@ Field (ERAM, ByteAcc, Lock, Preserve)
Offset (0x3A),
BCW0, 32,
BCL0, 32,
+ CYC0, 16, // Battery cycle count
Offset (0x68),
ECOS, 8, // Detected OS, 0 = no ACPI, 1 = ACPI but no driver, 2 = ACPI with driver
Offset (0xC8),