Linux Power Management development
 help / color / mirror / Atom feed
From: <louis.yu@mediatek.com>
To: Zhang Rui <rui.zhang@intel.com>, Eduardo Valentin <edubezval@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	dawei.chien@mediatek.com, fan.chen@mediatek.com,
	eddie.huang@mediatek.com, linux-pm@vger.kernel.org,
	linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com,
	Louis Yu <louis.yu@mediatek.com>
Subject: [PATCH v1 3/4] thermal: mediatek: extend calibration data for mt2712 chip
Date: Thu, 27 Jul 2017 13:46:56 +0800	[thread overview]
Message-ID: <1501134417-3505-4-git-send-email-louis.yu@mediatek.com> (raw)
In-Reply-To: <1501134417-3505-1-git-send-email-louis.yu@mediatek.com>

From: Louis Yu <louis.yu@mediatek.com>

This patch adds support for mt2712 chip thermal calibration data
and calculation.

Signed-off-by: Louis Yu <louis.yu@mediatek.com>
---
 drivers/thermal/mtk_thermal.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index e35d28d..f2a7155 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -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");
 	}
-- 
1.9.1

  parent reply	other threads:[~2017-07-27  5:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27  5:46 [PATCH v1 0/4] Add Mediatek thermal driver for mt2712 louis.yu
2017-07-27  5:46 ` [PATCH v1 1/4] dt-bindings: thermal: Add binding document for Mediatek thermal controller louis.yu
2017-07-27  5:46 ` [PATCH v1 2/4] thermal: mediatek: add Mediatek thermal driver for mt2712 louis.yu
2017-07-27  5:46 ` louis.yu [this message]
2017-07-27 15:46   ` [PATCH v1 3/4] thermal: mediatek: extend calibration data for mt2712 chip Matthias Brugger
2017-07-31  7:21     ` Louis Yu
2017-07-27  5:46 ` [PATCH v1 4/4] thermal: mediatek: minor mtk_thermal.c cleanups louis.yu
2017-07-27 15:49   ` Matthias Brugger
2017-07-31  7:23     ` Louis Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1501134417-3505-4-git-send-email-louis.yu@mediatek.com \
    --to=louis.yu@mediatek.com \
    --cc=dawei.chien@mediatek.com \
    --cc=eddie.huang@mediatek.com \
    --cc=edubezval@gmail.com \
    --cc=fan.chen@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srv_heupstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox