diff options
author | Subrata Banik <subratabanik@google.com> | 2024-09-13 21:07:49 +0530 |
---|---|---|
committer | Subrata Banik <subratabanik@google.com> | 2024-09-14 18:13:47 +0000 |
commit | fa5e3d9d4474e50758ddf2287d26b164806c597c (patch) | |
tree | 332a5193bc7379f25c3b12866383c16b801e9da1 /src/ec/google | |
parent | 3d5412f8d4ad2cd3c873a46d8f6fb6a20c5f9ad6 (diff) |
ec/google/chromeec: Optimize battery string readout with caching
This commit refactors the long battery string implementation to include
caching of the EC response for battery information (model, serial, and
manufacturer).
This optimization reduces resume time by approximately 63ms by
minimizing communication overhead between the AP and EC.
BUG=b:366338622
TEST=Verified on google/tivviks_ufs:
* Long battery string is displayed when
EC_GOOGLE_CHROMEEC_READ_BATTERY_LONG_STRING is enabled.
* Short battery string is displayed when
EC_GOOGLE_CHROMEEC_READ_BATTERY_LONG_STRING=n.
Change-Id: I32ae5b5e618f20335f3d344811a97f1416df529e
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84354
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Caveh Jalali <caveh@chromium.org>
Diffstat (limited to 'src/ec/google')
-rw-r--r-- | src/ec/google/chromeec/acpi/battery.asl | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/src/ec/google/chromeec/acpi/battery.asl b/src/ec/google/chromeec/acpi/battery.asl index 30fe0fce62..7d5208835a 100644 --- a/src/ec/google/chromeec/acpi/battery.asl +++ b/src/ec/google/chromeec/acpi/battery.asl @@ -60,6 +60,14 @@ Name(BRSS, 0xff) #else Name(BRSS, 0x0) #endif +// Cached battery string response indicator +Name(BRI1, 0) +Name(BRI2, 0) +Name(BRI3, 0) +// Cached battery string response data to save suspend-resume time +Name(BRS1, Buffer(32) {0}) +Name(BRS2, Buffer(32) {0}) +Name(BRS3, Buffer(32) {0}) // Read extended battery strings from the selected battery. // Arg0 = string index // @@ -82,11 +90,27 @@ Name(BRSS, 0x0) Method(BRSX, 1, Serialized) { // It doesn't make sense to read the FIFO support indicator. - if (Arg0 == 0) + if (Arg0 == 0 || Arg0 > 3) { Return ("") } + // Check if response is already cached + If (Arg0 == 1 && BRI1 == 1) + { + Return (BRS1) /* battery model name */ + } + + If (Arg0 == 2 && BRI2 == 1) + { + Return (BRS2) /* battery serial number */ + } + + If (Arg0 == 3 && BRI3 == 1) + { + Return (BRS3) /* battery manufacturer's name */ + } + If (BRSS == 0xff) { // Write 0 to BSRF to read back a support indicator; nonzero and @@ -109,34 +133,51 @@ Method(BRSX, 1, Serialized) { If (Arg0 == 1) { - Return (ToString (Concatenate (BMOD, 0))) + Local0 = ToString (Concatenate (BMOD, 0)) } ElseIf (Arg0 == 2) { - Return (ToString (Concatenate (BSER, 0))) + Local0 = ToString (Concatenate (BSER, 0)) } ElseIf (Arg0 == 3) { - Return (ToString (Concatenate (BMFG, 0))) + Local0 = ToString (Concatenate (BMFG, 0)) } - Else + } + Else + { + // Select requested parameter to read + BSRF = Arg0 + + // Read to end of string, or up to a reasonable maximum length. Reads of + // BSRF consume bytes from the FIFO, so take care to read it only once + // per byte of data. + Local0 = "" + Local1 = BSRF + While (Local1 != 0 && SizeOf (Local0) < 32) { - Return ("") + Local0 = Concatenate (Local0, ToString (Local1)) + Local1 = BSRF } } - // Select requested parameter to read - BSRF = Arg0 + // Store the result in the cache + If (Arg0 == 1) + { + BRS1 = Local0 + BRI1 = 1 + } - // Read to end of string, or up to a reasonable maximum length. Reads of - // BSRF consume bytes from the FIFO, so take care to read it only once - // per byte of data. - Local0 = "" - Local1 = BSRF - While (Local1 != 0 && SizeOf (Local0) < 32) + If (Arg0 == 2) { - Local0 = Concatenate (Local0, ToString (Local1)) - Local1 = BSRF + BRS2 = Local0 + BRI2 = 1 + } + + If (Arg0 == 3) + { + BRS3 = Local0 + BRI3 = 1 } Return (Local0) |