Lm-sensors support


(dorabmon) #21

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


(Frank W.) #22

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?


(Alex R.) #23

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

(Frank W.) #24
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

#25

CONFIG_MTK_EFUSE=m ?


(Frank W.) #26

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


#27
    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";
    };

(Frank W.) #28

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$