summaryrefslogtreecommitdiff
path: root/drivers/thermal/mtk_thermal.c
diff options
context:
space:
mode:
authorLouis Yu <louis.yu@mediatek.com>2017-08-01 10:28:32 +0300
committerZhang Rui <rui.zhang@intel.com>2017-08-31 16:13:47 +0300
commit0a0689933404c50f9ee2122b69b4be83e984afa2 (patch)
tree9a9f48c66dde87af9438a67d806b4bec26b897cf /drivers/thermal/mtk_thermal.c
parent6cf7f002e70773fc11d032628edd2ecc679fe05b (diff)
downloadlinux-0a0689933404c50f9ee2122b69b4be83e984afa2.tar.xz
thermal: mediatek: extend calibration data for mt2712 chip
This patch adds support for mt2712 chip thermal calibration data and calculation, and is compatible with the existing chips. Signed-off-by: Louis Yu <louis.yu@mediatek.com> Reviewed-by: Dawei Chien <dawei.chien@mediatek.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/mtk_thermal.c')
-rw-r--r--drivers/thermal/mtk_thermal.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index e35d28d4e8f8..b609589698c7 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -112,10 +112,10 @@
/*
* Layout of the fuses providing the calibration data
- * These macros could be used for both MT8173, MT2701, and MT2712.
- * MT8173 has five sensors and need five VTS calibration data,
- * and MT2701 has three sensors and need three VTS calibration data,
- * and MT2712 has four sensors and need four VTS calibration data.
+ * These macros could be used for MT8173, MT2701, and MT2712.
+ * MT8173 has 5 sensors and needs 5 VTS calibration data.
+ * MT2701 has 3 sensors and needs 3 VTS calibration data.
+ * MT2712 has 4 sensors and needs 4 VTS calibration data.
*/
#define MT8173_CALIB_BUF0_VALID BIT(0)
#define MT8173_CALIB_BUF1_ADC_GE(x) (((x) >> 22) & 0x3ff)
@@ -126,6 +126,8 @@
#define MT8173_CALIB_BUF2_VTS_TSABB(x) (((x) >> 14) & 0x1ff)
#define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
#define MT8173_CALIB_BUF0_O_SLOPE(x) (((x) >> 26) & 0x3f)
+#define MT8173_CALIB_BUF0_O_SLOPE_SIGN(x) (((x) >> 7) & 0x1)
+#define MT8173_CALIB_BUF1_ID(x) (((x) >> 9) & 0x1)
/* MT2701 thermal sensors */
#define MT2701_TS1 0
@@ -609,7 +611,11 @@ static int mtk_thermal_get_calibration_data(struct device *dev,
mt->vts[MT8173_TS4] = MT8173_CALIB_BUF2_VTS_TS4(buf[2]);
mt->vts[MT8173_TSABB] = MT8173_CALIB_BUF2_VTS_TSABB(buf[2]);
mt->degc_cali = MT8173_CALIB_BUF0_DEGC_CALI(buf[0]);
- mt->o_slope = MT8173_CALIB_BUF0_O_SLOPE(buf[0]);
+ if (MT8173_CALIB_BUF1_ID(buf[1]) &
+ MT8173_CALIB_BUF0_O_SLOPE_SIGN(buf[0]))
+ mt->o_slope = -MT8173_CALIB_BUF0_O_SLOPE(buf[0]);
+ else
+ mt->o_slope = MT8173_CALIB_BUF0_O_SLOPE(buf[0]);
} else {
dev_info(dev, "Device not calibrated, using default calibration values\n");
}