From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.58535.1598894771595988741 for ; Mon, 31 Aug 2020 10:26:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) 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 407E230E; Mon, 31 Aug 2020 10:26:11 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2F71B3F66F; Mon, 31 Aug 2020 10:26:11 -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: [PATCH v4 5/6] Platform/RaspberryPi4: Allow the user to set Temp Date: Mon, 31 Aug 2020 12:25:48 -0500 Message-Id: <20200831172549.24079-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200831172549.24079-1-jeremy.linton@arm.com> References: <20200831172549.24079-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Now that we have the ability to enable an AML fan object, allow the user to select the temperature at which the fan cycles on. 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/SsdtThermal.asl | 9 +++++---- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 11 ++++++++++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 ++++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 16 +++++++++++++= +++ Platform/RaspberryPi/Include/ConfigVars.h | 4 ++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 1 + Platform/RaspberryPi/RPi4/RPi4.dsc | 1 + Platform/RaspberryPi/RaspberryPi.dec | 1 + 9 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Platform/RaspberryPi/AcpiTables/SsdtThermal.asl b/Platform/Ras= pberryPi/AcpiTables/SsdtThermal.asl index ee028173e1..acfa4699bb 100644 --- a/Platform/RaspberryPi/AcpiTables/SsdtThermal.asl +++ b/Platform/RaspberryPi/AcpiTables/SsdtThermal.asl @@ -23,6 +23,7 @@ DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPITHFAN= ", 2) { // Define a NameOp we will modify during InstallTable Name (GIOP, 0x2) //08 47 49 4f 50 0a 02 (value must be >1) + Name (FTMP, 0x2) // Describe a fan PowerResource (PFAN, 0, 0) { OperationRegion (GPIO, SystemMemory, GPIO_BASE_ADDRESS, 0x1000) @@ -68,9 +69,9 @@ DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPITHFAN= ", 2) // merge in an active cooling point. Scope (\_SB_.EC00.TZ00) { - 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_.EC00.FAN0 }) // the fan used for AC0 ab= ove + Method (_AC0) { Return ( (FTMP * 10) + 2732) } // (60C) active cooling= trip point, + // if this is lower tha= n PSV then we + // prefer active cooling + Name (_AL0, Package () { \_SB_.EC00.FAN0 }) // the fan used for AC0= above } } diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index d58cbbdfe7..e8f964a329 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -256,8 +256,16 @@ SetupVariables ( PcdSet32 (PcdFanOnGpio, PcdGet32 (PcdFanOnGpio));=0D }=0D =0D - Size =3D sizeof(AssetTagVar);=0D + Size =3D sizeof (UINT32);=0D + Status =3D gRT->GetVariable (L"FanTemp",=0D + &gConfigDxeFormSetGuid,=0D + NULL, &Size, &Var32);=0D + if (EFI_ERROR (Status)) {=0D + PcdSet32 (PcdFanTemp, PcdGet32 (PcdFanTemp));=0D + }=0D +=0D =0D + Size =3D sizeof (AssetTagVar);=0D Status =3D gRT->GetVariable(L"AssetTag",=0D &gConfigDxeFormSetGuid,=0D NULL, &Size, AssetTagVar);=0D @@ -697,6 +705,7 @@ VerifyUpdateTable( =0D STATIC AML_NAME_OP_REPLACE SsdtNameOpReplace[] =3D {=0D {"GIOP", PcdToken(PcdFanOnGpio)},=0D + {"FTMP", PcdToken(PcdFanTemp)},=0D {}=0D };=0D =0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index 321e402e65..544e3b3e10 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -91,6 +91,7 @@ gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB=0D gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio=0D + gRaspberryPiTokenSpaceGuid.PcdFanTemp=0D =0D [Depex]=0D gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index e2d1bb4b39..2afe8f32ae 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -49,11 +49,14 @@ #string STR_ADVANCED_SYSTAB_DT #language en-US "Devicetree"=0D =0D #string STR_ADVANCED_FANONGPIO_PROMPT #language en-US "ACPI fan control"=0D -#string STR_ADVANCED_FANONGPIO_HELP #language en-US "Cycle a fan via GPI= O if temp exceeds 60C"=0D +#string STR_ADVANCED_FANONGPIO_HELP #language en-US "Cycle a fan via GPI= O at given temperature"=0D #string STR_ADVANCED_FANONGPIO_OFF #language en-US "Disabled"=0D #string STR_ADVANCED_FANONGPIO_18 #language en-US "Fan Shim/GPIO-18"=0D #string STR_ADVANCED_FANONGPIO_19 #language en-US "GPIO-19"=0D =0D +#string STR_ADVANCED_FANTEMP_PROMPT #language en-US "ACPI fan temperatur= e"=0D +#string STR_ADVANCED_FANTEMP_HELP #language en-US "Cycle a fan at C"=0D +=0D #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag"=0D #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asse= t Tag"=0D =0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Plat= form/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index 94332caab3..de5e43471a 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -51,6 +51,11 @@ formset name =3D FanOnGpio,=0D guid =3D CONFIGDXE_FORM_SET_GUID;=0D =0D + efivarstore ADVANCED_FANTEMP_VARSTORE_DATA,=0D + attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D + name =3D FanTemp,=0D + guid =3D CONFIGDXE_FORM_SET_GUID;=0D +=0D efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA,=0D attribute =3D EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME= _ACCESS | EFI_VARIABLE_NON_VOLATILE,=0D name =3D SystemTableMode,=0D @@ -191,6 +196,17 @@ formset option text =3D STRING_TOKEN(STR_ADVANCED_FANONGPIO_19), val= ue =3D 19, flags =3D 0;=0D endoneof;=0D endif;=0D +=0D + grayoutif ideqval FanOnGpio.Enabled =3D=3D 0;=0D + numeric varid =3D FanTemp.Value,=0D + prompt =3D STRING_TOKEN(STR_ADVANCED_FANTEMP_PROMPT),=0D + help =3D STRING_TOKEN(STR_ADVANCED_FANTEMP_HELP),=0D + flags =3D DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACT= IVE | RESET_REQUIRED,=0D + minimum =3D 50,=0D + maximum =3D 80,=0D + default =3D 60,=0D + endnumeric;=0D + endif;=0D #endif=0D string varid =3D AssetTag.AssetTag,=0D prompt =3D STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT),=0D diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/Raspberry= Pi/Include/ConfigVars.h index 1a40469bfa..8094d4ef9a 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -73,6 +73,10 @@ typedef struct { } ADVANCED_FAN_ON_GPIO_VARSTORE_DATA;=0D =0D typedef struct {=0D + UINT32 Value;=0D +} ADVANCED_FANTEMP_VARSTORE_DATA;=0D +=0D +typedef struct {=0D #define SYSTEM_TABLE_MODE_ACPI 0=0D #define SYSTEM_TABLE_MODE_BOTH 1=0D #define SYSTEM_TABLE_MODE_DT 2=0D diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index cef8932ca2..484a46ffba 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -502,6 +502,7 @@ # Enable a fan in the ACPI thermal zone on GPIO pin #=0D #=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0=0D + gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0= x0|0=0D =0D #=0D # Common UEFI ones.=0D diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 9d0eaf10a1..823c9fc007 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -516,6 +516,7 @@ # 19 - Enabled on pin 19=0D #=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGu= id|0x0|0=0D + gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0= x0|60=0D =0D #=0D # Common UEFI ones.=0D diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index a73650f2c3..c64c61930e 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -67,3 +67,4 @@ gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|0|UINT32|0x00000019=0D gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|0|UINT32|0x0000001A=0D gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C=0D + gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D=0D --=20 2.13.7