public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Platform/RasberryPi: Thermal zone
@ 2020-08-20  4:42 Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Jeremy Linton
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20  4:42 UTC (permalink / raw)
  To: devel; +Cc: Jeremy Linton

This set creates a basic thermal zone, which reads the
SOC temp via a direct register read in AML. It also
adds an active cooling policy using a GPIO pin for fan
control that can optionally be enabled/disabled on either
GPIO18 (commercial fan shim board) or GPIO19 by the
user from the BDS.

it should now be possible when booted in ACPI mode to:

# sensors
acpitz-acpi-0
Adapter: ACPI interface
temp1:        +57.6C  (crit = +90.0C)

and the fan state, if enabled may be read with:

/sys/bus/acpi/devices/PNP0C06:00/PNP0C0B:00/physical_node/thermal_cooling/cur_state

while the kernel will automatically cycle the fan if the SoC
temp exceeds 60C.


v1->v2:
  Add choice of GPIO pins to the BDS menu
  Correct whitespace/etc issues from v1 review
  Add an additional cleanup patch for contextual whitespace issues

Jeremy Linton (4):
  Platform/RaspberryPi4: Add a basic thermal zone
  Platform/RaspberryPi4: Create ACPI fan object
  Platform/RaspberryPi: Add entry for user fan control
  Platform/RaspberryPi: Trivial whitespace cleanup

 Platform/RaspberryPi/AcpiTables/Dsdt.asl           |  31 ++++++
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 104 ++++++++++++++++++---
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |   3 +
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   6 ++
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr |  18 ++++
 .../RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl  |  76 +++++++++++++++
 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 +
 11 files changed, 245 insertions(+), 13 deletions(-)
 create mode 100644 Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl

-- 
2.13.7


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone
  2020-08-20  4:42 [PATCH v2 0/4] Platform/RasberryPi: Thermal zone Jeremy Linton
@ 2020-08-20  4:42 ` Jeremy Linton
  2020-08-20  7:59   ` Ard Biesheuvel
  2020-08-20  4:42 ` [PATCH v2 2/4] Platform/RaspberryPi4: Create ACPI fan object Jeremy Linton
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20  4:42 UTC (permalink / raw)
  To: devel
  Cc: Jeremy Linton, Leif Lindholm, Pete Batard, Andrei Warkentin,
	Ard Biesheuvel, Samer El-Haj-Mahmoud

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 <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
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/RaspberryPi/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 temp
+    // via a register we can read, and give it to the OS. This enables basic
+    // reports from the "sensors" utility, and the OS can then poll and take
+    // 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 (immediate power-off)
+        Method (_HOT) { Return (3582) }    // (85C) HOT state where OS should hibernate
+        Method (_PSV) { Return (3532) }    // (80C) Passive cooling (CPU throttling) 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
 
   }
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 (PcdBcmGenetRegistersAddress)
 #define GENET_LENGTH               0x00010000
 
+#define THERM_SENSOR               0xfd5d2200
+
 #endif /* BCM2711_H__ */
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/4] Platform/RaspberryPi4: Create ACPI fan object
  2020-08-20  4:42 [PATCH v2 0/4] Platform/RasberryPi: Thermal zone Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Jeremy Linton
@ 2020-08-20  4:42 ` Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 4/4] Platform/RaspberryPi: Trivial whitespace cleanup Jeremy Linton
  3 siblings, 0 replies; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20  4:42 UTC (permalink / raw)
  To: devel
  Cc: Jeremy Linton, Leif Lindholm, Pete Batard, Andrei Warkentin,
	Ard Biesheuvel, Samer El-Haj-Mahmoud

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 <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
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/Platform/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 <IndustryStandard/Bcm2711.h>
+#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/Bcm2836Gpio.h>
+
+#include <IndustryStandard/Acpi.h>
+
+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 point,
+                                           // if this is lower than PSV then we
+                                           // prefer active cooling
+    Name (_AL0, Package () { \_SB_.EC0.FAN }) // the fan used for AC0 above
+  }
+}
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control
  2020-08-20  4:42 [PATCH v2 0/4] Platform/RasberryPi: Thermal zone Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Jeremy Linton
  2020-08-20  4:42 ` [PATCH v2 2/4] Platform/RaspberryPi4: Create ACPI fan object Jeremy Linton
@ 2020-08-20  4:42 ` Jeremy Linton
  2020-08-20 16:15   ` Andrei Warkentin
  2020-08-20  4:42 ` [PATCH v2 4/4] Platform/RaspberryPi: Trivial whitespace cleanup Jeremy Linton
  3 siblings, 1 reply; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20  4:42 UTC (permalink / raw)
  To: devel
  Cc: Jeremy Linton, Leif Lindholm, Pete Batard, Andrei Warkentin,
	Ard Biesheuvel, Samer El-Haj-Mahmoud

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 <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
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 <Library/AcpiLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DevicePathLib.h>
+#include <Library/DxeServicesLib.h>
 #include <Library/DxeServicesTableLib.h>
 #include <Library/GpioLib.h>
 #include <Library/HiiLib.h>
