![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
Cooling drivers implement **struct rt_thermal_cooling_device_ops** and register with **rt_thermal_cooling_device_register**. Zones reference them from **cooling-maps** (see Thermal management).
| Driver | Kconfig | compatible (typical) |
|---|---|---|
| PWM fan | **RT_THERMAL_COOL_PWM_FAN** | **pwm-fan** |
| GPIO fan | **RT_THERMAL_COOL_GPIO_FAN** | (see thermal-cool-gpio-fan.c) |
| DVFS | **RT_THERMAL_COOL_DVFS** | (see thermal-cool-dvfs.c) |
Sources: components/drivers/thermal/thermal-cool-*.c.
Maps thermal cooling level (0 … max_level) to PWM duty via optional **cooling-levels** LUT. Optional **fan** regulator supply (property resolves as supply name **fan** → **rt_regulator_get(dev, "fan")**).
Referenced from zone:
| Property | Role |
|---|---|
**pwms** | **#pwm-cells**: channel, period |
**cooling-levels** | PWM scale values per level; array length − 1 = max_level |
| Regulator | **rt_regulator_get(dev, "fan")** — wire **fan** supply in regulator/DT as on your BSP |
| Op | Behavior |
|---|---|
**get_max_level** | **levels_nr - 1** |
**get_cur_level** | Current level (spinlock) |
**set_cur_level** | LUT → **rt_pwm_set**; level 0 powers off PWM/regulator |
Power sequence: on — **rt_pwm_enable** then **rt_regulator_enable**; off — reverse with rollback on error.
pwms**, ensure PWM controller probed (**rt_platform_ofw_request** if needed).rt_regulator_get(dev, "fan")**.cooling-levels** array.rt_thermal_cooling_device_register** — attaches default **dumb** governor.set_cur_level(0)** (fan off).Platform driver: **RT_PLATFORM_DRIVER_EXPORT(pwm_fan_cool_driver)**.
Kconfig: **RT_THERMAL_COOL_GPIO_FAN** (**RT_USING_PIN**, **RT_USING_OFW**).
Controls fan speed via GPIO pins and a speed table (RPM / control value). Suitable for multi-wire fan tach/control GPIOs rather than PWM.
Inspect **gpio_fan_cool_probe** in the source for exact property names on your BSP.
Kconfig: **RT_THERMAL_COOL_DVFS** + **RT_USING_DVFS**.
Exposes OPP table indices as cooling levels — **set_cur_level** selects a lower performance point. Use when passive trip should throttle CPU/GPU frequency instead of spinning a fan.
probe** before dependent zone (or rely on init order).parent.ofw_node** on **rt_thermal_cooling_device.parent** so **thermal_ofw_setup** can match **cooling-device** phandles.cooling-levels** (PWM) or max level in ops consistently with DT **cooling-device** min/max cells.cooling-maps** **trip** must point at a trip node parsed under the same thermal zone.rt_thermal_zone_device_update** or wait for poller — verify **set_cur_level** at each trip.set_cur_level in ISR**: uses spinlock — do not call from ISR.dumb** only nudges level on temperature delta vs **hysteresis** — custom governor may be needed for fine control.components/drivers/thermal/thermal-cool-pwm-fan.c