From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web11.52855.1598879845909562435 for ; Mon, 31 Aug 2020 06:17:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=SQutY8y1; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.66, mailfrom: pete@akeo.ie) Received: by mail-wm1-f66.google.com with SMTP id e11so4492wme.0 for ; Mon, 31 Aug 2020 06:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=c//ZKNUGWLrYLfiA3QFyyaOLKVyN8zdHT6ZjPj4WSv8=; b=SQutY8y1MpUySMPcJhFf7Bgv6wfqx+6HACoFFijyGiLACdn3jWyheX8KjvAbcZfvGf jBkEfBKRauvm5IWQseo76gFzx9JtxUFQPK/gcbGUdiAP/Ktj8xgejsSJ56HJB/0WM1Zm P+hY7sqIg+xkLZId4vflpVZAe+9YYxruS72mhSQeYLx+pVvcS1aonYEnFq3zrfUhCVe+ KkAsi7mlURtr8IXP+p/cUbpTBBk7spUHh8N0PbV/7prjmkAIObMc1uvltuBXGbZr0LIx q46Y4Puv/hcwcNKLtxAmVfoL+twJOONeBtBpsTTowhLMAY84UkUkFTu+Tm7+AyQb+E/X 6l/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c//ZKNUGWLrYLfiA3QFyyaOLKVyN8zdHT6ZjPj4WSv8=; b=bFdjg9xJ0JX3eKG/zfUuxhsOTJMT60yFIcK5bIsh9zaJK8/c/K7uxVDxBbWena5XMH CBs2vAHasDzNWcWPFBxEY7gxPtCS4I0UepjXiMVf3DTOfV8de++wQJyEaeYYJ9SV9Inr TLrrgctEMejM9exyjZtzP3acMkVf6tHiL8c52hmF9Uwf+DCKVXjMvcE12nKGfjPmX7Gu LfKYKHSnc5GP5q7ixBDhQh6cMNPtA85HSMVlCWMl9iBxgdpS5Ff4UvKTANb7gEUq3S/Y /uo8t3yTK6Om+syydwafE4S6X/Ip7OUZiz4X1SS37un2KYSboqFf71wEIAXxK+56IDfD wagQ== X-Gm-Message-State: AOAM5320heGYcjzqFhq5jvR2OXZBZBg1xLkS5YE1OWMtDhgmd7kk0wz5 y3FNMwcG7cb//SbgZ2jFKZR/tg== X-Google-Smtp-Source: ABdhPJwBhT7+jwoot5o6bMGOgwLw9OP0FRqFoycNJY7ZOs21xTa+kXB4YsZvlkN8VVU8x0l+f7tf5w== X-Received: by 2002:a1c:3bd7:: with SMTP id i206mr1361221wma.162.1598879844356; Mon, 31 Aug 2020 06:17:24 -0700 (PDT) Return-Path: Received: from [10.0.0.130] ([84.203.85.10]) by smtp.googlemail.com with ESMTPSA id c10sm11640315wmk.30.2020.08.31.06.17.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Aug 2020 06:17:23 -0700 (PDT) Subject: Re: [PATCH v3 3/5] Platform/RaspberryPi: Add entry for user fan control To: Jeremy Linton , devel@edk2.groups.io Cc: Leif Lindholm , Andrei Warkentin , Ard Biesheuvel , Samer El-Haj-Mahmoud References: <20200828220215.101919-1-jeremy.linton@arm.com> <20200828220215.101919-4-jeremy.linton@arm.com> From: "Pete Batard" Message-ID: <43e63291-2eb3-114a-28b0-8d025950e7b4@akeo.ie> Date: Mon, 31 Aug 2020 14:17:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200828220215.101919-4-jeremy.linton@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit On 2020.08.28 23:02, Jeremy Linton wrote: > Add a menu item that allows the user to enable GPIO based > fan control via SSDT and the previous NameObj replacement > commit. This should only be seen/enabled on RPI4 > because that is what its been tested with. > > 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. Alternatively there are some commercial > boards (FAN SHIM) which operate via simple GPIO control. > > 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 | 26 ++++++++++++++++++++++ > .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 2 ++ > .../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, 70 insertions(+) > > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > index 9e5d9734ca..d58cbbdfe7 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); > > } > > > > + Size = sizeof (UINT32); > > + Status = gRT->GetVariable (L"FanOnGpio", > > + &gConfigDxeFormSetGuid, > > + NULL, &Size, &Var32); > > + if (EFI_ERROR (Status)) { > > + PcdSet32 (PcdFanOnGpio, PcdGet32 (PcdFanOnGpio)); > > + } > > + > > Size = sizeof(AssetTagVar); > > > > Status = gRT->GetVariable(L"AssetTag", > > @@ -368,6 +378,7 @@ ApplyVariables ( > UINT32 CpuClock = PcdGet32 (PcdCpuClock); > > UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock); > > UINT32 Rate = 0; > > + UINT32 FanOnGpio = PcdGet32 (PcdFanOnGpio); > > > > switch (CpuClock) { > > case CHIPSET_CPU_CLOCK_LOW: > > @@ -565,6 +576,11 @@ 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); > > + } > > } > > > > > > @@ -679,8 +695,18 @@ VerifyUpdateTable( > } > > > > > > +STATIC AML_NAME_OP_REPLACE SsdtNameOpReplace[] = { > > + {"GIOP", PcdToken(PcdFanOnGpio)}, > > + {} > > +}; > > + > > STATIC NAMESPACE_TABLES SdtTables[] = { > > { > > + SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'), > > + PcdToken(PcdFanOnGpio), > > + SsdtNameOpReplace > > + }, > > + { > > SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0), > > 0, > > NULL > > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > index cdce35bc74..321e402e65 100644 > --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > @@ -46,6 +46,7 @@ > AcpiLib > > BaseLib > > DebugLib > > + DxeServicesLib > > DxeServicesTableLib > > GpioLib > > HiiLib > > @@ -89,6 +90,7 @@ > gRaspberryPiTokenSpaceGuid.PcdSystemTableMode > > gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB > > gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB > > + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio > > > > [Depex] > > gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid > > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/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" > > > > +#string STR_ADVANCED_FANONGPIO_PROMPT #language en-US "ACPI fan control" > > +#string STR_ADVANCED_FANONGPIO_HELP #language en-US "Cycle a fan via GPIO 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 Asset Tag" > > > > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/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 > > > > // > > // EFI Variable attributes > > @@ -45,6 +46,11 @@ formset > name = RamLimitTo3GB, > > guid = CONFIGDXE_FORM_SET_GUID; > > > > + efivarstore ADVANCED_FAN_ON_GPIO_VARSTORE_DATA, > > + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, > > + name = FanOnGpio, > > + guid = CONFIGDXE_FORM_SET_GUID; > > + > > efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA, > > attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, > > name = SystemTableMode, > > @@ -174,6 +180,18 @@ formset > option text = STRING_TOKEN(STR_ADVANCED_SYSTAB_DT), value = SYSTEM_TABLE_MODE_DT, flags = DEFAULT; > > endoneof; > > > > +#if (RPI_MODEL == 4) > > + grayoutif NOT ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_ACPI; > > + oneof varid = FanOnGpio.Enabled, > > + prompt = STRING_TOKEN(STR_ADVANCED_FANONGPIO_PROMPT), > > + help = STRING_TOKEN(STR_ADVANCED_FANONGPIO_HELP), > > + flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, > > + option text = STRING_TOKEN(STR_ADVANCED_FANONGPIO_OFF), value = 0, flags = DEFAULT; > > + option text = STRING_TOKEN(STR_ADVANCED_FANONGPIO_18), value = 18, flags = 0; > > + option text = STRING_TOKEN(STR_ADVANCED_FANONGPIO_19), value = 19, flags = 0; > > + endoneof; > > + endif; > > +#endif > > string varid = AssetTag.AssetTag, > > prompt = STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT), > > help = STRING_TOKEN(STR_ADVANCED_ASSET_TAG_HELP), > > diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/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; > > > > 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"|gConfigDxeFormSetGuid|0x0|1 > > > > # > > + # Enable a fan in the ACPI thermal zone on GPIO pin # > > + # > > + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGuid|0x0|0 > > + > > + # > > # Common UEFI ones. > > # > > > > 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"|gConfigDxeFormSetGuid|0x0|0 > > > > # > > + # Enable a fan in the ACPI thermal zone on GPIO pin # > > + # > > + # 0 - DISABLED > > + # 19 - Enabled on pin 19 > > + # > > + gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGuid|0x0|0 > > + > > + # > > # Common UEFI ones. > > # > > > > diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.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 > Reviewed-by: Pete Batard