Lm-sensors support

Maybe this is related: http://lists.infradead.org/pipermail/linux-mediatek/2016-August/006638.html

thermal-block in dts is existing,but how to read the values?

It seems that also a driver must be activated in kernel (mtk_thermal):


added module MTK_TERMAL, but no success…

root@bpi-r2:~# modprobe mtk-thermal                                             
root@bpi-r2:~# lsmod                                                            
Module                  Size  Used by                                           
i2c_dev                20480  0                                                 
mt76x2e                61440  0                                                 
mt76                   32768  1 mt76x2e                                         
mtk_thermal            16384  0                                                 
thermal_sys            61440  1 mtk_thermal                                     
pwm_mediatek           16384  0                                                 
ip_tables              24576  0                                                 
x_tables               28672  1 ip_tables                                       
ipv6                  409600  18                                                
root@bpi-r2:~# sensors-detect                                                   
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)                      
# Kernel: 4.14.11-00002-ga352d6b armv7l                                         
# Processor: ARMv7 Processor rev 3 (v7l) (//)                                   
This program will help you determine which kernel modules you need              
to load to use lm_sensors most effectively. It is generally safe                
and recommended to accept the default answers to all questions,                 
unless you know what you're doing.                                              
Some south bridges, CPUs or memory controllers contain embedded sensors.        
Do you want to scan for them? This is totally safe. (YES/no):                   
modprobe: FATAL: Module cpuid not found in directory /lib/modules/4.14.11-00002b
Failed to load module cpuid.                                                    
Silicon Integrated Systems SIS5595...                       No                  
VIA VT82C686 Integrated Sensors...                          No                  
VIA VT8231 Integrated Sensors...                            No                  
AMD K8 thermal sensors...                                   No                  
AMD Family 10h thermal sensors...                           No                  
AMD Family 11h thermal sensors...                           No                  
AMD Family 12h and 14h thermal sensors...                   No                  
AMD Family 15h thermal sensors...                           No                  
AMD Family 16h thermal sensors...                           No                  
AMD Family 15h power sensors...                             No                  
AMD Family 16h power sensors...                             No                  
Intel digital thermal sensor...                             No                  
Intel AMB FB-DIMM thermal sensor...                         No                  
Intel 5500/5520/X58 thermal sensor...                       No                  
VIA C7 thermal sensor...                                    No                  
VIA Nano thermal sensor...                                  No                  
Lastly, we can probe the I2C/SMBus adapters for connected hardware              
monitoring devices. This is the most risky part, and while it works             
reasonably well on most systems, it has been reported to cause trouble          
on some systems.                             

i’ve found no config-option for CPUID, only CPUIDLE for different platforms…

searched also through sysfs and tried that which seems also not correct:

root@bpi-r2:~# cat /sys/class/thermal/thermal_zone0/temp                        

maybe it needs this:

Symbol: CPU_THERMAL [=n]
Prompt: generic cpu cooling support 


any Idea how to read out CPU-Temp?

had included and loaded now thermal_sys, mtk_thermal and mt6577_auxadc but sensors-detect does not find anything

anyone knows how to get at least the CPU-Temp?

Any success to read CPU temp?

I still have no clue how to read from auxadc :pensive:

On kernel 4.9, i can retrieved temp value, not sure the value is valid neither the unit. I have mtk_thermal and thermal_sys modules loaded.

# lsmod | grep ther
mtk_thermal             5385  0
thermal_sys            53003  1 mtk_thermal
# cat /sys/class/thermal/thermal_zone0/*temp

cat *temp in that dir is not the right way:

see here:

[17:59] root@bpi-r2:~# cat /sys/class/thermal/thermal_zone0/*temp                                                                                                              
cat: /sys/class/thermal/thermal_zone0/temp: Invalid argument                                                                                                                   
[18:00] root@bpi-r2:~# ls /sys/class/thermal/thermal_zone0/                                                                                                                    
available_policies  offset             trip_point_0_hyst  trip_point_2_temp                                                                                                    
integral_cutoff     policy             trip_point_0_temp  trip_point_2_type                                                                                                    
k_d                 power              trip_point_0_type  trip_point_3_hyst                                                                                                    
k_i                 slope              trip_point_1_hyst  trip_point_3_temp                                                                                                    
k_po                subsystem          trip_point_1_temp  trip_point_3_type                                                                                                    
k_pu                sustainable_power  trip_point_1_type  type                                                                                                                 
mode                temp               trip_point_2_hyst  uevent     

first you don’t know which “file” do you cat, second there are not only temperature-sensors there

kernel i used: 4.14.44-main

I take the same example as you in a previous post.

# cat /sys/class/thermal/thermal_zone0/temp 

can you compare dts(i) and (def)config between 4.9 and 4.14?

thermal-node and auxadc

I can retrieved a value, not sure the value is valid neither of the unit. If it is degrees Celsius it is high.

$ grep -i thermal .config | grep -v '#'

The thermal zone are describe in the arch/arm/boot/dts/mt7623.dtsi

Seems like Module i2c-dev and cpuid are need. sensors-detect is unable to find any sensors.

It is milli (1/1000) degrees celcius…

