From patchwork Mon Dec 21 07:27:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 7893911 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 61D219F32E for ; Mon, 21 Dec 2015 08:01:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 791F920389 for ; Mon, 21 Dec 2015 08:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E34220416 for ; Mon, 21 Dec 2015 08:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750931AbbLUIBQ (ORCPT ); Mon, 21 Dec 2015 03:01:16 -0500 Received: from mail-am1on0057.outbound.protection.outlook.com ([157.56.112.57]:32002 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750799AbbLUIBP (ORCPT ); Mon, 21 Dec 2015 03:01:15 -0500 X-Greylist: delayed 1983 seconds by postgrey-1.27 at vger.kernel.org; Mon, 21 Dec 2015 03:01:14 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ping.bai@nxp.com; Received: from b51503-01.ap.freescale.net (199.59.226.141) by AM3PR04MB531.eurprd04.prod.outlook.com (2a01:111:e400:8822::28) with Microsoft SMTP Server (TLS) id 15.1.361.13; Mon, 21 Dec 2015 07:28:04 +0000 From: Bai Ping To: , CC: Subject: [PATCH] thermal: imx: update the temperature calibration data for imx6 soc Date: Mon, 21 Dec 2015 15:27:56 +0800 Message-ID: <1450682876-26725-1-git-send-email-ping.bai@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [199.59.226.141] X-ClientProxiedBy: HK2PR04CA0023.apcprd04.prod.outlook.com (2a01:111:e400:5216::33) To AM3PR04MB531.eurprd04.prod.outlook.com (2a01:111:e400:8822::28) X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB531; 2:RT1bTMKG4nZ5k9jeViQqNJFNl/y5SQVdefP8Ypt9+5OdI0GMkheNQbjXxD9V6zTqcCIBSWKRxnRwanKhHzTK+r3ETzoWr7HsQugvZHDsHF6tWdYMJVO90J5rx0gM4whcbd4JNIbbObZifUMIUjGddw==; 3:OfNmQFyzH9eC7Pyxx76+RXv/nS0qb7ttWhzkBbsU0xpvviaaPz1xtjMQjM0WOX3oKzIjnTdeIJuA6dBuARQEfVpk68Xvtigsu97agklvir20kv8VGuTxVHERplo09Ed+; 25:Am36fw0lwyI9/sELOL/1bFvccXuTHLhTliUicp9bpq5MVtyutrH6wNuA8E59+GGBsryB/kw59E+YbYoPu8UZwJltHdH9YI4hlnpRdIXFSUV7RiYmjOFeF0fDh7jacSzLNrFBwZkk/alFj2lEgPksuv6ITLa9AAg0F3p93Fekmt1Gh6LXLNo426j/cI0Qx6/9BgqnylIssCSziNx4zKNJNkwYLeAzSlYTgTPTTrSIdcNrd/ppPf6F7iZU5CL2gDfERRxqFXIEy/qrgK9jPW0/tQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR04MB531; X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB531; 20:2OtBgI9PIqTm4u73i7dtIMPuAu2jOc5jzrAhIc5VyIkg71qoHoAmjGWbrIfyf0/OSodjnhXzywmPP/tNEXxuSUxx77mTdATBww7H8ylYkHx24zD/zOD5bGQahyWkftQcqauoz+tqAL07SB6DIlHXPbrx3K+1FaKiIBo5vgWK2cJbRZXXpG9Q/3Lrd/f5DnRASFzus0ZEk/7eZfBBijJztBc5T88jwW92RwxJPxTYq4dIZHdn18o/OaG+Pe8tvxKzxYHkNtGnYS6dgIIAga9p7F6wLuZlDSMfJMwULCRCFBjmD9xSSobDfWcxCvnQ2A+Qk3aEJ3FiDuWitwZsVZ72bl1BhvtwPuWjj57DNabAHxGzE/irFA2LWk9jJrwoXQyM6Z2xrW6weUni7QibQu674ZHAvaUo7SvOHkUHZI+UDFjaP8eee+vo0bD5W/0bdnmtMMW7vCfuEhCtNRJwJvnL9oLNsvh03YSZk5OvNNlXIYaeY6Wd3wfofBguMGnP6cvQ; 4:JyspWZ63Z0f7vXrqi4r5ptqu4ywhL4UMThkZhXbSrK6eE3wJOWtjOG5pqXyskHQQ6UK0pm/c/t+VdqIrI9VnOtfyYNp2sY/Cf9jVlsn7uc4vU5EdwNLodtqYu3Dj4sEQv5z+YP73b0cCWyFzJp3j7ccV4VxQKMVnoZs3uNwngqxBk6qG2v5zcyzMHfwEakrBv1OX5I2+14Z+TVykG0ATtdIB0TD1E9K9QY7upKcvo4xVb7Hk3xR0RUG3mvt2Y9ka1Epusqh9ymeLnWzVq1JztRH9PGjv6IEsJ9s4JvLQtG+ICkj9gGSvO7jb6O49Km3z1uKLylbUutk9yi6ymgDS2ul3qgboBSPtykaMsrgsfTrpt/Z2HuJ8ep2B3rG6S1smTOAx4OlJkhknpbxzsO/2apB1bp5L8ALmSNK6NfN fVqWfN/jeVeFcAgfEIqrdxPA0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:AM3PR04MB531; BCL:0; PCL:0; RULEID:; SRVR:AM3PR04MB531; X-Forefront-PRVS: 079756C6B9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(48376002)(5001770100001)(86362001)(47776003)(97736004)(189998001)(33646002)(50986999)(87976001)(5004730100002)(101416001)(66066001)(5001960100002)(92566002)(81156007)(50226001)(42186005)(40100003)(19580395003)(105586002)(106356001)(36756003)(19580405001)(3846002)(1096002)(50466002)(586003)(6116002)(122386002)(5003940100001)(229853001)(5008740100001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR04MB531; H:b51503-01.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR04MB531; 23:cXYzthmx737PLLk4T+wCZHiiDB/Q/ZIl2fvgkLIM52?= =?us-ascii?Q?mkhNVeeyKfy6kxF4SGFWgfo4dNvK8EGPWuxQk+buAgM9wR/N35BvI1qUpDb/?= =?us-ascii?Q?bpsfZG9xmoqiD2GNESoGFYdSYV9IuoyHfBDihumlMjj98/xZfu6/iBOpII1D?= =?us-ascii?Q?fDyY+6EqHaHSfScUyAbK/5XYyVbzsC6u8xvnm1HTzOaXeVNTvMICjlHMVsy8?= =?us-ascii?Q?Ah2L+SDRQmeQ1qTg7kgjzVQMu1sjrIfGXdJi8TSoqTJ4nOCSseOPbpqZsGQx?= =?us-ascii?Q?QNySUBkUE8jJTg5wE5M/5jldIBitC2C6VnT2CmHi0swy0zxQTbZCtOnxeE0P?= =?us-ascii?Q?Aor0Z7XA6g5GK/cFxTV4MaRK1NoSjeT2FVoXvT67bycLQ/LM4L0eKOmC89ii?= =?us-ascii?Q?gkaSb1nTnzwa11/86c6xBwEwoKc9ieIvAE/uZSEtIA4BCP1YDCizn6umtG+0?= =?us-ascii?Q?lrfj2qU2D6DKEsZx4ojb79/aUshPA/3SDrTKni0fF6slfGpVH/BWCv6B9i7I?= =?us-ascii?Q?KPvfF/A5hNtTqe0WQbNkbOmZPu7etsnhk3miO6XmwYt+NaAz3+ufnP2kqUbj?= =?us-ascii?Q?63co5+2l8z1DWIQBviTaUwM0kw0EWruUpE6FNaFSdsV99nQXZ1l30Rl77AqU?= =?us-ascii?Q?dR6b3+56dUZXg0pn78HCI23KCRnn6fTErgXAOlahuN2Nir4gWTI1V0PX6rpR?= =?us-ascii?Q?STqbrZb5By28zJzxSqOAfFM5uODzbdvYxpA1Ui7DS/tnGCdgNMXUmeaAsqmU?= =?us-ascii?Q?vr0wXqxjHdZmjC1jkFUwvqi+ZT2DARFordy07ENvvH8Ois+fQucVIzTEp4TA?= =?us-ascii?Q?WhrXETA5CO2oj51f+MohR1Jnz20R4gZk4Oc/zy+J7AGB7an6QHrEqwKb4Azp?= =?us-ascii?Q?AoGlxnTp6/RhLDKyBqrS6t/ouyXwxwN4NTlGmU8zwiQKfphbTEGecRLYigCq?= =?us-ascii?Q?DgYPpjBxWLjmEDDlZ3/CqIDjsMpWHG0bBI3PQud4VkkSSgW4p63yMa+viflG?= =?us-ascii?Q?Y=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM3PR04MB531; 5:uA2PqXoFu1vxGUguxdXXjmcdzndMz6VbB/mEL4lDJyTybgs98RQCwvriytkXWrTikSQCzmtUyaWMC5y/aX/N5rNxXH6U/XnpQqxz0Jem+VOVUjbWf/18sy+/uVkxtaFIYCC2fG733axL9pqEiasHLw==; 24:HVUdzwMnDSeJrK4ikbfOKZQdqGeZhthZagq05wtG3PIOGL63heALfdGj5EEITfU6tzgmc4hzonHmWHWPOmn6HgSsam0nBfT+yBIMA1ZN574= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2015 07:28:04.4435 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR04MB531 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the design team: After a thorough accuracy study of the Temp sense circuit,we found that with our current equation, an average part can read 7 degrees lower than a known forced temperature. We also found out that the standard variance was around 2C; which is the tightest distribution that we could create. We need to change the temp sense equation to center the average part around the target temperature. Old Equation: Temp = Troom,cal - slope*(Count measured - Count room fuse) Where Troom,cal = 25C and Slope = 0.4297157 - (0.0015974 * Count room fuse) New Equation: Temp = Troom,cal - slope*(Count measured - Count room fuse) +offset Where Troom,cal = 25C and Slope = 0.4148468 - (0.0015423 * Count room fuse) Offset = 3.580661 Signed-off-by: Bai Ping Tested-by: Leo Liu --- drivers/thermal/imx_thermal.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index c5547bd..9fb613e 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -69,8 +69,9 @@ enum imx_thermal_trip { #define IMX_PASSIVE_DELAY 1000 #define FACTOR0 10000000 -#define FACTOR1 15976 -#define FACTOR2 4297157 +#define FACTOR1 15423 +#define FACTOR2 4148468 +#define OFFSET 3580661 #define TEMPMON_IMX6Q 1 #define TEMPMON_IMX6SX 2 @@ -385,23 +386,26 @@ static int imx_get_sensor_data(struct platform_device *pdev) * Derived from linear interpolation: * slope = 0.4297157 - (0.0015976 * 25C fuse) * slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 + * offset = OFFSET / 1000000 * (Nmeas - n1) / (Tmeas - t1) = slope * We want to reduce this down to the minimum computation necessary * for each temperature read. Also, we want Tmeas in millicelsius * and we don't want to lose precision from integer division. So... - * Tmeas = (Nmeas - n1) / slope + t1 - * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 - * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 + * Tmeas = (Nmeas - n1) / slope + t1 + offset + * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 + OFFSET / 1000 + * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 + OFFSET / 1000 * Let constant c1 = (-1000 / slope) - * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 - * Let constant c2 = n1 *c1 + 1000 * t1 + * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 + OFFSET / 1000 + * Let constant c2 = n1 *c1 + 1000 * t1 + OFFSET / 1000 * milli_Tmeas = c2 - Nmeas * c1 */ temp64 = FACTOR0; temp64 *= 1000; do_div(temp64, FACTOR1 * n1 - FACTOR2); data->c1 = temp64; - data->c2 = n1 * data->c1 + 1000 * t1; + temp64 = OFFSET; + do_div(temp64, 1000); + data->c2 = n1 * data->c1 + 1000 * t1 + temp64; /* use OTP for thermal grade */ ret = regmap_read(map, OCOTP_MEM0, &val);