From ad78553f5d2456f1a7c22f9e9694b8c3c7e30693 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Thu, 11 Jun 2020 13:46:09 -0700 Subject: soc/amd/picasso/acpi: Add a wrapper method WAL1 for calling ALIB function 1 ALIB function 1 needs to be called every time there is a change in AC/DC state of the system. This change adds a wrapper method that can be called by PNOT (method to notify system power state change) to report to ALIB that system power state has changed i.e. AC <-> DC. Additionally, this change drops the call to ALIB from _INI method since the PWRS object might not be initialized correctly at that point. Instead EC makes a call to PNOT when PWRS is initialized. This wrapper also fixes the value of power state being passed into ALIB. ALIB expects 0 = AC and 1 = DC. On the other hand, PWRS reports 1 as AC and 0 as DC. WAL1() takes care of inverting the PWRS state before passing into ALIB. BUG=b:157752693 TEST=Verified that WAL1() gets called on AC connect/disconnect. Steps followed: $ echo 1 > /sys/module/acpi/parameters/aml_debug_output $ dmesg -w | grep ACPI [ 76.306947] ACPI Debug: "EC: AC DISCONNECTED" [ 76.307064] ACPI Debug: "ALIB call: func 1 params 0x03 0x00 0x01" [ 82.264946] ACPI Debug: "EC: GOT PD EVENT" [ 82.539833] ACPI Debug: "EC: GOT PD EVENT" [ 82.753721] ACPI Debug: "EC: GOT PD EVENT" [ 82.843676] ACPI Debug: "EC: GOT PD EVENT" [ 82.970596] ACPI Debug: "EC: AC CONNECTED" [ 82.970659] ACPI Debug: "ALIB call: func 1 params 0x03 0x00 0x00" [ 83.047598] ACPI Debug: "EC: GOT PD EVENT" [ 84.804733] ACPI Debug: "EC: GOT PD EVENT" [ 86.317934] ACPI Debug: "EC: GOT PD EVENT" [ 86.385920] ACPI Debug: "EC: GOT PD EVENT" [ 86.515830] ACPI Debug: "EC: AC DISCONNECTED" [ 86.515922] ACPI Debug: "ALIB call: func 1 params 0x03 0x00 0x01" [ 90.089062] ACPI Debug: "EC: GOT PD EVENT" [ 90.357914] ACPI Debug: "EC: GOT PD EVENT" [ 90.573812] ACPI Debug: "EC: GOT PD EVENT" [ 90.662744] ACPI Debug: "EC: GOT PD EVENT" [ 90.788706] ACPI Debug: "EC: AC CONNECTED" [ 90.788835] ACPI Debug: "ALIB call: func 1 params 0x03 0x00 0x00" [ 90.865675] ACPI Debug: "EC: GOT PD EVENT" [ 92.621793] ACPI Debug: "EC: GOT PD EVENT" Signed-off-by: Furquan Shaikh Change-Id: I1f2ade28ca35378ebf4647d8df3d2ea4d0b08096 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42297 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/soc/amd/picasso/acpi/cpu.asl | 29 ++++++++++++++++++++++++++++- src/soc/amd/picasso/acpi/sb_pci0_fch.asl | 11 ----------- 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'src/soc/amd') diff --git a/src/soc/amd/picasso/acpi/cpu.asl b/src/soc/amd/picasso/acpi/cpu.asl index 41d5bf5324..8b61b8f921 100644 --- a/src/soc/amd/picasso/acpi/cpu.asl +++ b/src/soc/amd/picasso/acpi/cpu.asl @@ -1,8 +1,35 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* Required function by EC, Notify OS to re-read CPU tables */ +/* + * Wrapper method that calls ALIB function 1 to report current AC/DC state. + */ +Method (WAL1) +{ + /* Send ALIB Function 1 the AC/DC state */ + Local0 = Buffer (0x03) {} + CreateWordField (Local0, 0, F1SZ) + CreateByteField (Local0, 2, F1DA) + + /* First argument is size i.e. 3 bytes */ + F1SZ = 3 + + /* + * Second argument is power state i.e. AC or DC. + * ALIB expects AC = 0, DC = 1. + * PWRS reports AC = 1, DC = 0. + * + * Hence, need to invert the state of PWRS. + */ + F1DA = \PWRS ^ 1 + + Printf ("ALIB call: func 1 params %o", Local0) + \_SB.ALIB (1, Local0) +} + Method (PNOT) { + /* Report AC/DC state to ALIB using WAL1() */ + \WAL1 () } /* diff --git a/src/soc/amd/picasso/acpi/sb_pci0_fch.asl b/src/soc/amd/picasso/acpi/sb_pci0_fch.asl index 751c178762..27c46611b3 100644 --- a/src/soc/amd/picasso/acpi/sb_pci0_fch.asl +++ b/src/soc/amd/picasso/acpi/sb_pci0_fch.asl @@ -128,17 +128,6 @@ Method(_INI, 0, Serialized) { /* Determine the OS we're running on */ OSFL() - - /* Send ALIB Function 1 the AC/DC state */ - Name(F1BF, Buffer(0x03){}) - CreateWordField(F1BF, 0, F1SZ) - CreateByteField(F1BF, 2, F1DA) - - Store(3, F1SZ) - Store(\PWRS, F1DA) - - \_SB.ALIB(1, F1BF) - } /* End Method(_SB._INI) */ Method(OSFL, 0){ -- cgit v1.2.3