HWMON、Thermal、IIO 与 Power Supply 边界
1. HWMON
适合:
- 读取健康监控值;
- 配置 sensor threshold;
- 读取 alarm/fault;
- 人工或 daemon 控制 PWM;
- libsensors 展示。
2. Thermal
负责:
- thermal zone;
- trip point;
- governor;
- cooling device;
- CPU/GPU/NPU cooling;
- shutdown critical temperature。
RK3588 TSADC直接注册 thermal sensors,温度主要见:
1 | /sys/class/thermal/thermal_zone*/ |
不保证同时出现 tempN_input。
3. HWMON 到 Thermal
现代 hwmon driver设置 HWMON_C_REGISTER_TZ,Core按 OF thermal-sensors引用把 temp channel注册到 Thermal。
这适用于外部温度 sensor作为 thermal zone provider。没有 OF引用时注册返回 -ENODEV,hwmon仍可正常存在。
4. Thermal 到 HWMON
hwmon_device_register_for_thermal() 是 legacy 专用 API,只允许 Thermal 子系统使用。新普通 hwmon driver不应调用它。
5. IIO
IIO适合:
- ADC;
- buffered sampling;
- trigger;
- timestamp;
- raw/scale/processed;
- 高速或事件数据。
iio_hwmon.c 将 IIO processed channels桥接成 HWMON inN_input/tempN_input 等,方便 lm-sensors。
6. Power Supply
负责 battery/charger/USB power:
- voltage_now;
- current_now;
- capacity;
- status;
- health。
单位和 ABI 与 HWMON 不同。电池 gauge 应优先 power_supply,不应为了 sensors 重复注册一套无协调接口。
7. Regulator
Regulator表示可供 consumer请求的电源 rail setpoint/enable,不等同于物理测量。PMIC寄存器的设定值不能替代 INA/ADC 的实际电压。
8. hwspin/SCMI
SCMI/SCPI firmware sensor可由 scmi-hwmon/scpi-hwmon 暴露。数据由固件提供,Linux无直接寄存器访问,采样率和错误语义受 firmware协议限制。
9. 决策
1 | 控制系统降频/关机 -> Thermal |
同一物理器件可跨子系统,但应有单一底层数据/锁管理,避免重复硬件访问和控制冲突。
正在加载留言…