@@ -22,6 +23,7 @@
 #include <Library/NetLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/AcpiTable.h>
 #include <Protocol/BcmGenetPlatformDevice.h>
 #include <Protocol/RpiFirmware.h>
 #include <ConfigVars.h>
@@ -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,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);
+  }
 }
 
+#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 = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
+                                (VOID **)&AcpiTable);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  for (Index = 0; !EFI_ERROR (Status); Index++) {
+    Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,
+                               (VOID **)&Ssdt, &SsdtSize);
+    if (Ssdt->OemTableId == OemTableId)
+      break;
+    SsdtSize = 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=byte, 0B=word, 0C=dword
+     * and XXXX is the name and VAL is the value
+    */
+    Pattern[0] = 0x08;    //NameOp
+    Pattern[1] = Name[0]; //Name
+    Pattern[2] = Name[1];
+    Pattern[3] = Name[2];
+    Pattern[4] = Name[3];
+    Pattern[5] = 0x0A;    //Size
+
+    for (Index = 0; Index < (SsdtSize - SSDT_PATTERN_LEN); Index++) {
+      if (CompareMem ((UINT8*)Ssdt + Index, Pattern, SSDT_PATTERN_LEN) == 0) {
+        *((UINT8 *)Ssdt + Index + SSDT_PATTERN_LEN) = Value;
+        break;
+      }
+    }
+
+    Status = 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;
+}
 
 EFI_STATUS
 EFIAPI
