From patchwork Thu Apr 24 20:23:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 4053831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A0E4BFF02 for ; Thu, 24 Apr 2014 20:27:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D8BD202EC for ; Thu, 24 Apr 2014 20:27:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0DBD20353 for ; Thu, 24 Apr 2014 20:27:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdQCc-0007Xa-Iz; Thu, 24 Apr 2014 20:25:02 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdQCK-0007IJ-W1 for linux-arm-kernel@lists.infradead.org; Thu, 24 Apr 2014 20:24:45 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id CEB2D970; Thu, 24 Apr 2014 22:24:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (unknown [190.2.108.30]) by mail.free-electrons.com (Postfix) with ESMTPSA id 14783895; Thu, 24 Apr 2014 22:24:18 +0200 (CEST) From: Ezequiel Garcia To: , Subject: [PATCH v2 05/10] thermal: armada: Allow to specify an 'inverted readout' sensor Date: Thu, 24 Apr 2014 17:23:19 -0300 Message-Id: <1398371004-15807-6-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398371004-15807-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1398371004-15807-1-git-send-email-ezequiel.garcia@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140424_132445_176363_97950DB3 X-CRM114-Status: GOOD ( 10.64 ) X-Spam-Score: 0.3 (/) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Tawfik Bayouk , devicetree@vger.kernel.org, Lior Amsalem , Ezequiel Garcia , Gregory Clement , Zhang Rui , Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support inverted-formula thermal sensor readout, this commit introduces an 'inverted' field in the SoC-specific structure which allows to specify an inversion of the temperature formula. Signed-off-by: Ezequiel Garcia --- drivers/thermal/armada_thermal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index aafcc4d..e228132 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -56,6 +56,7 @@ struct armada_thermal_data { unsigned long coef_b; unsigned long coef_m; unsigned long coef_div; + bool inverted; /* Offset and mask to access the sensor temperature */ unsigned int temp_offset; @@ -138,7 +139,10 @@ static int armada_get_temp(struct thermal_zone_device *thermal, m = priv->data->coef_m; div = priv->data->coef_div; - *temp = (b - (m * reg)) / div; + if (priv->data->inverted) + *temp = ((m * reg) - b) / div; + else + *temp = (b - (m * reg)) / div; return 0; }