Lm-sensors support

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

i had included auxadc as well

grep 'AUX' .config
# CONFIG_USB_SERIAL_QCAUX is not set
# CONFIG_AUXDISPLAY is not set
CONFIG_MEDIATEK_MT6577_AUXADC=m

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
46968
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                 
29732

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

CONFIG_MTK_EFUSE=m ?

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

    efuse: efuse@10206000 {
            compatible = "mediatek,mt7623-efuse",
                         "mediatek,mt8173-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",
                         "mediatek,mt2701-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", },
        { }
frank@frank-N56VZ:/media/data_ext/bpi-r2-kernel/github$

are any other files involved in the themal-read?

Hi Frank, I tested it again with

CONFIG_MTK_EFUSE = m

works mtk-thermal - without not

root@gate:~# uname -a
Linux gate 4.14.53-bpi-r2-main #8 SMP Thu Jul 5 22:57:48 CEST 2018 armv7l GNU/Linux
root@gate:~# lsmod
Module                  Size  Used by
ip6_tables             24576  0
iptable_filter         16384  1
mtk_thermal            16384  0
thermal_sys            61440  1 mtk_thermal
spi_mt65xx             20480  0
pwm_mediatek           16384  0
mt6577_auxadc          16384  0
nvmem_mtk_efuse        16384  0
cryptodev              53248  0
sunrpc                311296  1
ip_tables              24576  1 iptable_filter
x_tables               28672  3 ip_tables,iptable_filter,ip6_tables
root@gate:~# cat /sys/class/thermal/thermal_zone0/temp
49430
1 Like

Imho i set this option in my defconfig but the modulename nvmem_mtk_efuse looks new to me

mhm…strange 4.14.53 does not boot… seems like i made a mistake while merging (wonder why i merged 4.14.53 to gmac-branch)

reverted the strange merge, currently it displays 4.14.52, but i can’t merge 4.14.53 again…seems like i messed up my git-repo…any idea how to fix?

thermal with efuse works now (but still don’t know why it is neccessary in 4.14 but not in 4.16):

root@bpi-r2-ubuntu:~# modprobe mtk_thermal 
root@bpi-r2-ubuntu:~# modprobe thermal_sys 
root@bpi-r2-ubuntu:~# modprobe mt6577_auxadc
root@bpi-r2-ubuntu:~# modprobe nvmem_mtk_efuse
root@bpi-r2-ubuntu:~# cat /sys/class/thermal/thermal_zone0/temp
47320

Hi Frank

driver/thermal/Kconfig

4.16 -> 4.14

  depends on NVMEM || !NVMEM

I was wrong was another driver