@@ -620,6 +694,10 @@ ConfigInitialize (
       PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {
      Status = LocateAndInstallAcpiFromFv (&mAcpiTableFile);
      ASSERT_EFI_ERROR (Status);
+     if (PcdGet32 (PcdFanOnGpio)) {
+       FindInstallSsdt (SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'), 
+                        "GIOP", (UINT8)PcdGet32 (PcdFanOnGpio));
+     }
   }
 
   Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices,
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/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
 
 [Packages]
@@ -46,6 +47,7 @@
   AcpiLib
   BaseLib
   DebugLib
+  DxeServicesLib
   DxeServicesTableLib
   GpioLib
   HiiLib
@@ -89,6 +91,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 <Guid/HiiPlatformSetupFormset.h>
 #include "ConfigDxeFormSetGuid.h"
 #include <ConfigVars.h>
+#include <IndustryStandard/Bcm2711.h>
 
 //
 // 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
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/4] Platform/RaspberryPi: Trivial whitespace cleanup
  2020-08-20  4:42 [PATCH v2 0/4] Platform/RasberryPi: Thermal zone Jeremy Linton
                   ` (2 preceding siblings ...)
  2020-08-20  4:42 ` [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control Jeremy Linton
@ 2020-08-20  4:42 ` Jeremy Linton
  3 siblings, 0 replies; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20  4:42 UTC (permalink / raw)
  To: devel; +Cc: Jeremy Linton

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 <jeremy.linton@arm.com>
---
 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 (
   }
 
   Size = sizeof (UINT32);
-  Status = gRT->GetVariable(L"CustomCpuClock",
-                            &gConfigDxeFormSetGuid,
-                            NULL, &Size, &Var32);
+  Status = gRT->GetVariable (L"CustomCpuClock",
+                             &gConfigDxeFormSetGuid,
+                             NULL, &Size, &Var32);
   if (EFI_ERROR (Status)) {
     Status = PcdSet32S (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
     ASSERT_EFI_ERROR (Status);
@@ -256,9 +256,9 @@ SetupVariables (
     PcdSet32 (PcdFanOnGpio, PcdGet32 (PcdFanOnGpio));
   }
 
-  Size = sizeof(AssetTagVar);
+  Size = sizeof (AssetTagVar);
 
-  Status = gRT->GetVariable(L"AssetTag",
+  Status = gRT->GetVariable (L"AssetTag",
                   &gConfigDxeFormSetGuid,
                   NULL, &Size, AssetTagVar);
 
@@ -267,7 +267,7 @@ SetupVariables (
                     L"AssetTag",
                     &gConfigDxeFormSetGuid,
                     EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | 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 = MIN(SystemMemorySize, 4UL * SIZE_1GB);
-    SystemMemorySizeBelow4GB = MIN(SystemMemorySizeBelow4GB, BCM2836_SOC_REGISTERS);
-    SystemMemorySizeBelow4GB = MIN(SystemMemorySizeBelow4GB, BCM2711_SOC_REGISTERS);
+    SystemMemorySizeBelow4GB = MIN (SystemMemorySize, 4UL * SIZE_1GB);
+    SystemMemorySizeBelow4GB = MIN (SystemMemorySizeBelow4GB, BCM2836_SOC_REGISTERS);
+    SystemMemorySizeBelow4GB = MIN (SystemMemorySizeBelow4GB, BCM2711_SOC_REGISTERS);
 
     ASSERT (SystemMemorySizeBelow4GB > 3UL * SIZE_1GB);
 
@@ -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.
        */
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone
  2020-08-20  4:42 ` [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Jeremy Linton
@ 2020-08-20  7:59   ` Ard Biesheuvel
  2020-08-20 14:41     ` Jeremy Linton
  0 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2020-08-20  7:59 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: Leif Lindholm, Pete Batard, Andrei Warkentin,
	Samer El-Haj-Mahmoud

On 8/20/20 6:42 AM, Jeremy Linton wrote:
> 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 <leif@nuviainc.com>
> Cc: Pete Batard <pete@akeo.ie>
> Cc: Andrei Warkentin <awarkentin@vmware.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> Reviewed-by: Pete Batard <@pbatard>

This looks ok to me but I did not receive patch #4 or the cover letter.

> ---
>   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/RaspberryPi/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 temp
> +    // via a register we can read, and give it to the OS. This enables basic
> +    // reports from the "sensors" utility, and the OS can then poll and take
> +    // 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 (immediate power-off)
> +        Method (_HOT) { Return (3582) }    // (85C) HOT state where OS should hibernate
> +        Method (_PSV) { Return (3532) }    // (80C) Passive cooling (CPU throttling) 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
>   
>     }
> 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 (PcdBcmGenetRegistersAddress)
>   #define GENET_LENGTH               0x00010000
>   
> +#define THERM_SENSOR               0xfd5d2200
> +
>   #endif /* BCM2711_H__ */
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone
  2020-08-20  7:59   ` Ard Biesheuvel
@ 2020-08-20 14:41     ` Jeremy Linton
  2020-08-27  8:06       ` Ard Biesheuvel
  0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Linton @ 2020-08-20 14:41 UTC (permalink / raw)
  To: Ard Biesheuvel, devel
  Cc: Leif Lindholm, Pete Batard, Andrei Warkentin,
	Samer El-Haj-Mahmoud

Hi,

On 8/20/20 2:59 AM, Ard Biesheuvel wrote:
> On 8/20/20 6:42 AM, Jeremy Linton wrote:
>> 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 <leif@nuviainc.com>
>> Cc: Pete Batard <pete@akeo.ie>
>> Cc: Andrei Warkentin <awarkentin@vmware.com>
>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> Reviewed-by: Pete Batard <@pbatard>
> 
> This looks ok to me but I did not receive patch #4 or the cover letter.

I appear to have only CCed the groups.io ML on the cover letter and 4th 
patch (which is just whitespace).

Can you find them them there? If not I will just resend the whole series 
as v3.


> 
>> ---
>>   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/RaspberryPi/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 temp
>> +    // via a register we can read, and give it to the OS. This 
>> enables basic
>> +    // reports from the "sensors" utility, and the OS can then poll 
>> and take
>> +    // 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 (immediate power-off)
>> +        Method (_HOT) { Return (3582) }    // (85C) HOT state where 
>> OS should hibernate
>> +        Method (_PSV) { Return (3532) }    // (80C) Passive cooling 
>> (CPU throttling) 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
>>     }
>> 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 
>> (PcdBcmGenetRegistersAddress)
>>   #define GENET_LENGTH               0x00010000
>> +#define THERM_SENSOR               0xfd5d2200
>> +
>>   #endif /* BCM2711_H__ */
>>
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control
  2020-08-20  4:42 ` [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control Jeremy Linton
@ 2020-08-20 16:15   ` Andrei Warkentin
  2020-08-21  4:15     ` Jeremy Linton
  0 siblings, 1 reply; 11+ messages in thread
From: Andrei Warkentin @ 2020-08-20 16:15 UTC (permalink / raw)
  To: Jeremy Linton, devel@edk2.groups.io
  Cc: Leif Lindholm, Pete Batard, Ard Biesheuvel, Samer El-Haj-Mahmoud

[-- Attachment #1: Type: text/plain, Size: 13064 bytes --]

Hi Jeremy,

Overall, great idea. An improvement on your implementation would be to use LocateAndInstallAcpiFromFvConditional (which will call your call back on every table, so you can allow/disallow/patch) instead of calling LocateAndInstallAcpiFromFv and the locating the SSDT manually.

A
________________________________
From: Jeremy Linton <jeremy.linton@arm.com>
Sent: Wednesday, August 19, 2020 11:42 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Jeremy Linton <jeremy.linton@arm.com>; Leif Lindholm <leif@nuviainc.com>; Pete Batard <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>; Ard Biesheuvel <ard.biesheuvel@arm.com>; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control

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 <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
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 <Library/AcpiLib.h>

 #include <Library/DebugLib.h>

 #include <Library/DevicePathLib.h>

+#include <Library/DxeServicesLib.h>

 #include <Library/DxeServicesTableLib.h>

 #include <Library/GpioLib.h>

 #include <Library/HiiLib.h>

@@ -22,6 +23,7 @@
 #include <Library/NetLib.h>

 #include <Library/UefiBootServicesTableLib.h>

 #include <Library/UefiRuntimeServicesTableLib.h>

+#include <Protocol/AcpiTable.h>

 #include <Protocol/BcmGenetPlatformDevice.h>

 #include <Protocol/RpiFirmware.h>

 #include <ConfigVars.h>

@@ -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,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);

+  }

 }



