ec/starlabs/merlin/battery: Calculate unknown values

If the EC doesn't know a value, it will report it as 0xffff. In these
cases, calculate a value to used based on others. For example, if the
EC doesn't know the last full charge capacity, report the design
capacity to the OS.

Change-Id: I310555ff913c2e492bbaec4d77281ac32c0de7a3
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81408
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Sean Rhodes
2024-03-18 15:08:51 +00:00
committed by Felix Held
parent 7c4cc60a6c
commit cb9591cef0

View File

@@ -40,6 +40,8 @@ Device (BAT0)
SBIF [1] = B1DC SBIF [1] = B1DC
If (B1FC != 0xffff) { If (B1FC != 0xffff) {
SBIF [2] = B1FC SBIF [2] = B1FC
} Else {
SBIF [2] = B1DC
} }
SBIF [4] = B1DV SBIF [4] = B1DV
SBIF [5] = B1DC / 5 // 20% SBIF [5] = B1DC / 5 // 20%
@@ -88,6 +90,8 @@ Device (BAT0)
XBIF [2] = B1DC XBIF [2] = B1DC
If (B1FC != 0xffff) { If (B1FC != 0xffff) {
XBIF [3] = B1FC XBIF [3] = B1FC
} Else {
XBIF [3] = B1DC
} }
XBIF [5] = B1DV XBIF [5] = B1DV
XBIF [6] = B1DC / 5 // 20% XBIF [6] = B1DC / 5 // 20%
@@ -117,6 +121,8 @@ Device (BAT0)
PKG1[1] = B1PR PKG1[1] = B1PR
If (B1RC != 0xffff) { If (B1RC != 0xffff) {
PKG1[2] = B1RC PKG1[2] = B1RC
} Else {
PKG1[2] = B1RP * (B1DC / 100)
} }
PKG1[3] = B1PV PKG1[3] = B1PV
Return (PKG1) Return (PKG1)