4.5.3. 调试指南¶
4.5.3.1. 调试开关¶
在luban根目录下执行 make kernel-menuconfig,进入kernel的功能配置,可以打开 TSensor 模块的DEBUG选项:
Linux
    Kernel hacking
        Artinchip Debug
            [*] Thermal Sensor driver debug
此DEBUG选项打开的影响:
- TSensor 驱动以-O0编译 
- TSensor 的pr_dbg()和dev_dbg()调试信息会被编译 
在系统运行时,如果要打印pr_dbg()和dev_dbg()信息,还需要调整loglevel为8,两个方法:
- 在board.dts中修改bootargs,增加“loglevel=8” 
- 在板子启动到Linux shell后,执行命令: 
echo 8 > /proc/sys/kernel/printk
4.5.3.2. Sysfs 节点¶
4.5.3.2.1. 状态信息¶
在 TSensor 驱动初始化成功后,会在Sysfs中注册生成一个 status 节点,其中打印了当前的 TSensor 配置及状态信息:
 # cat /sys/devices/platform/soc/19253000.tsen/status
In Thermal Sensor V1.00:
 ch0: aic-tsen-cpu, Enable: 1, Value: 0
 ch1: aic-tsen-adc, Enable: 1,Value: 0
4.5.3.2.2. 读取温度¶
Linux Thermal 子系统提供一些 Sysfs 节点,可以用来获取温度值等操作。
# cd /sys/class/thermal/
[aic@thermal] # ls
thermal_zone0  thermal_zone1
[aic@thermal] # cd thermal_zone0/
[aic@thermal_zone0] # ls
available_policies  k_po                policy              type
hwmon0              k_pu                slope               uevent
integral_cutoff     mode                subsystem
k_d                 offset              sustainable_power
k_i                 passive             temp
[aic@thermal_zone0] # cat temp
0
[aic@thermal_zone0] # cat type
aic-tsen-cpu