+#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 = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,

+                                (VOID **)&AcpiTable);

+  if (EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  for (Index = 0; !EFI_ERROR (Status); Index++) {

+    Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,

+                               (VOID **)&Ssdt, &SsdtSize);

+    if (Ssdt->OemTableId == OemTableId)

+      break;

+    SsdtSize = 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=byte, 0B=word, 0C=dword

+     * and XXXX is the name and VAL is the value

+    */

+    Pattern[0] = 0x08;    //NameOp

+    Pattern[1] = Name[0]; //Name

+    Pattern[2] = Name[1];

+    Pattern[3] = Name[2];

+    Pattern[4] = Name[3];

+    Pattern[5] = 0x0A;    //Size

+

+    for (Index = 0; Index < (SsdtSize - SSDT_PATTERN_LEN); Index++) {

+      if (CompareMem ((UINT8*)Ssdt + Index, Pattern, SSDT_PATTERN_LEN) == 0) {

+        *((UINT8 *)Ssdt + Index + SSDT_PATTERN_LEN) = Value;

+        break;

+      }

+    }

+

+    Status = 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;

+}



 EFI_STATUS

 EFIAPI

@@ -620,6 +694,10 @@ ConfigInitialize (
       PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {

      Status = LocateAndInstallAcpiFromFv (&mAcpiTableFile);

      ASSERT_EFI_ERROR (Status);

+     if (PcdGet32 (PcdFanOnGpio)) {

+       FindInstallSsdt (SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),

+                        "GIOP", (UINT8)PcdGet32 (PcdFanOnGpio));

+     }

   }



   Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices,

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/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



 [Packages]

