From nobody Sun May 5 19:55:37 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+64257+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+64257+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597359702; cv=none; d=zohomail.com; s=zohoarc; b=bazsmlpx13ty5xaVpE1Zdb0aH6n+B+aFRbumv4eW3bK5KN78qkEBmqJX87KGmwRPJvKMnrzQhne+x1Nh3mrDoGTMeXSRDmcCHQZRE6mUA23VNMgtubheL3bqoVVi2ZjsWjAq59YSkjjUVfjDIDMwmlei/s3rS6jWFTEDy04c7AU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597359702; 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=XZi1Hqy+nICTj77lvZPERE7b6MC7VQXWBetxKvnXhmA=; b=BSRr8biwGr8BUlt5PUfk/x7vS/eI1fLEZY9mykOz5M/S+mpxk7620LxOo0G4FSiC/ulWuH/Sysp3A2niS1iEmOi0ElNFQVfxOUKqqTccLtt+xQTAdnmemxhXvwaVbGpwzS68N4j+QyKUcNlKsV4GnqGTDqRUFSwJn+hP1JqkUlY= 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+64257+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597359702800351.9061854281929; Thu, 13 Aug 2020 16:01:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VW7SYY1788612xX9mvaB8HYc; Thu, 13 Aug 2020 16:01:42 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.7131.1597359701329256416 for ; Thu, 13 Aug 2020 16:01:41 -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 BDA7331B; Thu, 13 Aug 2020 16:01:40 -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 636F03F22E; Thu, 13 Aug 2020 16:01:40 -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 1/3] Platform/RaspberryPi4: Add a basic thermal zone Date: Thu, 13 Aug 2020 18:00:54 -0500 Message-Id: <20200813230056.40526-2-jeremy.linton@arm.com> In-Reply-To: <20200813230056.40526-1-jeremy.linton@arm.com> References: <20200813230056.40526-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: HuTdZMESMkWZZbfrkdPcpVD0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597359702; bh=1J+3QZ3M/iFFVWbOR0usOE4scuvHHflOZCf8ybGM9R4=; h=Cc:Date:From:Reply-To:Subject:To; b=YG47EyF6F0yVBQS1zpHOZfz2APIuBMQ1Te5CXajTsFtLUSCo2ZUxleuXP1Cq7t/3ZlF xTPPbVE7i4ZVhnReIY7nsGMcx9YaSIZW5/ojNgCQaDHKr38ddUqetG2kjDFDHkk0zXSoV cTgPkFiNJxi1jCiOlj+cYgbD84aK7MF1e2c= 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 --- Platform/RaspberryPi/AcpiTables/Dsdt.asl | 31 ++++++++++++++++++++++++++++= +++ 1 file changed, 31 insertions(+) diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl b/Platform/RaspberryP= i/AcpiTables/Dsdt.asl index 353af2d876..a5c9567cdf 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, 0xfd5d2200, 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) } // (90K) Critical temp point (imm= ediate power-off) + Method(_HOT) { return(3582) } // (85K) HOT state where OS shoul= d hibernate + Method(_PSV) { return(3532) } // (80K) Passive cooling (CPU thr= ottling) 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_.CP= U3}) + } + } #endif =20 } --=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 (#64257): https://edk2.groups.io/g/devel/message/64257 Mute This Topic: https://groups.io/mt/76178274/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 Sun May 5 19:55:37 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+64258+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+64258+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597359704; cv=none; d=zohomail.com; s=zohoarc; b=Y8IDEsdAnb6MEGpYihbNSriuWSVpfi6cNMTemoc/lVZ3L1g7NPASwadlMY0LzYEwGPQipK6ZpO8CKFmZNm2Ttp38R1rHv+5ZFIhMkiyJgzDf3w/SxD+VWWwVDHw5vcjzsDNrByEHlzkGLhPSGwaB/LP9RJGxDbYyfKyvrpXT25k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597359704; 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=gnBoCXhgtnOuiBe1j1SO2kirsZShR0C6W4BSQ/eMDzM=; b=GpZlRVLxCUxcaq3Jl4Gysa5haL8gxs01ohklVLW6VFnBmURfLAiaZtxJBpPNoyUOrUfThiEIJ234YKFPp8eW5DO43G6U0Bvd1LLd0cq3Gz0ojMma+imbgLQzc/fJKj618PZFqtQ73xK0XQkleAT7xoEy3JHJxj10JGAEXIZfAKM= 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+64258+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597359704136910.8898309392827; Thu, 13 Aug 2020 16:01:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id i8wVYY1788612x40ZSbX6Lme; Thu, 13 Aug 2020 16:01:43 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.7167.1597359702140890521 for ; Thu, 13 Aug 2020 16:01:42 -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 B8CB1113E; Thu, 13 Aug 2020 16:01:41 -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 6BF8B3F22E; Thu, 13 Aug 2020 16:01:41 -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 2/3] Platform/RaspberryPi4: Create ACPI fan object Date: Thu, 13 Aug 2020 18:00:55 -0500 Message-Id: <20200813230056.40526-3-jeremy.linton@arm.com> In-Reply-To: <20200813230056.40526-1-jeremy.linton@arm.com> References: <20200813230056.40526-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: x5aVBDn1oGEqFrydkd8Kinfpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597359703; bh=DZEeG3nXKM9X2fYAkCYZ751VGBOkqnaUH3ZLXgQqVDo=; h=Cc:Date:From:Reply-To:Subject:To; b=qrDmXa1uqEE13B9su24pLXQOaPEMzq1XPaMQGrLbHNVejypalCr+3y1AYDOlwJIZhfj gnBTutvx5hiIgWAhD8zq2Yam0YLLwj15ObTJ+Jk9kQFzbVDXXYAgVDXxCXtEkJBE0EwFm VMw1leYTxywEuImRfrZiOZISSFFcDQZnheU= 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 --- .../RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl | 83 ++++++++++++++++++= ++++ 1 file changed, 83 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..c87bda6dbc --- /dev/null +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl @@ -0,0 +1,83 @@ +/** @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) +{ +#if (GPIO_FAN_PIN !=3D 0) + External(\_SB_.EC0, DeviceObj) + External(\_SB_.EC0.TZ0, DeviceObj) + + Scope (\_SB_.EC0) + { + // 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 the fan + // this assumes that UEFI has programmed the + // direction as OUT. + // (search "rpi gpio fan controller" for how to + // wire this up if your not electrically inclined + // the basic idea is to use a BJT/etc to switch a + // larger voltage through a fan where the GPIO pin + // feeds a NPN/PNP base. Thats because its unlikly + // that the fan can be driven directly from the GPIO + // pin due to hitting the current limit on the pins. + // Matching a resistor between the GPIO->Base can + // allow pretty much any random NPN with a reasonable + // EC current to work (to limit the GPIO current).) + Method (_STA) { + if ( GPL1 & (1 << GPIO_FAN_PIN) ) { + Return ( 1 ) // present and enabled + } + Return ( 0 ) + } + Method (_ON) { //turn fan on + Store((1 << GPIO_FAN_PIN), GPS0) + } + Method (_OFF) { //turn fan off + Store((1 << GPIO_FAN_PIN), 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) } // (60K) active cooling trip poin= t, + // if this is lower than PSV then= we + // prefer active cooling + Name(_AL0, Package(){\_SB_.EC0.FAN}) // the fan used for AC0 above + } +#endif +} --=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 (#64258): https://edk2.groups.io/g/devel/message/64258 Mute This Topic: https://groups.io/mt/76178275/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 Sun May 5 19:55:37 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+64259+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+64259+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1597359705; cv=none; d=zohomail.com; s=zohoarc; b=Em3oMYlWtibsQknJVg8FaIBe40TTD79p9CHywhd+gBbLR549XKtB2UpeXymloEgepmFou6LLcfkle+zVfnN6UZAf7KTWP/4OCn28z5j9jT/IFDuUuV3UKtih1JqObUeTSvmUlkgx+ETviLP2hQxLVu4Fvk+C3511A+HCYbB+mNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597359705; 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=qLoa+Qwu3H6h/u8XGE1vY9NxZAr9zMxZbYURLtepR0Y=; b=eq6FzamJah5U+GXFn0TWY6hprW4WdJfGHp8SA/uPFyd2WVQiypJ3s7J3qmL2h0miv7cnCChq/o804sWPuT73o8mY+YbyuQThuObhw8/zh5DuGGfDB9SiFHOIhi7QngWiM49TwD4HB3a5x/DbSETrpxEgeL0WJfVM3pf39MpPV3M= 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+64259+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1597359705834708.800310188239; Thu, 13 Aug 2020 16:01:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZyoJYY1788612xoeELNxddqz; Thu, 13 Aug 2020 16:01:45 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.7240.1597359703014590567 for ; Thu, 13 Aug 2020 16:01:43 -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 AEC0B12FC; Thu, 13 Aug 2020 16:01:42 -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 587153F73D; Thu, 13 Aug 2020 16:01:42 -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 3/3] Platform/RaspberryPi: Add entry for user fan control Date: Thu, 13 Aug 2020 18:00:56 -0500 Message-Id: <20200813230056.40526-4-jeremy.linton@arm.com> In-Reply-To: <20200813230056.40526-1-jeremy.linton@arm.com> References: <20200813230056.40526-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: wOcsr8dfZBvaMoT3QMQbMUwpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1597359705; bh=KBzn5KjTrYEbj+GCbvlWxvqZh20yZvAiHsYZ9HQkSwc=; h=Cc:Date:From:Reply-To:Subject:To; b=Ur/I2ZtxUK70VwO5cDE9IrRc4ntHYQecKBtvnt/pj6mielptyYB08DcBbzWCoLoMYuy 2Rh4fxMknSbrmgqInIdUDfVpkL4RuJIfR8Vx3mE85LmDKRrobsLPYyyCmNeI8N+n80RcQ IMjzkzGyIZYI6X44vPLJ7FNdA05LYfQwZMM= 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 --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 55 ++++++++++++++++++= ++++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 3 ++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 ++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++++ Platform/RaspberryPi/Include/ConfigVars.h | 4 ++ Platform/RaspberryPi/RPi3/RPi3.dsc | 5 ++ Platform/RaspberryPi/RPi4/RPi4.dsc | 8 ++++ Platform/RaspberryPi/RaspberryPi.dec | 1 + .../Bcm27xx/Include/IndustryStandard/Bcm2711.h | 2 + 9 files changed, 100 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index af54136ade..f10347be64 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,49 @@ 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 +EFI_STATUS +FindInstallSsdt(UINT64 OemTableId) +{ + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + UINTN Index; + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; + UINTN SsdtSize; + EFI_STATUS Status; + UINTN TableKey; + + + 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) { + 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 +672,9 @@ 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 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..491d022fff 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -48,6 +48,11 @@ #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-19 if temp exceeds 60C" +#string STR_ADVANCED_FANONGPIO_OFF #language en-US "Disabled" +#string STR_ADVANCED_FANONGPIO_ON #language en-US "Enabled" + #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..0a5e4163e8 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,17 @@ 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_ON), val= ue =3D GPIO_FAN_PIN, 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 diff --git a/Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h b/= Silicon/Broadcom/Bcm27xx/Include/IndustryStandard/Bcm2711.h index e9c81cafa1..7d9ea5d35c 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 GPIO_FAN_PIN 19 // fan shim uses GPIO 18 + #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 (#64259): https://edk2.groups.io/g/devel/message/64259 Mute This Topic: https://groups.io/mt/76178276/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-