Re: [edk2-devel] [PATCH v3 1/5] Platform/RaspberryPi4: Add a basic thermal zone

2020-08-31 Thread Jeremy Linton

On 8/31/20 10:33 AM, Ard Biesheuvel wrote:

On 8/31/20 5:13 PM, Jeremy Linton wrote:

Hi,

On 8/31/20 8:15 AM, Pete Batard wrote:

One general, non-blocking comment below:

On 2020.08.28 23:02, 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.

As a first pass add a basic passive cooling ACPI thermalzone
with trip points for passive cooling (throttling) handled
by the vc firmware, hibernate and critical shutdown. The
vc apparently kicks in at ~80C, so the hibernate and critical
set points are set at +5 and +10 of that. In the future
CPPC should be able to monitor the thermal throttling.

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Jeremy Linton 
Reviewed-by: Pete Batard <@pbatard>
---
  Platform/RaspberryPi/AcpiTables/Dsdt.asl   | 31 
++

  .../Bcm27xx/Include/IndustryStandard/Bcm2711.h |  2 ++
  2 files changed, 33 insertions(+)

diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl 
b/Platform/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)


Just going to point out that all the other ACPI devices we seem to 
define have 4 characters, so I'm not sure if we're breaking a 
convention by introducing a 3 character one here...


Well not an ACPI spec convention, because it seems the spec examples 
are mostly 3 characters. EDK2 OTOH, seems to be largely 4 but there 
are a fair number of 3 character device/etc methods around


I'm not sure it matters, unless there is a edk2 convention I'm unaware 
of.




I don't think such a convention exists, although I never tried the MS 
iasl compiler, and the RPi asl code (which was contributed by MS) 
suspiciously uses 4 letter identifiers everywhere.


Samer, any clue?



I have another patch to allow the user to set the temp trip point which 
IIRC Andrei had asked about months ago when I originally mentioned that 
I had hacked up a thermal zone.


I might as well roll a v4 with that, the whitespace, and "0"'s appended 
to EC0 and TZ0 just in case... I'm sanity checking right now that it 
still works.






-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64841): https://edk2.groups.io/g/devel/message/64841
Mute This Topic: https://groups.io/mt/76484330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/5] Platform/RaspberryPi4: Add a basic thermal zone

2020-08-31 Thread Ard Biesheuvel

On 8/31/20 5:13 PM, Jeremy Linton wrote:

Hi,

On 8/31/20 8:15 AM, Pete Batard wrote:

One general, non-blocking comment below:

On 2020.08.28 23:02, 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.

As a first pass add a basic passive cooling ACPI thermalzone
with trip points for passive cooling (throttling) handled
by the vc firmware, hibernate and critical shutdown. The
vc apparently kicks in at ~80C, so the hibernate and critical
set points are set at +5 and +10 of that. In the future
CPPC should be able to monitor the thermal throttling.

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Jeremy Linton 
Reviewed-by: Pete Batard <@pbatard>
---
  Platform/RaspberryPi/AcpiTables/Dsdt.asl   | 31 
++

  .../Bcm27xx/Include/IndustryStandard/Bcm2711.h |  2 ++
  2 files changed, 33 insertions(+)

diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl 
b/Platform/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)


Just going to point out that all the other ACPI devices we seem to 
define have 4 characters, so I'm not sure if we're breaking a 
convention by introducing a 3 character one here...


Well not an ACPI spec convention, because it seems the spec examples are 
mostly 3 characters. EDK2 OTOH, seems to be largely 4 but there are a 
fair number of 3 character device/etc methods around


I'm not sure it matters, unless there is a edk2 convention I'm unaware of.



I don't think such a convention exists, although I never tried the MS 
iasl compiler, and the RPi asl code (which was contributed by MS) 
suspiciously uses 4 letter identifiers everywhere.


Samer, any clue?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64839): https://edk2.groups.io/g/devel/message/64839
Mute This Topic: https://groups.io/mt/76484330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/5] Platform/RaspberryPi4: Add a basic thermal zone

2020-08-31 Thread Jeremy Linton

Hi,

On 8/31/20 8:15 AM, Pete Batard wrote:

One general, non-blocking comment below:

On 2020.08.28 23:02, 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.

As a first pass add a basic passive cooling ACPI thermalzone
with trip points for passive cooling (throttling) handled
by the vc firmware, hibernate and critical shutdown. The
vc apparently kicks in at ~80C, so the hibernate and critical
set points are set at +5 and +10 of that. In the future
CPPC should be able to monitor the thermal throttling.

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Jeremy Linton 
Reviewed-by: Pete Batard <@pbatard>
---
  Platform/RaspberryPi/AcpiTables/Dsdt.asl   | 31 
++

  .../Bcm27xx/Include/IndustryStandard/Bcm2711.h |  2 ++
  2 files changed, 33 insertions(+)

diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl 
b/Platform/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)


Just going to point out that all the other ACPI devices we seem to 
define have 4 characters, so I'm not sure if we're breaking a convention 
by introducing a 3 character one here...


Well not an ACPI spec convention, because it seems the spec examples are 
mostly 3 characters. EDK2 OTOH, seems to be largely 4 but there are a 
fair number of 3 character device/etc methods around


I'm not sure it matters, unless there is a edk2 convention I'm unaware of.





+    {

+  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) {


Likewise, what I'm seeing by googling around for ThermalZone () names 
would be 4 character ones such as "TZ00", "TZ01" or "TZS0" (For 'Thermal 
Zone Sensor 0') or "TMZN" for single entries.




+    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   0x0001


+#define THERM_SENSOR   0xfd5d2200

+

  #endif /* BCM2711_H__ */



Reviewed-by: Pete Batard 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64838): https://edk2.groups.io/g/devel/message/64838
Mute This Topic: https://groups.io/mt/76484330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/5] Platform/RaspberryPi4: Add a basic thermal zone

2020-08-31 Thread Pete Batard

One general, non-blocking comment below:

On 2020.08.28 23:02, 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.

As a first pass add a basic passive cooling ACPI thermalzone
with trip points for passive cooling (throttling) handled
by the vc firmware, hibernate and critical shutdown. The
vc apparently kicks in at ~80C, so the hibernate and critical
set points are set at +5 and +10 of that. In the future
CPPC should be able to monitor the thermal throttling.

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Jeremy Linton 
Reviewed-by: Pete Batard <@pbatard>
---
  Platform/RaspberryPi/AcpiTables/Dsdt.asl   | 31 ++
  .../Bcm27xx/Include/IndustryStandard/Bcm2711.h |  2 ++
  2 files changed, 33 insertions(+)

diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl 
b/Platform/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)


Just going to point out that all the other ACPI devices we seem to 
define have 4 characters, so I'm not sure if we're breaking a convention 
by introducing a 3 character one here...




+{

+  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) {


Likewise, what I'm seeing by googling around for ThermalZone () names 
would be 4 character ones such as "TZ00", "TZ01" or "TZS0" (For 'Thermal 
Zone Sensor 0') or "TMZN" for single entries.




+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   0x0001

  


+#define THERM_SENSOR   0xfd5d2200

+

  #endif /* BCM2711_H__ */



Reviewed-by: Pete Batard 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64829): https://edk2.groups.io/g/devel/message/64829
Mute This Topic: https://groups.io/mt/76484330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-