@@ -46,6 +47,7 @@
   AcpiLib

   BaseLib

   DebugLib

+  DxeServicesLib

   DxeServicesTableLib

   GpioLib

   HiiLib

@@ -89,6 +91,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 <Guid/HiiPlatformSetupFormset.h>

 #include "ConfigDxeFormSetGuid.h"

 #include <ConfigVars.h>

+#include <IndustryStandard/Bcm2711.h>



 //

 // 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

--
2.13.7


[-- Attachment #2: Type: text/html, Size: 21590 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control
  2020-08-20 16:15   ` Andrei Warkentin
@ 2020-08-21  4:15     ` Jeremy Linton
  0 siblings, 0 replies; 11+ messages in thread
From: Jeremy Linton @ 2020-08-21  4:15 UTC (permalink / raw)
  To: Andrei Warkentin, devel@edk2.groups.io
  Cc: Leif Lindholm, Pete Batard, Ard Biesheuvel, Samer El-Haj-Mahmoud

Hi,

On 8/20/20 11:15 AM, Andrei Warkentin wrote:
> Hi Jeremy,
> 
> Overall, great idea. An improvement on your implementation would be to use LocateAndInstallAcpiFromFvConditional (which will call your call back on every table, so you can allow/disallow/patch) instead of calling LocateAndInstallAcpiFromFv and the locating the SSDT manually.

Yes, I think a few people have heard me complaining about the lack of 
dyanmic PCD values being easily accessable from AML. It should be easier 
so we can provide more customization (the actual thermal limits for one) 
without a lot of additional effort.

I switched to doing this NameOp binary modification from the multiple 
pass SSDT compiles when I noticed another platform doing binary edits 
(which I had assumed was a litle to "hacky" for upstream). But, I didn't 
go to far down that path because the obvious next couple steps are 
providing a generic PCD->Name association structure and doing it for all 
DSDT/SSDT's being loaded. But I suspect that it would be a lot more 
useful to the edk2 project as a whole if we can encode the association 
directly in the AML with a edk2 specific macro and so i've assumed the 
time would be better spent coding up a deterministic way to do that.

(which at a minimum is probably a better binary parser than memcmp, or 
at least a edk2 specific custom nameobj assigment we can key off to 
upgrade to a standards compliant aml blob)

So, at the moment this is mostly a ok, let me look into it more 
response... :)