Cpuid is not available on arm-systems, i have tried with i2c-dev too, but no success

config is (nearly) same im 4.14:

$ grep -i thermal .config | grep -v '#'

@linkerosa have you an idea whats the Problem?

mtk-thermal is read by on-chip auxadc, not by i2c bus.

i had included auxadc as well

grep 'AUX' .config

and of course loaded the module:

[09:36] root@bpi-r2:~# lsmod                                                    
Module                  Size  Used by                                           
bridge                151552  0                                                 
spi_mt65xx             20480  0                                                 
mt6577_auxadc          16384  0                                                 
mtk_thermal            16384  0                                                 
thermal_sys            61440  1 mtk_thermal                                     
pwm_mediatek           16384  0                                                 
fuse                  102400  1                                                 
ipv6                  413696  33 bridge          

but still:

[09:38] root@bpi-r2:~# cat /sys/class/thermal/thermal_zone0/temp                
cat: /sys/class/thermal/thermal_zone0/temp: Invalid argument

@linkerosa can you please look whats missing/wrong?

Hi, Frank. As I see it’s everyting works in 4.16 kernel

bpi-r2-gentoo /dev # cat /sys/class/thermal/thermal_zone0/temp
1 Like
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.16.14-bpi-r2-main armv7l)              
root@bpi-r2-ubuntu:~# cat /sys/class/thermal/thermal_zone0/temp                 

can confirm it works with 4.16…so it seems to be a problem in 4.14 (same system):

Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.14.48-bpi-r2-main armv7l)              

root@bpi-r2-ubuntu:~# cat /sys/class/thermal/thermal_zone0/temp                 
cat: /sys/class/thermal/thermal_zone0/temp: Invalid argument


also not set in 4.16…it seems efuse is not be needed

    efuse: efuse@10206000 {
            compatible = "mediatek,mt7623-efuse",
            reg = <0 0x10206000 0 0x1000>;
            #address-cells = <1>;
            #size-cells = <1>;
            thermal_calibration_data: calib@424 {
                    reg = <0x424 0xc>;

    thermal: thermal@1100b000 {
            #thermal-sensor-cells = <1>;
            compatible = "mediatek,mt7623-thermal",
            reg = <0 0x1100b000 0 0x1000>;
            interrupts = <0 70 IRQ_TYPE_LEVEL_LOW>;
            clocks = <&pericfg CLK_PERI_THERM>, <&pericfg CLK_PERI_AUXADC>;
            clock-names = "therm", "auxadc";
            resets = <&pericfg MT2701_PERI_THERM_SW_RST>;
            reset-names = "therm";
            mediatek,auxadc = <&auxadc>;
            mediatek,apmixedsys = <&apmixedsys>;
            nvmem-cells = <&thermal_calibration_data>;
            nvmem-cell-names = "calibration-data";

i have compared thermal,efuse and auxadc-node between 4.14-main and 4.16-main, they are identical

frank@frank-N56VZ:/media/data_ext/bpi-r2-kernel/github$ git diff 4.14-main..4.16-main -- ./drivers/thermal/mtk_thermal.c
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 1e61c09153c9..c75661a3801a 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -32,15 +32,10 @@
 #include <linux/types.h>
 /* AUXADC Registers */
-#define AUXADC_CON0_V          0x000
-#define AUXADC_CON1_V          0x004
 #define AUXADC_CON1_SET_V      0x008
 #define AUXADC_CON1_CLR_V      0x00c
 #define AUXADC_CON2_V          0x010
 #define AUXADC_DATA(channel)   (0x14 + (channel) * 4)
-#define AUXADC_MISC_V          0x094
-#define AUXADC_CON1_CHANNEL(x) BIT(x)
 #define APMIXED_SYS_TS_CON1    0x604
@@ -158,8 +153,6 @@
 /* The number of sensing points per bank */
 #define MT2712_NUM_SENSORS_PER_ZONE    4
-#define THERMAL_NAME    "mtk-thermal"
 struct mtk_thermal;
 struct thermal_bank_cfg {
@@ -765,7 +758,7 @@ static struct platform_driver mtk_thermal_driver = {
        .probe = mtk_thermal_probe,
        .remove = mtk_thermal_remove,
        .driver = {
-               .name = THERMAL_NAME,
+               .name = "mtk-thermal",
                .of_match_table = mtk_thermal_of_match,
frank@frank-N56VZ:/media/data_ext/bpi-r2-kernel/github$ git diff 4.14-main..4.16-main -- ./drivers/iio/adc/mt6577_auxadc.c
diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 414cf44bf19d..95d76abb64ec 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -180,7 +180,6 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev,
 static const struct iio_info mt6577_auxadc_info = {
-       .driver_module = THIS_MODULE,
        .read_raw = &mt6577_auxadc_read_raw,
@@ -306,6 +305,7 @@ static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops,
 static const struct of_device_id mt6577_auxadc_of_match[] = {
        { .compatible = "mediatek,mt2701-auxadc", },
+       { .compatible = "mediatek,mt2712-auxadc", },
        { .compatible = "mediatek,mt7622-auxadc", },
        { .compatible = "mediatek,mt8173-auxadc", },
        { }