mb/samsung/stumpy: inline fan thresholds and drop GNVS programming

- mirror Beltino’s thermal AML pattern by including `thermal.h` and
  using the static macros directly
- add `_INI` and `_STA`-guarded power resources so FAN4 idle state is
  established without relying on preseeded GNVS values
- remove the now-unused GNVS fan table and temperature fields from
  `acpi_tables.c`, leaving only the USB suspend defaults

This simplifies Stumpy's fan control and unifies it with newer boards
like Beltino and Jecht, and fixes an issue where the fan was not
starting automatically under Windows.

TEST=build/boot Win11, Ubuntu 25.10 on Stumpy, verify fan starts and
adjusts automatically, CPU temps kept under control.

Change-Id: Ie9c8c46e4bf3412ea60d7fe8f2d97651bca266f1
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90056
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
This commit is contained in:
Matt DeVillier 2025-11-12 11:59:16 -06:00
commit 872e06d60c
2 changed files with 71 additions and 70 deletions

View file

@ -2,6 +2,8 @@
// Thermal Zone
#include "../thermal.h"
External (\PPKG, MethodObj)
Scope (\_TZ)
@ -31,13 +33,13 @@ Scope (\_TZ)
// Threshold for OS to shutdown
Method (_CRT, 0, Serialized)
{
Return (CTOK (\TCRT))
Return (CTOK (CRITICAL_TEMPERATURE))
}
// Threshold for passive cooling
Method (_PSV, 0, Serialized)
{
Return (CTOK (\TPSV))
Return (CTOK (PASSIVE_TEMPERATURE))
}
// Processors used for passive cooling
@ -46,6 +48,14 @@ Scope (\_TZ)
Return (\PPKG ())
}
// Initialize to the lowest cooling state (fan idle)
Method (_INI)
{
\FLVL = 4
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN4_PWM
Notify (\_TZ.THRM, 0x81)
}
Method (_TMP, 0, Serialized)
{
// Get CPU Temperature from PECI via SuperIO TMPIN3
@ -53,59 +63,59 @@ Scope (\_TZ)
// Check for invalid readings
If ((Local0 == 255) || (Local0 == 0)) {
Return (CTOK (\F2ON))
Return (CTOK (FAN2_THRESHOLD_ON))
}
// PECI raw value is an offset from Tj_max
Local1 = 255 - Local0
// Handle values greater than Tj_max
If (Local1 >= \TMAX) {
Return (CTOK (\TMAX))
If (Local1 >= MAX_TEMPERATURE) {
Return (CTOK (MAX_TEMPERATURE))
}
// Subtract from Tj_max to get temperature
Local0 = \TMAX - Local1
Local0 = MAX_TEMPERATURE - Local1
Return (CTOK (Local0))
}
Method (_AC0) {
If (\FLVL <= 0) {
Return (CTOK (\F0OF))
Return (CTOK (FAN0_THRESHOLD_OFF))
} Else {
Return (CTOK (\F0ON))
Return (CTOK (FAN0_THRESHOLD_ON))
}
}
Method (_AC1) {
If (\FLVL <= 1) {
Return (CTOK (\F1OF))
Return (CTOK (FAN1_THRESHOLD_OFF))
} Else {
Return (CTOK (\F1ON))
Return (CTOK (FAN1_THRESHOLD_ON))
}
}
Method (_AC2) {
If (\FLVL <= 2) {
Return (CTOK (\F2OF))
Return (CTOK (FAN2_THRESHOLD_OFF))
} Else {
Return (CTOK (\F2ON))
Return (CTOK (FAN2_THRESHOLD_ON))
}
}
Method (_AC3) {
If (\FLVL <= 3) {
Return (CTOK (\F3OF))
Return (CTOK (FAN3_THRESHOLD_OFF))
} Else {
Return (CTOK (\F3ON))
Return (CTOK (FAN3_THRESHOLD_ON))
}
}
Method (_AC4) {
If (\FLVL <= 4) {
Return (CTOK (\F4OF))
Return (CTOK (FAN4_THRESHOLD_OFF))
} Else {
Return (CTOK (\F4ON))
Return (CTOK (FAN4_THRESHOLD_ON))
}
}
@ -125,14 +135,18 @@ Scope (\_TZ)
}
}
Method (_ON) {
\FLVL = 0
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F0PW
Notify (\_TZ.THRM, 0x81)
If (! _STA ()) {
\FLVL = 0
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN0_PWM
Notify (\_TZ.THRM, 0x81)
}
}
Method (_OFF) {
\FLVL = 1
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F1PW
Notify (\_TZ.THRM, 0x81)
If (_STA ()) {
\FLVL = 1
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN1_PWM
Notify (\_TZ.THRM, 0x81)
}
}
}
@ -146,14 +160,18 @@ Scope (\_TZ)
}
}
Method (_ON) {
\FLVL = 1
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F1PW
Notify (\_TZ.THRM, 0x81)
If (! _STA ()) {
\FLVL = 1
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN1_PWM
Notify (\_TZ.THRM, 0x81)
}
}
Method (_OFF) {
\FLVL = 2
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F2PW
Notify (\_TZ.THRM, 0x81)
If (_STA ()) {
\FLVL = 2
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN2_PWM
Notify (\_TZ.THRM, 0x81)
}
}
}
@ -167,14 +185,18 @@ Scope (\_TZ)
}
}
Method (_ON) {
\FLVL = 2
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F2PW
Notify (\_TZ.THRM, 0x81)
If (! _STA ()) {
\FLVL = 2
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN2_PWM
Notify (\_TZ.THRM, 0x81)
}
}
Method (_OFF) {
\FLVL = 3
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F3PW
Notify (\_TZ.THRM, 0x81)
If (_STA ()) {
\FLVL = 3
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN3_PWM
Notify (\_TZ.THRM, 0x81)
}
}
}
@ -188,14 +210,18 @@ Scope (\_TZ)
}
}
Method (_ON) {
\FLVL = 3
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F3PW
Notify (\_TZ.THRM, 0x81)
If (! _STA ()) {
\FLVL = 3
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN3_PWM
Notify (\_TZ.THRM, 0x81)
}
}
Method (_OFF) {
\FLVL = 4
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F4PW
Notify (\_TZ.THRM, 0x81)
If (_STA ()) {
\FLVL = 4
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN4_PWM
Notify (\_TZ.THRM, 0x81)
}
}
}
@ -209,9 +235,11 @@ Scope (\_TZ)
}
}
Method (_ON) {
\FLVL = 4
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = \F4PW
Notify (\_TZ.THRM, 0x81)
If (! _STA ()) {
\FLVL = 4
\_SB.PCI0.LPCB.SIO.ENVC.F3PS = FAN4_PWM
Notify (\_TZ.THRM, 0x81)
}
}
Method (_OFF) {
// FAN4 is the minimum cooling state (idle/lowest fan speed)

View file

@ -4,8 +4,6 @@
#include <device/device.h>
#include <soc/nvs.h>
#include "thermal.h"
void mainboard_fill_gnvs(struct global_nvs *gnvs)
{
/* Enable Front USB ports in S3 by default */
@ -18,29 +16,4 @@ void mainboard_fill_gnvs(struct global_nvs *gnvs)
*/
gnvs->s5u0 = 1;
gnvs->s5u1 = 1;
gnvs->f4of = FAN4_THRESHOLD_OFF;
gnvs->f4on = FAN4_THRESHOLD_ON;
gnvs->f4pw = FAN4_PWM;
gnvs->f3of = FAN3_THRESHOLD_OFF;
gnvs->f3on = FAN3_THRESHOLD_ON;
gnvs->f3pw = FAN3_PWM;
gnvs->f2of = FAN2_THRESHOLD_OFF;
gnvs->f2on = FAN2_THRESHOLD_ON;
gnvs->f2pw = FAN2_PWM;
gnvs->f1of = FAN1_THRESHOLD_OFF;
gnvs->f1on = FAN1_THRESHOLD_ON;
gnvs->f1pw = FAN1_PWM;
gnvs->f0of = FAN0_THRESHOLD_OFF;
gnvs->f0on = FAN0_THRESHOLD_ON;
gnvs->f0pw = FAN0_PWM;
gnvs->tcrt = CRITICAL_TEMPERATURE;
gnvs->tpsv = PASSIVE_TEMPERATURE;
gnvs->tmax = MAX_TEMPERATURE;
gnvs->flvl = 5;
}