> 
> A
> ________________________________
> From: Jeremy Linton <jeremy.linton@arm.com>
> Sent: Wednesday, August 19, 2020 11:42 PM
> To: devel@edk2.groups.io <devel@edk2.groups.io>
> Cc: Jeremy Linton <jeremy.linton@arm.com>; Leif Lindholm <leif@nuviainc.com>; Pete Batard <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>; Ard Biesheuvel <ard.biesheuvel@arm.com>; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Subject: [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control
> 
> 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 <leif@nuviainc.com>
> Cc: Pete Batard <pete@akeo.ie>
> Cc: Andrei Warkentin <awarkentin@vmware.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> 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 <Library/AcpiLib.h>
> 
>   #include <Library/DebugLib.h>
> 
>   #include <Library/DevicePathLib.h>
> 
> +#include <Library/DxeServicesLib.h>
> 
>   #include <Library/DxeServicesTableLib.h>
> 
>   #include <Library/GpioLib.h>
> 
>   #include <Library/HiiLib.h>
> 
> @@ -22,6 +23,7 @@
>   #include <Library/NetLib.h>
> 
>   #include <Library/UefiBootServicesTableLib.h>
> 
>   #include <Library/UefiRuntimeServicesTableLib.h>
> 
> +#include <Protocol/AcpiTable.h>
> 
>   #include <Protocol/BcmGenetPlatformDevice.h>
> 
>   #include <Protocol/RpiFirmware.h>
> 
>   #include <ConfigVars.h>
> 
> @@ -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,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);
> 
> +  }
> 
>   }
> 
> 
> 
> +#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 = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
> 
> +                                (VOID **)&AcpiTable);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    return Status;
> 
> +  }
> 
> +
> 
> +  for (Index = 0; !EFI_ERROR (Status); Index++) {
> 
> +    Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,
> 
> +                               (VOID **)&Ssdt, &SsdtSize);
> 
> +    if (Ssdt->OemTableId == OemTableId)
> 
> +      break;
> 
> +    SsdtSize = 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=byte, 0B=word, 0C=dword
> 
> +     * and XXXX is the name and VAL is the value
> 
> +    */
> 
> +    Pattern[0] = 0x08;    //NameOp
> 
> +    Pattern[1] = Name[0]; //Name
> 
> +    Pattern[2] = Name[1];
> 
> +    Pattern[3] = Name[2];
> 
> +    Pattern[4] = Name[3];
> 
> +    Pattern[5] = 0x0A;    //Size
> 
> +
> 
> +    for (Index = 0; Index < (SsdtSize - SSDT_PATTERN_LEN); Index++) {
> 
> +      if (CompareMem ((UINT8*)Ssdt + Index, Pattern, SSDT_PATTERN_LEN) == 0) {
> 
> +        *((UINT8 *)Ssdt + Index + SSDT_PATTERN_LEN) = Value;
> 
> +        break;
> 
> +      }
> 
> +    }
> 
> +
> 
> +    Status = 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;
> 
> +}
> 
> 
> 
>   EFI_STATUS
> 
>   EFIAPI
> 
> @@ -620,6 +694,10 @@ ConfigInitialize (
>         PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {
> 
>        Status = LocateAndInstallAcpiFromFv (&mAcpiTableFile);
> 
>        ASSERT_EFI_ERROR (Status);
> 
> +     if (PcdGet32 (PcdFanOnGpio)) {
> 
> +       FindInstallSsdt (SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
> 
> +                        "GIOP", (UINT8)PcdGet32 (PcdFanOnGpio));
> 
> +     }
> 
>     }
> 
> 
> 
>     Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices,
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/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
> 
> 
> 
>   [Packages]
> 
> @@ -46,6 +47,7 @@
>     AcpiLib
> 
>     BaseLib
> 
>     DebugLib
> 
> +  DxeServicesLib
> 
>     DxeServicesTableLib
> 
>     GpioLib
> 
>     HiiLib
> 
> @@ -89,6 +91,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 <Guid/HiiPlatformSetupFormset.h>
> 
>   #include "ConfigDxeFormSetGuid.h"
> 
>   #include <ConfigVars.h>
> 
> +#include <IndustryStandard/Bcm2711.h>
> 
> 
> 
>   //
> 
>   // 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
> 
> --
> 2.13.7
> 
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone
  2020-08-20 14:41     ` Jeremy Linton
@ 2020-08-27  8:06       ` Ard Biesheuvel
  2020-08-27 15:21         ` Jeremy Linton
  0 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2020-08-27  8:06 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: Leif Lindholm, Pete Batard, Andrei Warkentin,
	Samer El-Haj-Mahmoud

On 8/20/20 4:41 PM, Jeremy Linton wrote:
> Hi,
> 
> On 8/20/20 2:59 AM, Ard Biesheuvel wrote:
>> On 8/20/20 6:42 AM, Jeremy Linton wrote:
>>> 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 <leif@nuviainc.com>
>>> Cc: Pete Batard <pete@akeo.ie>
>>> Cc: Andrei Warkentin <awarkentin@vmware.com>
>>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>> Reviewed-by: Pete Batard <@pbatard>
>>
>> This looks ok to me but I did not receive patch #4 or the cover letter.
> 
> I appear to have only CCed the groups.io ML on the cover letter and 4th 
> patch (which is just whitespace).
> 
> Can you find them them there? If not I will just resend the whole series 
> as v3.
> 

Mind resending them? Grabbing and applying patches from the web UI is 
not really feasible with the groups.io interface.


> 
>>
>>> ---
>>>   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/RaspberryPi/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 temp
>>> +    // via a register we can read, and give it to the OS. This 
>>> enables basic
>>> +    // reports from the "sensors" utility, and the OS can then poll 
>>> and take
>>> +    // 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 (immediate power-off)
>>> +        Method (_HOT) { Return (3582) }    // (85C) HOT state where 
>>> OS should hibernate
>>> +        Method (_PSV) { Return (3532) }    // (80C) Passive cooling 
>>> (CPU throttling) 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
>>>     }
>>> 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 
>>> (PcdBcmGenetRegistersAddress)
>>>   #define GENET_LENGTH               0x00010000
>>> +#define THERM_SENSOR               0xfd5d2200
>>> +
>>>   #endif /* BCM2711_H__ */
>>>
>>
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone
  2020-08-27  8:06       ` Ard Biesheuvel
@ 2020-08-27 15:21         ` Jeremy Linton
  0 siblings, 0 replies; 11+ messages in thread
From: Jeremy Linton @ 2020-08-27 15:21 UTC (permalink / raw)
  To: Ard Biesheuvel, devel
  Cc: Leif Lindholm, Pete Batard, Andrei Warkentin,
	Samer El-Haj-Mahmoud

On 8/27/20 3:06 AM, Ard Biesheuvel wrote:
> On 8/20/20 4:41 PM, Jeremy Linton wrote:
>> Hi,
>>
>> On 8/20/20 2:59 AM, Ard Biesheuvel wrote:
>>> On 8/20/20 6:42 AM, Jeremy Linton wrote:
>>>> 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 <leif@nuviainc.com>
>>>> Cc: Pete Batard <pete@akeo.ie>
>>>> Cc: Andrei Warkentin <awarkentin@vmware.com>
>>>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>>>> Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
>>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>>> Reviewed-by: Pete Batard <@pbatard>
>>>
>>> This looks ok to me but I did not receive patch #4 or the cover letter.
>>
>> I appear to have only CCed the groups.io ML on the cover letter and 
>> 4th patch (which is just whitespace).
>>
>> Can you find them them there? If not I will just resend the whole 
>> series as v3.
>>
> 
> Mind resending them? Grabbing and applying patches from the web UI is 
> not really feasible with the groups.io interface.

Sure, let me apply Andrei's suggestion. I was planning on fleshing out a 
more generic AML update mechanism but no sense in holding this up for that.


> 
> 
>>
>>>
>>>> ---
>>>>   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/RaspberryPi/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 temp
>>>> +    // via a register we can read, and give it to the OS. This 
>>>> enables basic
>>>> +    // reports from the "sensors" utility, and the OS can then poll 
>>>> and take
>>>> +    // 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 (immediate power-off)
>>>> +        Method (_HOT) { Return (3582) }    // (85C) HOT state where 
>>>> OS should hibernate
>>>> +        Method (_PSV) { Return (3532) }    // (80C) Passive cooling 
>>>> (CPU throttling) 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
>>>>     }
>>>> 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 
>>>> (PcdBcmGenetRegistersAddress)
>>>>   #define GENET_LENGTH               0x00010000
>>>> +#define THERM_SENSOR               0xfd5d2200
>>>> +
>>>>   #endif /* BCM2711_H__ */
>>>>
>>>
>>
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-08-27 15:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-20  4:42 [PATCH v2 0/4] Platform/RasberryPi: Thermal zone Jeremy Linton
2020-08-20  4:42 ` [PATCH v2 1/4] Platform/RaspberryPi4: Add a basic thermal zone Jeremy Linton
2020-08-20  7:59   ` Ard Biesheuvel
2020-08-20 14:41     ` Jeremy Linton
2020-08-27  8:06       ` Ard Biesheuvel
2020-08-27 15:21         ` Jeremy Linton
2020-08-20  4:42 ` [PATCH v2 2/4] Platform/RaspberryPi4: Create ACPI fan object Jeremy Linton
2020-08-20  4:42 ` [PATCH v2 3/4] Platform/RaspberryPi: Add entry for user fan control Jeremy Linton
2020-08-20 16:15   ` Andrei Warkentin
2020-08-21  4:15     ` Jeremy Linton
2020-08-20  4:42 ` [PATCH v2 4/4] Platform/RaspberryPi: Trivial whitespace cleanup Jeremy Linton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox