From 8702450e51114d6e366005ac78331661bc5ad93b Mon Sep 17 00:00:00 2001 From: Tim Wawrzynczak Date: Tue, 28 Jun 2022 12:08:52 -0600 Subject: mb/google/brya/acpi: Add support for D Notify event from the Chrome EC The agah EC code includes a driver to keep track of the current D Notify level that the GPU should be at. When it changes, it will send a host event to the ACPI FW, which will then pass that Notify on to the kernel driver. This patch adds support for that feature, which is described in the Nvidia Software Design Guide. BUG=b:229405562 TEST=add Printf() calls to the ACPI, and work through the various scenarios on the EC that will cause D Notify levels to change; this will cause the Printfs() to show up in the kernel log. Signed-off-by: Tim Wawrzynczak Change-Id: I5cd8bd7d177ea10a165613ed0726a6d6fd86c226 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65486 Tested-by: build bot (Jenkins) Reviewed-by: Robert Zieba Reviewed-by: Paul Menzel Reviewed-by: Eric Lai --- src/mainboard/google/brya/acpi/gpu_defines.h | 12 ++++++++++++ src/mainboard/google/brya/acpi/gpu_ec.asl | 13 +++++++++++++ src/mainboard/google/brya/acpi/gpu_top.asl | 27 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/mainboard/google/brya/acpi/gpu_ec.asl (limited to 'src/mainboard') diff --git a/src/mainboard/google/brya/acpi/gpu_defines.h b/src/mainboard/google/brya/acpi/gpu_defines.h index ec17a1c452..1cb03145b0 100644 --- a/src/mainboard/google/brya/acpi/gpu_defines.h +++ b/src/mainboard/google/brya/acpi/gpu_defines.h @@ -46,3 +46,15 @@ #define REVISION_MIN_NBCI 0x102 #define REVISION_MIN_NVPCF 0x200 #define REVISION_MIN_GPS 0x200 + +#define D1_EC 0 +#define D2_EC 1 +#define D3_EC 2 +#define D4_EC 3 +#define D5_EC 4 + +#define D1_GPU 0xD1 +#define D2_GPU 0xD2 +#define D3_GPU 0xD3 +#define D4_GPU 0xD4 +#define D5_GPU 0xD5 diff --git a/src/mainboard/google/brya/acpi/gpu_ec.asl b/src/mainboard/google/brya/acpi/gpu_ec.asl new file mode 100644 index 0000000000..998d9c0e6a --- /dev/null +++ b/src/mainboard/google/brya/acpi/gpu_ec.asl @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#define EC_D_NOTIFY_MASK 0x7 + +Scope (\_SB.PCI0.LPCB.EC0) +{ + /* EC has data for GPU in memmap */ + Method (_Q0C, 0, Serialized) + { + Local0 = ToInteger(GPUD) & EC_D_NOTIFY_MASK + \_SB.PCI0.PEG0.PEGP.DNOT (Local0) + } +} diff --git a/src/mainboard/google/brya/acpi/gpu_top.asl b/src/mainboard/google/brya/acpi/gpu_top.asl index f3b348aba8..c98358ff8d 100644 --- a/src/mainboard/google/brya/acpi/gpu_top.asl +++ b/src/mainboard/google/brya/acpi/gpu_top.asl @@ -25,6 +25,33 @@ Scope (\_SB.PCI0.PEG0) #include "nbci.asl" #include "nvpcf.asl" #include "gps.asl" + #include "gpu_ec.asl" + + /* Convert D Notify from EC to GPU */ + Method (CNVD, 1, NotSerialized) + { + Switch (ToInteger(Arg0)) { + Case (D1_EC) { Return (D1_GPU) } + Case (D2_EC) { Return (D2_GPU) } + Case (D3_EC) { Return (D3_GPU) } + Case (D4_EC) { Return (D4_GPU) } + Case (D5_EC) { Return (D5_GPU) } + Default { Return (D5_GPU) } + } + } + + /* Current D Notify Value, defaults to D1 */ + Name (CDNV, D1_EC) + Method (DNOT, 1, Serialized) + { + Printf ("EC: GPU D-Notify, %o", Arg0) + If (Arg0 != CDNV) + { + CDNV = Arg0 + Local0 = CNVD (Arg0) + Notify (\_SB.PCI0.PEG0.PEGP, Local0) + } + } Method (_DSM, 4, Serialized) { -- cgit v1.2.3