From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by mx.groups.io with SMTP id smtpd.web08.2377.1662486192931954863 for ; Tue, 06 Sep 2022 10:43:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FztxYGb6; spf=pass (domain: gmail.com, ip: 209.85.222.173, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qk1-f173.google.com with SMTP id w18so8714434qki.8 for ; Tue, 06 Sep 2022 10:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=rDUFxJLmWfki6scj3Pl+PQD2IV54HVuYqitMZxcGN/M=; b=FztxYGb6u+JBeNYPsMrKS3S8lMQPQ2FXH+7qA1ZK1b0pAU1+dLpzWNcggX+YParlR4 MxJIBb1CgDq4ooL3VrEjEu9qpzKSS5JGUfNGvvVBu5NreUAiy5ol4ORb/kSG1cXf1ZMA 6UaFZMBlkAisO+9L5/XXQtMCYENxCPMunLLzYkVGvkBSAhvbcZ88xrbSGP8aJnEdRSkI FC81QxgLn1syS+8odthOVkO+MUHmMiyLEs5ORqk4gNaiPmkbHhO90xujAihMn3kfyphq uICJ5PMzScuQsHHaDQc2tntUmW3IR19oSMNB4unoF9oujGfku/lNln+scRr2TWyybL20 ipZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=rDUFxJLmWfki6scj3Pl+PQD2IV54HVuYqitMZxcGN/M=; b=UoLbIOjb/LxXZNDSkpQZ7VnhGUkcWugnOENUqs9lNmh9gPr5abmhO1sgpTKTzDcMLF z2flVmZIu5nFGw755FtKya55R8sGbddD7fAgnYiCWZFu3m2piL3VKgBBCeMEVdHpyA76 cDtkrcNtAuFzUC+Xaa8gjLqYToPem48i/LrX3STMdjzR38XdLDkI78xOaXOJiW7OxKzx Pgu/D6nrczyu04lHna3qIRyUq0okcNWstEGUfR9v0+uwrYPeWej8QIsLy4zLTLqPyKZ6 m/6ksQKOEjdv5f/g873Cn8lkOzmFtG7L8/mLHMrkjfRgZ7eoR+hKmweDFCdEVhiYOvXy dcQQ== X-Gm-Message-State: ACgBeo098jPDLuIKBTOhNhtp3I1jmawVZ8o5iy/Pgk7Aj1CVlBn90X/K j3B45JFUUIwB7VZuCqKouVFPinZWMrhBHQ== X-Google-Smtp-Source: AA6agR4BPMuf0bXmnBFgrBy0tdoJbh4m4wCKcqqVVR82H8KStl+z/4Z3fYoxL//a70YNQd0H61JkgQ== X-Received: by 2002:a05:620a:4147:b0:6bb:86e5:e4e5 with SMTP id k7-20020a05620a414700b006bb86e5e4e5mr37567565qko.334.1662486191758; Tue, 06 Sep 2022 10:43:11 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:b132:3785:fa38:a51]) by smtp.gmail.com with ESMTPSA id bi3-20020a05620a318300b006b61b2cb1d2sm11221482qkb.46.2022.09.06.10.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:43:11 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Sai Chaganty , Isaac Oram , Nate DeSimone , Chasel Chiu Subject: [edk2-devel][edk2-platforms][PATCH v1 3/7] KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi: Improvements for EC ACPI Date: Tue, 6 Sep 2022 13:42:54 -0400 Message-Id: <5febbddf7f101a0a53a948f6c9c1a2c1866891dd.1662485273.git.benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Perform EC read and write via SystemIO when EmbeddedControl is unavailable. Not properly tested yet. Re-sync against coreboot port. Does not yet handle SMM traps. In-progress. Cc: Sai Chaganty Cc: Isaac Oram Cc: Nate DeSimone Cc: Chasel Chiu Signed-off-by: Benjamin Doron --- .../Acpi/BoardAcpiTables.inf | 4 + .../AspireVn7Dash572G/Acpi/BoardSsdt.asl | 29 +++- .../AspireVn7Dash572G/Acpi/battery.asl | 11 +- .../AspireVn7Dash572G/Acpi/ec.asl | 130 ++++++++-------- .../AspireVn7Dash572G/Acpi/eclib.asl | 141 ++++++++++++++++++ .../AspireVn7Dash572G/Acpi/mainboard.asl | 6 +- .../AspireVn7Dash572G/Acpi/thermal.asl | 16 +- 7 files changed, 256 insertions(+), 81 deletions(-) create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/A= cpi/eclib.asl diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/Boa= rdAcpiTables.inf b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Ac= pi/BoardAcpiTables.inf index 806c0d2575c8..9a31b400a35e 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/BoardAcpiT= ables.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/BoardAcpiT= ables.inf @@ -13,5 +13,9 @@ MODULE_TYPE =3D USER_DEFINED=0D VERSION_STRING =3D 1.0=0D =0D +[Packages]=0D + KabylakeOpenBoardPkg/OpenBoardPkg.dec=0D + MdePkg/MdePkg.dec=0D +=0D [Sources]=0D BoardSsdt.asl=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/Boa= rdSsdt.asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/Boa= rdSsdt.asl index cdec0434883e..d1609131ecf7 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/BoardSsdt.= asl +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/BoardSsdt.= asl @@ -6,17 +6,44 @@ =0D **/=0D =0D +#include =0D +=0D DefinitionBlock (=0D "Board.aml",=0D "SSDT",=0D - 0x02,=0D + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION,=0D "ACRSKL",=0D "AcerSKL ",=0D 0x20141018=0D )=0D {=0D + External (SSMP, IntObj)=0D + External (SMIF, IntObj)=0D External (\MDBG, MethodObj)=0D =0D + // SW SMI data port=0D + OperationRegion (DPRT, SystemIO, 0xB3, 1)=0D + Field (DPRT, ByteAcc, Lock, Preserve)=0D + {=0D + SSDP, 8=0D + }=0D +=0D + Name (ESMI, 0xDD) // TODO: Patch at runtime=0D + Method (TRPS, 3, Serialized)=0D + {=0D + \DBGH (Concatenate ("SMIF: ", ToHexString (Arg0)))=0D + \DBGH (Concatenate ("Param0: ", ToHexString (Arg1)))=0D + \DBGH (Concatenate ("Param1: ", ToHexString (Arg2)))=0D +=0D + Local0 =3D Arg1=0D + Local0 |=3D (Arg2 << 4)=0D + \DBGH (Concatenate ("Local0: ", ToHexString (Local0)))=0D +=0D + SMIF =3D Arg0=0D + SSDP =3D Local0=0D + SSMP =3D ESMI=0D + }=0D +=0D // Debug print helper=0D Method (DBGH, 1)=0D {=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/bat= tery.asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/batte= ry.asl index 5ae4bdca89d5..1bf652c4a01e 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/battery.asl +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/battery.asl @@ -184,11 +184,17 @@ Method (GBIF, 3, NotSerialized) Local7 =3D EBSN=0D #endif=0D Name (SERN, Buffer (0x06) { " " })=0D + /* Convert hex to decimal.=0D + * - There appears to be a bug in the vendor's implementation:=0D + * The correct answer has, or can have, 5 digits, so Local6 =3D 5.=0D + * Also see "SERN" buffer.=0D + * - Userspace prints reversed serial number?=0D + */=0D Local6 =3D 4=0D While (Local7)=0D {=0D Divide (Local7, 10, Local5, Local7)=0D - SERN[Local6] =3D (Local5 + 0x30) // Add ASCII 0x30 to get character= =0D + SERN[Local6] =3D (Local5 + 0x30) // Add 0x30 to get numeric charact= er=0D Local6--=0D }=0D =0D @@ -310,7 +316,7 @@ Method (GBST, 4, NotSerialized) // All on one page If (Arg2)=0D {=0D Local1 *=3D Local3=0D - Local1 /=3D 1000 /* Remainder ignored */=0D + Local1 /=3D 1000 /* Remainder ignored by vendor */=0D }=0D }=0D Else=0D @@ -382,6 +388,7 @@ Device (BAT0) =0D Method (_BIF, 0, NotSerialized) // _BIF: Battery Information=0D {=0D + /* Bitwise AND by vendor is lossy? */=0D Local6 =3D B0ST=0D Local7 =3D 20=0D While (Local6 && Local7)=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/ec.= asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/ec.asl index df71dd69b491..b8f0dba1597f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/ec.asl +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/ec.asl @@ -5,18 +5,33 @@ =0D **/=0D =0D -/* Global TODO: (externally: Optimus GC6 and GPS)=0D +/*=0D + * Global TODO: (externally: Optimus GC6 and GPS)=0D * - TRPS: This is SMI 0xDD, likely in SmmOemDriver. This SW SMI adds to a= nd executes=0D * a table of function pointers produced throughout the OEM 'value= -add' stack.=0D + * - Arg0 - "SFUN" - is index into "$FNC" pointer table? It's easi= er to=0D + * correlate *CommonService use: Offset 13 creates TRPS handlers= .=0D + * - Known functions:=0D + * - 0x80 calls offset 0 in ACER_BOOT_DEVICE_SERVICE_PROTOCOL_GU= ID.=0D + * - NB: efiXplorer can miss InstallProtocolInterface() when I= nterface is local=0D + * - 0x81 toggles Intel Dynamic Acceleration in IA32_MISC_ENABLE= MSR.=0D + * - 0x82 does switch on "OSYS" to set EC byte. Suspect this is = for OS features.=0D + * (A CVE exists in the vendor code only if it never sets the offs= et in the buffer.)=0D + * - RBEC/WBEC/MBEC: This is SMI 0xDD, "functions" 0x10, 0x11 and 0x12 in = SmmKbcDriver,=0D + * added into SmmCommonService table at its protocol notify. Perfor= ms read, write=0D + * and read-modify-write from buffer. We will use ACPI instead.=0D * - WMI: This is likely SMI 0xD0 in A01WMISmmCallback. This SW SMI likely= uses the WMI=0D * object and consumes the OEM 'value-add' stack for EC and presuma= bly the A01*=0D - * OEM/ODM 'value-add' stack.=0D + * OEM/ODM 'value-add' stack. An SSDT contains the device and EC0 p= rovides "GCMS"=0D + * and "GOTS" method helpers.=0D *=0D - * Generally, more reversing is needed.=0D + * Generally, more information is needed.=0D + * TODO: Restore stripped features using reference code (except, check Boa= rdAcpiDxe first)=0D + * and implement more board features: lid and touchpad trigger wake = from S3,=0D + * Fn-Ctrl swap, sticky Fn keys and always-on USB charger.=0D */=0D -/* TODO: Implement more features around reference code (except, check Boar= dAcpiDxe first) */=0D =0D -// TODO: Enable and test=0D +// TODO/TEST=0D #undef LGMR_ENABLED=0D =0D // "DIDX" - "DeviceIdX" is uninitialised, cannot use "BRTN" method yet=0D @@ -40,17 +55,7 @@ Device (\_SB.PCI0.LPCB.EC0) IO (Decode16, 0x66, 0x66, 0, 1)=0D })=0D =0D - OperationRegion (ECO1, SystemIO, 0x62, 1)=0D - Field (ECO1, ByteAcc, Lock, Preserve)=0D - {=0D - PX62, 8=0D - }=0D -=0D - OperationRegion (ECO2, SystemIO, 0x66, 1)=0D - Field (ECO2, ByteAcc, Lock, Preserve)=0D - {=0D - PX66, 8=0D - }=0D + #include "eclib.asl"=0D =0D #ifdef LGMR_ENABLED=0D OperationRegion (ECMB, SystemMemory, LGMR, 0x200)=0D @@ -84,10 +89,12 @@ Device (\_SB.PCI0.LPCB.EC0) EX3G, 1, /* 3G */=0D , 3,=0D RFEX, 1, /* RF present */=0D -#if 0 // Merely a guess=0D - Offset (0x55),=0D - BTH0, 8, /* Battery threshold? TODO: Actually diff in modified = vendor FW */=0D -#endif=0D +/*=0D + * NOTE: Some reverse engineering, as well as corroborating vendor's hidde= n SetupUtility=0D + * options with the EC's memory space, suggests that offset 0x55 might be = the battery=0D + * threshold=0D + * - TODO: Actually diff changes in modified vendor FW=0D + */=0D Offset (0x57),=0D , 7,=0D AHKB, 1, /* Hotkey triggered */=0D @@ -204,14 +211,19 @@ Device (\_SB.PCI0.LPCB.EC0) {=0D TINI ()=0D EOSS =3D 0x05=0D -// OSIN ()=0D + // OSYS retrieved by SMM, Arg3 is unused=0D +// TRPS (0x82, 1, 0)=0D =0D - /* Other pages return valid data too, but this seems to be the pag= e=0D + /*=0D + * Other pages return valid data too, but this seems to be the pag= e=0D * we are expecting - persistently in ectool dump with vendor firm= ware=0D - * FIXME: Contents of other pages? */=0D + * FIXME: Contents of other pages?=0D + */=0D ETID =3D 0x20=0D }=0D }=0D +=0D + /* iGFX RC method call stripped */=0D }=0D =0D Method (TINI, 0, NotSerialized)=0D @@ -223,10 +235,8 @@ Device (\_SB.PCI0.LPCB.EC0) }=0D Else=0D {=0D - /* WBEC: Called SMI function 0x11 */=0D -// EC_WRITE (0x92, 0) // ETAF =3D 0=0D - /* MBEC: Called SMI function 0x12 */=0D -// MBEC (0x10, 0xFD, 0x02) // ETEE =3D 1=0D + WBEC (0x92, 0) // ETAF =3D 0=0D + MBEC (0x10, 0xFD, 0x02) // ETEE =3D 1=0D }=0D }=0D =0D @@ -234,10 +244,8 @@ Device (\_SB.PCI0.LPCB.EC0) Method (ECPS, 1, NotSerialized) // _PTS: Prepare To Sleep=0D {=0D ECSS =3D Arg0=0D -// COSI =3D OSYS=0D -// SPR1 =3D Arg0=0D - /* TRPS: Generic SMI trap handler */=0D -// TRPS (0x82, 0x02)=0D + // OSYS retrieved by SMM=0D +// TRPS (0x82, 0x02, Arg0)=0D If ((Arg0 =3D=3D 3) || (Arg0 =3D=3D 4))=0D {=0D RFST =3D RFEX=0D @@ -250,38 +258,23 @@ Device (\_SB.PCI0.LPCB.EC0) EOSS =3D Arg0=0D TINI ()=0D Notify (BAT0, 0x81) // Information Change=0D -// COSI =3D OSYS=0D -// SPR1 =3D Arg0=0D - /* TRPS: Generic SMI trap handler */=0D -// TRPS (0x82, 0x03)=0D + // OSYS retrieved by SMM=0D +// TRPS (0x82, 0x03, Arg0)=0D If ((Arg0 =3D=3D 3) || (Arg0 =3D=3D 4))=0D {=0D RFEX =3D RFST=0D Notify (SLPB, 0x02) // Device Wake=0D }=0D + /* iGFX RC method call stripped */=0D }=0D =0D -#if 0 // TODO: Figure out what this is for=0D - Method (OSIN, 0, NotSerialized)=0D + Method (MBEC, 3, Serialized)=0D {=0D - COSI =3D OSYS=0D - /* TRPS: Generic SMI trap handler */=0D - TRPS (0x82, 1)=0D - }=0D -#endif=0D -=0D -#if 0 // TODO: Implement=0D - Method (MBEC, 3, Serialized) // Read-Modify-Write=0D - {=0D - /* Based on similar methods/tables at=0D - * https://github.com/linuxhw/ACPI/blob/master/Notebook/Sony/SVE1713/S= VE1713S1RW/506CDC50E671#L9359=0D - * which use ASL instead of SMM calls */=0D - Local0 =3D EC_READ (Arg0)=0D + Local0 =3D RBEC (Arg0)=0D Local0 &=3D Arg1=0D Local0 |=3D Arg2=0D - EC_WRITE (Arg0, Local0)=0D + WBEC (Arg0, Local0)=0D }=0D -#endif=0D =0D /* Graphical hotkey */=0D Method (_Q19, 0, NotSerialized)=0D @@ -316,7 +309,8 @@ Device (\_SB.PCI0.LPCB.EC0) }=0D ElseIf ((Local1 > 0x80) && (Local1 < 0xA0))=0D {=0D - TPEN ^=3D 1 /* TODO: Not working. What else does WMI do here? *= /=0D + /* TODO: Not working when called by HID mode. What does WMI do h= ere? */=0D + TPEN ^=3D 1=0D }=0D }=0D }=0D @@ -330,8 +324,7 @@ Device (\_SB.PCI0.LPCB.EC0) }=0D Else=0D {=0D - /* MBEC: Called SMI function 0x12 */=0D -// MBEC (0x92, 0xF7, 0x08) // EOSD =3D 1=0D + MBEC (0x92, 0xF7, 0x08) // EOSD =3D 1=0D }=0D =0D Sleep (500)=0D @@ -341,9 +334,8 @@ Device (\_SB.PCI0.LPCB.EC0) =0D Method (_Q3F, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x3F - TRPS")=0D - /* TRPS: Generic SMI trap handler */=0D -// TRPS (0x80, 0)=0D + // Arg3 is unused=0D +// TRPS (0x80, 0, 0)=0D }=0D =0D Method (_Q40, 0, NotSerialized)=0D @@ -397,46 +389,44 @@ Device (\_SB.PCI0.LPCB.EC0) =0D Method (_Q60, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x60 -> WMI")=0D + \DBGH ("EC Query (0x60): WMI")=0D }=0D =0D Method (_Q61, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x61 -> WMI")=0D + \DBGH ("EC Query (0x61): WMI")=0D }=0D =0D Method (_Q62, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x62 -> Optimus GC6")=0D + \DBGH ("EC Query (0x62): Optimus GC6 or NVIDIA GPS")=0D }=0D =0D Method (_Q63, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x63 -> Optimus GC6")=0D + \DBGH ("EC Query (0x63): Optimus GC6 or NVIDIA GPS")=0D }=0D =0D Method (_Q67, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x67 -> NVIDIA GPS")=0D + \DBGH ("EC Query (0x67): NVIDIA GPS")=0D }=0D =0D Method (_Q68, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x68 -> NVIDIA GPS")=0D + \DBGH ("EC Query (0x68): NVIDIA GPS")=0D }=0D =0D Method (_Q6C, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x6C - TRPS")=0D - /* TRPS: Generic SMI trap handler */=0D -// TRPS (0x81, 0)=0D + // Arg3 is unused=0D +// TRPS (0x81, 0, 0)=0D }=0D =0D Method (_Q6D, 0, NotSerialized)=0D {=0D - \DBGH ("EC Query: 0x6D - TRPS")=0D - /* TRPS: Generic SMI trap handler */=0D -// TRPS (0x81, 1)=0D + // Arg3 is unused=0D +// TRPS (0x81, 1, 0)=0D }=0D =0D #include "ac.asl"=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/ecl= ib.asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/eclib.a= sl new file mode 100644 index 000000000000..57921eb09c8b --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/eclib.asl @@ -0,0 +1,141 @@ +/** @file=0D + This file contains the EC library for ACPI.=0D +=0D + Copyright (c) 2021, Baruch Binyamin Doron=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +=0D +Mutex (EMTX, 0)=0D +=0D +OperationRegion (ECO1, SystemIO, EC_D_PORT, 1)=0D +Field (ECO1, ByteAcc, Lock, Preserve)=0D +{=0D + ECDT, 8=0D +}=0D +=0D +OperationRegion (ECO2, SystemIO, EC_C_PORT, 1)=0D +Field (ECO2, ByteAcc, Lock, Preserve)=0D +{=0D + ECSC, 8=0D +}=0D +=0D +// Send EC command=0D +// Return time elapsed on success, EC_TIME_OUT on failure=0D +Method (SECC, 1, Serialized)=0D +{=0D + // Wait EC timeout for input buffer to be empty=0D + Local0 =3D 0=0D + While ((ECSC & EC_S_IBF) && Local0 < EC_TIME_OUT)=0D + {=0D + Stall (1)=0D + Local0++=0D + }=0D + // Send command if timeout was not reached=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + ECSC =3D Arg0=0D + }=0D +=0D + // Return status=0D + Return (Local0)=0D +}=0D +=0D +// Send EC data=0D +// Return time elapsed on success, EC_TIME_OUT on failure=0D +Method (SECD, 1, Serialized)=0D +{=0D + // Wait EC timeout for input buffer to be empty=0D + Local0 =3D 0=0D + While ((ECSC & EC_S_IBF) && Local0 < EC_TIME_OUT)=0D + {=0D + Stall (1)=0D + Local0++=0D + }=0D + // Send data if timeout was not reached=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + ECDT =3D Arg0=0D + }=0D +=0D + // Return status=0D + Return (Local0)=0D +}=0D +=0D +// Receive EC data=0D +// Return data on success, EC_TIME_OUT on failure=0D +Method (RECD, 0, Serialized)=0D +{=0D + // Wait EC timeout for input buffer to be empty=0D + Local0 =3D 0=0D + While ((ECSC & EC_S_OBF) && Local0 < EC_TIME_OUT)=0D + {=0D + Stall (1)=0D + Local0++=0D + }=0D + // Return data=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + Return (ECDT)=0D + }=0D +=0D + // Timeout exceeded, return failure=0D + Return (Local0)=0D +}=0D +=0D +// Read EC byte=0D +// Return data on success, EC_TIME_OUT on failure=0D +Method (RBEC, 1, Serialized)=0D +{=0D + // Check for mutex acquired to not run with another function=0D + Local0 =3D Acquire (EMTX, 0xFFFF)=0D + If (Local0 =3D=3D 0)=0D + {=0D + Local0 =3D SECC (EC_C_ACPI_READ)=0D + }=0D +=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + // Send address=0D + Local0 =3D SECD (Arg0)=0D + }=0D +=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + // Receive data=0D + Local0 =3D RECD ()=0D + }=0D +=0D + Release (EMTX)=0D + Return (Local0)=0D +}=0D +=0D +// Write EC byte=0D +// Return time elapsed on success, EC_TIME_OUT on failure=0D +Method (WBEC, 2, Serialized)=0D +{=0D + // Check for mutex acquired to not run with another function=0D + Local0 =3D Acquire (EMTX, 0xFFFF)=0D + If (Local0 =3D=3D 0)=0D + {=0D + Local0 =3D SECC (EC_C_ACPI_READ)=0D + }=0D +=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + // Send address=0D + Local0 =3D SECD (Arg0)=0D + }=0D +=0D + If (Local0 < EC_TIME_OUT)=0D + {=0D + // Send data=0D + Local0 =3D SECD (Arg1)=0D + }=0D +=0D + Release (EMTX)=0D + // Return data=0D + Return (Local0)=0D +}=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/mai= nboard.asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/mai= nboard.asl index 7a73d37429d0..46edce92fb47 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/mainboard.= asl +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/mainboard.= asl @@ -6,25 +6,27 @@ **/=0D =0D // TODO: Add HID support for touchpad, etc.=0D +// - Does board actually support DPTF?=0D #include "thermal.asl"=0D =0D External (\_SB.SLPB, DeviceObj)=0D =0D -// TODO: Need hooks from BoardAcpiDxe=0D -=0D Scope (_SB)=0D {=0D Method (MPTS, 1, NotSerialized) // _PTS: Prepare To Sleep=0D {=0D ^PCI0.LPCB.EC0.ECPS (Arg0)=0D + /* TBT and DTS not supported, TPM.PTS can be called elsewhere */=0D }=0D =0D Method (MWAK, 1, Serialized) // _WAK: Wake=0D {=0D ^PCI0.LPCB.EC0.ECWK (Arg0)=0D + /* No GPIO expander, 8254 clock-gating and PCIe PME can be performed e= lsewhere */=0D =0D If ((Arg0 =3D=3D 3) || (Arg0 =3D=3D 4))=0D {=0D + /* DTS and TBT not supported, iGFX RC variable update stripped */=0D Notify (LID0, 0x80) // Status Change=0D }=0D }=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/the= rmal.asl b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/therm= al.asl index 805ee0700cd0..5d6604b41a9f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/thermal.asl +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Acpi/thermal.asl @@ -15,12 +15,16 @@ Scope (_TZ) {=0D #ifdef LGMR_ENABLED=0D Local0 =3D \_SB.PCI0.LPCB.EC0.MS0T=0D -// Local1 =3D \_SB.PCI0.LPCB.EC0.MCSS=0D + Local1 =3D \_SB.PCI0.LPCB.EC0.MCSS=0D + /* Suppress warning over reading status flag by dummy OR */=0D + Or (Local1, 1, Local1)=0D Local2 =3D \_SB.PCI0.LPCB.EC0.MOSD=0D #else=0D Local0 =3D \_SB.PCI0.LPCB.EC0.ES0T=0D -// Local1 =3D \_SB.PCI0.LPCB.EC0.ESSF // "MCSS": Considering neighbour= ing bits, likely=0D - // "ESSF" in thermals, not "ECSS" = in notify=0D + /* "MCSS": Considering neighbouring bits, likely=0D + * "ESSF" in thermals, not "ECSS" in power notifications */=0D + Local1 =3D \_SB.PCI0.LPCB.EC0.ESSF=0D + Or (Local1, 1, Local1)=0D Local2 =3D \_SB.PCI0.LPCB.EC0.EOSD=0D #endif=0D If (Local2) // Thermal trip=0D @@ -59,7 +63,7 @@ Scope (_TZ) Else=0D {=0D /* MBEC: Called SMI function 0x12 */=0D -// \_SB.PCI0.LPCB.EC0.MBEC (0x90, 0xFE, Arg0) // SCPM =3D Arg0=0D + \_SB.PCI0.LPCB.EC0.MBEC (0x90, 0xFE, Arg0) // SCPM =3D Arg0=0D }=0D }=0D =0D @@ -89,6 +93,7 @@ Scope (_TZ) #else=0D Local0 =3D \_SB.PCI0.LPCB.EC0.ES1T=0D #endif=0D +=0D Return (C2K (Local0))=0D }=0D =0D @@ -116,7 +121,6 @@ Scope (_TZ) Local0 =3D 30=0D }=0D =0D - Local0 =3D ((Local0 * 10) + 2732) // Celsius to Kelvin=0D - Return (Local0)=0D + Return ((Local0 * 10) + 2732) // Celsius to centi-Kelvin=0D }=0D }=0D --=20 2.37.2