nuttx/drivers/thermal/Kconfig
Justin Hammond 7efdd31994 drivers/thermal: Cool a devfreq device instead of a cpufreq policy.
The cooling device renamed in the previous commit was written against a
cpufreq framework that never landed.  It includes nuttx/cpufreq.h, which
does not exist, and THERMAL_CDEV_CPUFREQ depends on CPUFREQ, which no
Kconfig in the tree defines, so it has never been selectable and has never
been compiled.  The cpufreq half of the dummy driver is orphaned the same
way behind THERMAL_DUMMY_CPUFREQ.  Upstream noticed once already and
dropped cpufreq from the sim thermal configuration in 898a5d501f.

devfreq does the same job and is here.  It carries the frequency table,
arbitrates windows through QoS, and its DEVFREQ_CONFLICT_PREFER_LOW is
documented as the policy for a device protecting a thermal budget, which
is exactly a cooling device's claim on it.  Point the cooling device at
that instead, and the thermal framework can throttle again.

Two things change beyond the API.  The cooling state now names a ceiling
rather than a two entry window, because devfreq resolves a conflicting
floor in the ceiling's favour, and that makes the whole table reachable:
max_state is one less than the number of usable entries, state zero leaves
the top entry available and the highest state holds the device at the
bottom one.  A DEVFREQ_ENTRY_INVALID entry is a hole the driver has
punched and cannot be installed as a ceiling, so it earns no cooling
state; counting it would both advertise a state the device cannot deliver
and, on reaching it, install a ceiling of ~0u, which caps nothing.  And the device is found by name, since devfreq is multi instance
where a cpufreq policy was singular, so THERMAL_CDEV_DEVFREQ_NAME says
which one to cool and what to call the cooling device in a zone's map.

The dummy driver gains a devfreq lower half in place of its cpufreq one,
which gives the tree its first devfreq consumer and makes the whole path
testable without hardware.  On sim, walking the dummy zone from 45 to 90
degrees:

  temp   cooling state   frequency
    60               0         900
    62               1         700
    61               2         500
    72               3         300
    74               4         100

and back down again as it cools.

Also fixes two faults the file could not previously reveal: it called
therr and thinfo without including nuttx/debug.h, and it reached the
driver by casting the policy pointer, which worked only while driver was
the first member.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 09:46:47 -03:00

80 lines
1.7 KiB
Text

#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig THERMAL
bool "Thermal framework"
default n
depends on SCHED_LPWORK
---help---
Enable thermal framework.
if THERMAL
config THERMAL_DEFAULT_GOVERNOR
string "Thermal default governor name"
default "step_wise"
---help---
Default governor name.
config THERMAL_GOVERNOR_STEP_WISE
bool "Enable step wise governor"
default y
---help---
Enable step wise governor.
config THERMAL_CDEV_DEVFREQ
bool "Thermal devfreq cooling device"
default n
depends on DEVFREQ
---help---
Enable thermal devfreq cooling device, which cools a device by
capping the frequency of its devfreq instance.
if THERMAL_CDEV_DEVFREQ
config THERMAL_CDEV_DEVFREQ_NAME
string "Name of the devfreq device to cool"
default "cpu"
---help---
The devfreq device this cooling device caps, and the name the
cooling device itself takes, so that a zone's cooling map can
refer to it. The devfreq device must be registered before
thermal_init() runs.
endif # THERMAL_CDEV_DEVFREQ
config THERMAL_PROCFS
bool "Thermal PROCFS support"
default n
depends on FS_PROCFS
---help---
Enable thermal procfs.
config THERMAL_DUMMY
bool "Thermal dummy driver"
default n
---help---
Enable thermal dummy driver.
if THERMAL_DUMMY
config THERMAL_DUMMY_POLLING_DELAY
int "Polling delay"
default 200
---help---
Polling delay(tick).
config THERMAL_DUMMY_DEVFREQ
bool "Dummy devfreq driver"
default n
depends on DEVFREQ
select THERMAL_CDEV_DEVFREQ
---help---
Enable devfreq dummy driver, giving the dummy zone a frequency
capped cooling device as well as its fan.
endif # THERMAL_DUMMY
endif # THERMAL