From nobody Mon Apr 29 15:20:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64481+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64481+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597898572; cv=none; d=zohomail.com; s=zohoarc; b=YJLbfrQWXx02II8lsjNVuzF756RRXYHS/f5ORvhEuWNq0GsPigd/Q/R5syNw+qB/mY00tlvrSAMqvoyxrzSSURui2j6xfZV4KXuGsbS/0JDaJE6uLy5T50KY/JSCzphuJdyWjeYLDmP1WrHuz3o27lsg/gkMjWsNBKIrx9D61I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597898572; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=3hOF6gzlX59CehvqTsSjuI9/YOIJYBeDpaZyIsQXFy0=; b=K6jwfhNeIj+G+MHem9d4+UMPc/D6UVosQKgBtJXXBicI/ZL3Wkz2N/iHly0aalI1Tokv4QbS8HFXZZkavqRpAnqW9FtIRwg4jXT/6kjf8dU5q81mBy7imVKq+F2+dwuaMriv/KNfCEIslUruVu4BL/HO+CyStSO8f7DmvYdr7Cg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64481+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597898572281649.5402306075667; Wed, 19 Aug 2020 21:42:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UZXiYY1788612xPfd2JSrHsY; Wed, 19 Aug 2020 21:42:51 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.103922.1597898571037869164 for ; Wed, 19 Aug 2020 21:42:51 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F30091045; Wed, 19 Aug 2020 21:42:49 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD5BA3F71F; Wed, 19 Aug 2020 21:42:49 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: Jeremy Linton , Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Date: Wed, 19 Aug 2020 23:42:14 -0500 Message-Id: <20200820044217.39839-2-jeremy.linton@arm.com> In-Reply-To: <20200820044217.39839-1-jeremy.linton@arm.com> References: <20200820044217.39839-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com X-Gm-Message-State: knIWdqA4Vj3F9B6Htaa6Jvcbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597898571; bh=Q24p7Lse8bJRZqmtPhF95TJsoyDn0yQQt5zZrug/bug=; h=Cc:Date:From:Reply-To:Subject:To; b=DhIsCfX82Y4XQthWJHmxjsL0ImM8EbZA9s9/d7tZCFD6VAGVU+HYwF5JFIb/R2ZdUB9 2eG0ykf5IvwKTSfhFnRn1TBfQFFWgNp0WolbBa6NaTJnHoe0XUR8rI+gNySEWjUr/mqJg ze64qLe4I2Mlkc2I+MdKElGOSXD8A27Oz/0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Rather than exporting the temp sensor or mailbox in ACPI land we can wrap them in AML and use the default ACPI drivers provided by the OS. This enables the use of "sensors" in linux to report the SOC temp. This commit also adds a basic passive cooling ACPI thermalzone with trip points for passive cooling (throttling) handled by the vc firmware, hibernate and critical shutdown. The vc apparently kicks in at ~80C, so the hibernate and critical set points are set at +5 and +10 of that. In the future CPPC should be able to monitor the thermal throttling. Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Samer El-Haj-Mahmoud Signed-off-by: Jeremy Linton Reviewed-by: Pete Batard <@pbatard> --- Platform/RaspberryPi/AcpiTables/Dsdt.asl | 31 ++++++++++++++++++= ++++ .../Bcm27xx/Include/IndustryStandard/Bcm2711.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl b/Platform/RaspberryP= i/AcpiTables/Dsdt.asl index 353af2d876..73067aefd2 100644 --- a/Platform/RaspberryPi/AcpiTables/Dsdt.asl +++ b/Platform/RaspberryPi/AcpiTables/Dsdt.asl @@ -252,6 +252,37 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "RPIFDN", "RPI= ", 2) } }) } + + // Define a simple thermal zone. The idea here is we compute the SOC t= emp + // via a register we can read, and give it to the OS. This enables bas= ic + // reports from the "sensors" utility, and the OS can then poll and ta= ke + // actions if that temp exceeds any of the given thresholds. + Device (EC0) + { + Name (_HID, EISAID ("PNP0C06")) + Name (_CCA, 0x0) + + // all temps in are tenths of K (aka 2732 is the min temps in Linux = (aka 0C)) + ThermalZone (TZ0) { + Method (_TMP, 0, Serialized) { + OperationRegion (TEMS, SystemMemory, THERM_SENSOR, 0x8) + Field (TEMS, DWordAcc, NoLock, Preserve) { + TMPS, 32 + } + return (((419949 - ((TMPS & 0x3ff) * 487)) / 100) + 2732); + } + Method (_SCP, 3) { } // receive cooling policy from = OS + + Method (_CRT) { Return (3632) } // (90C) Critical temp point (i= mmediate power-off) + Method (_HOT) { Return (3582) } // (85C) HOT state where OS sho= uld hibernate + Method (_PSV) { Return (3532) } // (80C) Passive cooling (CPU t= hrottling) trip point + + // SSDT inserts _AC0/_AL0 @60C here, if a FAN is configured + + Name (_TZP, 10) //The OSPM must poll this device= every 1 seconds + Name (_PSL, Package () { \_SB_.CPU0, \_SB_.CPU1, \_SB_.CPU2, \_SB_= .CPU3 }) + } + } #endif =20 } diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h b/= Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h index e9c81cafa1..86906b2438 100644 --- a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h +++ b/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h @@ -86,4 +86,6 @@ #define GENET_BASE_ADDRESS FixedPcdGet64 (PcdBcmGenetRegistersAddr= ess) #define GENET_LENGTH 0x00010000 =20 +#define THERM_SENSOR 0xfd5d2200 + #endif /* BCM2711_H__ */ --=20 2.13.7 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64481): https://edk2.groups.io/g/devel/message/64481 Mute This Topic: https://groups.io/mt/76302316/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 15:20:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64482+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64482+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597898574; cv=none; d=zohomail.com; s=zohoarc; b=T9Ba9CqTB0v42iPEpY8cPp9IBSbSVeiT7zqcGyX6sfElcUr2oR/KiiOsZXRBoWXX8Txy/el4BeIF/alyu5g8/LZ4PGFNCQN0hC6QTlNBu91/Skw6pFu38DeeMTmFAu1r/Vp6K697v0pOZUOnXfHObYXHiL6cNK1CchW/PwusduU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597898574; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=DYdy0Dh3cjRcXG01XV7nxZP2jOa1qvTODWy/J1OvS8k=; b=Wr9ZiocRUEsir2O4UsFkJakdpwXqPkBjrZ9LxCD3q5+SSa23HGs3tP3CtUsrC4YrsVVaPkUdNIc6BDcu3B8YJydtzMq/HD4Z6r/6pqklzD2plEPCwyuI2GgAcDrXum+bpqR6ypl9XtrnPJQDcSUCrdp7QqvVUmwUGd5qKfxzP8Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64482+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597898574646234.34467407157865; Wed, 19 Aug 2020 21:42:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZbxFYY1788612x6UWTwdwfkP; Wed, 19 Aug 2020 21:42:54 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.105015.1597898573808954620 for ; Wed, 19 Aug 2020 21:42:53 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 78A4F1063; Wed, 19 Aug 2020 21:42:53 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F33233F71F; Wed, 19 Aug 2020 21:42:52 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: Jeremy Linton , Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v2 2/4] Platform/RaspberryPi4: Create ACPI fan object Date: Wed, 19 Aug 2020 23:42:15 -0500 Message-Id: <20200820044217.39839-3-jeremy.linton@arm.com> In-Reply-To: <20200820044217.39839-1-jeremy.linton@arm.com> References: <20200820044217.39839-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com X-Gm-Message-State: Gf4ofzrxcVzzzaNeSZZd74hxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597898574; bh=lqcIscQQf/vBtFQsCjx+VQa7WTgsZPvvnIbb9eDZpiE=; h=Cc:Date:From:Reply-To:Subject:To; b=guyhNSjtFTGrM0Jl/E6iRT+cE+OvK/kZNmkCJ9Ay4ZECni2xEYyS0awXoAmRvMJ0aAG DYjDAH4pLy+fZSbveWZN0yPesAFCnP0N941D2CysIm1BV0QCK43o6ZhpFCDQ3tSHUJ8LO HOqpQEBDEDNKSocjZFt3Tj8KWcMpczUPZns= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Now that we have a thermal zone we can add active cooling by specifying active cooling points (_ACx) which can be tied to fan objects that turn fans on/off using GPIO pins. Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Samer El-Haj-Mahmoud Signed-off-by: Jeremy Linton Reviewed-by: Pete Batard <@pbatard> --- .../RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl | 76 ++++++++++++++++++= ++++ 1 file changed, 76 insertions(+) create mode 100644 Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl b/Platf= orm/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl new file mode 100644 index 0000000000..b26e9a07a8 --- /dev/null +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl @@ -0,0 +1,76 @@ +/** @file + * + * Secondary System Description Table (SSDT) for active (fan) cooling + * + * Copyright (c) 2020, Arm Ltd. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include + +#include + +DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPITHFAN", 2) +{ + External (\_SB_.EC0, DeviceObj) + External (\_SB_.EC0.TZ0, DeviceObj) + + Scope (\_SB_.EC0) + { + // Define a NameOp we will modify during InstallTable + Name (GIOP, 2) //08 47 49 4f 50 0a 02 (value must be >1) + // Describe a fan + PowerResource (PFAN, 0, 0) { + OperationRegion (GPIO, SystemMemory, GPIO_BASE_ADDRESS, 0x1000) + Field (GPIO, DWordAcc, NoLock, Preserve) { + Offset (0x1C), + GPS0, 32, + GPS1, 32, + RES1, 32, + GPC0, 32, + GPC1, 32, + RES2, 32, + GPL1, 32, + GPL2, 32 + } + // We are hitting a GPIO pin to on/off a fan. + // This assumes that UEFI has programmed the + // direction as OUT. Given the current limitations + // on the GPIO pins, its recommended to use + // the GPIO to switch a larger voltage/current + // for the fan rather than driving it directly. + Method (_STA) { + if (GPL1 & (1 << GIOP)) { + Return (1) // present and enabled + } + Return (0) + } + Method (_ON) { //turn fan on + Store (1 << GIOP, GPS0) + } + Method (_OFF) { //turn fan off + Store (1 << GIOP, GPC0) + } + } + Device (FAN) { + // Note, not currently an ACPIv4 fan + // the latter adds speed control/detection + // but in the case of linux needs FIF, FPS, FSL, and FST + Name (_HID, EISAID ("PNP0C0B")) + Name (_PR0, Package () { PFAN }) + } + } + + // merge in an active cooling point. + Scope (\_SB_.EC0.TZ0) + { + Method (_AC0) { Return (3332) } // (60C) active cooling trip po= int, + // if this is lower than PSV th= en we + // prefer active cooling + Name (_AL0, Package () { \_SB_.EC0.FAN }) // the fan used for AC0 above + } +} --=20 2.13.7 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64482): https://edk2.groups.io/g/devel/message/64482 Mute This Topic: https://groups.io/mt/76302318/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 15:20:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64483+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64483+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597898577; cv=none; d=zohomail.com; s=zohoarc; b=P/8JRADcCd6rCAim57x84uN2xCMlYWSt0aZdlttglmaTrN0838pVa621/Yaw2UTADKeRj1CDGVpOLBvVeQlINAWZjwIy/+kviAq34RqVSgTDc/hAFDzrxtBlSUYfjmsYNrdWhwbpFYjTRRhDWCXlVKNPly7CMkELj/rPS9/80sM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597898577; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cd8RjL7ylyilhGHRI0ExkkW5HGnkQotEsqVnaAcfAGU=; b=KiEeiKl60+GNpfx/0nHYWAjsIuMTp3utyHWxA2XuUazULYyAorQFWwfjPjZkV6uHlqNubscOShuRydqXd0sO1pSyL6oo1LNi/tRHqL+F7nSg187+LZyMFdqvA4UWEA9Q0T37oze3TktX++kk0VSGhhBoW4+stpjEbO3w/ajdqZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64483+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597898577921176.75964692003265; Wed, 19 Aug 2020 21:42:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LYREYY1788612xYtL2VXXYvt; Wed, 19 Aug 2020 21:42:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.104497.1597898576871387601 for ; Wed, 19 Aug 2020 21:42:57 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 799A51045; Wed, 19 Aug 2020 21:42:56 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33DDA3F71F; Wed, 19 Aug 2020 21:42:56 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: Jeremy Linton , Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control Date: Wed, 19 Aug 2020 23:42:16 -0500 Message-Id: <20200820044217.39839-4-jeremy.linton@arm.com> In-Reply-To: <20200820044217.39839-1-jeremy.linton@arm.com> References: <20200820044217.39839-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com X-Gm-Message-State: VfM25AyCpSAIEUMkrDQl1bulx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597898577; bh=g2ovtHQRMpikL4N1/ihHw/p3xaw9kukVMlJ1kV0tkNo=; h=Cc:Date:From:Reply-To:Subject:To; b=kVQsy9vixHy/g4G3wElp0p3bxXAWM5JV+U1X8dG/PLkp0jiXTFzTuCwqMFywcIBAYR5 urMDrJnzq9iagAYyz5tpz3UkuDFnAyT6HRnEOCF2DT0qrjGLkw7JPHeCRp1tyO2trMFfh 6yagWYYqtdqNMFe2+tPOwXsV4xl0wOJYEeQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add a menu item that allows the user to enable GPIO based fan control via SSDT. This should only be seen/enabled on RPI4 because that is what its been tested with. As of this commit its currently limited to only operating on a single GPIO pin (19). Given GPIO pin current limitations its likely that a bit of additional circuitry is required to drive a fan, and the GPIO high/low signal can only be used as a enable/disable signal. A search for "rpi npn gpio fan" or similar should turn up some hits for how to do this simply. It appears there are a couple boards (fan SHIM) which operate this way, and probably should have custom menu items/SSDT edits as people acquire the boards and test them. Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Samer El-Haj-Mahmoud Signed-off-by: Jeremy Linton Reviewed-by: Pete Batard <@pbatard> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 78 ++++++++++++++++++= ++++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 3 + .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 6 ++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 18 +++++ Platform/RaspberryPi/Include/ConfigVars.h | 4 ++ Platform/RaspberryPi/RPi3/RPi3.dsc | 5 ++ Platform/RaspberryPi/RPi4/RPi4.dsc | 8 +++ Platform/RaspberryPi/RaspberryPi.dec | 1 + 8 files changed, 123 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index af54136ade..24e65eeb5e 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -246,6 +248,14 @@ SetupVariables ( ASSERT_EFI_ERROR (Status); } =20 + Size =3D sizeof (UINT32); + Status =3D gRT->GetVariable (L"FanOnGpio", + &gConfigDxeFormSetGuid, + NULL, &Size, &Var32); + if (EFI_ERROR (Status)) { + PcdSet32 (PcdFanOnGpio, PcdGet32 (PcdFanOnGpio)); + } + Size =3D sizeof(AssetTagVar); =20 Status =3D gRT->GetVariable(L"AssetTag", @@ -368,6 +378,7 @@ ApplyVariables ( UINT32 CpuClock =3D PcdGet32 (PcdCpuClock); UINT32 CustomCpuClock =3D PcdGet32 (PcdCustomCpuClock); UINT32 Rate =3D 0; + UINT32 FanOnGpio =3D PcdGet32 (PcdFanOnGpio); =20 switch (CpuClock) { case CHIPSET_CPU_CLOCK_LOW: @@ -565,8 +576,71 @@ ApplyVariables ( GpioPinFuncSet (23, GPIO_FSEL_INPUT); GpioPinFuncSet (24, GPIO_FSEL_INPUT); } + + if (FanOnGpio) { + DEBUG ((DEBUG_INFO, "Fan enabled on GPIO %d\n", FanOnGpio)); + GpioPinFuncSet (FanOnGpio, GPIO_FSEL_OUTPUT); + } } =20 +#define SSDT_PATTERN_LEN 6 + +EFI_STATUS +FindInstallSsdt (UINT64 OemTableId, CHAR8 *Name, UINT8 Value) +{ + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + UINTN Index; + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; + UINTN SsdtSize; + EFI_STATUS Status; + UINTN TableKey; + CHAR8 Pattern[SSDT_PATTERN_LEN]; + + + Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, + (VOID **)&AcpiTable); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index =3D 0; !EFI_ERROR (Status); Index++) { + Status =3D GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index, + (VOID **)&Ssdt, &SsdtSize); + if (Ssdt->OemTableId =3D=3D OemTableId) + break; + SsdtSize =3D 0; + } + + if (SsdtSize > 0) { + /* + * Do a single 8 bit NameOp variable replacement these are of the + * form 08 XXXX SIZE VAL, where SIZE is 0A=3Dbyte, 0B=3Dword, 0C=3Ddwo= rd + * and XXXX is the name and VAL is the value + */ + Pattern[0] =3D 0x08; //NameOp + Pattern[1] =3D Name[0]; //Name + Pattern[2] =3D Name[1]; + Pattern[3] =3D Name[2]; + Pattern[4] =3D Name[3]; + Pattern[5] =3D 0x0A; //Size + + for (Index =3D 0; Index < (SsdtSize - SSDT_PATTERN_LEN); Index++) { + if (CompareMem ((UINT8*)Ssdt + Index, Pattern, SSDT_PATTERN_LEN) =3D= =3D 0) { + *((UINT8 *)Ssdt + Index + SSDT_PATTERN_LEN) =3D Value; + break; + } + } + + Status =3D AcpiTable->InstallAcpiTable (AcpiTable, Ssdt, SsdtSize, + &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table %r\n", + __FUNCTION__, Status)); + } + } + + return Status; +} =20 EFI_STATUS EFIAPI @@ -620,6 +694,10 @@ ConfigInitialize ( PcdGet32 (PcdSystemTableMode) =3D=3D SYSTEM_TABLE_MODE_BOTH) { Status =3D LocateAndInstallAcpiFromFv (&mAcpiTableFile); ASSERT_EFI_ERROR (Status); + if (PcdGet32 (PcdFanOnGpio)) { + FindInstallSsdt (SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', '= N'),=20 + "GIOP", (UINT8)PcdGet32 (PcdFanOnGpio)); + } } =20 Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDe= vices, diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index cdce35bc74..fe3a01a570 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -28,6 +28,7 @@ ConfigDxeFormSetGuid.h ConfigDxeHii.vfr ConfigDxeHii.uni + SsdtThermal.asl XhciQuirk.c =20 [Packages] @@ -46,6 +47,7 @@ AcpiLib BaseLib DebugLib + DxeServicesLib DxeServicesTableLib GpioLib HiiLib @@ -89,6 +91,7 @@ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio =20 [Depex] gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 03763710a1..e2d1bb4b39 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -48,6 +48,12 @@ #string STR_ADVANCED_SYSTAB_BOTH #language en-US "ACPI + Devicetree" #string STR_ADVANCED_SYSTAB_DT #language en-US "Devicetree" =20 +#string STR_ADVANCED_FANONGPIO_PROMPT #language en-US "ACPI fan control" +#string STR_ADVANCED_FANONGPIO_HELP #language en-US "Cycle a fan via GPI= O if temp exceeds 60C" +#string STR_ADVANCED_FANONGPIO_OFF #language en-US "Disabled" +#string STR_ADVANCED_FANONGPIO_18 #language en-US "Fan Shim/GPIO-18" +#string STR_ADVANCED_FANONGPIO_19 #language en-US "GPIO-19" + #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag" #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asse= t Tag" =20 diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index d5615d7af0..94332caab3 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -10,6 +10,7 @@ #include #include "ConfigDxeFormSetGuid.h" #include +#include =20 // // EFI Variable attributes @@ -45,6 +46,11 @@ formset name =3D RamLimitTo3GB, guid =3D CONFIGDXE_FORM_SET_GUID; =20 + efivarstore ADVANCED_FAN_ON_GPIO_VARSTORE_DATA, + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE, + name =3D FanOnGpio, + guid =3D CONFIGDXE_FORM_SET_GUID; + efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA, attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE, name =3D SystemTableMode, @@ -174,6 +180,18 @@ formset option text =3D STRING_TOKEN(STR_ADVANCED_SYSTAB_DT), value = =3D SYSTEM_TABLE_MODE_DT, flags =3D DEFAULT; endoneof; =20 +#if (RPI_MODEL =3D=3D 4) + grayoutif NOT ideqval SystemTableMode.Mode =3D=3D SYSTEM_TABLE_MOD= E_ACPI; + oneof varid =3D FanOnGpio.Enabled, + prompt =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_PROMPT), + help =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_HELP), + flags =3D NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRE= D, + option text =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_OFF), va= lue =3D 0, flags =3D DEFAULT; + option text =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_18), val= ue =3D 18, flags =3D 0; + option text =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_19), val= ue =3D 19, flags =3D 0; + endoneof; + endif; +#endif string varid =3D AssetTag.AssetTag, prompt =3D STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT), help =3D STRING_TOKEN(STR_ADVANCED_ASSET_TAG_HELP), diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/Raspberry= Pi/Include/ConfigVars.h index b1689b004d..1a40469bfa 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -69,6 +69,10 @@ typedef struct { } ADVANCED_RAM_LIMIT_TO_3GB_VARSTORE_DATA; =20 typedef struct { + UINT32 Enabled; +} ADVANCED_FAN_ON_GPIO_VARSTORE_DATA; + +typedef struct { #define SYSTEM_TABLE_MODE_ACPI 0 #define SYSTEM_TABLE_MODE_BOTH 1 #define SYSTEM_TABLE_MODE_DT 2 diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 0998d8366c..cef8932ca2 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -499,6 +499,11 @@ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfig= DxeFormSetGuid|0x0|1 =20 # + # Enable a fan in the ACPI thermal zone on GPIO pin # + # + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0 + + # # Common UEFI ones. # =20 diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index baa7e63483..9d0eaf10a1 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -510,6 +510,14 @@ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfig= DxeFormSetGuid|0x0|0 =20 # + # Enable a fan in the ACPI thermal zone on GPIO pin # + # + # 0 - DISABLED + # 19 - Enabled on pin 19 + # + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0 + + # # Common UEFI ones. # =20 diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index c71177a2f7..a73650f2c3 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -66,3 +66,4 @@ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|1|UINT32|0x0000001B gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|0|UINT32|0x00000019 gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|0|UINT32|0x0000001A + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C --=20 2.13.7 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64483): https://edk2.groups.io/g/devel/message/64483 Mute This Topic: https://groups.io/mt/76302320/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 15:20:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64484+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64484+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597898588; cv=none; d=zohomail.com; s=zohoarc; b=D4XYwGLi+CF8YcZPxkyJwB/t7YmGmDzobGx2orEI7D98W1w4Man1YaS0C6vgBdG9J0k7rLNwSzje59tQTIzRn3ZT/sIzNerSvKeLsCCm/gewK/8+iRqtIKFbvYLXRIL6tHc+Wb4fpm6jCc//ul801XhNkwxW69hUMVWcIUyDbEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597898588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tSvXMILQESX7LnYc2CR0Nvr4680qskD+wJxmhCr16DY=; b=HiXhA3fMZ0XtkVF9LKR8CZ5RWMF2i6vevtQcZiZ1WBnLDHZNxk881DfJNuuWmEzESJ1frunqip7TGWgZFvpiuvlNQX0TxhmiW9+sqoc1OZNXKMYdMBI/nIV16MO8ueN0Z2eH36uGcpQNU78VV4IpnntqNQ3gKgSHI7wfZinvcpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64484+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597898587991729.7362136567862; Wed, 19 Aug 2020 21:43:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ecJFYY1788612x1Kg8pcyrXT; Wed, 19 Aug 2020 21:43:07 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.105019.1597898586866357319 for ; Wed, 19 Aug 2020 21:43:07 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 838FE1045; Wed, 19 Aug 2020 21:43:06 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62F9B3F71F; Wed, 19 Aug 2020 21:43:06 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: Jeremy Linton Subject: [edk2-devel] [PATCH v2 4/4] Platform/RaspberryPi: Trivial whitespace cleanup Date: Wed, 19 Aug 2020 23:42:17 -0500 Message-Id: <20200820044217.39839-5-jeremy.linton@arm.com> In-Reply-To: <20200820044217.39839-1-jeremy.linton@arm.com> References: <20200820044217.39839-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com X-Gm-Message-State: lpBYO4rxzxtLGGiUkglkPRZXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597898587; bh=YW0RBsy97+BEUWdg1g6HqqvOcZky0WmgZGkIF0/DmwE=; h=Cc:Date:From:Reply-To:Subject:To; b=NdMxkYdub/H4c6FwOkRlCqyUcLYZDCxSOb5nSykBgTaLj/+GCAm01DA0IA+O4TWnF4M S04Ja57BHso0gYFrczttqZ7NPr6+TfPqqijPttKvy4bJXgAfhJYoFI0FkfyespSHFeZX+ X7DozK8yMs5SEvT+QUucH5iy7rAoirIDT2w= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Pete's review pointed out some whitespace issues in the context of a previous patch. Since there are a number of similar errors in the file lets fix them separately. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 26 +++++++++++-------= ---- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 24e65eeb5e..4a47160c42 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -209,9 +209,9 @@ SetupVariables ( } =20 Size =3D sizeof (UINT32); - Status =3D gRT->GetVariable(L"CustomCpuClock", - &gConfigDxeFormSetGuid, - NULL, &Size, &Var32); + Status =3D gRT->GetVariable (L"CustomCpuClock", + &gConfigDxeFormSetGuid, + NULL, &Size, &Var32); if (EFI_ERROR (Status)) { Status =3D PcdSet32S (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock)); ASSERT_EFI_ERROR (Status); @@ -256,9 +256,9 @@ SetupVariables ( PcdSet32 (PcdFanOnGpio, PcdGet32 (PcdFanOnGpio)); } =20 - Size =3D sizeof(AssetTagVar); + Size =3D sizeof (AssetTagVar); =20 - Status =3D gRT->GetVariable(L"AssetTag", + Status =3D gRT->GetVariable (L"AssetTag", &gConfigDxeFormSetGuid, NULL, &Size, AssetTagVar); =20 @@ -267,7 +267,7 @@ SetupVariables ( L"AssetTag", &gConfigDxeFormSetGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A= CCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof(AssetTagVar), + sizeof (AssetTagVar), AssetTagVar ); } @@ -433,9 +433,9 @@ ApplyVariables ( * spaces. SystemMemorySizeBelow4GB tracks the maximum memory below 4GB * line, factoring in the limit imposed by the SoC register range. */ - SystemMemorySizeBelow4GB =3D MIN(SystemMemorySize, 4UL * SIZE_1GB); - SystemMemorySizeBelow4GB =3D MIN(SystemMemorySizeBelow4GB, BCM2836_SOC= _REGISTERS); - SystemMemorySizeBelow4GB =3D MIN(SystemMemorySizeBelow4GB, BCM2711_SOC= _REGISTERS); + SystemMemorySizeBelow4GB =3D MIN (SystemMemorySize, 4UL * SIZE_1GB); + SystemMemorySizeBelow4GB =3D MIN (SystemMemorySizeBelow4GB, BCM2836_SO= C_REGISTERS); + SystemMemorySizeBelow4GB =3D MIN (SystemMemorySizeBelow4GB, BCM2711_SO= C_REGISTERS); =20 ASSERT (SystemMemorySizeBelow4GB > 3UL * SIZE_1GB); =20 @@ -528,14 +528,14 @@ ApplyVariables ( /* * SD card pins go to Arasan. */ - MmioWrite32((GPIO_BASE_ADDRESS + 0xD0), - MmioRead32(GPIO_BASE_ADDRESS + 0xD0) | 0x2); + MmioWrite32 ((GPIO_BASE_ADDRESS + 0xD0), + MmioRead32 (GPIO_BASE_ADDRESS + 0xD0) | 0x2); } else { /* * SD card pins back to eMMC2. */ - MmioWrite32((GPIO_BASE_ADDRESS + 0xD0), - MmioRead32(GPIO_BASE_ADDRESS + 0xD0) & ~0x2); + MmioWrite32 ((GPIO_BASE_ADDRESS + 0xD0), + MmioRead32 (GPIO_BASE_ADDRESS + 0xD0) & ~0x2); /* * WiFi back to Arasan. */ --=20 2.13.7 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#64484): https://edk2.groups.io/g/devel/message/64484 Mute This Topic: https://groups.io/mt/76302321/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-